Skip to content

[PW_SID:952333] Support page table check on PowerPC#291

Closed
linux-riscv-bot wants to merge 11 commits intoworkflow__riscv__fixesfrom
pw952333
Closed

[PW_SID:952333] Support page table check on PowerPC#291
linux-riscv-bot wants to merge 11 commits intoworkflow__riscv__fixesfrom
pw952333

Conversation

@linux-riscv-bot
Copy link

PR for series 952333 applied to workflow__riscv__fixes

Name: Support page table check on PowerPC
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=952333
Version: 14

…eck_pud_set()

This reverts commit 6d14443 ("mm/page_table_check: remove unused
parameter in [__]page_table_check_pud_set").

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>
Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
[ajd: rebase on riscv changes, remove riscv commit message comment]
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
…eck_pmd_set()

This reverts commit a3b8371 ("mm/page_table_check: remove unused
parameter in [__]page_table_check_pmd_set").

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>
Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
[ajd: rebase on riscv and mm/page_table_check.c changes, remove riscv
commit message comment]
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
…et()

To provide support for powerpc platforms, provide an addr 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 form the
addr parameter.

Signed-off-by: Rohan McLure <rmclure@linux.ibm.com>
Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
[ajd: rebase]
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
…eck_pud_clear()

This reverts commit 931c38e ("mm/page_table_check: remove unused
parameter in [__]page_table_check_pud_clear").

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>
Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
…eck_pmd_clear()

This reverts commit 1831414 ("mm/page_table_check: remove unused
parameter in [__]page_table_check_pmd_clear").

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>
Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
…eck_pte_clear()

This reverts commit aa23220 ("mm/page_table_check: remove unused
parameter in [__]page_table_check_pte_clear").

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>
Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
[ajd: rebase and fix additional occurrence]
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
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>
Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
[ajd: rebase on arm64 changes]
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The page table check feature requires that pud_pfn() be defined
on each consuming architecture. Since only 64-bit, Book3S platforms
allow for hugepages at this upper level, and since the calling code is
gated by a call to pud_user_accessible_page(), which will return zero,
include this stub as a BUILD_BUG().

Signed-off-by: Rohan McLure <rmclure@linux.ibm.com>
Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
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 preliminary 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 of
pte_user_accessible_page() are specialised.

Signed-off-by: Rohan McLure <rmclure@linux.ibm.com>
Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
[ajd: rebase and fix commit message]
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
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.

Signed-off-by: Rohan McLure <rmclure@linux.ibm.com>
[ajd: don't change to unchecked for early boot/kernel mappings]
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
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>
Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
[ajd: rebase]
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
@linux-riscv-bot
Copy link
Author

Patch 1: "[v14,01/11] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pud_set()"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 99.32 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[v14,01/11] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pud_set()"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1683.98 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[v14,01/11] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pud_set()"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 2261.73 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[v14,01/11] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pud_set()"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 19.29 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[v14,01/11] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pud_set()"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 20.79 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[v14,01/11] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pud_set()"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.48 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[v14,01/11] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pud_set()"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 69.59 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[v14,01/11] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pud_set()"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 16.55 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[v14,01/11] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pud_set()"
kdoc
Desc: Detects for kdoc errors
Duration: 1.40 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[v14,01/11] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pud_set()"
module-param
Desc: Detect module_param changes
Duration: 0.27 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[v14,01/11] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pud_set()"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[v14,01/11] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pud_set()"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.30 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 2: "[v14,02/11] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pmd_set()"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 99.90 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 2: "[v14,02/11] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pmd_set()"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1685.75 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 2: "[v14,02/11] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pmd_set()"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 2264.11 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 2: "[v14,02/11] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pmd_set()"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 19.37 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 2: "[v14,02/11] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pmd_set()"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 20.90 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 2: "[v14,02/11] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pmd_set()"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.49 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 2: "[v14,02/11] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pmd_set()"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 38.08 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 9: "[v14,09/11] powerpc: mm: Implement *_user_accessible_page() for ptes"
kdoc
Desc: Detects for kdoc errors
Duration: 0.93 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 9: "[v14,09/11] powerpc: mm: Implement *_user_accessible_page() for ptes"
module-param
Desc: Detect module_param changes
Duration: 0.29 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 9: "[v14,09/11] powerpc: mm: Implement *_user_accessible_page() for ptes"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.73 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 9: "[v14,09/11] powerpc: mm: Implement *_user_accessible_page() for ptes"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 5.97 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 10: "[v14,10/11] powerpc: mm: Use set_pte_at_unchecked() for internal usages"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 99.53 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 10: "[v14,10/11] powerpc: mm: Use set_pte_at_unchecked() for internal usages"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 851.66 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 10: "[v14,10/11] powerpc: mm: Use set_pte_at_unchecked() for internal usages"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1135.42 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 10: "[v14,10/11] powerpc: mm: Use set_pte_at_unchecked() for internal usages"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 19.58 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 10: "[v14,10/11] powerpc: mm: Use set_pte_at_unchecked() for internal usages"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 20.59 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 10: "[v14,10/11] powerpc: mm: Use set_pte_at_unchecked() for internal usages"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 10: "[v14,10/11] powerpc: mm: Use set_pte_at_unchecked() for internal usages"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 37.94 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 10: "[v14,10/11] powerpc: mm: Use set_pte_at_unchecked() for internal usages"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.25 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 10: "[v14,10/11] powerpc: mm: Use set_pte_at_unchecked() for internal usages"
kdoc
Desc: Detects for kdoc errors
Duration: 0.85 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 10: "[v14,10/11] powerpc: mm: Use set_pte_at_unchecked() for internal usages"
module-param
Desc: Detect module_param changes
Duration: 0.27 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 10: "[v14,10/11] powerpc: mm: Use set_pte_at_unchecked() for internal usages"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 10: "[v14,10/11] powerpc: mm: Use set_pte_at_unchecked() for internal usages"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.32 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 11: "[v14,11/11] powerpc: mm: Support page table check"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 99.91 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 11: "[v14,11/11] powerpc: mm: Support page table check"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 852.37 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 11: "[v14,11/11] powerpc: mm: Support page table check"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1133.35 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 11: "[v14,11/11] powerpc: mm: Support page table check"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 20.12 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 11: "[v14,11/11] powerpc: mm: Support page table check"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 34.82 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 11: "[v14,11/11] powerpc: mm: Support page table check"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 3.01 seconds
Result: WARNING
Output:

WARNING: braces {} are not necessary for any arm of this statement
#130: FILE: arch/powerpc/include/asm/book3s/64/pgtable.h:1324:
+	if (radix_enabled()) {
[...]
+	} else {
[...]

WARNING: braces {} are not necessary for any arm of this statement
#151: FILE: arch/powerpc/include/asm/book3s/64/pgtable.h:1341:
+	if (radix_enabled()) {
[...]
+	} else {
[...]

WARNING: Do not crash the kernel unless it is absolutely unavoidable--use WARN_ON_ONCE() plus recovery code (if feasible) instead of BUG() or variants
#154: FILE: arch/powerpc/include/asm/book3s/64/pgtable.h:1344:
+		BUG();

WARNING: line length of 102 exceeds 100 columns
#248: FILE: arch/powerpc/mm/book3s64/pgtable.c:189:
+	old_pmd = __pmd(pmd_hugepage_update(vma->vm_mm, address, pmdp, _PAGE_PRESENT, _PAGE_INVALID));

total: 0 errors, 4 warnings, 0 checks, 210 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Commit 095c3d9f5695 ("powerpc: mm: Support page table check") has style problems, please review.

NOTE: Ignored message types: ALLOC_SIZEOF_STRUCT CAMELCASE COMMIT_LOG_LONG_LINE GIT_COMMIT_ID MACRO_ARG_REUSE NO_AUTHOR_SIGN_OFF

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.
total: 0 errors, 4 warnings, 0 checks, 210 lines checked
WARNING: Do not crash the kernel unless it is absolutely unavoidable--use WARN_ON_ONCE() plus recovery code (if feasible) instead of BUG() or variants
WARNING: braces {} are not necessary for any arm of this statement
WARNING: line length of 102 exceeds 100 columns


@linux-riscv-bot
Copy link
Author

Patch 11: "[v14,11/11] powerpc: mm: Support page table check"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 45.41 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 11: "[v14,11/11] powerpc: mm: Support page table check"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.26 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 11: "[v14,11/11] powerpc: mm: Support page table check"
kdoc
Desc: Detects for kdoc errors
Duration: 0.92 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 11: "[v14,11/11] powerpc: mm: Support page table check"
module-param
Desc: Detect module_param changes
Duration: 0.29 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 11: "[v14,11/11] powerpc: mm: Support page table check"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 5.99 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 11: "[v14,11/11] powerpc: mm: Support page table check"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.32 seconds
Result: PASS

@linux-riscv-bot linux-riscv-bot deleted the pw952333 branch April 16, 2025 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants