• Frank van der Linden's avatar
    mm/debug: use valid physical memory for pmd/pud tests · c4876ff6
    Frank van der Linden authored
    The page table debug tests need a physical address to validate low-level
    page table manipulation with.  The memory at this address is not actually
    touched, it just encoded in the page table entries at various levels
    during the tests only.
    
    Since the memory is not used, the code just picks the physical address of
    the start_kernel symbol.  This value is then truncated to get a properly
    aligned address that is to be used for various tests.  Because of the
    truncation, the address might not actually exist, or might not describe a
    complete huge page.  That's not a problem for most tests, but the
    arch-specific code may check for attribute validity and consistency.  The
    x86 version of {pud,pmd}_set_huge actually validates the MTRRs for the
    PMD/PUD range.  This may fail with an address derived from start_kernel,
    depending on where the kernel was loaded and what the physical memory
    layout of the system is.  This then leads to false negatives for the
    {pud,pmd}_set_huge tests.
    
    Avoid this by finding a properly aligned memory range that exists and is
    usable.  If such a range is not found, skip the tests that needed it.
    
    [fvdl@google.com: v3]
      Link: https://lkml.kernel.org/r/20230110181208.1633879-1-fvdl@google.com
    Link: https://lkml.kernel.org/r/20230109174332.329366-1-fvdl@google.com
    Fixes: 399145f9 ("mm/debug: add tests validating architecture page table helpers")
    Signed-off-by: default avatarFrank van der Linden <fvdl@google.com>
    Reviewed-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    c4876ff6
debug_vm_pgtable.c 39.4 KB