KVM: PPC: Ultravisor: fix mtspr and mfspr
PATCH 8/13 KVM: PPC: Ultravisor: fix mtspr and mfspr
fix mtspr and mfspr to conditionally make ucalls if the target register is previleged.
Signed-off-by Ram Pai <[email protected]>
Signed-off-by Sukadev Bhattiprolu <[email protected]>
--- arch/powerpc/include/asm/reg.h | 30 ++++++++++++++---- arch/powerpc/include/asm/ucall-api.h | 8 ++++- arch/powerpc/kernel/paca.c | 4 +-- arch/powerpc/oprofile/op_model_pa6t.c | 4 +-- arch/powerpc/perf/core-book3s.c | 8 ++--- arch/powerpc/xmon/xmon.c | 58 +++++++++++++++++++---------------- 6 files changed, 70 insertions(+), 42 deletions(-)
arch/powerpc/include/asm/reg.h +24 -6
@@ -1350,20 +1350,38 @@#define __MTMSR "mtmsr"#endif +#include <asm/ucall-api.h> +static inline void mtmsr_isync (unsigned long val) { asm volatile(__MTMSR " %0; " ASM_FTR_IFCLR("isync", "nop", %1) : : "r" (val), "i" (CPU_FTR_ARCH_206) : "memory"); } -#define mfspr (rn) ({unsigned long rval; \ - asm volatile("mfspr %0," __stringify(rn) \ - : "=r" (rval)); rval;}) +#ifndef mfspr +static inline __attribute__((always_inline)) +u64 mfspr (const unsigned int spr) +{ +u64 val; +if (is_uv_register (spr)) +uv_restricted_spr_read (spr, &val); +else + asmvolatile ("mfspr %0,%1" :"=r" (val) :"i" (spr) :"memory" ); +return val; +} +#endif +#ifndef mtspr -#define mtspr (rn, v) asm volatile("mtspr " __stringify(rn) ",%0" : \ - : "r" ((unsigned long)(v)) \ - : "memory") +static inline __attribute__((always_inline)) +void mtspr (const unsigned int rn,unsigned long v) +{ +if (is_uv_register (rn)) +uv_restricted_spr_write (rn, (u64 )v); +else + asmvolatile ("mtspr %0,%1" : :"i" (rn),"r" (v) :"memory" ); +}#endif +#define wrtspr (rn) asm volatile("mtspr " __stringify(rn) ",0" : \ : : "memory")
arch/powerpc/include/asm/ucall-api.h +7 -1
@@ -21,6 +21,12 @@ static inline bool smf_enabled(void)return (smf_state =2 ); } +static inline bool is_uv_register (u64 reg) +{ +return ((reg =SPRN_DAWR || reg =SPRN_DAWRX || reg =SPRN_CIABR ) && +smf_enabled ()); +} +#define PLPAR_UCALL_BUFSIZE 4long plpar_ucall (unsigned long opcode,unsigned long *retbuf, ...);
@@ -48,5 +54,5 @@ static inline int uv_restricted_spr_read(u64 reg, u64 *val)return rc; } -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLY__ */ #endif /* _ASM_POWERPC_UCALL_API_H */
arch/powerpc/kernel/paca.c +2 -2
@@ -183,9 +183,9 @@ void setup_paca(struct paca_struct *new_paca)* applied */ if (early_cpu_has_feature (CPU_FTR_HVMODE )) -mtspr (SPRN_SPRG_HPACA , local_paca); +mtspr (SPRN_SPRG_HPACA , (u64 )local_paca);#endif -mtspr (SPRN_SPRG_PACA , local_paca); +mtspr (SPRN_SPRG_PACA , (u64 )local_paca); }
arch/powerpc/oprofile/op_model_pa6t.c +2 -2
@@ -151,9 +151,9 @@ static int pa6t_cpu_setup(struct op_counter_config *ctr)/* program selected programmable events in */ mtspr (SPRN_PA6T_MMCR1 , mmcr1); -pr_debug ("setup on cpu %d, mmcr0 %016lx\n" ,smp_processor_id (), +pr_debug ("setup on cpu %d, mmcr0 %016llx\n" ,smp_processor_id (),mfspr (SPRN_PA6T_MMCR0 )); -pr_debug ("setup on cpu %d, mmcr1 %016lx\n" ,smp_processor_id (), +pr_debug ("setup on cpu %d, mmcr1 %016llx\n" ,smp_processor_id (),mfspr (SPRN_PA6T_MMCR1 ));return 0 ;
arch/powerpc/perf/core-book3s.c +4 -4
@@ -834,7 +834,7 @@ void perf_event_print_debug(void)pr_info ("PMC5: %08x PMC6: %08x PMC7: %08x PMC8: %08x\n" , pmcs[4 ], pmcs[5 ], pmcs[6 ], pmcs[7 ]); -pr_info ("MMCR0: %016lx MMCR1: %016lx MMCRA: %016lx\n" , +pr_info ("MMCR0: %016llx MMCR1: %016llx MMCRA: %016llx\n" ,mfspr (SPRN_MMCR0 ),mfspr (SPRN_MMCR1 ),mfspr (SPRN_MMCRA )); sdar = sier =0 ;
@@ -845,13 +845,13 @@ void perf_event_print_debug(void) sier =mfspr (SPRN_SIER );if (ppmu->flags &PPMU_ARCH_207S ) { -pr_info ("MMCR2: %016lx EBBHR: %016lx\n" , +pr_info ("MMCR2: %016llx EBBHR: %016llx\n" ,mfspr (SPRN_MMCR2 ),mfspr (SPRN_EBBHR )); -pr_info ("EBBRR: %016lx BESCR: %016lx\n" , +pr_info ("EBBRR: %016llx BESCR: %016llx\n" ,mfspr (SPRN_EBBRR ),mfspr (SPRN_BESCR )); }#endif -pr_info ("SIAR: %016lx SDAR: %016lx SIER: %016lx\n" , +pr_info ("SIAR: %016llx SDAR: %016lx SIER: %016lx\n" ,mfspr (SPRN_SIAR ), sdar, sier);local_irq_restore (flags);
arch/powerpc/xmon/xmon.c +31 -27
133 lines not on this page · raw message
Signature · 1 line
1.8.3.1