Skip to content

of: reserved_mem: several fixes about reserved memory

Wandun Chen linux-devicetree linux-mm lkml 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest5 patches 6 repliesIn review
  2. v25 patches 15 repliesSuperseded
  3. v13 patches 0 repliesSuperseded

Changes in v3 from the cover letter

1. Rework the mechanism that checks in the late scan whether the early reservation succeeded (patches 3-5, suggested by Marek, thanks).

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5of: reserved_mem: release dynamically allocated no-map region on init failuredrivers/of/of_reserved_mem.c+8 -50 replies
2/5of: reserved_mem: retain static no-map memory on init failuredrivers/of/of_reserved_mem.c+1 -10 replies
3/5of: reserved_mem: skip init for regions whose early reservation faileddrivers/of/of_reserved_mem.c include/linux/memblock.h mm/memblock.c+110 -110 replies
4/5of: reserved_mem: reject static regions overlapping no-map memorydrivers/of/of_reserved_mem.c include/linux/memblock.h mm/memblock.c+48 -20 replies
5/5of: reserved_mem: reject static mapped regions overlapping existing reservationsdrivers/of/of_reserved_mem.c+5 -10 replies

Reviews trailers per patch

2 of 5 patches have a Reviewed-by or Acked-by.

PatchMarek Szyprowski
1/5A-b
2/5A-b
3/5
4/5
5/5

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/5] of: reserved_mem: several fixes about reserved memory

From: Wandun Chen <[email protected]>

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://sashiko.dev/#/message/20260814090305.4C8741F00A3D%40smtp.kernel.org
[2] https://sashiko.dev/#/message/20260814084718.29C341F000E9%40smtp.kernel.org
[3] https://sashiko.dev/#/message/20260806100605.2C2C01F000E9%40smtp.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.

Patches 4 and 5 are reworked to reject regions that overlap or are contained by an existing reservation. The code makes a little different from what was acked in v2, so the Acked-by tags for these patches are not carried over.

2. Reorder the patches: the two cleanup fixes in v2 now come first. In v3, the first patch now introduces the 'dynamic' distinction in fdt_init_reserved_mem_node(), which the following patche 3 build on, so the series reads more fluently.

v1 --> v2:
1. Rework failed-node tracking in patch 1: do not track zero-sized nodes, and keep a reserved_mem slot when tracking overflows.
2. Reject static reserved regions overlapping existing no-map regions.
3. Keep MEMBLOCK_NOMAP flag for static no-map regions when init failure.

Wandun Chen (5):
of: reserved_mem: release dynamically allocated no-map region on init
failure
of: reserved_mem: retain static no-map memory on init failure
of: reserved_mem: skip init for regions whose early reservation failed
of: reserved_mem: reject static regions overlapping no-map memory
of: reserved_mem: reject static mapped regions overlapping existing
reservations

 drivers/of/of_reserved_mem.c | 86 +++++++++++++++++++++++++-------
 include/linux/memblock.h     |  7 +++
 mm/memblock.c                | 95 ++++++++++++++++++++++++++++++++++++
 3 files changed, 170 insertions(+), 18 deletions(-)
Signature · 1 line
2.43.0