From: Andrew Donnellan <ajd@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org, pasha.tatashin@soleen.com,
akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, x86@kernel.org,
linux-riscv@lists.infradead.org,
linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org,
sweettea-kernel@dorminy.me, christophe.leroy@csgroup.eu,
mingo@kernel.org
Subject: [PATCH v15 00/13] Support page table check on PowerPC
Date: Wed, 25 Jun 2025 16:37:40 +1000 [thread overview]
Message-ID: <20250625063753.77511-1-ajd@linux.ibm.com> (raw)
Support page table check on all PowerPC platforms. This works by
serialising assignments, reassignments and clears of page table
entries at each level in order to ensure that anonymous mappings
have at most one writable consumer, and likewise that file-backed
mappings are not simultaneously also anonymous mappings.
In order to support this infrastructure, a number of stubs must be
defined for all powerpc platforms. Additionally, separate set_pte_at()
and set_pte_at_unchecked(), to allow for internal, uninstrumented mappings.
On some PowerPC platforms, implementing {pte,pmd,pud}_user_accessible_page()
requires the address. We revert previous changes that removed the address
parameter from various interfaces, and add it to some other interfaces,
in order to allow this.
(This series was initially written by Rohan McLure, who has left IBM and
is no longer working on powerpc.)
v15:
* Rebase on mainline, including commit 91e40668e70a
("mm/page_table_check: Batch-check pmds/puds just like ptes") and
associated arm64 changes
* Clarify/fix some commit messages
* Fix handling of address in a loop in __page_table_check_ptes_set()
v14:
* Fix a call to page_table_check_pud_set() that was missed (akpm)
Link: https://lore.kernel.org/all/20250411054354.511145-1-ajd@linux.ibm.com/
v13:
* Rebase on mainline
* Don't use set_pte_at_unchecked() for early boot purposes (Pasha)
Link: https://lore.kernel.org/linuxppc-dev/20250211161404.850215-1-ajd@linux.ibm.com/
v12:
* Rename commits that revert changes to instead reflect that we are
reinstating old behaviour due to it providing more flexibility
* Add return line to pud_pfn() stub
* Instrument ptep_get_and_clear() for nohash
Link: https://lore.kernel.org/linuxppc-dev/20240402051154.476244-1-rmclure@linux.ibm.com/
v11:
* The pud_pfn() stub, which previously had no legitimate users on any
powerpc platform, now has users in Book3s64 with transparent pages.
Include a stub of the same name for each platform that does not
define their own.
* Drop patch that standardised use of p*d_leaf(), as already included
upstream in v6.9.
* Provide fallback definitions of p{m,u}d_user_accessible_page() that
do not reference p*d_leaf(), p*d_pte(), as they are defined after
powerpc/mm headers by linux/mm headers.
* Ensure that set_pte_at_unchecked() has the same checks as
set_pte_at().
Link: https://lore.kernel.org/linuxppc-dev/20240328045535.194800-14-rmclure@linux.ibm.com/
v10:
* Revert patches that removed address and mm parameters from page table
check routines, including consuming code from arm64, x86_64 and
riscv.
* Implement *_user_accessible_page() routines in terms of pte_user()
where available (64-bit, book3s) but otherwise by checking the
address (on platforms where the pte does not imply whether the
mapping is for user or kernel)
* Internal set_pte_at() calls replaced with set_pte_at_unchecked(), which
is identical, but prevents double instrumentation.
Link: https://lore.kernel.org/linuxppc-dev/20240313042118.230397-9-rmclure@linux.ibm.com/T/
v9:
* Adapt to using the set_ptes() API, using __set_pte_at() where we need
must avoid instrumentation.
* Use the logic of *_access_permitted() for implementing
*_user_accessible_page(), which are required routines for page table
check.
* Even though we no longer need p{m,u,4}d_leaf(), still default
implement these to assist in refactoring out extant
p{m,u,4}_is_leaf().
* Add p{m,u}_pte() stubs where asm-generic does not provide them, as
page table check wants all *user_accessible_page() variants, and we
would like to default implement the variants in terms of
pte_user_accessible_page().
* Avoid the ugly pmdp_collapse_flush() macro nonsense! Just instrument
its constituent calls instead for radix and hash.
Link: https://lore.kernel.org/linuxppc-dev/20231130025404.37179-2-rmclure@linux.ibm.com/
v8:
* Fix linux/page_table_check.h include in asm/pgtable.h breaking
32-bit.
Link: https://lore.kernel.org/linuxppc-dev/20230215231153.2147454-1-rmclure@linux.ibm.com/
v7:
* Remove use of extern in set_pte prototypes
* Clean up pmdp_collapse_flush macro
* Replace set_pte_at with static inline function
* Fix commit message for patch 7
Link: https://lore.kernel.org/linuxppc-dev/20230215020155.1969194-1-rmclure@linux.ibm.com/
v6:
* Support huge pages and p{m,u}d accounting.
* Remove instrumentation from set_pte from kernel internal pages.
* 64s: Implement pmdp_collapse_flush in terms of __pmdp_collapse_flush
as access to the mm_struct * is required.
Link: https://lore.kernel.org/linuxppc-dev/20230214015939.1853438-1-rmclure@linux.ibm.com/
v5:
Link: https://lore.kernel.org/linuxppc-dev/20221118002146.25979-1-rmclure@linux.ibm.com/
Andrew Donnellan (2):
arm64/mm: Add addr parameter to __set_{ptes_anysz,ptes,pmds,puds}()
arm64/mm: Add addr parameter to __ptep_get_and_clear_anysz()
Rohan McLure (11):
mm/page_table_check: Reinstate address parameter in
[__]page_table_check_pud[s]_set()
mm/page_table_check: Reinstate address parameter in
[__]page_table_check_pmd[s]_set()
mm/page_table_check: Provide addr parameter to
[__]page_table_check_ptes_set()
mm/page_table_check: Reinstate address parameter in
[__]page_table_check_pud_clear()
mm/page_table_check: Reinstate address parameter in
[__]page_table_check_pmd_clear()
mm/page_table_check: Reinstate address parameter in
[__]page_table_check_pte_clear()
mm: Provide address parameter to p{te,md,ud}_user_accessible_page()
powerpc: mm: Add pud_pfn() stub
powerpc: mm: Implement *_user_accessible_page() for ptes
powerpc: mm: Use set_pte_at_unchecked() for internal usages
powerpc: mm: Support page table check
arch/arm64/include/asm/pgtable.h | 46 ++++++-------
arch/arm64/mm/hugetlbpage.c | 15 +++--
arch/powerpc/Kconfig | 1 +
arch/powerpc/include/asm/book3s/32/pgtable.h | 12 +++-
arch/powerpc/include/asm/book3s/64/pgtable.h | 62 +++++++++++++++---
arch/powerpc/include/asm/nohash/pgtable.h | 13 +++-
arch/powerpc/include/asm/pgtable.h | 19 ++++++
arch/powerpc/mm/book3s64/hash_pgtable.c | 4 ++
arch/powerpc/mm/book3s64/pgtable.c | 17 +++--
arch/powerpc/mm/book3s64/radix_pgtable.c | 9 ++-
arch/powerpc/mm/pgtable.c | 12 ++++
arch/riscv/include/asm/pgtable.h | 20 +++---
arch/x86/include/asm/pgtable.h | 22 +++----
include/linux/page_table_check.h | 69 ++++++++++++--------
include/linux/pgtable.h | 10 +--
mm/page_table_check.c | 41 ++++++------
16 files changed, 247 insertions(+), 125 deletions(-)
--
2.49.0
next reply other threads:[~2025-06-25 7:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-25 6:37 Andrew Donnellan [this message]
2025-06-25 6:37 ` [PATCH v15 01/13] arm64/mm: Add addr parameter to __set_{ptes_anysz,ptes,pmds,puds}() Andrew Donnellan
2025-06-25 6:37 ` [PATCH v15 02/13] arm64/mm: Add addr parameter to __ptep_get_and_clear_anysz() Andrew Donnellan
2025-06-25 6:37 ` [PATCH v15 03/13] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pud[s]_set() Andrew Donnellan
2025-06-25 6:37 ` [PATCH v15 04/13] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pmd[s]_set() Andrew Donnellan
2025-06-25 6:37 ` [PATCH v15 05/13] mm/page_table_check: Provide addr parameter to [__]page_table_check_ptes_set() Andrew Donnellan
2025-06-25 6:37 ` [PATCH v15 06/13] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pud_clear() Andrew Donnellan
2025-06-25 6:37 ` [PATCH v15 07/13] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pmd_clear() Andrew Donnellan
2025-06-25 6:37 ` [PATCH v15 08/13] mm/page_table_check: Reinstate address parameter in [__]page_table_check_pte_clear() Andrew Donnellan
2025-06-25 6:37 ` [PATCH v15 09/13] mm: Provide address parameter to p{te,md,ud}_user_accessible_page() Andrew Donnellan
2025-06-25 6:37 ` [PATCH v15 10/13] powerpc: mm: Add pud_pfn() stub Andrew Donnellan
2025-06-25 6:37 ` [PATCH v15 11/13] powerpc: mm: Implement *_user_accessible_page() for ptes Andrew Donnellan
2025-06-25 6:37 ` [PATCH v15 12/13] powerpc: mm: Use set_pte_at_unchecked() for internal usages Andrew Donnellan
2025-06-25 6:37 ` [PATCH v15 13/13] powerpc: mm: Support page table check Andrew Donnellan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250625063753.77511-1-ajd@linux.ibm.com \
--to=ajd@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=christophe.leroy@csgroup.eu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mingo@kernel.org \
--cc=pasha.tatashin@soleen.com \
--cc=sweettea-kernel@dorminy.me \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).