Skip to content

Commit 787d563

Browse files
kvaneeshtorvalds
authored andcommitted
mm/debug_vm_pgtable: fix kernel crash by checking for THP support
Architectures can have CONFIG_TRANSPARENT_HUGEPAGE enabled but no THP support enabled based on platforms. For ex: with 4K PAGE_SIZE ppc64 supports THP only with radix translation. This results in below crash when running with hash translation and 4K PAGE_SIZE. kernel BUG at arch/powerpc/include/asm/book3s/64/hash-4k.h:140! cpu 0x61: Vector: 700 (Program Check) at [c000000ff948f860] pc: debug_vm_pgtable+0x480/0x8b0 lr: debug_vm_pgtable+0x474/0x8b0 ... debug_vm_pgtable+0x374/0x8b0 (unreliable) do_one_initcall+0x98/0x4f0 kernel_init_freeable+0x330/0x3fc kernel_init+0x24/0x148 Check for THP support correctly Link: http://lkml.kernel.org/r/[email protected] Fixes: 399145f ("mm/debug: add tests validating architecture page table helpers") Signed-off-by: Aneesh Kumar K.V <[email protected]> Reviewed-by: Anshuman Khandual <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 81c4f4d commit 787d563

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

mm/debug_vm_pgtable.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ static void __init pmd_basic_tests(unsigned long pfn, pgprot_t prot)
6060
{
6161
pmd_t pmd = pfn_pmd(pfn, prot);
6262

63+
if (!has_transparent_hugepage())
64+
return;
65+
6366
WARN_ON(!pmd_same(pmd, pmd));
6467
WARN_ON(!pmd_young(pmd_mkyoung(pmd_mkold(pmd))));
6568
WARN_ON(!pmd_dirty(pmd_mkdirty(pmd_mkclean(pmd))));
@@ -79,6 +82,9 @@ static void __init pud_basic_tests(unsigned long pfn, pgprot_t prot)
7982
{
8083
pud_t pud = pfn_pud(pfn, prot);
8184

85+
if (!has_transparent_hugepage())
86+
return;
87+
8288
WARN_ON(!pud_same(pud, pud));
8389
WARN_ON(!pud_young(pud_mkyoung(pud_mkold(pud))));
8490
WARN_ON(!pud_write(pud_mkwrite(pud_wrprotect(pud))));

0 commit comments

Comments
 (0)