Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support page table check PowerPC #724

Closed
wants to merge 12 commits into from
Closed

Commits on Mar 15, 2024

  1. Revert "mm/page_table_check: remove unused parameter in [__]page_tabl…

    …e_check_pud_set"
    
    This reverts commit 6d14443.
    
    Reinstate previously unused parameters for the purpose of supporting
    powerpc platforms, as many do not encode user/kernel ownership of the
    page in the pte, but instead in the address of the access.
    
    riscv: Respect change to delete mm, addr parameters from __set_pte_at()
    
    This commit also changed calls to __set_pte_at() to use fewer parameters
    on riscv. Keep that change rather than reverting it, as the signature of
    __set_pte_at() is changed in a different commit.
    
    Signed-off-by: Rohan McLure <rmclure@linux.ibm.com>
    Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
    rohanmclure authored and Björn Töpel committed Mar 15, 2024
    Configuration menu
    Copy the full SHA
    b70d3ad View commit details
    Browse the repository at this point in the history
  2. Revert "mm/page_table_check: remove unused parameter in [__]page_tabl…

    …e_check_pmd_set"
    
    This reverts commit a3b8371.
    
    Reinstate previously unused parameters for the purpose of supporting
    powerpc platforms, as many do not encode user/kernel ownership of the
    page in the pte, but instead in the address of the access.
    
    riscv: Respect change to delete mm, addr parameters from __set_pte_at()
    
    This commit also changed calls to __set_pte_at() to use fewer parameters
    on riscv. Keep that change rather than reverting it, as the signature of
    __set_pte_at() is changed in a different commit.
    
    Signed-off-by: Rohan McLure <rmclure@linux.ibm.com>
    Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
    rohanmclure authored and Björn Töpel committed Mar 15, 2024
    Configuration menu
    Copy the full SHA
    c6c1013 View commit details
    Browse the repository at this point in the history
  3. mm: Provide addr parameter to page_table_check_pte_set()

    To provide support for powerpc platforms, provide an address parameter
    to the page_table_check_pte_set() routine. This parameter is needed on
    some powerpc platforms which do not encode whether a mapping is for
    user or kernel in the pte. On such platforms, this can be inferred
    from the addr parameter.
    
    Signed-off-by: Rohan McLure <rmclure@linux.ibm.com>
    Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
    rohanmclure authored and Björn Töpel committed Mar 15, 2024
    Configuration menu
    Copy the full SHA
    1038dac View commit details
    Browse the repository at this point in the history
  4. Revert "mm/page_table_check: remove unused parameter in [__]page_tabl…

    …e_check_pud_clear"
    
    This reverts commit 931c38e.
    
    Reinstate previously unused parameters for the purpose of supporting
    powerpc platforms, as many do not encode user/kernel ownership of the
    page in the pte, but instead in the address of the access.
    
    Signed-off-by: Rohan McLure <rmclure@linux.ibm.com>
    Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
    rohanmclure authored and Björn Töpel committed Mar 15, 2024
    Configuration menu
    Copy the full SHA
    56e89da View commit details
    Browse the repository at this point in the history
  5. Revert "mm/page_table_check: remove unused parameter in [__]page_tabl…

    …e_check_pmd_clear"
    
    This reverts commit 1831414.
    
    Reinstate previously unused parameters for the purpose of supporting
    powerpc platforms, as many do not encode user/kernel ownership of the
    page in the pte, but instead in the address of the access.
    
    Signed-off-by: Rohan McLure <rmclure@linux.ibm.com>
    Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
    rohanmclure authored and Björn Töpel committed Mar 15, 2024
    Configuration menu
    Copy the full SHA
    a9039a6 View commit details
    Browse the repository at this point in the history
  6. Revert "mm/page_table_check: remove unused parameter in [__]page_tabl…

    …e_check_pte_clear"
    
    This reverts commit aa23220.
    
    Reinstate previously unused parameters for the purpose of supporting
    powerpc platforms, as many do not encode user/kernel ownership of the
    page in the pte, but instead in the address of the access.
    
    Signed-off-by: Rohan McLure <rmclure@linux.ibm.com>
    Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
    rohanmclure authored and Björn Töpel committed Mar 15, 2024
    Configuration menu
    Copy the full SHA
    782491d View commit details
    Browse the repository at this point in the history
  7. mm: Provide address parameter to p{te,md,ud}_user_accessible_page()

    On several powerpc platforms, a page table entry may not imply whether
    the relevant mapping is for userspace or kernelspace. Instead, such
    platforms infer this by the address which is being accessed.
    
    Add an additional address argument to each of these routines in order to
    provide support for page table check on powerpc.
    
    Signed-off-by: Rohan McLure <rmclure@linux.ibm.com>
    Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
    rohanmclure authored and Björn Töpel committed Mar 15, 2024
    Configuration menu
    Copy the full SHA
    4a2ee04 View commit details
    Browse the repository at this point in the history
  8. powerpc: mm: Replace p{u,m,4}d_is_leaf with p{u,m,4}_leaf

    Replace occurrences of p{u,m,4}d_is_leaf with p{u,m,4}_leaf, as the
    latter is the name given to checking that a higher-level entry in
    multi-level paging contains a page translation entry (pte) throughout
    all other archs.
    
    Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
    Signed-off-by: Rohan McLure <rmclure@linux.ibm.com>
    Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
    rohanmclure authored and Björn Töpel committed Mar 15, 2024
    Configuration menu
    Copy the full SHA
    b7923f9 View commit details
    Browse the repository at this point in the history
  9. powerpc: mm: Add common pud_pfn stub for all platforms

    Prior to this commit, pud_pfn was implemented with BUILD_BUG as the inline
    function for 64-bit Book3S systems but is never included, as its
    invocations in generic code are guarded by calls to pud_devmap which return
    zero on such systems. A future patch will provide support for page table
    checks, the generic code for which depends on a pud_pfn stub being
    implemented, even while the patch will not interact with puds directly.
    
    Remove the 64-bit Book3S stub and define pud_pfn to warn on all
    platforms. pud_pfn may be defined properly on a per-platform basis
    should it grow real usages in future.
    
    Signed-off-by: Rohan McLure <rmclure@linux.ibm.com>
    Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
    rohanmclure authored and Björn Töpel committed Mar 15, 2024
    Configuration menu
    Copy the full SHA
    43a9e0f View commit details
    Browse the repository at this point in the history
  10. poweprc: mm: Implement *_user_accessible_page() for ptes

    Page table checking depends on architectures providing an
    implementation of p{te,md,ud}_user_accessible_page. With
    refactorisations made on powerpc/mm, the pte_access_permitted() and
    similar methods verify whether a userland page is accessible with the
    required permissions.
    
    Since page table checking is the only user of
    p{te,md,ud}_user_accessible_page(), implement these for all platforms,
    using some of the same preliminay checks taken by pte_access_permitted()
    on that platform.
    
    Since Commit 8e9bd41 ("powerpc/nohash: Replace pte_user() by pte_read()")
    pte_user() is no longer required to be present on all platforms as it
    may be equivalent to or implied by pte_read(). Hence implementations are
    specialised.
    
    Signed-off-by: Rohan McLure <rmclure@linux.ibm.com>
    Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
    rohanmclure authored and Björn Töpel committed Mar 15, 2024
    Configuration menu
    Copy the full SHA
    09d5351 View commit details
    Browse the repository at this point in the history
  11. powerpc: mm: Use set_pte_at_unchecked() for early-boot / internal usages

    In the new set_ptes() API, set_pte_at() (a special case of set_ptes())
    is intended to be instrumented by the page table check facility. There
    are however several other routines that constitute the API for setting
    page table entries, including set_pmd_at() among others. Such routines
    are themselves implemented in terms of set_ptes_at().
    
    A future patch providing support for page table checking on powerpc
    must take care to avoid duplicate calls to
    page_table_check_p{te,md,ud}_set(). Allow for assignment of pte entries
    without instrumentation through the set_pte_at_unchecked() routine
    introduced in this patch.
    
    Cause API-facing routines that call set_pte_at() to instead call
    set_pte_at_unchecked(), which will remain uninstrumented by page
    table check. set_ptes() is itself implemented by calls to
    __set_pte_at(), so this eliminates redundant code.
    
    Also prefer set_pte_at_unchecked() in early-boot usages which should not be
    instrumented.
    
    Signed-off-by: Rohan McLure <rmclure@linux.ibm.com>
    Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
    rohanmclure authored and Björn Töpel committed Mar 15, 2024
    Configuration menu
    Copy the full SHA
    e5b2890 View commit details
    Browse the repository at this point in the history
  12. powerpc: mm: Support page table check

    On creation and clearing of a page table mapping, instrument such calls
    by invoking page_table_check_pte_set and page_table_check_pte_clear
    respectively. These calls serve as a sanity check against illegal
    mappings.
    
    Enable ARCH_SUPPORTS_PAGE_TABLE_CHECK for all platforms.
    
    See also:
    
    riscv support in commit 3fee229 ("riscv/mm: enable
    ARCH_SUPPORTS_PAGE_TABLE_CHECK")
    arm64 in commit 42b2547 ("arm64/mm: enable
    ARCH_SUPPORTS_PAGE_TABLE_CHECK")
    x86_64 in commit d283d42 ("x86: mm: add x86_64 support for page table
    check")
    
    Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
    Signed-off-by: Rohan McLure <rmclure@linux.ibm.com>
    Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
    rohanmclure authored and Björn Töpel committed Mar 15, 2024
    Configuration menu
    Copy the full SHA
    58aa237 View commit details
    Browse the repository at this point in the history