mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marek Szyprowski <m.szyprowski@samsung.com>
To: Mike Rapoport <rppt@kernel.org>, Wandun <chenwandun1@gmail.com>
Cc: robh@kernel.org, saravanak@kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, akpm@linux-foundation.org
Subject: Re: [PATCH v3 0/5] of: reserved_mem: several fixes about reserved memory
Date: Tue, 6 Oct 2026 15:26:21 +0200	[thread overview]
Message-ID: <5dccea9b-a9e1-44f5-84d9-bc9efe04edee@samsung.com> (raw)
In-Reply-To: <asC3DBvtlcO5AVsz@kernel.org>

On 03.10.2026 10:04, Mike Rapoport wrote:
> On Tue, Sep 22, 2026 at 05:24:32PM +0800, Wandun wrote:
>> On 9/22/26 16:48, Mike Rapoport wrote:
>>> On Sun, Sep 20, 2026 at 05:28:47PM +0800, Wandun Chen wrote:
>>>> From: Wandun Chen <chenwandun@lixiang.com>
>>>>
>>>> This series fixes several error-handling issues in the reserved-memory
>>>> initialization paths.
>>>>
>>>> The first two patches fix cleanup of no-map regions after driver
>>>> initialization failure.
>>>>
>>>> Static reserved-memory nodes are reserved during the early DT scan but
>>>> initialized later. The third patch tags regions whose early reservation
>>>> succeeded, so the late scan can skip the nodes whose early reservation
>>>> failed.
>>>>
>>>> The last two patches reject overlapping static regions. Without
>>>> these checks, overlapping nodes can be initialized over the same
>>>> physical memory, result in data corrupt.
>>>>
>>>> Sashiko reported these issues in [1] [2] [3].
>>>>
>>>> [1] https://protect2.fireeye.com/v1/url?k=7e2f7441-1fa46164-7e2eff0e-74fe485cbff6-619f01488e6b7010&q=1&e=f3c07e6c-275b-4aa1-aec1-d931cda5f11a&u=https%3A%2F%2Fsashiko.dev%2F%23%2Fmessage%2F20260814090305.4C8741F00A3D%2540smtp.kernel.org
>>>> [2] https://protect2.fireeye.com/v1/url?k=a92ba57b-c8a0b05e-a92a2e34-74fe485cbff6-5f58f4b0f32080b9&q=1&e=f3c07e6c-275b-4aa1-aec1-d931cda5f11a&u=https%3A%2F%2Fsashiko.dev%2F%23%2Fmessage%2F20260814084718.29C341F000E9%2540smtp.kernel.org
>>>> [3] https://protect2.fireeye.com/v1/url?k=4f58aae4-2ed3bfc1-4f5921ab-74fe485cbff6-f4c4b3d0ed61b93e&q=1&e=f3c07e6c-275b-4aa1-aec1-d931cda5f11a&u=https%3A%2F%2Fsashiko.dev%2F%23%2Fmessage%2F20260806100605.2C2C01F000E9%2540smtp.kernel.org
>>>>
>>>> v2 --> v3:
>>>> 1. Rework the mechanism that checks in the late scan whether the early
>>>>    reservation succeeded (patches 3-5, suggested by Marek, thanks).
>>>>
>>>>    Patch 3 adds a new memblock flag MEMBLOCK_RSRV_RMEM, which is set when
>>>>    the early reservation of a static region succeeds and checked in the
>>>>    late scan.
>>> Can we keep this local to of_reserved_mem please?
>> Probably not. I do not see a way to keep this entirely local to
>> of_reserved_mem while handling the issue robustly.
>>
>> I previously implemented an approach in of_reserved_mem that records
>> static reserved-memory nodes whose early reservation failed in a local
>> array [1]. However, the early scan runs before paging_init(), so the array
>> cannot be dynamically expanded. If the number of failed nodes exceeds
>> the array size, some failures cannot be recorded and the issue remains,
>> and that is why Marek said "partial solution", although in practice
>> having that many failed nodes is unlikely.
> Even before paging_init() there is memblock_alloc().

One can call it, but such memory cannot be dereferenced/accessed for example
on ARM64, because it is not yet mapped in the linear map.

>> To handle this robustly, the late scan needs a way to determine whether
>> the corresponding early reservation actually succeeded. Current approach
>> uses memblock to retain that state.
> I can't say I like the idea of keeping this state in memblock.
> This add flags and code to memblock to deal with corner cases of bad
> firmware that reports weird memory layouts, and once there is a flag in
> the common infrastructure, people tend to abuse it.

So far I found no better place to store the information about successful
region reservation.

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


      reply	other threads:[~2026-10-06 13:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-20  9:28 Wandun Chen
2026-09-20  9:28 ` [PATCH v3 1/5] of: reserved_mem: release dynamically allocated no-map region on init failure Wandun Chen
2026-09-20  9:28 ` [PATCH v3 2/5] of: reserved_mem: retain static no-map memory " Wandun Chen
2026-09-20  9:28 ` [PATCH v3 3/5] of: reserved_mem: skip init for regions whose early reservation failed Wandun Chen
2026-09-20  9:28 ` [PATCH v3 4/5] of: reserved_mem: reject static regions overlapping no-map memory Wandun Chen
2026-09-20  9:28 ` [PATCH v3 5/5] of: reserved_mem: reject static mapped regions overlapping existing reservations Wandun Chen
2026-09-22  8:48 ` [PATCH v3 0/5] of: reserved_mem: several fixes about reserved memory Mike Rapoport
2026-09-22  9:24   ` Wandun
2026-10-03  8:04     ` Mike Rapoport
2026-10-06 13:26       ` Marek Szyprowski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5dccea9b-a9e1-44f5-84d9-bc9efe04edee@samsung.com \
    --to=m.szyprowski@samsung.com \
    --cc=akpm@linux-foundation.org \
    --cc=chenwandun1@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=robh@kernel.org \
    --cc=rppt@kernel.org \
    --cc=saravanak@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®