Skip to content

Commit 640b7ea

Browse files
rpptmattst88
authored andcommitted
alpha: register early reserved memory in memblock
The memory reserved by console/PALcode or non-volatile memory is not added to memblock.memory. Since commit fa3354e (mm: free_area_init: use maximal zone PFNs rather than zone sizes) the initialization of the memory map relies on the accuracy of memblock.memory to properly calculate zone sizes. The holes in memblock.memory caused by absent regions reserved by the firmware cause incorrect initialization of struct pages which leads to BUG() during the initial page freeing: BUG: Bad page state in process swapper pfn:2ffc53 page:fffffc000ecf14c0 refcount:0 mapcount:1 mapping:0000000000000000 index:0x0 flags: 0x0() raw: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 raw: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 page dumped because: nonzero mapcount Modules linked in: CPU: 0 PID: 0 Comm: swapper Not tainted 5.7.0-03841-gfa3354e4ea39-dirty Rust-for-Linux#26 fffffc0001b5bd68 fffffc0001b5be80 fffffc00011cd148 fffffc000ecf14c0 fffffc00019803df fffffc0001b5be80 fffffc00011ce340 fffffc000ecf14c0 0000000000000000 fffffc0001b5be80 fffffc0001b482c0 fffffc00027d6618 fffffc00027da7d0 00000000002ff97a 0000000000000000 fffffc0001b5be80 fffffc00011d1abc fffffc000ecf14c0 fffffc0002d00000 fffffc0001b5be80 fffffc0001b2350c 0000000000300000 fffffc0001b48298 fffffc0001b482c0 Trace: [<fffffc00011cd148>] bad_page+0x168/0x1b0 [<fffffc00011ce340>] free_pcp_prepare+0x1e0/0x290 [<fffffc00011d1abc>] free_unref_page+0x2c/0xa0 [<fffffc00014ee5f0>] cmp_ex_sort+0x0/0x30 [<fffffc00014ee5f0>] cmp_ex_sort+0x0/0x30 [<fffffc000101001c>] _stext+0x1c/0x20 Fix this by registering the reserved ranges in memblock.memory. Link: https://lore.kernel.org/lkml/20210726192311.uffqnanxw3ac5wwi@ivybridge Fixes: fa3354e ("mm: free_area_init: use maximal zone PFNs rather than zone sizes") Reported-by: Matt Turner <[email protected]> Cc: <[email protected]> Signed-off-by: Mike Rapoport <[email protected]> Signed-off-by: Matt Turner <[email protected]>
1 parent fc52052 commit 640b7ea

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

arch/alpha/kernel/setup.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -319,18 +319,19 @@ setup_memory(void *kernel_end)
319319
i, cluster->usage, cluster->start_pfn,
320320
cluster->start_pfn + cluster->numpages);
321321

322-
/* Bit 0 is console/PALcode reserved. Bit 1 is
323-
non-volatile memory -- we might want to mark
324-
this for later. */
325-
if (cluster->usage & 3)
326-
continue;
327-
328322
end = cluster->start_pfn + cluster->numpages;
329323
if (end > max_low_pfn)
330324
max_low_pfn = end;
331325

332326
memblock_add(PFN_PHYS(cluster->start_pfn),
333327
cluster->numpages << PAGE_SHIFT);
328+
329+
/* Bit 0 is console/PALcode reserved. Bit 1 is
330+
non-volatile memory -- we might want to mark
331+
this for later. */
332+
if (cluster->usage & 3)
333+
memblock_reserve(PFN_PHYS(cluster->start_pfn),
334+
cluster->numpages << PAGE_SHIFT);
334335
}
335336

336337
/*

0 commit comments

Comments
 (0)