Re: [PATCH v9 4/7] powerpc: mm: Default p{m,u}d_pte implementations
From: Rohan McLure <hidden>
Date: 2023-12-11 02:54:53
On 11/30/23 18:35, Christophe Leroy wrote:
Le 30/11/2023 à 03:53, Rohan McLure a écrit :quoted
For 32-bit systems which have no usecases for p{m,u}d_pte() prior to page table checking, implement default stubs.Is that the best solution ? If I understand correctly, it is only needed for pmd_user_accessible_page(). Why not provide a stub pmd_user_accessible_page() that returns false on those architectures ?
Yep, this seems reasonable to me.
Same for pud_user_accessible_page() But if you decide to keep it I think that: - It should be squashed with following patch to make it clear it's needed for that only. - Remove the WARN_ONCE().
I might however move those WARN_ONCE() calls to the default, false-returning
p{m,u}d_user_accessible_page() implementations, to be consistent with
pud_pfn().- Only have a special one for books/64 and a generic only common to he 3 others.quoted
Signed-off-by: Rohan McLure <redacted> --- v9: New patch --- arch/powerpc/include/asm/book3s/64/pgtable.h | 3 +++ arch/powerpc/include/asm/nohash/64/pgtable.h | 2 ++ arch/powerpc/include/asm/pgtable.h | 17 +++++++++++++++++ 3 files changed, 22 insertions(+)diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index 8fdb7667c509..2454174b26cb 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h@@ -887,6 +887,8 @@ static inline int pud_present(pud_t pud) extern struct page *pud_page(pud_t pud); extern struct page *pmd_page(pmd_t pmd); + +#define pud_pte pud_pte static inline pte_t pud_pte(pud_t pud) { return __pte_raw(pud_raw(pud));@@ -1043,6 +1045,7 @@ static inline void __kernel_map_pages(struct page *page, int numpages, int enabl } #endif +#define pmd_pte pmd_pte static inline pte_t pmd_pte(pmd_t pmd) { return __pte_raw(pmd_raw(pmd));diff --git a/arch/powerpc/include/asm/nohash/64/pgtable.h b/arch/powerpc/include/asm/nohash/64/pgtable.h index f58cbebde26e..09a34fe196ae 100644 --- a/arch/powerpc/include/asm/nohash/64/pgtable.h +++ b/arch/powerpc/include/asm/nohash/64/pgtable.h@@ -93,6 +93,7 @@ static inline void pmd_clear(pmd_t *pmdp) *pmdp = __pmd(0); } +#define pmd_pte pmd_pte static inline pte_t pmd_pte(pmd_t pmd) { return __pte(pmd_val(pmd));@@ -134,6 +135,7 @@ static inline pmd_t *pud_pgtable(pud_t pud) extern struct page *pud_page(pud_t pud); +#define pud_pte pud_pte static inline pte_t pud_pte(pud_t pud) { return __pte(pud_val(pud));diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index 9c0f2151f08f..d7d0f47760d3 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h@@ -233,6 +233,23 @@ static inline int pud_pfn(pud_t pud) } #endif +#ifndef pmd_pte +#define pmd_pte pmd_pte +static inline pte_t pmd_pte(pmd_t pmd) +{ + WARN_ONCE(1, "pmd: platform does not use pmd entries directly"); + return __pte(pmd_val(pmd)); +} +#endif + +#ifndef pud_pte +#define pud_pte pud_pte +static inline pte_t pud_pte(pud_t pud) +{ + WARN_ONCE(1, "pud: platform does not use pud entries directly"); + return __pte(pud_val(pud)); +} +#endif #endif /* __ASSEMBLY__ */ #endif /* _ASM_POWERPC_PGTABLE_H */