[PATCH v18 10/12] powerpc/mm: Implement *_user_accessible_page() for ptes

Alexander Gordeev agordeev at linux.ibm.com
Tue Jan 27 07:51:36 PST 2026


On Fri, Dec 19, 2025 at 04:09:42AM +1100, Andrew Donnellan wrote:

Hi All,

...
> Page table checking depends on architectures providing an
> implementation of p{te,md,ud}_user_accessible_page.
...
> +static inline bool pte_user_accessible_page(pte_t pte, unsigned long addr)
> +{
> +	return pte_present(pte) && !is_kernel_addr(addr);
> +}

We looked into implementing this for s390 and for us the only possible
user vs kernel entry attribute is comparing mm to init_mm. The generic
code already does that, but I am not sure whether such check alone is
enough.

But it occured to me that we could implement e.g. ARCH_SUPPORTS_PTC_USER_PAGE
that adds an extra field to struct page_table_check:

struct page_table_check {
	atomic_t anon_map_count;
	atomic_t file_map_count;
#ifdef CONFIG_ARCH_SUPPORTS_PTC_USER_PAGE
	bool user_page;
#endif
};

Page Table Extensions already used by PTC, so that would fit pretty natural.
Once a page is mapped into a user process it would be marked as user_page,
while p{te,md,ud}_user_accessible_page() could go generic:

static inline bool pte_user_accessible_page(pte_t pte, unsigned long addr)
{
	return pte_present(pte) && page_table_check_is_user_page(pte);
}
...

I guess, many architectures without viable p.._user() support could benefit
from that.

But I am not sure whether is it doable, so opinions are very welcomed!

Thanks!



More information about the linux-riscv mailing list