powerpc/64s: Rename PPC_INVALIDATE_ERAT to PPC_ARCH_300_INVALIDATE_ERAT
Subsystems (2)
Nicholas Piggin
reviewerPATCH 1/2 powerpc/64s: Rename PPC_INVALIDATE_ERAT to PPC_ARCH_300_INVALIDATE_ERAT
This makes it clear to the caller that it can only be used on POWER9 and later CPUs.
---
I think I added a bug in machine checks at one point that I might have been able to avoid with this name :)
arch/powerpc/include/asm/ppc-opcode.h | 2 +- arch/powerpc/kernel/mce_power.c | 3 +-- arch/powerpc/kvm/book3s_hv_builtin.c | 2 +- arch/powerpc/mm/book3s64/hash_native.c | 2 +- arch/powerpc/mm/book3s64/radix_tlb.c | 8 ++++---- arch/powerpc/platforms/powernv/idle.c | 2 +- 6 files changed, 9 insertions(+), 10 deletions(-)
arch/powerpc/include/asm/ppc-opcode.h +1 -1
@@ -588,7 +588,7 @@#define PPC_SLBIA (IH ) stringify_in_c(.long PPC_INST_SLBIA | \ ((IH & 0x7) << 21)) -#define PPC_INVALIDATE_ERAT PPC_SLBIA(7) +#define PPC_ARCH_300_INVALIDATE_ERAT PPC_SLBIA(7)#define VCMPEQUD_RC (vrt, vra, vrb) stringify_in_c(.long PPC_INST_VCMPEQUD | \ ___PPC_RT(vrt) | ___PPC_RA(vra) | \
arch/powerpc/kernel/mce_power.c +1 -2
@@ -82,8 +82,7 @@ static void flush_erat(void)return ; }#endif -/* PPC_INVALIDATE_ERAT can only be used on ISA v3 and newer */ - asm volatile(PPC_INVALIDATE_ERAT : : :"memory"); + asm volatile(PPC_ARCH_300_INVALIDATE_ERAT : : :"memory"); }#define MCE_FLUSH_SLB 1
arch/powerpc/kvm/book3s_hv_builtin.c +1 -1
@@ -830,7 +830,7 @@ static void flush_guest_tlb(struct kvm *kvm) } } asmvolatile ("ptesync" : : :"memory" ); - asm volatile(PPC_INVALIDATE_ERAT : : :"memory"); + asm volatile(PPC_ARCH_300_INVALIDATE_ERAT : : :"memory"); } void kvmppc_check_need_tlb_flush(struct kvm *kvm, int pcpu,
arch/powerpc/mm/book3s64/hash_native.c +1 -1
@@ -112,7 +112,7 @@ static void tlbiel_all_isa300(unsigned int num_sets, unsigned int is) asmvolatile ("ptesync" : : :"memory" ); - asmvolatile (PPC_INVALIDATE_ERAT "; isync" : : :"memory" ); + asmvolatile (PPC_ARCH_300_INVALIDATE_ERAT "; isync" : : :"memory" ); }void hash__tlbiel_all (unsigned int action)
arch/powerpc/mm/book3s64/radix_tlb.c +4 -4
@@ -83,7 +83,7 @@ void radix__tlbiel_all(unsigned int action)else WARN (1 ,"%s called on pre-POWER9 CPU\n" , __func__); - asmvolatile (PPC_INVALIDATE_ERAT "; isync" : : :"memory" ); + asmvolatile (PPC_ARCH_300_INVALIDATE_ERAT "; isync" : : :"memory" ); } static __always_inline void __tlbiel_pid(unsigned long pid, int set,
@@ -258,7 +258,7 @@ static inline void _tlbiel_pid(unsigned long pid, unsigned long ric)__tlbiel_pid (pid, set,RIC_FLUSH_TLB ); asmvolatile ("ptesync" : : :"memory" ); - asmvolatile (PPC_INVALIDATE_ERAT "; isync" : : :"memory" ); + asmvolatile (PPC_ARCH_300_INVALIDATE_ERAT "; isync" : : :"memory" ); }static inline void _tlbie_pid (unsigned long pid,unsigned long ric)
@@ -310,7 +310,7 @@ static inline void _tlbiel_lpid(unsigned long lpid, unsigned long ric)__tlbiel_lpid (lpid, set,RIC_FLUSH_TLB ); asmvolatile ("ptesync" : : :"memory" ); - asmvolatile (PPC_INVALIDATE_ERAT "; isync" : : :"memory" ); + asmvolatile (PPC_ARCH_300_INVALIDATE_ERAT "; isync" : : :"memory" ); }static inline void _tlbie_lpid (unsigned long lpid,unsigned long ric)
@@ -362,7 +362,7 @@ static inline void _tlbiel_lpid_guest(unsigned long lpid, unsigned long ric)__tlbiel_lpid_guest (lpid, set,RIC_FLUSH_TLB ); asmvolatile ("ptesync" : : :"memory" ); - asm volatile(PPC_INVALIDATE_ERAT : : :"memory"); + asm volatile(PPC_ARCH_300_INVALIDATE_ERAT : : :"memory"); }
arch/powerpc/platforms/powernv/idle.c +1 -1
@@ -716,7 +716,7 @@ static unsigned long power9_idle_stop(unsigned long psscr, bool mmu_on)* to reload MMCR0 (see mmcr0 comment above). */ if (!cpu_has_feature (CPU_FTR_POWER9_DD2_1 )) { - asm volatile(PPC_INVALIDATE_ERAT); + asm volatile(PPC_ARCH_300_INVALIDATE_ERAT);mtspr (SPRN_MMCR0 , mmcr0); }
Signature · 1 line
2.20.1
Nicholas Piggin
reviewerPATCH 2/2 powerpc/64s/radix: keep kernel ERAT over local process/guest invalidates
ISAv3 radix modes provide SLBIA variants which can invalidate ERAT for effPID!=0 or for effLPID!=0, which allows user and guest invalidations to retain kernel/host ERAT entries.
--- arch/powerpc/include/asm/ppc-opcode.h | 8 ++++++++ arch/powerpc/kvm/book3s_hv_builtin.c | 6 ++++-- arch/powerpc/mm/book3s64/radix_tlb.c | 6 +++--- 3 files changed, 15 insertions(+), 5 deletions(-)
arch/powerpc/include/asm/ppc-opcode.h +8 -0
@@ -588,7 +588,15 @@#define PPC_SLBIA (IH ) stringify_in_c(.long PPC_INST_SLBIA | \ ((IH & 0x7) << 21)) + +/* +* These may only be used by ARCH_300 (radix implies ARCH_300). +* USER/GUEST invalidates may only be used by radix mode (on HPT these +* would also invalidate various SLBEs which may not be desired). +*/ #define PPC_ARCH_300_INVALIDATE_ERAT PPC_SLBIA(7) +#define PPC_RADIX_INVALIDATE_ERAT_USER PPC_SLBIA(3) +#define PPC_RADIX_INVALIDATE_ERAT_GUEST PPC_SLBIA(6)#define VCMPEQUD_RC (vrt, vra, vrb) stringify_in_c(.long PPC_INST_VCMPEQUD | \ ___PPC_RT(vrt) | ___PPC_RA(vra) | \
arch/powerpc/kvm/book3s_hv_builtin.c +4 -2
@@ -820,6 +820,8 @@ static void flush_guest_tlb(struct kvm *kvm) : : "r" (rb), "i" (1), "i" (1), "i" (0), "r" (0) : "memory"); } + asmvolatile ("ptesync" : : :"memory" ); + asm volatile(PPC_RADIX_INVALIDATE_ERAT_GUEST : : :"memory"); }else {for (set =0 ; set < kvm->arch.tlb_sets; ++set) {/* R=0 PRS=0 RIC=0 */
@@ -828,9 +830,9 @@ static void flush_guest_tlb(struct kvm *kvm) "r" (0) : "memory"); rb += PPC_BIT(51); /* increment set number */ } + asmvolatile ("ptesync" : : :"memory" ); + asm volatile(PPC_ARCH_300_INVALIDATE_ERAT : : :"memory"); } - asmvolatile ("ptesync" : : :"memory" ); - asm volatile(PPC_ARCH_300_INVALIDATE_ERAT : : :"memory"); } void kvmppc_check_need_tlb_flush(struct kvm *kvm, int pcpu,
arch/powerpc/mm/book3s64/radix_tlb.c +3 -3
@@ -258,7 +258,7 @@ static inline void _tlbiel_pid(unsigned long pid, unsigned long ric)__tlbiel_pid (pid, set,RIC_FLUSH_TLB ); asmvolatile ("ptesync" : : :"memory" ); - asmvolatile (PPC_ARCH_300_INVALIDATE_ERAT "; isync" : : :"memory" ); + asmvolatile (PPC_RADIX_INVALIDATE_ERAT_USER "; isync" : : :"memory" ); }static inline void _tlbie_pid (unsigned long pid,unsigned long ric)
@@ -310,7 +310,7 @@ static inline void _tlbiel_lpid(unsigned long lpid, unsigned long ric)__tlbiel_lpid (lpid, set,RIC_FLUSH_TLB ); asmvolatile ("ptesync" : : :"memory" ); - asmvolatile (PPC_ARCH_300_INVALIDATE_ERAT "; isync" : : :"memory" ); + asmvolatile (PPC_RADIX_INVALIDATE_ERAT_GUEST "; isync" : : :"memory" ); }static inline void _tlbie_lpid (unsigned long lpid,unsigned long ric)
@@ -362,7 +362,7 @@ static inline void _tlbiel_lpid_guest(unsigned long lpid, unsigned long ric)__tlbiel_lpid_guest (lpid, set,RIC_FLUSH_TLB ); asmvolatile ("ptesync" : : :"memory" ); - asm volatile(PPC_ARCH_300_INVALIDATE_ERAT : : :"memory"); + asm volatile(PPC_RADIX_INVALIDATE_ERAT_GUEST : : :"memory"); }
Signature · 1 line
2.20.1
arch/powerpc/include/asm/ppc-opcode.h line 591
Quoted 5 lines · Nicholas Piggin
This makes it clear to the caller that it can only be used on POWER9 and later CPUs.
arch/powerpc/include/asm/ppc-opcode.h +1
-1-#define PPC_INVALIDATE_ERAT PPC_SLBIA(7) +#define PPC_ARCH_300_INVALIDATE_ERAT PPC_SLBIA(7)
The architecture version is 3.0 (or 3.0B), not "300". This will work on implementations of later architecture versions as well, so maybe the name isn't so great anyway?
Segher
Nicholas Piggin
reviewerSegher Boessenkool's on June 23, 2019 10:03 pm:
Quoted 10 lines · Nicholas Piggin
arch/powerpc/include/asm/ppc-opcode.h line 591
Quoted 5 lines
This makes it clear to the caller that it can only be used on POWER9 and later CPUs.
arch/powerpc/include/asm/ppc-opcode.h +1
-1-#define PPC_INVALIDATE_ERAT PPC_SLBIA(7) +#define PPC_ARCH_300_INVALIDATE_ERAT PPC_SLBIA(7)The architecture version is 3.0 (or 3.0B), not "300". This will work on implementations of later architecture versions as well, so maybe the name isn't so great anyway?
Yeah... this is kernel convention for better or worse. ISA v3.0B feature support is called CPU_FTR_ARCH_300, and later architectures will advertise that support. For the most part we can use architected features (incompatible changes would require additional code).
Thanks,
Nick
Michael Ellerman
reviewerQuoted 12 lines · Nicholas Piggin
Segher Boessenkool's on June 23, 2019 10:03 pm:
Quoted 10 lines · Nicholas Piggin
arch/powerpc/include/asm/ppc-opcode.h line 591
Quoted 5 lines
This makes it clear to the caller that it can only be used on POWER9 and later CPUs.
arch/powerpc/include/asm/ppc-opcode.h +1
-1-#define PPC_INVALIDATE_ERAT PPC_SLBIA(7) +#define PPC_ARCH_300_INVALIDATE_ERAT PPC_SLBIA(7)The architecture version is 3.0 (or 3.0B), not "300". This will work on implementations of later architecture versions as well, so maybe the name isn't so great anyway?
Quoted 4 lines
Yeah... this is kernel convention for better or worse. ISA v3.0B feature support is called
CPU_FTR_ARCH_300, and later architectures will advertise that support. For the most part we can use architected features (incompatible changes would require additional code).
I'd rather we used 3_0B or something inside the kernel, but I'm not sure it's worth the churn to rename the existing feature everywhere. And we can't rename the user visible feature.
But if you're adding a new usage then I'd prefer: PPC_ISA_3_0B_INVALIDATE_ERAT
I dislike "300" because it implies we support ISA v3.0 but we actually don't, we only support v3.0B.
cheers
Quoted 4 lines · Nicholas Piggin
This makes it clear to the caller that it can only be used on POWER9 and later CPUs.
Signed-off-by Nicholas Piggin <[email protected]>
Series applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/fe7946ce0808eb0e43711f5db7d2d1599b362d02
cheers