Skip to content

Commit

Permalink
Revert "memblock: exclude NOMAP regions from kmemleak"
Browse files Browse the repository at this point in the history
Commit 6e44bd6 ("memblock: exclude NOMAP regions from kmemleak")
breaks boot on EFI systems with kmemleak and VM_DEBUG enabled:

efi: Processing EFI memory map:
efi:   0x000090000000-0x000091ffffff [Conventional|   |  |  |  |  |  |  |  |  |   |WB|WT|WC|UC]
efi:   0x000092000000-0x0000928fffff [Runtime Data|RUN|  |  |  |  |  |  |  |  |   |WB|WT|WC|UC]
------------[ cut here ]------------
kernel BUG at mm/kmemleak.c:1140!
Internal error: Oops - BUG: 0 [#1] SMP
Modules linked in:
CPU: 0 PID: 0 Comm: swapper Not tainted 5.15.0-rc6-next-20211019+ torvalds#104
pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : kmemleak_free_part_phys+0x64/0x8c
lr : kmemleak_free_part_phys+0x38/0x8c
sp : ffff800011eafbc0
x29: ffff800011eafbc0 x28: 1fffff7fffb41c0d x27: fffffbfffda0e068
x26: 0000000092000000 x25: 1ffff000023d5f94 x24: ffff800011ed84d0
x23: ffff800011ed84c0 x22: ffff800011ed83d8 x21: 0000000000900000
x20: ffff800011782000 x19: 0000000092000000 x18: ffff800011ee0730
x17: 0000000000000000 x16: 0000000000000000 x15: 1ffff0000233252c
x14: ffff800019a905a0 x13: 0000000000000001 x12: ffff7000023d5ed7
x11: 1ffff000023d5ed6 x10: ffff7000023d5ed6 x9 : dfff800000000000
x8 : ffff800011eaf6b7 x7 : 0000000000000001 x6 : ffff800011eaf6b0
x5 : 00008ffffdc2a12a x4 : ffff7000023d5ed7 x3 : 1ffff000023dbf99
x2 : 1ffff000022f0463 x1 : 0000000000000000 x0 : ffffffffffffffff
Call trace:
 kmemleak_free_part_phys+0x64/0x8c
 memblock_mark_nomap+0x5c/0x78
 reserve_regions+0x294/0x33c
 efi_init+0x2d0/0x490
 setup_arch+0x80/0x138
 start_kernel+0xa0/0x3ec
 __primary_switched+0xc0/0xc8
Code: 34000041 97d526e7 f9418e80 36000040 (d4210000)
random: get_random_bytes called from print_oops_end_marker+0x34/0x80 with crng_init=0
---[ end trace 0000000000000000 ]---

The crash happens because kmemleak_free_part_phys() tries to use __va()
before memstart_addr is initialized and this triggers a VM_BUG_ON() in
arch/arm64/include/asm/memory.h:

Revert 6e44bd6 ("memblock: exclude NOMAP regions from kmemleak"), the
issue it is fixing will be fixed differently.

Reported-by: Qian Cai <[email protected]>
Acked-by: Catalin Marinas <[email protected]>
Signed-off-by: Mike Rapoport <[email protected]>
  • Loading branch information
rppt committed Oct 21, 2021
1 parent 519d819 commit 5be8b16
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions mm/memblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -936,12 +936,7 @@ int __init_memblock memblock_mark_mirror(phys_addr_t base, phys_addr_t size)
*/
int __init_memblock memblock_mark_nomap(phys_addr_t base, phys_addr_t size)
{
int ret = memblock_setclr_flag(base, size, 1, MEMBLOCK_NOMAP);

if (!ret)
kmemleak_free_part_phys(base, size);

return ret;
return memblock_setclr_flag(base, size, 1, MEMBLOCK_NOMAP);
}

/**
Expand Down

0 comments on commit 5be8b16

Please sign in to comment.