Fixes for Radix support
v2 cover Fixes for Radix support
Hi Michael,
This series includes patches I had posted before. I collected them in a series and marked the series V2. This address the review feedback I received from last post.
Aneesh Kumar K.V (9):
powerpc/mm/radix: Update to tlb functions ric argument powerpc/mm/radix: Flush page walk cache when freeing page table powerpc/mm/radix: Update LPCR HR bit as per ISA powerpc/mm: use _raw variant of page table accessors powerpc/mm: Compile out radix related functions if RADIX_MMU is
disabled
powerpc/hash: Use the correct ppp mask when updating hpte powerpc/mm: Clear top 16 bits of va only on older cpus powerpc/mm: Print formation regarding the the MMU mode powerpc/mm/hash: Update SDR1 size encoding as documented in ISA 3.0
Balbir Singh (1):
Fix .long's in mm/tlb-radix.c to more meaningful
arch/powerpc/include/asm/book3s/32/pgalloc.h | 1 - arch/powerpc/include/asm/book3s/64/mmu-hash.h | 1 + arch/powerpc/include/asm/book3s/64/mmu.h | 5 ++ arch/powerpc/include/asm/book3s/64/pgalloc.h | 16 +++- arch/powerpc/include/asm/book3s/64/pgtable-4k.h | 6 +- arch/powerpc/include/asm/book3s/64/pgtable-64k.h | 6 +- arch/powerpc/include/asm/book3s/64/pgtable.h | 99 +++++++++++++++------- .../powerpc/include/asm/book3s/64/tlbflush-radix.h | 3 + arch/powerpc/include/asm/book3s/64/tlbflush.h | 15 +++- arch/powerpc/include/asm/book3s/pgalloc.h | 5 -- arch/powerpc/include/asm/mmu.h | 12 ++- arch/powerpc/include/asm/pgtable-be-types.h | 15 ++++ arch/powerpc/include/asm/ppc-opcode.h | 14 +++ arch/powerpc/include/asm/reg.h | 1 + arch/powerpc/mm/hash_native_64.c | 14 +-- arch/powerpc/mm/hash_utils_64.c | 12 +-- arch/powerpc/mm/pgtable-radix.c | 7 +- arch/powerpc/mm/tlb-radix.c | 94 +++++++++++++------- 18 files changed, 236 insertions(+), 90 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/10 Fix .long's in mm/tlb-radix.c to more meaningful
From: Balbir Singh <[email protected]>
The .longs with the shifts are harder to read, use more meaningful names for the opcodes. PPC_TLBIE_5 is introduced for the 5 opcode variation of the instruction due to an existing op-code for the 2 opcode variant
--- arch/powerpc/include/asm/ppc-opcode.h | 14 ++++++++++++++ arch/powerpc/mm/tlb-radix.c | 13 +++++-------- 2 files changed, 19 insertions(+), 8 deletions(-)
arch/powerpc/include/asm/ppc-opcode.h +14 -0
@@ -184,6 +184,7 @@#define PPC_INST_STSWX 0x7c00052a#define PPC_INST_STXVD2X 0x7c000798#define PPC_INST_TLBIE 0x7c000264 +#define PPC_INST_TLBIEL 0x7c000224#define PPC_INST_TLBILX 0x7c000024#define PPC_INST_WAIT 0x7c00007c#define PPC_INST_TLBIVAX 0x7c000624
@@ -257,6 +258,9 @@#define ___PPC_RB (b) (((b) & 0x1f) << 11)#define ___PPC_RS (s) (((s) & 0x1f) << 21)#define ___PPC_RT (t) ___PPC_RS(t) +#define ___PPC_R (r) (((r) & 0x1) << 16) +#define ___PPC_PRS (prs) (((prs) & 0x1) << 17) +#define ___PPC_RIC (ric) (((ric) & 0x3) << 18)#define __PPC_RA (a) ___PPC_RA(__REG_##a)#define __PPC_RA0 (a) ___PPC_RA(__REGA0_##a)#define __PPC_RB (b) ___PPC_RB(__REG_##b)
@@ -321,6 +325,16 @@ __PPC_WC(w))#define PPC_TLBIE (lp,a) stringify_in_c(.long PPC_INST_TLBIE | \ ___PPC_RB(a) | ___PPC_RS(lp)) +#define PPC_TLBIE_5 (rb,rs,ric,prs,r) \ + stringify_in_c(.long PPC_INST_TLBIE | \ + ___PPC_RB(rb) | ___PPC_RS(rs) | \ + ___PPC_RIC(ric) | ___PPC_PRS(prs) | \ + ___PPC_R(r)) +#define PPC_TLBIEL (rb,rs,ric,prs,r) \ + stringify_in_c(.long PPC_INST_TLBIEL | \ + ___PPC_RB(rb) | ___PPC_RS(rs) | \ + ___PPC_RIC(ric) | ___PPC_PRS(prs) | \ + ___PPC_R(r))#define PPC_TLBSRX_DOT (a,b) stringify_in_c(.long PPC_INST_TLBSRX_DOT | \ __PPC_RA0(a) | __PPC_RB(b))#define PPC_TLBIVAX (a,b) stringify_in_c(.long PPC_INST_TLBIVAX | \
arch/powerpc/mm/tlb-radix.c +5 -8
@@ -12,6 +12,7 @@#include <linux/mm.h> #include <linux/hugetlb.h> #include <linux/memblock.h> +#include <asm/ppc-opcode.h> #include <asm/tlb.h> #include <asm/tlbflush.h>
@@ -30,8 +31,7 @@ static inline void __tlbiel_pid(unsigned long pid, int set) ric =2 ;/* invalidate all the caches */ asmvolatile ("ptesync" : : :"memory" ); - asmvolatile (".long 0x7c000224 | (%0 << 11) | (%1 << 16) |" -"(%2 << 17) | (%3 << 18) | (%4 << 21)" + asm volatile(PPC_TLBIEL(%0, %4, %3, %2, %1) : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory"); asm volatile("ptesync": : :"memory"); }
@@ -60,8 +60,7 @@ static inline void _tlbie_pid(unsigned long pid) ric =2 ;/* invalidate all the caches */ asmvolatile ("ptesync" : : :"memory" ); - asmvolatile (".long 0x7c000264 | (%0 << 11) | (%1 << 16) |" -"(%2 << 17) | (%3 << 18) | (%4 << 21)" + asm volatile(PPC_TLBIE_5(%0, %4, %3, %2, %1) : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory"); asm volatile("eieio; tlbsync; ptesync": : :"memory"); }
@@ -79,8 +78,7 @@ static inline void _tlbiel_va(unsigned long va, unsigned long pid, ric =0 ;/* no cluster flush yet */ asmvolatile ("ptesync" : : :"memory" ); - asmvolatile (".long 0x7c000224 | (%0 << 11) | (%1 << 16) |" -"(%2 << 17) | (%3 << 18) | (%4 << 21)" + asm volatile(PPC_TLBIEL(%0, %4, %3, %2, %1) : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory"); asm volatile("ptesync": : :"memory"); }
@@ -98,8 +96,7 @@ static inline void _tlbie_va(unsigned long va, unsigned long pid, ric =0 ;/* no cluster flush yet */ asmvolatile ("ptesync" : : :"memory" ); - asmvolatile (".long 0x7c000264 | (%0 << 11) | (%1 << 16) |" -"(%2 << 17) | (%3 << 18) | (%4 << 21)" + asm volatile(PPC_TLBIE_5(%0, %4, %3, %2, %1) : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory"); asm volatile("eieio; tlbsync; ptesync": : :"memory"); }
Signature · 1 line
2.7.4
PATCH v2 2/10 powerpc/mm/radix: Update to tlb functions ric argument
In reply to Aneesh Kumar K.VRadix invalidate control (RIC) is used to control which cache to flush using tlb instructions. When doing a PID flush, we currently flush everything including page walk cache. For address range flush, we flush only the TLB. In the later patch, we add support for flushing only page walk cache.
--- arch/powerpc/mm/tlb-radix.c | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-)
arch/powerpc/mm/tlb-radix.c +22 -21
@@ -19,16 +19,20 @@static DEFINE_RAW_SPINLOCK (native_tlbie_lock); -static inline void __tlbiel_pid (unsigned long pid,int set) +#define RIC_FLUSH_TLB 0 +#define RIC_FLUSH_PWC 1 +#define RIC_FLUSH_ALL 2 + +static inline void __tlbiel_pid (unsigned long pid,int set, +unsigned long ric) { -unsigned long rb,rs,ric,prs,r; +unsigned long rb,rs,prs,r; rb =PPC_BIT (53 );/* IS = 1 */ rb |= set <<PPC_BITLSHIFT (51 ); rs = ((unsigned long )pid) <<PPC_BITLSHIFT (31 ); prs =1 ;/* process scoped */ r =1 ;/* raidx format */ - ric =2 ;/* invalidate all the caches */ asmvolatile ("ptesync" : : :"memory" ); asm volatile(PPC_TLBIEL(%0, %4, %3, %2, %1)
@@ -39,25 +43,24 @@ static inline void __tlbiel_pid(unsigned long pid, int set)/* * We use 128 set in radix mode and 256 set in hpt mode. */ -static inline void _tlbiel_pid (unsigned long pid) +static inline void _tlbiel_pid (unsigned long pid,unsigned long ric) {int set;for (set =0 ; set <POWER9_TLB_SETS_RADIX ; set++) { -__tlbiel_pid (pid, set); +__tlbiel_pid (pid, set, ric); }return ; } -static inline void _tlbie_pid (unsigned long pid) +static inline void _tlbie_pid (unsigned long pid,unsigned long ric) { -unsigned long rb,rs,ric,prs,r; +unsigned long rb,rs,prs,r; rb =PPC_BIT (53 );/* IS = 1 */ rs = pid <<PPC_BITLSHIFT (31 ); prs =1 ;/* process scoped */ r =1 ;/* raidx format */ - ric =2 ;/* invalidate all the caches */ asmvolatile ("ptesync" : : :"memory" ); asm volatile(PPC_TLBIE_5(%0, %4, %3, %2, %1)
@@ -66,16 +69,15 @@ static inline void _tlbie_pid(unsigned long pid) }static inline void _tlbiel_va (unsigned long va,unsigned long pid, -unsigned long ap) +unsigned long ap,unsigned long ric) { -unsigned long rb,rs,ric,prs,r; +unsigned long rb,rs,prs,r; rb = va & ~(PPC_BITMASK (52 ,63 )); rb |= ap <<PPC_BITLSHIFT (58 ); rs = pid <<PPC_BITLSHIFT (31 ); prs =1 ;/* process scoped */ r =1 ;/* raidx format */ - ric =0 ;/* no cluster flush yet */ asmvolatile ("ptesync" : : :"memory" ); asm volatile(PPC_TLBIEL(%0, %4, %3, %2, %1)
@@ -84,16 +86,15 @@ static inline void _tlbiel_va(unsigned long va, unsigned long pid, }static inline void _tlbie_va (unsigned long va,unsigned long pid, -unsigned long ap) +unsigned long ap,unsigned long ric) { -unsigned long rb,rs,ric,prs,r; +unsigned long rb,rs,prs,r; rb = va & ~(PPC_BITMASK (52 ,63 )); rb |= ap <<PPC_BITLSHIFT (58 ); rs = pid <<PPC_BITLSHIFT (31 ); prs =1 ;/* process scoped */ r =1 ;/* raidx format */ - ric =0 ;/* no cluster flush yet */ asmvolatile ("ptesync" : : :"memory" ); asm volatile(PPC_TLBIE_5(%0, %4, %3, %2, %1)
@@ -119,7 +120,7 @@ void radix__local_flush_tlb_mm(struct mm_struct *mm)preempt_disable (); pid = mm->context.id;if (pid !=MMU_NO_CONTEXT ) -_tlbiel_pid (pid); +_tlbiel_pid (pid,RIC_FLUSH_ALL );preempt_enable (); }EXPORT_SYMBOL (radix__local_flush_tlb_mm);
@@ -132,7 +133,7 @@ void radix___local_flush_tlb_page(struct mm_struct *mm, unsigned long vmaddr,preempt_disable (); pid = mm ? mm->context.id :0 ;if (pid !=MMU_NO_CONTEXT ) -_tlbiel_va (vmaddr, pid, ap); +_tlbiel_va (vmaddr, pid, ap,RIC_FLUSH_TLB );preempt_enable (); }
@@ -169,11 +170,11 @@ void radix__flush_tlb_mm(struct mm_struct *mm)if (lock_tlbie)raw_spin_lock (&native_tlbie_lock); -_tlbie_pid (pid); +_tlbie_pid (pid,RIC_FLUSH_ALL );if (lock_tlbie)raw_spin_unlock (&native_tlbie_lock); }else -_tlbiel_pid (pid); +_tlbiel_pid (pid,RIC_FLUSH_ALL ); no_context:preempt_enable (); }
@@ -193,11 +194,11 @@ void radix___flush_tlb_page(struct mm_struct *mm, unsigned long vmaddr,if (lock_tlbie)raw_spin_lock (&native_tlbie_lock); -_tlbie_va (vmaddr, pid, ap); +_tlbie_va (vmaddr, pid, ap,RIC_FLUSH_TLB );if (lock_tlbie)raw_spin_unlock (&native_tlbie_lock); }else -_tlbiel_va (vmaddr, pid, ap); +_tlbiel_va (vmaddr, pid, ap,RIC_FLUSH_TLB ); bail:preempt_enable (); }
@@ -221,7 +222,7 @@ void radix__flush_tlb_kernel_range(unsigned long start, unsigned long end)if (lock_tlbie)raw_spin_lock (&native_tlbie_lock); -_tlbie_pid (0 ); +_tlbie_pid (0 ,RIC_FLUSH_ALL );if (lock_tlbie)raw_spin_unlock (&native_tlbie_lock); }
Signature · 1 line
2.7.4
Re: [V2, 02/10] powerpc/mm/radix: Update to tlb functions ric argument
Quoted 7 lines · Aneesh Kumar K.V
Radix invalidate control (RIC) is used to control which cache to flush using tlb instructions. When doing a PID flush, we currently flush everything including page walk cache. For address range flush, we flush only the TLB. In the later patch, we add support for flushing only page walk cache.
Signed-off-by Aneesh Kumar K.V <[email protected]>
Applied to powerpc fixes, thanks.
https://git.kernel.org/powerpc/c/36194812a4063dd2a72070aec3
cheers
PATCH v2 3/10 powerpc/mm/radix: Flush page walk cache when freeing page table
In reply to Aneesh Kumar K.VEven though a tlb_flush() does a flush with invalidate all cache, we can end up doing an RCU page table free before calling tlb_flush(). That means we can have page walk cache entries even after we free the page table pages. This can result in us doing wrong page table walk.
Avoid this by doing pwc flush on every page table free. We can't batch the pwc flush, because the rcu call back function where we free the page table pages doesn't have information of the mmu gather. Thus we have to do a pwc on every page table page freed.
Note: I also removed the dummy tlb_flush_pgtable call functions for hash 32.
--- arch/powerpc/include/asm/book3s/32/pgalloc.h | 1 - arch/powerpc/include/asm/book3s/64/pgalloc.h | 16 ++++++++- .../powerpc/include/asm/book3s/64/tlbflush-radix.h | 3 ++ arch/powerpc/include/asm/book3s/64/tlbflush.h | 15 ++++++++- arch/powerpc/include/asm/book3s/pgalloc.h | 5 --- arch/powerpc/mm/tlb-radix.c | 38 ++++++++++++++++++++++ 6 files changed, 70 insertions(+), 8 deletions(-)
arch/powerpc/include/asm/book3s/32/pgalloc.h +0 -1
@@ -102,7 +102,6 @@ static inline void pgtable_free_tlb(struct mmu_gather *tlb,static inline void __pte_free_tlb (struct mmu_gather *tlb,pgtable_t table,unsigned long address) { -tlb_flush_pgtable (tlb, address);pgtable_page_dtor (table);pgtable_free_tlb (tlb,page_address (table),0 ); }
arch/powerpc/include/asm/book3s/64/pgalloc.h +15 -1
@@ -110,6 +110,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)static inline void __pud_free_tlb (struct mmu_gather *tlb,pud_t *pud,unsigned long address) { +/* +* By now all the pud entries should be none entries. So go +* ahead and flush the page walk cache +*/ +flush_tlb_pgtable (tlb, address);pgtable_free_tlb (tlb, pud,PUD_INDEX_SIZE ); }
@@ -127,6 +132,11 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)static inline void __pmd_free_tlb (struct mmu_gather *tlb,pmd_t *pmd,unsigned long address) { +/* +* By now all the pud entries should be none entries. So go +* ahead and flush the page walk cache +*/ +flush_tlb_pgtable (tlb, address);return pgtable_free_tlb (tlb, pmd,PMD_CACHE_INDEX ); }
@@ -198,7 +208,11 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t ptepage)static inline void __pte_free_tlb (struct mmu_gather *tlb,pgtable_t table,unsigned long address) { -tlb_flush_pgtable (tlb, address); +/* +* By now all the pud entries should be none entries. So go +* ahead and flush the page walk cache +*/ +flush_tlb_pgtable (tlb, address);pgtable_free_tlb (tlb, table,0 ); }
arch/powerpc/include/asm/book3s/64/tlbflush-radix.h +3 -0
@@ -18,16 +18,19 @@ extern void radix__local_flush_tlb_mm(struct mm_struct *mm);extern void radix__local_flush_tlb_page (struct vm_area_struct *vma,unsigned long vmaddr);extern void radix___local_flush_tlb_page (struct mm_struct *mm,unsigned long vmaddr,unsigned long ap,int nid); +extern void radix__local_flush_tlb_pwc (struct mmu_gather *tlb,unsigned long addr);extern void radix__tlb_flush (struct mmu_gather *tlb);#ifdef CONFIG_SMP extern void radix__flush_tlb_mm (struct mm_struct *mm);extern void radix__flush_tlb_page (struct vm_area_struct *vma,unsigned long vmaddr);extern void radix___flush_tlb_page (struct mm_struct *mm,unsigned long vmaddr,unsigned long ap,int nid); +extern void radix__flush_tlb_pwc (struct mmu_gather *tlb,unsigned long addr);#else #define radix__flush_tlb_mm (mm) radix__local_flush_tlb_mm(mm)#define radix__flush_tlb_page (vma,addr) radix__local_flush_tlb_page(vma,addr)#define radix___flush_tlb_page (mm,addr,p,i) radix___local_flush_tlb_page(mm,addr,p,i) +#define radix__flush_tlb_pwc (tlb, addr) radix__local_flush_tlb_pwc(tlb, addr)#endif #endif
arch/powerpc/include/asm/book3s/64/tlbflush.h +14 -1
@@ -72,5 +72,18 @@ static inline void flush_tlb_page(struct vm_area_struct *vma,#define flush_tlb_mm (mm) local_flush_tlb_mm(mm)#define flush_tlb_page (vma, addr) local_flush_tlb_page(vma, addr)#endif /* CONFIG_SMP */ - +/* +* flush the page walk cache for the address +*/ +static inline void flush_tlb_pgtable (struct mmu_gather *tlb,unsigned long address) +{ +/* +* flush the page table walk cache on freeing page table. We already +* have marked the upper/higher level page table entry none by now. +* So it is safe to flush PWC here. +*/ +if (!radix_enabled ()) +return ; +radix__flush_tlb_pwc (tlb, address); +}#endif /* _ASM_POWERPC_BOOK3S_64_TLBFLUSH_H */
arch/powerpc/include/asm/book3s/pgalloc.h +0 -5
@@ -4,11 +4,6 @@#include <linux/mm.h> extern void tlb_remove_table (struct mmu_gather *tlb,void *table); -static inline void tlb_flush_pgtable (struct mmu_gather *tlb, -unsigned long address) -{ - -}#ifdef CONFIG_PPC64 #include <asm/book3s/64/pgalloc.h>
arch/powerpc/mm/tlb-radix.c +38 -0
@@ -125,6 +125,19 @@ void radix__local_flush_tlb_mm(struct mm_struct *mm) }EXPORT_SYMBOL (radix__local_flush_tlb_mm); +void radix__local_flush_tlb_pwc (struct mmu_gather *tlb,unsigned long addr) +{ +unsigned long pid; +struct mm_struct *mm = tlb->mm; + +preempt_disable (); + pid = mm->context.id; +if (pid !=MMU_NO_CONTEXT ) +_tlbiel_pid (pid,RIC_FLUSH_PWC ); +preempt_enable (); +} +EXPORT_SYMBOL (radix__local_flush_tlb_pwc); +void radix___local_flush_tlb_page (struct mm_struct *mm,unsigned long vmaddr,unsigned long ap,int nid) {
@@ -180,6 +193,31 @@ no_context: }EXPORT_SYMBOL (radix__flush_tlb_mm); +void radix__flush_tlb_pwc (struct mmu_gather *tlb,unsigned long addr) +{ +unsigned long pid; +struct mm_struct *mm = tlb->mm; + +preempt_disable (); + pid = mm->context.id; +if (unlikely (pid ==MMU_NO_CONTEXT )) + goto no_context; + +if (!mm_is_core_local (mm)) { +int lock_tlbie = !mmu_has_feature (MMU_FTR_LOCKLESS_TLBIE ); + +if (lock_tlbie) +raw_spin_lock (&native_tlbie_lock); +_tlbie_pid (pid,RIC_FLUSH_PWC ); +if (lock_tlbie) +raw_spin_unlock (&native_tlbie_lock); + }else +_tlbiel_pid (pid,RIC_FLUSH_PWC ); +no_context: +preempt_enable (); +} +EXPORT_SYMBOL (radix__flush_tlb_pwc); +void radix___flush_tlb_page (struct mm_struct *mm,unsigned long vmaddr,unsigned long ap,int nid) {
Signature · 1 line
2.7.4
Re: [V2, 03/10] powerpc/mm/radix: Flush page walk cache when freeing page table
Quoted 5 lines · Aneesh Kumar K.V
Even though a
tlb_flush()does a flush with invalidate all cache, we can end up doing an RCU page table free before callingtlb_flush(). That means we can have page walk cache entries even after we free the page table pages. This can result in us doing wrong page table walk.
Quoted 8 lines
Avoid this by doing pwc flush on every page table free. We can't batch the pwc flush, because the rcu call back function where we free the page table pages doesn't have information of the mmu gather. Thus we have to do a pwc on every page table page freed.
Note: I also removed the dummy
tlb_flush_pgtablecall functions for hash 32.Signed-off-by Aneesh Kumar K.V <[email protected]>
Applied to powerpc fixes, thanks.
https://git.kernel.org/powerpc/c/a145abf12c9f7d30d8c330c9d8
cheers
PATCH v2 4/10 powerpc/mm/radix: Update LPCR HR bit as per ISA
In reply to Aneesh Kumar K.VPowerISA 3.0 requires the MMU mode (radix vs. hash) of the hypervisor to be mirrored in the LPCR register, in addition to the partition table. This is done to avoid fetching from the table when deciding, among other things, how to perform transitions to HV mode on some interrupts. So let's set it up appropriately
--- arch/powerpc/include/asm/reg.h | 1 + arch/powerpc/mm/pgtable-radix.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/reg.h +1 -0
@@ -348,6 +348,7 @@#define LPCR_RMI 0x00000002/* real mode is cache inhibit */ #define LPCR_HDICE 0x00000001/* Hyp Decr enable (HV,PR,EE) */ #define LPCR_UPRT 0x00400000/* Use Process Table (ISA 3) */ +#define LPCR_HR 0x00100000#ifndef SPRN_LPID #define SPRN_LPID 0x13F/* Logical Partition Identifier */ #endif
arch/powerpc/mm/pgtable-radix.c +2 -2
@@ -340,7 +340,7 @@ void __init radix__early_init_mmu(void)radix_init_page_sizes ();if (!firmware_has_feature (FW_FEATURE_LPAR )) { lpcr =mfspr (SPRN_LPCR ); -mtspr (SPRN_LPCR , lpcr |LPCR_UPRT ); +mtspr (SPRN_LPCR , lpcr |LPCR_UPRT |LPCR_HR );radix_init_partition_table (); }
@@ -355,7 +355,7 @@ void radix__early_init_mmu_secondary(void)*/ if (!firmware_has_feature (FW_FEATURE_LPAR )) { lpcr =mfspr (SPRN_LPCR ); -mtspr (SPRN_LPCR , lpcr |LPCR_UPRT ); +mtspr (SPRN_LPCR , lpcr |LPCR_UPRT |LPCR_HR );mtspr (SPRN_PTCR ,__pa (partition_tb) | (PATB_SIZE_SHIFT -12 ));
Signature · 1 line
2.7.4
PATCH v2 5/10 powerpc/mm: use _raw variant of page table accessors
In reply to Aneesh Kumar K.VThis switch few of the page table accessor to use the __raw variant and does the cpu to big endian conversion of constants. This helps in generating better code.
For ex: a pgd_none(pgd) check with and without fix is listed below
Without fix:
------------
2240: 20 00 61 eb ld r27,32(r1)
/* PGD level */
typedef struct { __be64 pgd; } pgd_t;
static inline unsigned long pgd_val(pgd_t x)
{
return be64_to_cpu(x.pgd);
2244: 22 00 66 78 rldicl r6,r3,32,32
2248: 3e 40 7d 54 rotlwi r29,r3,8
224c: 0e c0 7d 50 rlwimi r29,r3,24,0,7
2250: 3e 40 c5 54 rotlwi r5,r6,8
2254: 2e c4 7d 50 rlwimi r29,r3,24,16,23
2258: 0e c0 c5 50 rlwimi r5,r6,24,0,7
225c: 2e c4 c5 50 rlwimi r5,r6,24,16,23
2260: c6 07 bd 7b rldicr r29,r29,32,31
2264: 78 2b bd 7f or r29,r29,r5
if (pgd_none(pgd))
2268: 00 00 bd 2f cmpdi cr7,r29,0
226c: 54 03 9e 41 beq cr7,25c0 <__get_user_pages_fast+0x500>With fix:
---------
2370: 20 00 61 eb ld r27,32(r1)
if (pgd_none(pgd))
2374: 00 00 bd 2f cmpdi cr7,r29,0
2378: a8 03 9e 41 beq cr7,2720 <__get_user_pages_fast+0x530>
break;--- arch/powerpc/include/asm/book3s/64/pgtable-4k.h | 6 +- arch/powerpc/include/asm/book3s/64/pgtable-64k.h | 6 +- arch/powerpc/include/asm/book3s/64/pgtable.h | 99 +++++++++++++++++------- arch/powerpc/include/asm/pgtable-be-types.h | 15 ++++ 4 files changed, 91 insertions(+), 35 deletions(-)
arch/powerpc/include/asm/book3s/64/pgtable-4k.h +3 -3
@@ -11,7 +11,7 @@ static inline int pmd_huge(pmd_t pmd)* leaf pte for huge page */ if (radix_enabled ()) -return !!(pmd_val (pmd) & _PAGE_PTE); +return !!(pmd_raw (pmd) &cpu_to_be64 (_PAGE_PTE));return 0 ; }
@@ -21,7 +21,7 @@ static inline int pud_huge(pud_t pud)* leaf pte for huge page */ if (radix_enabled ()) -return !!(pud_val (pud) & _PAGE_PTE); +return !!(pud_raw (pud) &cpu_to_be64 (_PAGE_PTE));return 0 ; }
@@ -31,7 +31,7 @@ static inline int pgd_huge(pgd_t pgd)* leaf pte for huge page */ if (radix_enabled ()) -return !!(pgd_val (pgd) & _PAGE_PTE); +return !!(pgd_raw (pgd) &cpu_to_be64 (_PAGE_PTE));return 0 ; }#define pgd_huge pgd_huge
arch/powerpc/include/asm/book3s/64/pgtable-64k.h +3 -3
@@ -15,7 +15,7 @@ static inline int pmd_huge(pmd_t pmd)/* * leaf pte for huge page */ -return !!(pmd_val (pmd) & _PAGE_PTE); +return !!(pmd_raw (pmd) &cpu_to_be64 (_PAGE_PTE)); }static inline int pud_huge (pud_t pud)
@@ -23,7 +23,7 @@ static inline int pud_huge(pud_t pud)/* * leaf pte for huge page */ -return !!(pud_val (pud) & _PAGE_PTE); +return !!(pud_raw (pud) &cpu_to_be64 (_PAGE_PTE)); }static inline int pgd_huge (pgd_t pgd)
@@ -31,7 +31,7 @@ static inline int pgd_huge(pgd_t pgd)/* * leaf pte for huge page */ -return !!(pgd_val (pgd) & _PAGE_PTE); +return !!(pgd_raw (pgd) &cpu_to_be64 (_PAGE_PTE)); }#define pgd_huge pgd_huge
arch/powerpc/include/asm/book3s/64/pgtable.h +70 -29
217 lines not on this page · raw message
arch/powerpc/include/asm/pgtable-be-types.h +15 -0
@@ -6,6 +6,7 @@/* PTE level */ typedef struct {__be64 pte; }pte_t ;#define __pte (x) ((pte_t) { cpu_to_be64(x) }) +#define __pte_raw (x) ((pte_t) { (x) })static inline unsigned long pte_val (pte_t x) {return be64_to_cpu (x.pte);
@@ -20,6 +21,7 @@ static inline __be64 pte_raw(pte_t x)#ifdef CONFIG_PPC64 typedef struct {__be64 pmd; }pmd_t ;#define __pmd (x) ((pmd_t) { cpu_to_be64(x) }) +#define __pmd_raw (x) ((pmd_t) { (x) })static inline unsigned long pmd_val (pmd_t x) {return be64_to_cpu (x.pmd);
@@ -37,21 +39,34 @@ static inline __be64 pmd_raw(pmd_t x)#if defined(CONFIG_PPC_BOOK3S_64 ) || !defined(CONFIG_PPC_64K_PAGES )typedef struct {__be64 pud; }pud_t ;#define __pud (x) ((pud_t) { cpu_to_be64(x) }) +#define __pud_raw (x) ((pud_t) { (x) })static inline unsigned long pud_val (pud_t x) {return be64_to_cpu (x.pud); } + +static inline __be64 pud_raw (pud_t x) +{ +return x.pud; +} +#endif /* CONFIG_PPC_BOOK3S_64 || !CONFIG_PPC_64K_PAGES */ #endif /* CONFIG_PPC64 */ /* PGD level */ typedef struct {__be64 pgd; }pgd_t ;#define __pgd (x) ((pgd_t) { cpu_to_be64(x) }) +#define __pgd_raw (x) ((pgd_t) { (x) })static inline unsigned long pgd_val (pgd_t x) {return be64_to_cpu (x.pgd); } +static inline __be64 pgd_raw (pgd_t x) +{ +return x.pgd; +} +/* Page protection bits */ typedef struct {unsigned long pgprot; }pgprot_t ;#define pgprot_val (x) ((x).pgprot)
Signature · 1 line
2.7.4
PATCH v2 6/10 powerpc/mm: Compile out radix related functions if RADIX_MMU is disabled
In reply to Aneesh Kumar K.VCurrently we depend on mmu_has_feature to evalute to zero based on MMU_FTRS_POSSIBLE mask. In a later patch, we want to update radix_enabled() to runtime update the conditional operation to a jump instruction. This implies we cannot depend on MMU_FTRS_POSSIBLE mask. Instead define radix_enabled to return 0 if RADIX_MMU is not enabled.
--- arch/powerpc/include/asm/book3s/64/mmu.h | 5 +++++ 1 file changed, 5 insertions(+)
arch/powerpc/include/asm/book3s/64/mmu.h +5 -0
@@ -23,7 +23,12 @@ struct mmu_psize_def { };extern struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT ]; +#ifdef CONFIG_PPC_RADIX_MMU #define radix_enabled () mmu_has_feature(MMU_FTR_RADIX) +#else +#define radix_enabled () (0) +#endif +#endif /* __ASSEMBLY__ */
Signature · 1 line
2.7.4
PATCH v2 7/10 powerpc/hash: Use the correct ppp mask when updating hpte
In reply to Aneesh Kumar K.VWith commit: e58e87adc8bf9 ("powerpc/mm: Update _PAGE_KERNEL_RO") we now use all the three PPP bits. The top bit is now used to have a PPP value of 0b110 which will be mapped to kernel read only. When updating the hpte entry use right mask such that we update the 63rd bit (top 'P' bit) too.
--- arch/powerpc/include/asm/book3s/64/mmu-hash.h | 1 + arch/powerpc/mm/hash_native_64.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-)
arch/powerpc/include/asm/book3s/64/mmu-hash.h +1 -0
@@ -88,6 +88,7 @@#define HPTE_R_RPN_SHIFT 12#define HPTE_R_RPN ASM_CONST(0x0ffffffffffff000)#define HPTE_R_PP ASM_CONST(0x0000000000000003) +#define HPTE_R_PPP ASM_CONST(0x8000000000000003)#define HPTE_R_N ASM_CONST(0x0000000000000004)#define HPTE_R_G ASM_CONST(0x0000000000000008)#define HPTE_R_M ASM_CONST(0x0000000000000010)
arch/powerpc/mm/hash_native_64.c +4 -4
@@ -316,8 +316,8 @@ static long native_hpte_updatepp(unsigned long slot, unsigned long newpp,DBG_LOW (" -> hit\n" );/* Update the HPTE */ hptep->r =cpu_to_be64 ((be64_to_cpu (hptep->r) & - ~(HPTE_R_PP |HPTE_R_N )) | - (newpp & (HPTE_R_PP |HPTE_R_N | + ~(HPTE_R_PPP |HPTE_R_N )) | + (newpp & (HPTE_R_PPP |HPTE_R_N |HPTE_R_C ))); }native_unlock_hpte (hptep);
@@ -385,8 +385,8 @@ static void native_hpte_updateboltedpp(unsigned long newpp, unsigned long ea,/* Update the HPTE */ hptep->r =cpu_to_be64 ((be64_to_cpu (hptep->r) & - ~(HPTE_R_PP |HPTE_R_N )) | - (newpp & (HPTE_R_PP |HPTE_R_N ))); + ~(HPTE_R_PPP |HPTE_R_N )) | + (newpp & (HPTE_R_PPP |HPTE_R_N )));/* * Ensure it is out of the tlb too. Bolted entries base and * actual page size will be same.
Signature · 1 line
2.7.4
Re: [V2, 07/10] powerpc/hash: Use the correct ppp mask when updating hpte
Quoted 7 lines · Aneesh Kumar K.V
With commit:
e58e87adc8bf9("powerpc/mm: Update_PAGE_KERNEL_RO") we now use all the three PPP bits. The top bit is now used to have a PPP value of 0b110 which will be mapped to kernel read only. When updating the hpte entry use right mask such that we update the 63rd bit (top 'P' bit) too.Signed-off-by Aneesh Kumar K.V <[email protected]>
Applied to powerpc fixes, thanks.
https://git.kernel.org/powerpc/c/8550e2fa34f077c8a87cf1ba24
cheers
PATCH v2 8/10 powerpc/mm: Clear top 16 bits of va only on older cpus
In reply to Aneesh Kumar K.VAs per ISA, we need to do this only for architecture version 2.02 and earlier. This continued to work even for 2.07. But let's not do this for anything after 2.02
--- arch/powerpc/include/asm/mmu.h | 12 +++++++++--- arch/powerpc/mm/hash_native_64.c | 6 ++++-- 2 files changed, 13 insertions(+), 5 deletions(-)
arch/powerpc/include/asm/mmu.h +9 -3
@@ -24,6 +24,11 @@/* * This is individual features */ +/* +* We need to clear top 16bits of va (from the remaining 64 bits )in +* tlbie* instructions +*/ +#define MMU_FTR_TLBIE_CROP_VA ASM_CONST(0x00008000)/* Enable use of high BAT registers */ #define MMU_FTR_USE_HIGH_BATS ASM_CONST(0x00010000)
@@ -96,8 +101,9 @@/* MMU feature bit sets for various CPUs */ #define MMU_FTRS_DEFAULT_HPTE_ARCH_V2 \ MMU_FTR_HPTE_TABLE | MMU_FTR_PPCAS_ARCH_V2 -#define MMU_FTRS_POWER4 MMU_FTRS_DEFAULT_HPTE_ARCH_V2 -#define MMU_FTRS_PPC970 MMU_FTRS_POWER4 +#define MMU_FTRS_POWER4 MMU_FTRS_DEFAULT_HPTE_ARCH_V2 | \ + MMU_FTR_TLBIE_CROP_VA +#define MMU_FTRS_PPC970 MMU_FTRS_POWER4 | MMU_FTR_TLBIE_CROP_VA#define MMU_FTRS_POWER5 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE#define MMU_FTRS_POWER6 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE#define MMU_FTRS_POWER7 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE
@@ -124,7 +130,7 @@ enum { MMU_FTR_USE_TLBRSRV | MMU_FTR_USE_PAIRED_MAS | MMU_FTR_NO_SLBIE_B | MMU_FTR_16M_PAGE | MMU_FTR_TLBIEL | MMU_FTR_LOCKLESS_TLBIE | MMU_FTR_CI_LARGE_PAGE | - MMU_FTR_1T_SEGMENT | + MMU_FTR_1T_SEGMENT | MMU_FTR_TLBIE_CROP_VA |#ifdef CONFIG_PPC_RADIX_MMU MMU_FTR_RADIX |#endif
arch/powerpc/mm/hash_native_64.c +4 -2
@@ -64,7 +64,8 @@ static inline void __tlbie(unsigned long vpn, int psize, int apsize, int ssize)* Older versions of the architecture (2.02 and earler) require the * masking of the top 16 bits. */ - va &= ~(0xffffULL <<48 ); +if (mmu_has_feature (MMU_FTR_TLBIE_CROP_VA )) + va &= ~(0xffffULL <<48 );switch (psize) {case MMU_PAGE_4K :
@@ -113,7 +114,8 @@ static inline void __tlbiel(unsigned long vpn, int psize, int apsize, int ssize)* Older versions of the architecture (2.02 and earler) require the * masking of the top 16 bits. */ - va &= ~(0xffffULL <<48 ); +if (mmu_has_feature (MMU_FTR_TLBIE_CROP_VA )) + va &= ~(0xffffULL <<48 );switch (psize) {case MMU_PAGE_4K :
Signature · 1 line
2.7.4
Re: [PATCH V2 08/10] powerpc/mm: Clear top 16 bits of va only on older cpus
Quoted 28 lines · Aneesh Kumar K.V
As per ISA, we need to do this only for architecture version 2.02 and earlier. This continued to work even for 2.07. But let's not do this for anything after 2.02
Signed-off-by Aneesh Kumar K.V <[email protected]>--- arch/powerpc/include/asm/mmu.h | 12 +++++++++--- arch/powerpc/mm/hash_native_64.c | 6 ++++-- 2 files changed, 13 insertions(+), 5 deletions(-)arch/powerpc/include/asm/mmu.h +5
-0@@ -24,6 +24,11 @@/* * This is individual features */ +/* +* We need to clear top 16bits of va (from the remaining 64 bits )in +* tlbie* instructions +*/ +#define MMU_FTR_TLBIE_CROP_VA ASM_CONST(0x00008000)/* Enable use of high BAT registers */ #define MMU_FTR_USE_HIGH_BATS ASM_CONST(0x00010000)@@ -96,8 +101,9 @@/* MMU feature bit sets for various CPUs */
arch/powerpc/include/asm/mmu.h line 109
Quoted 10 lines
arch/powerpc/include/asm/mmu.h +3
-2#define MMU_FTRS_DEFAULT_HPTE_ARCH_V2 \ MMU_FTR_HPTE_TABLE | MMU_FTR_PPCAS_ARCH_V2 -#define MMU_FTRS_POWER4 MMU_FTRS_DEFAULT_HPTE_ARCH_V2 -#define MMU_FTRS_PPC970 MMU_FTRS_POWER4 +#define MMU_FTRS_POWER4 MMU_FTRS_DEFAULT_HPTE_ARCH_V2 | \ + MMU_FTR_TLBIE_CROP_VA +#define MMU_FTRS_PPC970 MMU_FTRS_POWER4 | MMU_FTR_TLBIE_CROP_VA#define MMU_FTRS_POWER5 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE#define MMU_FTRS_POWER6 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE#define MMU_FTRS_POWER7 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE
Updated patch below. MMU_FTRS_POWER4 is inherited by others, hence don't update that.
Quoted 1 line
From
4ed66fd24dc4f976969cc34aca8df2ddbc69fe61Mon Sep 17 00:00:00 2001
From: "Aneesh Kumar K.V" <[email protected]>
Date: Sat, 4 Jun 2016 19:58:26 +0530
Subject: [PATCH] powerpc/mm: Clear top 16 bits of va only on older cpus
As per ISA, we need to do this only for architecture version 2.02 and earlier. This continued to work even for 2.07. But let's not do this for anything after 2.02
--- arch/powerpc/include/asm/mmu.h | 7 ++++++- arch/powerpc/kernel/cputable.c | 14 +++++++------- arch/powerpc/mm/hash_native_64.c | 6 ++++-- 3 files changed, 17 insertions(+), 10 deletions(-)
arch/powerpc/include/asm/mmu.h +6 -1
@@ -24,6 +24,11 @@/* * This is individual features */ +/* +* We need to clear top 16bits of va (from the remaining 64 bits )in +* tlbie* instructions +*/ +#define MMU_FTR_TLBIE_CROP_VA ASM_CONST(0x00008000)/* Enable use of high BAT registers */ #define MMU_FTR_USE_HIGH_BATS ASM_CONST(0x00010000)
@@ -124,7 +129,7 @@ enum { MMU_FTR_USE_TLBRSRV | MMU_FTR_USE_PAIRED_MAS | MMU_FTR_NO_SLBIE_B | MMU_FTR_16M_PAGE | MMU_FTR_TLBIEL | MMU_FTR_LOCKLESS_TLBIE | MMU_FTR_CI_LARGE_PAGE | - MMU_FTR_1T_SEGMENT | + MMU_FTR_1T_SEGMENT | MMU_FTR_TLBIE_CROP_VA |#ifdef CONFIG_PPC_RADIX_MMU MMU_FTR_RADIX |#endif
arch/powerpc/kernel/cputable.c +7 -7
@@ -137,7 +137,7 @@ static struct cpu_spec __initdata cpu_specs[] = { .cpu_name = "POWER4 (gp)", .cpu_features = CPU_FTRS_POWER4, .cpu_user_features = COMMON_USER_POWER4, - .mmu_features = MMU_FTRS_POWER4, + .mmu_features = MMU_FTRS_POWER4 | MMU_FTR_TLBIE_CROP_VA, .icache_bsize = 128, .dcache_bsize = 128, .num_pmcs = 8,
@@ -152,7 +152,7 @@ static struct cpu_spec __initdata cpu_specs[] = { .cpu_name = "POWER4+ (gq)", .cpu_features = CPU_FTRS_POWER4, .cpu_user_features = COMMON_USER_POWER4, - .mmu_features = MMU_FTRS_POWER4, + .mmu_features = MMU_FTRS_POWER4 | MMU_FTR_TLBIE_CROP_VA, .icache_bsize = 128, .dcache_bsize = 128, .num_pmcs = 8,
@@ -168,7 +168,7 @@ static struct cpu_spec __initdata cpu_specs[] = { .cpu_features = CPU_FTRS_PPC970, .cpu_user_features =COMMON_USER_POWER4 | PPC_FEATURE_HAS_ALTIVEC_COMP, - .mmu_features = MMU_FTRS_PPC970, + .mmu_features = MMU_FTRS_PPC970 | MMU_FTR_TLBIE_CROP_VA, .icache_bsize = 128, .dcache_bsize = 128, .num_pmcs = 8,
@@ -186,7 +186,7 @@ static struct cpu_spec __initdata cpu_specs[] = { .cpu_features = CPU_FTRS_PPC970, .cpu_user_features =COMMON_USER_POWER4 | PPC_FEATURE_HAS_ALTIVEC_COMP, - .mmu_features = MMU_FTRS_PPC970, + .mmu_features = MMU_FTRS_PPC970 | MMU_FTR_TLBIE_CROP_VA, .icache_bsize = 128, .dcache_bsize = 128, .num_pmcs = 8,
@@ -204,7 +204,7 @@ static struct cpu_spec __initdata cpu_specs[] = { .cpu_features = CPU_FTRS_PPC970, .cpu_user_features =COMMON_USER_POWER4 | PPC_FEATURE_HAS_ALTIVEC_COMP, - .mmu_features = MMU_FTRS_PPC970, + .mmu_features = MMU_FTRS_PPC970 | MMU_FTR_TLBIE_CROP_VA, .icache_bsize = 128, .dcache_bsize = 128, .num_pmcs = 8,
@@ -222,7 +222,7 @@ static struct cpu_spec __initdata cpu_specs[] = { .cpu_features = CPU_FTRS_PPC970, .cpu_user_features =COMMON_USER_POWER4 | PPC_FEATURE_HAS_ALTIVEC_COMP, - .mmu_features = MMU_FTRS_PPC970, + .mmu_features = MMU_FTRS_PPC970 | MMU_FTR_TLBIE_CROP_VA, .icache_bsize = 128, .dcache_bsize = 128, .num_pmcs = 8,
@@ -240,7 +240,7 @@ static struct cpu_spec __initdata cpu_specs[] = { .cpu_features = CPU_FTRS_PPC970, .cpu_user_features =COMMON_USER_POWER4 | PPC_FEATURE_HAS_ALTIVEC_COMP, - .mmu_features = MMU_FTRS_PPC970, + .mmu_features = MMU_FTRS_PPC970 | MMU_FTR_TLBIE_CROP_VA, .icache_bsize = 128, .dcache_bsize = 128, .num_pmcs = 8,
arch/powerpc/mm/hash_native_64.c +4 -2
@@ -64,7 +64,8 @@ static inline void __tlbie(unsigned long vpn, int psize, int apsize, int ssize)* Older versions of the architecture (2.02 and earler) require the * masking of the top 16 bits. */ - va &= ~(0xffffULL <<48 ); +if (mmu_has_feature (MMU_FTR_TLBIE_CROP_VA )) + va &= ~(0xffffULL <<48 );switch (psize) {case MMU_PAGE_4K :
@@ -113,7 +114,8 @@ static inline void __tlbiel(unsigned long vpn, int psize, int apsize, int ssize)* Older versions of the architecture (2.02 and earler) require the * masking of the top 16 bits. */ - va &= ~(0xffffULL <<48 ); +if (mmu_has_feature (MMU_FTR_TLBIE_CROP_VA )) + va &= ~(0xffffULL <<48 );switch (psize) {case MMU_PAGE_4K :
Signature · 1 line
2.7.4
Michael Ellerman
reviewerRe: [V2, 08/10] powerpc/mm: Clear top 16 bits of va only on older cpus
Quoted 11 lines · Aneesh Kumar K.V
Updated patch below.
MMU_FTRS_POWER4is inherited by others, hence don't update that.Quoted 1 line
From
4ed66fd24dc4f976969cc34aca8df2ddbc69fe61Mon Sep 17 00:00:00 2001From: "Aneesh Kumar K.V" <[email protected]>
Date: Sat, 4 Jun 2016 19:58:26 +0530
Subject: [PATCH] powerpc/mm: Clear top 16 bits of va only on older cpusAs per ISA, we need to do this only for architecture version 2.02 and earlier. This continued to work even for 2.07. But let's not do this for anything after 2.02
What are the practical effects of this?
Quoted 48 lines
arch/powerpc/include/asm/mmu.h +6
-1@@ -24,6 +24,11 @@/* * This is individual features */ +/* +* We need to clear top 16bits of va (from the remaining 64 bits )in +* tlbie* instructions +*/ +#define MMU_FTR_TLBIE_CROP_VA ASM_CONST(0x00008000)/* Enable use of high BAT registers */ #define MMU_FTR_USE_HIGH_BATS ASM_CONST(0x00010000)@@ -124,7 +129,7 @@ enum { MMU_FTR_USE_TLBRSRV | MMU_FTR_USE_PAIRED_MAS | MMU_FTR_NO_SLBIE_B | MMU_FTR_16M_PAGE | MMU_FTR_TLBIEL | MMU_FTR_LOCKLESS_TLBIE | MMU_FTR_CI_LARGE_PAGE | - MMU_FTR_1T_SEGMENT | + MMU_FTR_1T_SEGMENT | MMU_FTR_TLBIE_CROP_VA |#ifdef CONFIG_PPC_RADIX_MMU MMU_FTR_RADIX |#endif arch/powerpc/kernel/cputable.c +2
-2@@ -137,7 +137,7 @@ static struct cpu_spec __initdata cpu_specs[] = { .cpu_name = "POWER4 (gp)", .cpu_features = CPU_FTRS_POWER4, .cpu_user_features = COMMON_USER_POWER4, - .mmu_features = MMU_FTRS_POWER4, + .mmu_features = MMU_FTRS_POWER4 | MMU_FTR_TLBIE_CROP_VA, .icache_bsize = 128, .dcache_bsize = 128, .num_pmcs = 8,@@ -152,7 +152,7 @@ static struct cpu_spec __initdata cpu_specs[] = { .cpu_name = "POWER4+ (gq)", .cpu_features = CPU_FTRS_POWER4, .cpu_user_features = COMMON_USER_POWER4, - .mmu_features = MMU_FTRS_POWER4, + .mmu_features = MMU_FTRS_POWER4 | MMU_FTR_TLBIE_CROP_VA, .icache_bsize = 128, .dcache_bsize = 128, .num_pmcs = 8,
arch/powerpc/kernel/cputable.c static struct cpu_spec __initdata cpu_specs[] = { · line 171
Quoted 5 lines
arch/powerpc/kernel/cputable.c +1
-1@@ -168,7 +168,7 @@ static struct cpu_spec __initdata cpu_specs[] = { .cpu_features = CPU_FTRS_PPC970, .cpu_user_features =COMMON_USER_POWER4 | PPC_FEATURE_HAS_ALTIVEC_COMP, - .mmu_features = MMU_FTRS_PPC970, + .mmu_features = MMU_FTRS_PPC970 | MMU_FTR_TLBIE_CROP_VA,
Please add it to MMU_FTRS_PPC970, rather than at every usage.
cheers
Re: [V2, 08/10] powerpc/mm: Clear top 16 bits of va only on older cpus
Quoted 9 lines · Michael Ellerman
Quoted 8 lines · Aneesh Kumar K.V
Updated patch below.
MMU_FTRS_POWER4is inherited by others, hence don't update that.Quoted 1 line
From
4ed66fd24dc4f976969cc34aca8df2ddbc69fe61Mon Sep 17 00:00:00 2001From: "Aneesh Kumar K.V" <[email protected]>
Date: Sat, 4 Jun 2016 19:58:26 +0530
Subject: [PATCH] powerpc/mm: Clear top 16 bits of va only on older cpus
Quoted 5 lines
Quoted 3 lines
As per ISA, we need to do this only for architecture version 2.02 and earlier. This continued to work even for 2.07. But let's not do this for anything after 2.02
What are the practical effects of this?
For ISA 3.0 we require these top bits to be not cleared. I have updated the commit message to reflect that.
Quoted 48 lines
Quoted 48 lines
arch/powerpc/include/asm/mmu.h +6
-1@@ -24,6 +24,11 @@/* * This is individual features */ +/* +* We need to clear top 16bits of va (from the remaining 64 bits )in +* tlbie* instructions +*/ +#define MMU_FTR_TLBIE_CROP_VA ASM_CONST(0x00008000)/* Enable use of high BAT registers */ #define MMU_FTR_USE_HIGH_BATS ASM_CONST(0x00010000)@@ -124,7 +129,7 @@ enum { MMU_FTR_USE_TLBRSRV | MMU_FTR_USE_PAIRED_MAS | MMU_FTR_NO_SLBIE_B | MMU_FTR_16M_PAGE | MMU_FTR_TLBIEL | MMU_FTR_LOCKLESS_TLBIE | MMU_FTR_CI_LARGE_PAGE | - MMU_FTR_1T_SEGMENT | + MMU_FTR_1T_SEGMENT | MMU_FTR_TLBIE_CROP_VA |#ifdef CONFIG_PPC_RADIX_MMU MMU_FTR_RADIX |#endif arch/powerpc/kernel/cputable.c +2
-2@@ -137,7 +137,7 @@ static struct cpu_spec __initdata cpu_specs[] = { .cpu_name = "POWER4 (gp)", .cpu_features = CPU_FTRS_POWER4, .cpu_user_features = COMMON_USER_POWER4, - .mmu_features = MMU_FTRS_POWER4, + .mmu_features = MMU_FTRS_POWER4 | MMU_FTR_TLBIE_CROP_VA, .icache_bsize = 128, .dcache_bsize = 128, .num_pmcs = 8,@@ -152,7 +152,7 @@ static struct cpu_spec __initdata cpu_specs[] = { .cpu_name = "POWER4+ (gq)", .cpu_features = CPU_FTRS_POWER4, .cpu_user_features = COMMON_USER_POWER4, - .mmu_features = MMU_FTRS_POWER4, + .mmu_features = MMU_FTRS_POWER4 | MMU_FTR_TLBIE_CROP_VA, .icache_bsize = 128, .dcache_bsize = 128, .num_pmcs = 8,
Quoted 9 lines
arch/powerpc/kernel/cputable.c static struct cpu_spec __initdata cpu_specs[] = { · line 171
Quoted 6 lines
arch/powerpc/kernel/cputable.c +1
-1@@ -168,7 +168,7 @@ static struct cpu_spec __initdata cpu_specs[] = { .cpu_features = CPU_FTRS_PPC970, .cpu_user_features =COMMON_USER_POWER4 | PPC_FEATURE_HAS_ALTIVEC_COMP, - .mmu_features = MMU_FTRS_PPC970, + .mmu_features = MMU_FTRS_PPC970 | MMU_FTR_TLBIE_CROP_VA,Please add it to
MMU_FTRS_PPC970, rather than at every usage.
Done
-aneesh
PATCH v2 9/10 powerpc/mm: Print formation regarding the the MMU mode
In reply to Aneesh Kumar K.VThis helps in easily identifying the MMU mode with which the kernel is operating.
--- arch/powerpc/mm/hash_utils_64.c | 3 ++- arch/powerpc/mm/pgtable-radix.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
arch/powerpc/mm/hash_utils_64.c +2 -1
@@ -720,7 +720,7 @@ static void __init hash_init_partition_table(phys_addr_t hash_table,* For now UPRT is 0 for us. */ partition_tb->patb1 =0 ; -DBG ("Partition table %p\n" , partition_tb); +pr_info ("Partition table %p\n" , partition_tb);/* * update partition table control register, * 64 K size.
@@ -924,6 +924,7 @@ void __init hash__early_init_mmu(void)*/ htab_initialize (); +pr_info ("Initializing hash mmu with SLB\n" );/* Initialize SLB management */ slb_initialize (); }
arch/powerpc/mm/pgtable-radix.c +2 -1
@@ -185,7 +185,8 @@ static void __init radix_init_partition_table(void) partition_tb =early_alloc_pgtable (1UL <<PATB_SIZE_SHIFT ); partition_tb->patb0 =cpu_to_be64 (rts_field |__pa (init_mm.pgd) |RADIX_PGD_INDEX_SIZE |PATB_HR ); -printk ("Partition table %p\n" , partition_tb); +pr_info ("Initializing Radix MMU\n" ); +pr_info ("Partition table %p\n" , partition_tb);memblock_set_current_limit (MEMBLOCK_ALLOC_ANYWHERE );/*
Signature · 1 line
2.7.4
PATCH v2 10/10 powerpc/mm/hash: Update SDR1 size encoding as documented in ISA 3.0
In reply to Aneesh Kumar K.VISA 3.0 document hash table size in bytes = 2^(HTABSIZE + 18)
No functionality change by this patch.
--- arch/powerpc/mm/hash_utils_64.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
arch/powerpc/mm/hash_utils_64.c +4 -5
@@ -695,10 +695,9 @@ int remove_section_mapping(unsigned long start, unsigned long end)#endif /* CONFIG_MEMORY_HOTPLUG */ static void __init hash_init_partition_table (phys_addr_t hash_table, -unsigned long pteg_count) +unsigned long htab_size) {unsigned long ps_field; -unsigned long htab_size;unsigned long patb_size =1UL <<PATB_SIZE_SHIFT ;/*
@@ -706,7 +705,7 @@ static void __init hash_init_partition_table(phys_addr_t hash_table,* We can ignore that for lpid 0 */ ps_field =0 ; - htab_size =__ilog2 (pteg_count) -11 ; + htab_size =__ilog2 (htab_size) -18 ;BUILD_BUG_ON_MSG ((PATB_SIZE_SHIFT >24 ),"Partition table size too large." ); partition_tb = __va(memblock_alloc_base(patb_size, patb_size,
@@ -792,7 +791,7 @@ static void __init htab_initialize(void) htab_address =__va (table);/* htab absolute addr + encoded htabsize */ - _SDR1 = table +__ilog2 (pteg_count) -11 ; + _SDR1 = table +__ilog2 (htab_size_bytes) -18 ;/* Initialize the HPT with no entries */ memset ((void *)table,0 , htab_size_bytes);
@@ -801,7 +800,7 @@ static void __init htab_initialize(void)/* Set SDR1 */ mtspr (SPRN_SDR1 , _SDR1); else -hash_init_partition_table (table ,pteg_count ); +hash_init_partition_table (table ,htab_size_bytes ); } prot =pgprot_val (PAGE_KERNEL );
Signature · 1 line
2.7.4