Message ID | 20221118002146.25979-2-rmclure@linux.ibm.com (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Series | [v5,1/5] powerpc: mm: Replace p{u,m,4}d_is_leaf with p{u,m,4}_leaf | expand |
Rohan McLure <rmclure@linux.ibm.com> writes: > The check that a higher-level entry in multi-level pages contains a page > translation entry (pte) is performed by p{m,u,4}d_leaf stubs, which may > be specialised for each choice of mmu. In a prior commit, we replace > uses to the catch-all stubs, p{m,u,4}d_is_leaf with p{m,u,4}d_leaf. > > Replace the catch-all stub definitions for p{m,u,4}d_is_leaf with > definitions for p{m,u,4}d_leaf. A future patch will assume that > p{m,u,4}d_leaf is defined on all platforms. > > In particular, implement pud_leaf for Book3E-64, pmd_leaf for all Book3E > and Book3S-64 platforms, with a catch-all definition for p4d_leaf. > > Signed-off-by: Rohan McLure <rmclure@linux.ibm.com> > --- > v5: Split patch that replaces p{m,u,4}d_is_leaf into two patches, first > replacing callsites and afterward providing generic definition. > Remove ifndef-defines implementing p{m,u}d_leaf in favour of > implementing stubs in headers belonging to the particular platforms > needing them. > --- > arch/powerpc/include/asm/book3s/32/pgtable.h | 4 ++++ > arch/powerpc/include/asm/book3s/64/pgtable.h | 8 ++----- > arch/powerpc/include/asm/nohash/64/pgtable.h | 5 +++++ > arch/powerpc/include/asm/nohash/pgtable.h | 5 +++++ > arch/powerpc/include/asm/pgtable.h | 22 ++------------------ > 5 files changed, 18 insertions(+), 26 deletions(-) I needed the delta below to prevent the generic versions being defined and overriding our versions. cheers diff --git a/arch/powerpc/include/asm/book3s/32/pgtable.h b/arch/powerpc/include/asm/book3s/32/pgtable.h index 44703c8c590c..117135be8cc2 100644 --- a/arch/powerpc/include/asm/book3s/32/pgtable.h +++ b/arch/powerpc/include/asm/book3s/32/pgtable.h @@ -244,6 +244,7 @@ static inline void pmd_clear(pmd_t *pmdp) *pmdp = __pmd(0); } +#define pmd_leaf pmd_leaf static inline bool pmd_leaf(pmd_t pmd) { return false; diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index 436632d04304..f00aa2d203c2 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -1438,11 +1438,13 @@ static inline bool is_pte_rw_upgrade(unsigned long old_val, unsigned long new_va /* * Like pmd_huge() and pmd_large(), but works regardless of config options */ +#define pmd_leaf pmd_leaf static inline bool pmd_leaf(pmd_t pmd) { return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE)); } +#define pud_leaf pud_leaf static inline bool pud_leaf(pud_t pud) { return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE)); diff --git a/arch/powerpc/include/asm/nohash/64/pgtable.h b/arch/powerpc/include/asm/nohash/64/pgtable.h index 2488da8f0deb..d88b22c753d3 100644 --- a/arch/powerpc/include/asm/nohash/64/pgtable.h +++ b/arch/powerpc/include/asm/nohash/64/pgtable.h @@ -147,6 +147,7 @@ static inline void pud_clear(pud_t *pudp) *pudp = __pud(0); } +#define pud_leaf pud_leaf static inline bool pud_leaf(pud_t pud) { return false; diff --git a/arch/powerpc/include/asm/nohash/pgtable.h b/arch/powerpc/include/asm/nohash/pgtable.h index 487804f5b1d1..dfae1dbb9c3b 100644 --- a/arch/powerpc/include/asm/nohash/pgtable.h +++ b/arch/powerpc/include/asm/nohash/pgtable.h @@ -60,6 +60,7 @@ static inline bool pte_hw_valid(pte_t pte) return pte_val(pte) & _PAGE_PRESENT; } +#define pmd_leaf pmd_leaf static inline bool pmd_leaf(pmd_t pmd) { return false;
Great job spotting this. Somehow lost these throughout the revisions. Thanks. > On 7 Dec 2022, at 9:24 am, Michael Ellerman <mpe@ellerman.id.au> wrote: > > Rohan McLure <rmclure@linux.ibm.com> writes: >> The check that a higher-level entry in multi-level pages contains a page >> translation entry (pte) is performed by p{m,u,4}d_leaf stubs, which may >> be specialised for each choice of mmu. In a prior commit, we replace >> uses to the catch-all stubs, p{m,u,4}d_is_leaf with p{m,u,4}d_leaf. >> >> Replace the catch-all stub definitions for p{m,u,4}d_is_leaf with >> definitions for p{m,u,4}d_leaf. A future patch will assume that >> p{m,u,4}d_leaf is defined on all platforms. >> >> In particular, implement pud_leaf for Book3E-64, pmd_leaf for all Book3E >> and Book3S-64 platforms, with a catch-all definition for p4d_leaf. >> >> Signed-off-by: Rohan McLure <rmclure@linux.ibm.com> >> --- >> v5: Split patch that replaces p{m,u,4}d_is_leaf into two patches, first >> replacing callsites and afterward providing generic definition. >> Remove ifndef-defines implementing p{m,u}d_leaf in favour of >> implementing stubs in headers belonging to the particular platforms >> needing them. >> --- >> arch/powerpc/include/asm/book3s/32/pgtable.h | 4 ++++ >> arch/powerpc/include/asm/book3s/64/pgtable.h | 8 ++----- >> arch/powerpc/include/asm/nohash/64/pgtable.h | 5 +++++ >> arch/powerpc/include/asm/nohash/pgtable.h | 5 +++++ >> arch/powerpc/include/asm/pgtable.h | 22 ++------------------ >> 5 files changed, 18 insertions(+), 26 deletions(-) > > I needed the delta below to prevent the generic versions being defined > and overriding our versions. > > cheers > > diff --git a/arch/powerpc/include/asm/book3s/32/pgtable.h b/arch/powerpc/include/asm/book3s/32/pgtable.h > index 44703c8c590c..117135be8cc2 100644 > --- a/arch/powerpc/include/asm/book3s/32/pgtable.h > +++ b/arch/powerpc/include/asm/book3s/32/pgtable.h > @@ -244,6 +244,7 @@ static inline void pmd_clear(pmd_t *pmdp) > *pmdp = __pmd(0); > } > > +#define pmd_leaf pmd_leaf > static inline bool pmd_leaf(pmd_t pmd) > { > return false; > diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h > index 436632d04304..f00aa2d203c2 100644 > --- a/arch/powerpc/include/asm/book3s/64/pgtable.h > +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h > @@ -1438,11 +1438,13 @@ static inline bool is_pte_rw_upgrade(unsigned long old_val, unsigned long new_va > /* > * Like pmd_huge() and pmd_large(), but works regardless of config options > */ > +#define pmd_leaf pmd_leaf > static inline bool pmd_leaf(pmd_t pmd) > { > return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE)); > } > > +#define pud_leaf pud_leaf > static inline bool pud_leaf(pud_t pud) > { > return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE)); > diff --git a/arch/powerpc/include/asm/nohash/64/pgtable.h b/arch/powerpc/include/asm/nohash/64/pgtable.h > index 2488da8f0deb..d88b22c753d3 100644 > --- a/arch/powerpc/include/asm/nohash/64/pgtable.h > +++ b/arch/powerpc/include/asm/nohash/64/pgtable.h > @@ -147,6 +147,7 @@ static inline void pud_clear(pud_t *pudp) > *pudp = __pud(0); > } > > +#define pud_leaf pud_leaf > static inline bool pud_leaf(pud_t pud) > { > return false; > diff --git a/arch/powerpc/include/asm/nohash/pgtable.h b/arch/powerpc/include/asm/nohash/pgtable.h > index 487804f5b1d1..dfae1dbb9c3b 100644 > --- a/arch/powerpc/include/asm/nohash/pgtable.h > +++ b/arch/powerpc/include/asm/nohash/pgtable.h > @@ -60,6 +60,7 @@ static inline bool pte_hw_valid(pte_t pte) > return pte_val(pte) & _PAGE_PRESENT; > } > > +#define pmd_leaf pmd_leaf > static inline bool pmd_leaf(pmd_t pmd) > { > return false;
diff --git a/arch/powerpc/include/asm/book3s/32/pgtable.h b/arch/powerpc/include/asm/book3s/32/pgtable.h index 75823f39e042..921ae95cd939 100644 --- a/arch/powerpc/include/asm/book3s/32/pgtable.h +++ b/arch/powerpc/include/asm/book3s/32/pgtable.h @@ -242,6 +242,10 @@ static inline void pmd_clear(pmd_t *pmdp) *pmdp = __pmd(0); } +static inline bool pmd_leaf(pmd_t pmd) +{ + return false; +} /* * When flushing the tlb entry for a page, we also need to flush the hash diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index c436d8422654..9a6db4ad3228 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -1426,16 +1426,12 @@ static inline bool is_pte_rw_upgrade(unsigned long old_val, unsigned long new_va /* * Like pmd_huge() and pmd_large(), but works regardless of config options */ -#define pmd_is_leaf pmd_is_leaf -#define pmd_leaf pmd_is_leaf -static inline bool pmd_is_leaf(pmd_t pmd) +static inline bool pmd_leaf(pmd_t pmd) { return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE)); } -#define pud_is_leaf pud_is_leaf -#define pud_leaf pud_is_leaf -static inline bool pud_is_leaf(pud_t pud) +static inline bool pud_leaf(pud_t pud) { return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE)); } diff --git a/arch/powerpc/include/asm/nohash/64/pgtable.h b/arch/powerpc/include/asm/nohash/64/pgtable.h index 879e9a6e5a87..34e618bb9140 100644 --- a/arch/powerpc/include/asm/nohash/64/pgtable.h +++ b/arch/powerpc/include/asm/nohash/64/pgtable.h @@ -141,6 +141,11 @@ static inline void pud_clear(pud_t *pudp) *pudp = __pud(0); } +static inline bool pud_leaf(pud_t pud) +{ + return false; +} + #define pud_none(pud) (!pud_val(pud)) #define pud_bad(pud) (!is_kernel_addr(pud_val(pud)) \ || (pud_val(pud) & PUD_BAD_BITS)) diff --git a/arch/powerpc/include/asm/nohash/pgtable.h b/arch/powerpc/include/asm/nohash/pgtable.h index d9067dfc531c..455ae13822ee 100644 --- a/arch/powerpc/include/asm/nohash/pgtable.h +++ b/arch/powerpc/include/asm/nohash/pgtable.h @@ -60,6 +60,11 @@ static inline bool pte_hw_valid(pte_t pte) return pte_val(pte) & _PAGE_PRESENT; } +static inline bool pmd_leaf(pmd_t pmd) +{ + return false; +} + /* * Don't just check for any non zero bits in __PAGE_USER, since for book3e * and PTE_64BIT, PAGE_KERNEL_X contains _PAGE_BAP_SR which is also in diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index 283f40d05a4d..68a3f271aebe 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -134,29 +134,11 @@ static inline void pte_frag_set(mm_context_t *ctx, void *p) } #endif -#ifndef pmd_is_leaf -#define pmd_is_leaf pmd_is_leaf -static inline bool pmd_is_leaf(pmd_t pmd) +#define p4d_leaf p4d_leaf +static inline bool p4d_leaf(p4d_t p4d) { return false; } -#endif - -#ifndef pud_is_leaf -#define pud_is_leaf pud_is_leaf -static inline bool pud_is_leaf(pud_t pud) -{ - return false; -} -#endif - -#ifndef p4d_is_leaf -#define p4d_is_leaf p4d_is_leaf -static inline bool p4d_is_leaf(p4d_t p4d) -{ - return false; -} -#endif #define pmd_pgtable pmd_pgtable static inline pgtable_t pmd_pgtable(pmd_t pmd)
The check that a higher-level entry in multi-level pages contains a page translation entry (pte) is performed by p{m,u,4}d_leaf stubs, which may be specialised for each choice of mmu. In a prior commit, we replace uses to the catch-all stubs, p{m,u,4}d_is_leaf with p{m,u,4}d_leaf. Replace the catch-all stub definitions for p{m,u,4}d_is_leaf with definitions for p{m,u,4}d_leaf. A future patch will assume that p{m,u,4}d_leaf is defined on all platforms. In particular, implement pud_leaf for Book3E-64, pmd_leaf for all Book3E and Book3S-64 platforms, with a catch-all definition for p4d_leaf. Signed-off-by: Rohan McLure <rmclure@linux.ibm.com> --- v5: Split patch that replaces p{m,u,4}d_is_leaf into two patches, first replacing callsites and afterward providing generic definition. Remove ifndef-defines implementing p{m,u}d_leaf in favour of implementing stubs in headers belonging to the particular platforms needing them. --- arch/powerpc/include/asm/book3s/32/pgtable.h | 4 ++++ arch/powerpc/include/asm/book3s/64/pgtable.h | 8 ++----- arch/powerpc/include/asm/nohash/64/pgtable.h | 5 +++++ arch/powerpc/include/asm/nohash/pgtable.h | 5 +++++ arch/powerpc/include/asm/pgtable.h | 22 ++------------------ 5 files changed, 18 insertions(+), 26 deletions(-)