From: Madhavan Srinivasan <maddy@linux.ibm.com>
To: Alexander Gordeev <agordeev@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
Andrew Morton <akpm@linux-foundation.org>,
Vasily Gorbik <gor@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>
Cc: linux-s390@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linuxppc-dev@lists.ozlabs.org, x86@kernel.org
Subject: Re: [PATCH v2 1/4] mm/page_table_check: Pass mm_struct to pxx_user_accessible_page()
Date: Wed, 11 Mar 2026 18:11:16 +0530 [thread overview]
Message-ID: <ef7212dd-429c-4b64-bad6-4c37d27775d5@linux.ibm.com> (raw)
In-Reply-To: <ca77f3489453c2fe01b25e50e53b778929e0dfc5.1772812343.git.agordeev@linux.ibm.com>
On 3/6/26 9:46 PM, Alexander Gordeev wrote:
> From: Tobias Huschle <huschle@linux.ibm.com>
>
> Unlike other architectures, s390 does not have means to
> distinguish kernel vs user page table entries - neither
> an entry itself, nor the address could be used for that.
> It is only the mm_struct that indicates whether an entry
> in question is mapped to a user space. So pass mm_struct
> to pxx_user_accessible_page() callbacks.
Changes looks fine to me
Acked-by: Madhavan Srinivasan <maddy@linux.ibm.com>
> [agordeev@linux.ibm.com: rephrased commit message, removed braces]
>
> Reviewed-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
> Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Tobias Huschle <huschle@linux.ibm.com>
> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
> ---
> arch/arm64/include/asm/pgtable.h | 6 +++---
> arch/powerpc/include/asm/book3s/32/pgtable.h | 2 +-
> arch/powerpc/include/asm/book3s/64/pgtable.h | 10 +++++-----
> arch/powerpc/include/asm/nohash/pgtable.h | 2 +-
> arch/powerpc/include/asm/pgtable.h | 4 ++--
> arch/riscv/include/asm/pgtable.h | 6 +++---
> arch/x86/include/asm/pgtable.h | 6 +++---
> mm/page_table_check.c | 15 ++++++---------
> 8 files changed, 24 insertions(+), 27 deletions(-)
>
> diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
> index b3e58735c49b..ccf0e0638767 100644
> --- a/arch/arm64/include/asm/pgtable.h
> +++ b/arch/arm64/include/asm/pgtable.h
> @@ -1263,17 +1263,17 @@ static inline int pmdp_set_access_flags(struct vm_area_struct *vma,
> #endif
>
> #ifdef CONFIG_PAGE_TABLE_CHECK
> -static inline bool pte_user_accessible_page(pte_t pte, unsigned long addr)
> +static inline bool pte_user_accessible_page(struct mm_struct *mm, unsigned long addr, pte_t pte)
> {
> return pte_valid(pte) && (pte_user(pte) || pte_user_exec(pte));
> }
>
> -static inline bool pmd_user_accessible_page(pmd_t pmd, unsigned long addr)
> +static inline bool pmd_user_accessible_page(struct mm_struct *mm, unsigned long addr, pmd_t pmd)
> {
> return pmd_valid(pmd) && !pmd_table(pmd) && (pmd_user(pmd) || pmd_user_exec(pmd));
> }
>
> -static inline bool pud_user_accessible_page(pud_t pud, unsigned long addr)
> +static inline bool pud_user_accessible_page(struct mm_struct *mm, unsigned long addr, pud_t pud)
> {
> return pud_valid(pud) && !pud_table(pud) && (pud_user(pud) || pud_user_exec(pud));
> }
> diff --git a/arch/powerpc/include/asm/book3s/32/pgtable.h b/arch/powerpc/include/asm/book3s/32/pgtable.h
> index 001e28f9eabc..75195bb44d06 100644
> --- a/arch/powerpc/include/asm/book3s/32/pgtable.h
> +++ b/arch/powerpc/include/asm/book3s/32/pgtable.h
> @@ -438,7 +438,7 @@ static inline bool pte_access_permitted(pte_t pte, bool write)
> return true;
> }
>
> -static inline bool pte_user_accessible_page(pte_t pte, unsigned long addr)
> +static inline bool pte_user_accessible_page(struct mm_struct *mm, unsigned long addr, pte_t pte)
> {
> return pte_present(pte) && !is_kernel_addr(addr);
> }
> diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h
> index 1a91762b455d..a56df313b585 100644
> --- a/arch/powerpc/include/asm/book3s/64/pgtable.h
> +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
> @@ -549,7 +549,7 @@ static inline bool pte_access_permitted(pte_t pte, bool write)
> return arch_pte_access_permitted(pte_val(pte), write, 0);
> }
>
> -static inline bool pte_user_accessible_page(pte_t pte, unsigned long addr)
> +static inline bool pte_user_accessible_page(struct mm_struct *mm, unsigned long addr, pte_t pte)
> {
> return pte_present(pte) && pte_user(pte);
> }
> @@ -925,9 +925,9 @@ static inline bool pud_access_permitted(pud_t pud, bool write)
> }
>
> #define pud_user_accessible_page pud_user_accessible_page
> -static inline bool pud_user_accessible_page(pud_t pud, unsigned long addr)
> +static inline bool pud_user_accessible_page(struct mm_struct *mm, unsigned long addr, pud_t pud)
> {
> - return pud_leaf(pud) && pte_user_accessible_page(pud_pte(pud), addr);
> + return pud_leaf(pud) && pte_user_accessible_page(mm, addr, pud_pte(pud));
> }
>
> #define __p4d_raw(x) ((p4d_t) { __pgd_raw(x) })
> @@ -1096,9 +1096,9 @@ static inline bool pmd_access_permitted(pmd_t pmd, bool write)
> }
>
> #define pmd_user_accessible_page pmd_user_accessible_page
> -static inline bool pmd_user_accessible_page(pmd_t pmd, unsigned long addr)
> +static inline bool pmd_user_accessible_page(struct mm_struct *mm, unsigned long addr, pmd_t pmd)
> {
> - return pmd_leaf(pmd) && pte_user_accessible_page(pmd_pte(pmd), addr);
> + return pmd_leaf(pmd) && pte_user_accessible_page(mm, addr, pmd_pte(pmd));
> }
>
> #ifdef CONFIG_TRANSPARENT_HUGEPAGE
> diff --git a/arch/powerpc/include/asm/nohash/pgtable.h b/arch/powerpc/include/asm/nohash/pgtable.h
> index e6da5eaccff6..0665d0abe89f 100644
> --- a/arch/powerpc/include/asm/nohash/pgtable.h
> +++ b/arch/powerpc/include/asm/nohash/pgtable.h
> @@ -249,7 +249,7 @@ static inline bool pte_access_permitted(pte_t pte, bool write)
> return true;
> }
>
> -static inline bool pte_user_accessible_page(pte_t pte, unsigned long addr)
> +static inline bool pte_user_accessible_page(struct mm_struct *mm, unsigned long addr, pte_t pte)
> {
> return pte_present(pte) && !is_kernel_addr(addr);
> }
> diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
> index dcd3a88caaf6..29ed509cd235 100644
> --- a/arch/powerpc/include/asm/pgtable.h
> +++ b/arch/powerpc/include/asm/pgtable.h
> @@ -205,11 +205,11 @@ static inline bool arch_supports_memmap_on_memory(unsigned long vmemmap_size)
> #endif /* CONFIG_PPC64 */
>
> #ifndef pmd_user_accessible_page
> -#define pmd_user_accessible_page(pmd, addr) false
> +#define pmd_user_accessible_page(mm, addr, pmd) false
> #endif
>
> #ifndef pud_user_accessible_page
> -#define pud_user_accessible_page(pud, addr) false
> +#define pud_user_accessible_page(mm, addr, pud) false
> #endif
>
> #endif /* __ASSEMBLER__ */
> diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
> index 08d1ca047104..affe46cf3bc5 100644
> --- a/arch/riscv/include/asm/pgtable.h
> +++ b/arch/riscv/include/asm/pgtable.h
> @@ -984,17 +984,17 @@ static inline void set_pud_at(struct mm_struct *mm, unsigned long addr,
> }
>
> #ifdef CONFIG_PAGE_TABLE_CHECK
> -static inline bool pte_user_accessible_page(pte_t pte, unsigned long addr)
> +static inline bool pte_user_accessible_page(struct mm_struct *mm, unsigned long addr, pte_t pte)
> {
> return pte_present(pte) && pte_user(pte);
> }
>
> -static inline bool pmd_user_accessible_page(pmd_t pmd, unsigned long addr)
> +static inline bool pmd_user_accessible_page(struct mm_struct *mm, unsigned long addr, pmd_t pmd)
> {
> return pmd_leaf(pmd) && pmd_user(pmd);
> }
>
> -static inline bool pud_user_accessible_page(pud_t pud, unsigned long addr)
> +static inline bool pud_user_accessible_page(struct mm_struct *mm, unsigned long addr, pud_t pud)
> {
> return pud_leaf(pud) && pud_user(pud);
> }
> diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
> index 1662c5a8f445..f9353d5c7464 100644
> --- a/arch/x86/include/asm/pgtable.h
> +++ b/arch/x86/include/asm/pgtable.h
> @@ -1680,17 +1680,17 @@ static inline bool arch_has_hw_nonleaf_pmd_young(void)
> #endif
>
> #ifdef CONFIG_PAGE_TABLE_CHECK
> -static inline bool pte_user_accessible_page(pte_t pte, unsigned long addr)
> +static inline bool pte_user_accessible_page(struct mm_struct *mm, unsigned long addr, pte_t pte)
> {
> return (pte_val(pte) & _PAGE_PRESENT) && (pte_val(pte) & _PAGE_USER);
> }
>
> -static inline bool pmd_user_accessible_page(pmd_t pmd, unsigned long addr)
> +static inline bool pmd_user_accessible_page(struct mm_struct *mm, unsigned long addr, pmd_t pmd)
> {
> return pmd_leaf(pmd) && (pmd_val(pmd) & _PAGE_PRESENT) && (pmd_val(pmd) & _PAGE_USER);
> }
>
> -static inline bool pud_user_accessible_page(pud_t pud, unsigned long addr)
> +static inline bool pud_user_accessible_page(struct mm_struct *mm, unsigned long addr, pud_t pud)
> {
> return pud_leaf(pud) && (pud_val(pud) & _PAGE_PRESENT) && (pud_val(pud) & _PAGE_USER);
> }
> diff --git a/mm/page_table_check.c b/mm/page_table_check.c
> index 2708c2b3ac1f..53a8997ec043 100644
> --- a/mm/page_table_check.c
> +++ b/mm/page_table_check.c
> @@ -151,9 +151,8 @@ void __page_table_check_pte_clear(struct mm_struct *mm, unsigned long addr,
> if (&init_mm == mm)
> return;
>
> - if (pte_user_accessible_page(pte, addr)) {
> + if (pte_user_accessible_page(mm, addr, pte))
> page_table_check_clear(pte_pfn(pte), PAGE_SIZE >> PAGE_SHIFT);
> - }
> }
> EXPORT_SYMBOL(__page_table_check_pte_clear);
>
> @@ -163,9 +162,8 @@ void __page_table_check_pmd_clear(struct mm_struct *mm, unsigned long addr,
> if (&init_mm == mm)
> return;
>
> - if (pmd_user_accessible_page(pmd, addr)) {
> + if (pmd_user_accessible_page(mm, addr, pmd))
> page_table_check_clear(pmd_pfn(pmd), PMD_SIZE >> PAGE_SHIFT);
> - }
> }
> EXPORT_SYMBOL(__page_table_check_pmd_clear);
>
> @@ -175,9 +173,8 @@ void __page_table_check_pud_clear(struct mm_struct *mm, unsigned long addr,
> if (&init_mm == mm)
> return;
>
> - if (pud_user_accessible_page(pud, addr)) {
> + if (pud_user_accessible_page(mm, addr, pud))
> page_table_check_clear(pud_pfn(pud), PUD_SIZE >> PAGE_SHIFT);
> - }
> }
> EXPORT_SYMBOL(__page_table_check_pud_clear);
>
> @@ -211,7 +208,7 @@ void __page_table_check_ptes_set(struct mm_struct *mm, unsigned long addr,
>
> for (i = 0; i < nr; i++)
> __page_table_check_pte_clear(mm, addr + PAGE_SIZE * i, ptep_get(ptep + i));
> - if (pte_user_accessible_page(pte, addr))
> + if (pte_user_accessible_page(mm, addr, pte))
> page_table_check_set(pte_pfn(pte), nr, pte_write(pte));
> }
> EXPORT_SYMBOL(__page_table_check_ptes_set);
> @@ -241,7 +238,7 @@ void __page_table_check_pmds_set(struct mm_struct *mm, unsigned long addr,
>
> for (i = 0; i < nr; i++)
> __page_table_check_pmd_clear(mm, addr + PMD_SIZE * i, *(pmdp + i));
> - if (pmd_user_accessible_page(pmd, addr))
> + if (pmd_user_accessible_page(mm, addr, pmd))
> page_table_check_set(pmd_pfn(pmd), stride * nr, pmd_write(pmd));
> }
> EXPORT_SYMBOL(__page_table_check_pmds_set);
> @@ -257,7 +254,7 @@ void __page_table_check_puds_set(struct mm_struct *mm, unsigned long addr,
>
> for (i = 0; i < nr; i++)
> __page_table_check_pud_clear(mm, addr + PUD_SIZE * i, *(pudp + i));
> - if (pud_user_accessible_page(pud, addr))
> + if (pud_user_accessible_page(mm, addr, pud))
> page_table_check_set(pud_pfn(pud), stride * nr, pud_write(pud));
> }
> EXPORT_SYMBOL(__page_table_check_puds_set);
next prev parent reply other threads:[~2026-03-11 12:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-06 16:16 mm/pgtable: Support for page table check on s390 Alexander Gordeev
2026-03-06 16:16 ` [PATCH v2 1/4] mm/page_table_check: Pass mm_struct to pxx_user_accessible_page() Alexander Gordeev
2026-03-11 2:59 ` Ritesh Harjani
2026-03-11 12:41 ` Madhavan Srinivasan [this message]
2026-03-12 15:02 ` Vasily Gorbik
2026-03-12 20:57 ` Andrew Morton
2026-03-12 22:45 ` Vasily Gorbik
2026-03-06 16:16 ` [PATCH v2 2/4] s390/pgtable: Use set_pmd_bit() to invalidate PMD entry Alexander Gordeev
2026-03-06 16:16 ` [PATCH v2 3/4] s390/pgtable: Add s390 support for page table check Alexander Gordeev
2026-03-06 16:16 ` [PATCH v2 4/4] s390: Enable page table check for debug_defconfig Alexander Gordeev
2026-03-12 22:46 ` mm/pgtable: Support for page table check on s390 Vasily Gorbik
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=ef7212dd-429c-4b64-bad6-4c37d27775d5@linux.ibm.com \
--to=maddy@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--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=linux-s390@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=pasha.tatashin@soleen.com \
--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