• Gavin Shan's avatar
    mm/debug_vm_pgtable: introduce struct pgtable_debug_args · 3c9b84f0
    Gavin Shan authored
    Patch series "mm/debug_vm_pgtable: Enhancements", v6.
    
    There are a couple of issues with current implementations and this series
    tries to resolve the issues:
    
      (a) All needed information are scattered in variables, passed to various
          test functions. The code is organized in pretty much relaxed fashion.
    
      (b) The page isn't allocated from buddy during page table entry modifying
          tests. The page can be invalid, conflicting to the implementations
          of set_xxx_at() on ARM64. The target page is accessed so that the
          iCache can be flushed when execution permission is given on ARM64.
          Besides, the target page can be unmapped and accessing to it causes
          kernel crash.
    
    "struct pgtable_debug_args" is introduced to address issue (a).  For issue
    (b), the used page is allocated from buddy in page table entry modifying
    tests.  The corresponding tets will be skipped if we fail to allocate the
    (huge) page.  For other test cases, the original page around to kernel
    symbol (@start_kernel) is still used.
    
    The patches are organized as below.  PATCH[2-10] could be combined to one
    patch, but it will make the review harder:
    
      PATCH[1] introduces "struct pgtable_debug_args" as place holder of all
               needed information. With it, the old and new implementation
               can coexist.
      PATCH[2-10] uses "struct pgtable_debug_args" in various test functions.
      PATCH[11] removes the unused code for old implementation.
      PATCH[12] fixes the issue of corrupted page flag for ARM64
    
    This patch (of 6):
    
    In debug_vm_pgtable(), there are many local variables introduced to track
    the needed information and they are passed to the functions for various
    test cases.  It'd better to introduce a struct as place holder for these
    information.  With it, what the tests functions need is the struct.  In
    this way, the code is simplified and easier to be maintained.
    
    Besides, set_xxx_at() could access the data on the corresponding pages in
    the page table modifying tests.  So the accessed pages in the tests should
    have been allocated from buddy.  Otherwise, we're accessing pages that
    aren't owned by us.  This causes issues like page flag corruption or
    kernel crash on accessing unmapped page when CONFIG_DEBUG_PAGEALLOC is
    enabled.
    
    This introduces "struct pgtable_debug_args".  The struct is initialized
    and destroyed, but the information in the struct isn't used yet.  It will
    be used in subsequent patches.
    
    Link: https://lkml.kernel.org/r/20210809092631.1888748-1-gshan@redhat.com
    Link: https://lkml.kernel.org/r/20210809092631.1888748-2-gshan@redhat.comSigned-off-by: default avatarGavin Shan <gshan@redhat.com>
    Reviewed-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
    Tested-by: Christophe Leroy <christophe.leroy@csgroup.eu>	[powerpc 8xx]
    Tested-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>	[s390]
    Cc: Anshuman Khandual <anshuman.khandual@arm.com>
    Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
    Cc: Qian Cai <cai@lca.pw>
    Cc: Catalin Marinas <catalin.marinas@arm.com>
    Cc: Will Deacon <will@kernel.org>
    Cc: Vineet Gupta <vgupta@synopsys.com>
    Cc: Chunyu Hu <chuhu@redhat.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    3c9b84f0
debug_vm_pgtable.c 38 KB