KVM: PPC: Book3S PR: Add POWER8 support
Subsystems (3)
cover KVM: PPC: Book3S PR: Add POWER8 support
When running on a POWER8 host, we get away with running the guest as POWER7 and nothing falls apart.
However, when we start exposing POWER8 as guest CPU, guests will start using new abilities on POWER8 which we need to handle.
This patch set does a minimalistic approach to implementing those bits to make guests happy enough to run.
Alex
Alexander Graf (6):
KVM: PPC: Book3S PR: Ignore PMU SPRs
KVM: PPC: Book3S PR: Emulate TIR register
KVM: PPC: Book3S PR: Handle Facility interrupt and FSCR
KVM: PPC: Book3S PR: Expose TAR facility to guest
KVM: PPC: Book3S PR: Expose EBB registers
KVM: PPC: Book3S PR: Expose TM registers
arch/powerpc/include/asm/kvm_asm.h | 18 ++++--- arch/powerpc/include/asm/kvm_book3s_asm.h | 2 + arch/powerpc/include/asm/kvm_host.h | 3 ++ arch/powerpc/kernel/asm-offsets.c | 3 ++ arch/powerpc/kvm/book3s.c | 34 +++++++++++++ arch/powerpc/kvm/book3s_emulate.c | 53 ++++++++++++++++++++ arch/powerpc/kvm/book3s_hv.c | 30 ----------- arch/powerpc/kvm/book3s_pr.c | 82 +++++++++++++++++++++++++++++++ arch/powerpc/kvm/book3s_segment.S | 25 ++++++++++ 9 files changed, 212 insertions(+), 38 deletions(-)
Signature · 1 line
1.8.1.4
PATCH 1/6 KVM: PPC: Book3S PR: Ignore PMU SPRs
When we expose a POWER8 CPU into the guest, it will start accessing PMU SPRs that we don't emulate. Just ignore accesses to them.
--- arch/powerpc/kvm/book3s_emulate.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/powerpc/kvm/book3s_emulate.c +10 -0
@@ -455,6 +455,11 @@ int kvmppc_core_emulate_mtspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val)case SPRN_WPAR_GEKKO :case SPRN_MSSSR0 :case SPRN_DABR : +case SPRN_MMCRS : +case SPRN_MMCRA : +case SPRN_MMCR0 : +case SPRN_MMCR1 : +case SPRN_MMCR2 :break ; unprivileged:default :
@@ -553,6 +558,11 @@ int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_valcase SPRN_WPAR_GEKKO :case SPRN_MSSSR0 :case SPRN_DABR : +case SPRN_MMCRS : +case SPRN_MMCRA : +case SPRN_MMCR0 : +case SPRN_MMCR1 : +case SPRN_MMCR2 : *spr_val =0 ;break ;default :
Signature · 1 line
1.8.1.4
PATCH 2/6 KVM: PPC: Book3S PR: Emulate TIR register
In reply to Alexander GrafIn parallel to the Processor ID Register (PIR) threaded POWER8 also adds a Thread ID Register (TID). Since PR KVM doesn't emulate more than one thread per core, we can just always expose 0 here.
--- arch/powerpc/kvm/book3s_emulate.c | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/kvm/book3s_emulate.c +1 -0
@@ -563,6 +563,7 @@ int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_valcase SPRN_MMCR0 :case SPRN_MMCR1 :case SPRN_MMCR2 : +case SPRN_TIR : *spr_val =0 ;break ;default :
Signature · 1 line
1.8.1.4
PATCH 3/6 KVM: PPC: Book3S PR: Handle Facility interrupt and FSCR
In reply to Alexander GrafPOWER8 introduced a new interrupt type called "Facility unavailable interrupt" which contains its status message in a new register called FSCR.
Handle these exits and try to emulate instructions for unhandled facilities. Follow-on patches enable KVM to expose specific facilities into the guest.
--- arch/powerpc/include/asm/kvm_asm.h | 18 +++++---- arch/powerpc/include/asm/kvm_book3s_asm.h | 2 + arch/powerpc/include/asm/kvm_host.h | 1 + arch/powerpc/kernel/asm-offsets.c | 3 ++ arch/powerpc/kvm/book3s.c | 10 +++++ arch/powerpc/kvm/book3s_emulate.c | 6 +++ arch/powerpc/kvm/book3s_hv.c | 6 --- arch/powerpc/kvm/book3s_pr.c | 63 +++++++++++++++++++++++++++++++ arch/powerpc/kvm/book3s_segment.S | 25 ++++++++++++ 9 files changed, 120 insertions(+), 14 deletions(-)
arch/powerpc/include/asm/kvm_asm.h +10 -8
@@ -102,6 +102,7 @@#define BOOK3S_INTERRUPT_PERFMON 0xf00#define BOOK3S_INTERRUPT_ALTIVEC 0xf20#define BOOK3S_INTERRUPT_VSX 0xf40 +#define BOOK3S_INTERRUPT_FAC_UNAVAIL 0xf60#define BOOK3S_INTERRUPT_H_FAC_UNAVAIL 0xf80#define BOOK3S_IRQPRIO_SYSTEM_RESET 0
@@ -114,14 +115,15 @@#define BOOK3S_IRQPRIO_FP_UNAVAIL 7#define BOOK3S_IRQPRIO_ALTIVEC 8#define BOOK3S_IRQPRIO_VSX 9 -#define BOOK3S_IRQPRIO_SYSCALL 10 -#define BOOK3S_IRQPRIO_MACHINE_CHECK 11 -#define BOOK3S_IRQPRIO_DEBUG 12 -#define BOOK3S_IRQPRIO_EXTERNAL 13 -#define BOOK3S_IRQPRIO_DECREMENTER 14 -#define BOOK3S_IRQPRIO_PERFORMANCE_MONITOR 15 -#define BOOK3S_IRQPRIO_EXTERNAL_LEVEL 16 -#define BOOK3S_IRQPRIO_MAX 17 +#define BOOK3S_IRQPRIO_FAC_UNAVAIL 10 +#define BOOK3S_IRQPRIO_SYSCALL 11 +#define BOOK3S_IRQPRIO_MACHINE_CHECK 12 +#define BOOK3S_IRQPRIO_DEBUG 13 +#define BOOK3S_IRQPRIO_EXTERNAL 14 +#define BOOK3S_IRQPRIO_DECREMENTER 15 +#define BOOK3S_IRQPRIO_PERFORMANCE_MONITOR 16 +#define BOOK3S_IRQPRIO_EXTERNAL_LEVEL 17 +#define BOOK3S_IRQPRIO_MAX 18#define BOOK3S_HFLAG_DCBZ32 0x1#define BOOK3S_HFLAG_SLB 0x2
arch/powerpc/include/asm/kvm_book3s_asm.h +2 -0
@@ -104,6 +104,7 @@ struct kvmppc_host_state {#ifdef CONFIG_PPC_BOOK3S_64 u64 cfar;u64 ppr; +u64 host_fscr;#endif };
@@ -133,6 +134,7 @@ struct kvmppc_book3s_shadow_vcpu {u64 esid; u64 vsid; } slb[64 ];/* guest SLB */ +u64 shadow_fscr;#endif };
arch/powerpc/include/asm/kvm_host.h +1 -0
@@ -475,6 +475,7 @@ struct kvm_vcpu_arch {ulong ppr;ulong pspb;ulong fscr; +ulong shadow_fscr;ulong ebbhr;ulong ebbrr;ulong bescr;
arch/powerpc/kernel/asm-offsets.c +3 -0
@@ -535,6 +535,7 @@ int main(void) DEFINE(VCPU_CFAR, offsetof(struct kvm_vcpu, arch.cfar)); DEFINE(VCPU_PPR, offsetof(struct kvm_vcpu, arch.ppr)); DEFINE(VCPU_FSCR, offsetof(struct kvm_vcpu, arch.fscr)); + DEFINE(VCPU_SHADOW_FSCR, offsetof(struct kvm_vcpu, arch.shadow_fscr)); DEFINE(VCPU_PSPB, offsetof(struct kvm_vcpu, arch.pspb)); DEFINE(VCPU_EBBHR, offsetof(struct kvm_vcpu, arch.ebbhr)); DEFINE(VCPU_EBBRR, offsetof(struct kvm_vcpu, arch.ebbrr));
@@ -616,6 +617,7 @@ int main(void)#ifdef CONFIG_PPC64 SVCPU_FIELD (SVCPU_SLB , slb);SVCPU_FIELD (SVCPU_SLB_MAX , slb_max); +SVCPU_FIELD (SVCPU_SHADOW_FSCR , shadow_fscr);#endif HSTATE_FIELD (HSTATE_HOST_R1 , host_r1);
@@ -651,6 +653,7 @@ int main(void)#ifdef CONFIG_PPC_BOOK3S_64 HSTATE_FIELD (HSTATE_CFAR , cfar);HSTATE_FIELD (HSTATE_PPR , ppr); +HSTATE_FIELD (HSTATE_HOST_FSCR , host_fscr);#endif /* CONFIG_PPC_BOOK3S_64 */ #else /* CONFIG_PPC_BOOK3S */
arch/powerpc/kvm/book3s.c +10 -0
@@ -145,6 +145,7 @@ static int kvmppc_book3s_vec2irqprio(unsigned int vec)case 0xd00 : prio =BOOK3S_IRQPRIO_DEBUG ;break ;case 0xf20 : prio =BOOK3S_IRQPRIO_ALTIVEC ;break ;case 0xf40 : prio =BOOK3S_IRQPRIO_VSX ;break ; +case 0xf60 : prio =BOOK3S_IRQPRIO_FAC_UNAVAIL ;break ;default : prio =BOOK3S_IRQPRIO_MAX ;break ; }
@@ -275,6 +276,9 @@ int kvmppc_book3s_irqprio_deliver(struct kvm_vcpu *vcpu, unsigned int priority)case BOOK3S_IRQPRIO_PERFORMANCE_MONITOR : vec =BOOK3S_INTERRUPT_PERFMON ;break ; +case BOOK3S_IRQPRIO_FAC_UNAVAIL : + vec =BOOK3S_INTERRUPT_FAC_UNAVAIL ; +break ;default : deliver =0 ;printk (KERN_ERR "KVM: Unknown interrupt: 0x%x\n" , priority);
@@ -627,6 +631,9 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) val =get_reg_val (reg->id,kvmppc_xics_get_icp (vcpu));break ;#endif /* CONFIG_KVM_XICS */ +case KVM_REG_PPC_FSCR : + val =get_reg_val (reg->id, vcpu->arch.fscr); +break ;default : r = -EINVAL ;break ;
@@ -716,6 +723,9 @@ int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) set_reg_val(reg->id, val));break ;#endif /* CONFIG_KVM_XICS */ +case KVM_REG_PPC_FSCR : + vcpu->arch.fscr =set_reg_val (reg->id, val); +break ;default : r = -EINVAL ;break ;
arch/powerpc/kvm/book3s_emulate.c +6 -0
@@ -438,6 +438,9 @@ int kvmppc_core_emulate_mtspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val)case SPRN_GQR7 :to_book3s (vcpu)->gqr[sprn -SPRN_GQR0 ] = spr_val;break ; +case SPRN_FSCR : + vcpu->arch.fscr = spr_val; +break ;case SPRN_ICTC :case SPRN_THRM1 :case SPRN_THRM2 :
@@ -543,6 +546,9 @@ int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_valcase SPRN_GQR7 : *spr_val =to_book3s (vcpu)->gqr[sprn -SPRN_GQR0 ];break ; +case SPRN_FSCR : + *spr_val = vcpu->arch.fscr; +break ;case SPRN_THRM1 :case SPRN_THRM2 :case SPRN_THRM3 :
arch/powerpc/kvm/book3s_hv.c +0 -6
@@ -879,9 +879,6 @@ static int kvmppc_get_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,case KVM_REG_PPC_IAMR : *val =get_reg_val (id, vcpu->arch.iamr);break ; -case KVM_REG_PPC_FSCR : - *val =get_reg_val (id, vcpu->arch.fscr); -break ;case KVM_REG_PPC_PSPB : *val =get_reg_val (id, vcpu->arch.pspb);break ;
@@ -1091,9 +1088,6 @@ static int kvmppc_set_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,case KVM_REG_PPC_IAMR : vcpu->arch.iamr =set_reg_val (id, *val);break ; -case KVM_REG_PPC_FSCR : - vcpu->arch.fscr =set_reg_val (id, *val); -break ;case KVM_REG_PPC_PSPB : vcpu->arch.pspb =set_reg_val (id, *val);break ;
arch/powerpc/kvm/book3s_pr.c +63 -0
105 lines not on this page · raw message
arch/powerpc/kvm/book3s_segment.S +25 -0
@@ -90,6 +90,15 @@ kvmppc_handler_trampoline_enter: LOAD_GUEST_SEGMENTS #ifdef CONFIG_PPC_BOOK3S_64 +BEGIN_FTR_SECTION + /* Save host FSCR */ + mfspr r8, SPRN_FSCR + std r8, HSTATE_HOST_FSCR(r13) + /* Set FSCR during guest execution */ + ld r9, SVCPU_SHADOW_FSCR(r13) + mtspr SPRN_FSCR, r9 +END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) + /* Some guests may need to have dcbz set to 32 byte length. * * Usually we ensure that by patching the guest's instructions
@@ -255,6 +264,10 @@ BEGIN_FTR_SECTION cmpwi r12, BOOK3S_INTERRUPT_H_EMUL_ASSIST beq- ld_last_inst END_FTR_SECTION_IFSET(CPU_FTR_HVMODE) +BEGIN_FTR_SECTION + cmpwi r12, BOOK3S_INTERRUPT_FAC_UNAVAIL + beq- ld_last_inst +END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) #endif b no_ld_last_inst
@@ -311,6 +324,18 @@ no_ld_last_inst: no_dcbz32_off: +BEGIN_FTR_SECTION + /* Save guest FSCR on a FAC_UNAVAIL interrupt */ + cmpwi r12, BOOK3S_INTERRUPT_FAC_UNAVAIL + bne+ no_fscr_save + mfspr r7, SPRN_FSCR + std r7, SVCPU_SHADOW_FSCR(r13) +no_fscr_save: + /* Restore host FSCR */ + ld r8, HSTATE_HOST_FSCR(r13) + mtspr SPRN_FSCR, r8 +END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) + #endif /* CONFIG_PPC_BOOK3S_64 */ /*
Signature · 1 line
1.8.1.4
PATCH 4/6 KVM: PPC: Book3S PR: Expose TAR facility to guest
In reply to Alexander GrafPOWER8 implements a new register called TAR. This register has to be enabled in FSCR and then from KVM's point of view is mere storage.
This patch enables the guest to use TAR.
--- arch/powerpc/include/asm/kvm_host.h | 2 ++ arch/powerpc/kvm/book3s.c | 6 ++++++ arch/powerpc/kvm/book3s_hv.c | 6 ------ arch/powerpc/kvm/book3s_pr.c | 18 ++++++++++++++++++ 4 files changed, 26 insertions(+), 6 deletions(-)
arch/powerpc/include/asm/kvm_host.h +2 -0
@@ -449,7 +449,9 @@ struct kvm_vcpu_arch {ulong pc;ulong ctr;ulong lr; +#ifdef CONFIG_PPC_BOOK3S ulong tar; +#endif ulong xer;u32 cr;
arch/powerpc/kvm/book3s.c +6 -0
@@ -634,6 +634,9 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)case KVM_REG_PPC_FSCR : val =get_reg_val (reg->id, vcpu->arch.fscr);break ; +case KVM_REG_PPC_TAR : + val =get_reg_val (reg->id, vcpu->arch.tar); +break ;default : r = -EINVAL ;break ;
@@ -726,6 +729,9 @@ int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)case KVM_REG_PPC_FSCR : vcpu->arch.fscr =set_reg_val (reg->id, val);break ; +case KVM_REG_PPC_TAR : + vcpu->arch.tar =set_reg_val (reg->id, val); +break ;default : r = -EINVAL ;break ;
arch/powerpc/kvm/book3s_hv.c +0 -6
@@ -891,9 +891,6 @@ static int kvmppc_get_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,case KVM_REG_PPC_BESCR : *val =get_reg_val (id, vcpu->arch.bescr);break ; -case KVM_REG_PPC_TAR : - *val =get_reg_val (id, vcpu->arch.tar); -break ;case KVM_REG_PPC_DPDES : *val =get_reg_val (id, vcpu->arch.vcore->dpdes);break ;
@@ -1100,9 +1097,6 @@ static int kvmppc_set_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,case KVM_REG_PPC_BESCR : vcpu->arch.bescr =set_reg_val (id, *val);break ; -case KVM_REG_PPC_TAR : - vcpu->arch.tar =set_reg_val (id, *val); -break ;case KVM_REG_PPC_DPDES : vcpu->arch.vcore->dpdes =set_reg_val (id, *val);break ;
arch/powerpc/kvm/book3s_pr.c +18 -0
@@ -90,6 +90,7 @@ static void kvmppc_core_vcpu_put_pr(struct kvm_vcpu *vcpu)#endif kvmppc_giveup_ext (vcpu,MSR_FP |MSR_VEC |MSR_VSX ); +kvmppc_giveup_fac (vcpu,FSCR_TAR_LG ); vcpu->cpu =-1 ; }
@@ -625,6 +626,14 @@ static void kvmppc_giveup_fac(struct kvm_vcpu *vcpu, ulong fac)/* Facility not available to the guest, ignore giveup request*/ return; } + +switch (fac) { +case FSCR_TAR_LG : + vcpu->arch.tar =mfspr (SPRN_TAR ); +mtspr (SPRN_TAR , current->thread.tar); + vcpu->arch.shadow_fscr &= ~FSCR_TAR ; +break ; + }#endif }
@@ -783,6 +792,12 @@ static int kvmppc_handle_fac(struct kvm_vcpu *vcpu, ulong fac) }switch (fac) { +case FSCR_TAR_LG : +/* TAR switching isn't lazy in Linux yet */ + current->thread.tar =mfspr (SPRN_TAR ); +mtspr (SPRN_TAR , vcpu->arch.tar); + vcpu->arch.shadow_fscr |=FSCR_TAR ; +break ;default :kvmppc_emulate_fac (vcpu, fac);break ;
@@ -1365,6 +1380,9 @@ static int kvmppc_vcpu_run_pr(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)/* Make sure we save the guest FPU/Altivec/VSX state */ kvmppc_giveup_ext (vcpu,MSR_FP |MSR_VEC |MSR_VSX ); +/* Make sure we save the guest TAR/EBB/DSCR state */ +kvmppc_giveup_fac (vcpu,FSCR_TAR_LG ); + out: vcpu->mode =OUTSIDE_GUEST_MODE ;return ret;
Signature · 1 line
1.8.1.4
PATCH 5/6 KVM: PPC: Book3S PR: Expose EBB registers
In reply to Alexander GrafPOWER8 introduces a new facility called the "Event Based Branch" facility. It contains of a few registers that indicate where a guest should branch to when a defined event occurs and it's in PR mode.
We don't want to really enable EBB as it will create a big mess with !PR guest mode while hardware is in PR and we don't really emulate the PMU anyway.
So instead, let's just leave it at emulation of all its registers.
--- arch/powerpc/kvm/book3s.c | 18 ++++++++++++++++++ arch/powerpc/kvm/book3s_emulate.c | 18 ++++++++++++++++++ arch/powerpc/kvm/book3s_hv.c | 18 ------------------ 3 files changed, 36 insertions(+), 18 deletions(-)
arch/powerpc/kvm/book3s.c +18 -0
@@ -637,6 +637,15 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)case KVM_REG_PPC_TAR : val =get_reg_val (reg->id, vcpu->arch.tar);break ; +case KVM_REG_PPC_EBBHR : + val =get_reg_val (reg->id, vcpu->arch.ebbhr); +break ; +case KVM_REG_PPC_EBBRR : + val =get_reg_val (reg->id, vcpu->arch.ebbrr); +break ; +case KVM_REG_PPC_BESCR : + val =get_reg_val (reg->id, vcpu->arch.bescr); +break ;default : r = -EINVAL ;break ;
@@ -732,6 +741,15 @@ int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)case KVM_REG_PPC_TAR : vcpu->arch.tar =set_reg_val (reg->id, val);break ; +case KVM_REG_PPC_EBBHR : + vcpu->arch.ebbhr =set_reg_val (reg->id, val); +break ; +case KVM_REG_PPC_EBBRR : + vcpu->arch.ebbrr =set_reg_val (reg->id, val); +break ; +case KVM_REG_PPC_BESCR : + vcpu->arch.bescr =set_reg_val (reg->id, val); +break ;default : r = -EINVAL ;break ;
arch/powerpc/kvm/book3s_emulate.c +18 -0
@@ -441,6 +441,15 @@ int kvmppc_core_emulate_mtspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val)case SPRN_FSCR : vcpu->arch.fscr = spr_val;break ; +case SPRN_BESCR : + vcpu->arch.bescr = spr_val; +break ; +case SPRN_EBBHR : + vcpu->arch.ebbhr = spr_val; +break ; +case SPRN_EBBRR : + vcpu->arch.ebbrr = spr_val; +break ;case SPRN_ICTC :case SPRN_THRM1 :case SPRN_THRM2 :
@@ -549,6 +558,15 @@ int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_valcase SPRN_FSCR : *spr_val = vcpu->arch.fscr;break ; +case SPRN_BESCR : + *spr_val = vcpu->arch.bescr; +break ; +case SPRN_EBBHR : + *spr_val = vcpu->arch.ebbhr; +break ; +case SPRN_EBBRR : + *spr_val = vcpu->arch.ebbrr; +break ;case SPRN_THRM1 :case SPRN_THRM2 :case SPRN_THRM3 :
arch/powerpc/kvm/book3s_hv.c +0 -18
@@ -882,15 +882,6 @@ static int kvmppc_get_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,case KVM_REG_PPC_PSPB : *val =get_reg_val (id, vcpu->arch.pspb);break ; -case KVM_REG_PPC_EBBHR : - *val =get_reg_val (id, vcpu->arch.ebbhr); -break ; -case KVM_REG_PPC_EBBRR : - *val =get_reg_val (id, vcpu->arch.ebbrr); -break ; -case KVM_REG_PPC_BESCR : - *val =get_reg_val (id, vcpu->arch.bescr); -break ;case KVM_REG_PPC_DPDES : *val =get_reg_val (id, vcpu->arch.vcore->dpdes);break ;
@@ -1088,15 +1079,6 @@ static int kvmppc_set_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,case KVM_REG_PPC_PSPB : vcpu->arch.pspb =set_reg_val (id, *val);break ; -case KVM_REG_PPC_EBBHR : - vcpu->arch.ebbhr =set_reg_val (id, *val); -break ; -case KVM_REG_PPC_EBBRR : - vcpu->arch.ebbrr =set_reg_val (id, *val); -break ; -case KVM_REG_PPC_BESCR : - vcpu->arch.bescr =set_reg_val (id, *val); -break ;case KVM_REG_PPC_DPDES : vcpu->arch.vcore->dpdes =set_reg_val (id, *val);break ;
Signature · 1 line
1.8.1.4
PATCH 6/6 KVM: PPC: Book3S PR: Expose TM registers
In reply to Alexander GrafPOWER8 introduces transactional memory which brings along a number of new registers and MSR bits.
Implementing all of those is a pretty big headache, so for now let's at least emulate enough to make Linux's context switching code happy.
--- arch/powerpc/kvm/book3s_emulate.c | 18 ++++++++++++++++++ arch/powerpc/kvm/book3s_pr.c | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-)
arch/powerpc/kvm/book3s_emulate.c +18 -0
@@ -450,6 +450,15 @@ int kvmppc_core_emulate_mtspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val)case SPRN_EBBRR : vcpu->arch.ebbrr = spr_val;break ; +case SPRN_TFHAR : + vcpu->arch.tfhar = spr_val; +break ; +case SPRN_TEXASR : + vcpu->arch.texasr = spr_val; +break ; +case SPRN_TFIAR : + vcpu->arch.tfiar = spr_val; +break ;case SPRN_ICTC :case SPRN_THRM1 :case SPRN_THRM2 :
@@ -567,6 +576,15 @@ int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_valcase SPRN_EBBRR : *spr_val = vcpu->arch.ebbrr;break ; +case SPRN_TFHAR : + *spr_val = vcpu->arch.tfhar; +break ; +case SPRN_TEXASR : + *spr_val = vcpu->arch.texasr; +break ; +case SPRN_TFIAR : + *spr_val = vcpu->arch.tfiar; +break ;case SPRN_THRM1 :case SPRN_THRM2 :case SPRN_THRM3 :
arch/powerpc/kvm/book3s_pr.c +2 -1
@@ -785,7 +785,8 @@ static int kvmppc_handle_fac(struct kvm_vcpu *vcpu, ulong fac) {BUG_ON (!cpu_has_feature (CPU_FTR_ARCH_207S )); -if (!(vcpu->arch.fscr & (1ULL << fac))) { +/* We get TM interrupts only when EBB is disabled? Sigh. */ +if ((fac !=FSCR_TM_LG ) && !(vcpu->arch.fscr & (1ULL << fac))) {/* Facility not enabled by the guest */ kvmppc_trigger_fac_interrupt (vcpu, fac);return RESUME_GUEST ;
Signature · 1 line
1.8.1.4
Re: [PATCH 2/6] KVM: PPC: Book3S PR: Emulate TIR register
In reply to Alexander GrafQuoted 2 lines
In parallel to the Processor ID Register (PIR) threaded POWER8 also adds a Thread ID Register (TID). Since PR KVM doesn't emulate more than one thread
s/TID/TIR/ above
Quoted 1 line
per core, we can just always expose 0 here.
I'm not sure if we ever do, but if we IPI ourselves using a doorbell, we'll need to emulate the doorbell as well.
Mikey
Quoted 25 lines
Signed-off-by Alexander Graf <[email protected]>--- arch/powerpc/kvm/book3s_emulate.c | 1 + 1 file changed, 1 insertion(+)arch/powerpc/kvm/book3s_emulate.c +1
-0@@ -563,6 +563,7 @@ int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_valcase SPRN_MMCR0 :case SPRN_MMCR1 :case SPRN_MMCR2 : +case SPRN_TIR : *spr_val =0 ;break ;default :Signature · 6 lines
1.8.1.4 -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/6] KVM: PPC: Book3S PR: Emulate TIR register
Quoted 3 lines · Michael Neuling
Quoted 2 lines
In parallel to the Processor ID Register (PIR) threaded POWER8 also adds a Thread ID Register (TID). Since PR KVM doesn't emulate more than one thread
s/TID/TIR/ above
Oops :)
Quoted 4 lines
Quoted 2 lines
per core, we can just always expose 0 here.
I'm not sure if we ever do, but if we IPI ourselves using a doorbell, we'll need to emulate the doorbell as well.
Yeah, we don't. I'm surprised we don't myself, but I'd rather not implement the logic to emulate doorbells until I can easily verify it works - which means either have a Linux guest that does doorbells or have a test harness for kernel level test cases.
Alex
Re: [PATCH 1/6] KVM: PPC: Book3S PR: Ignore PMU SPRs
In reply to Alexander GrafQuoted 4 lines · Alexander Graf
When we expose a POWER8 CPU into the guest, it will start accessing PMU SPRs that we don't emulate. Just ignore accesses to them.
Signed-off-by Alexander Graf <[email protected]>
This patch is OK as it stands, but in fact the architecture says that kernel accesses to unimplemented SPRs are mostly supposed to be no-ops rather than causing a trap (mostly == excluding mtspr to 0 or mfspr from 0, 4, 5 or 6). I have a patch to implement that, which I'll post.
Paul.
Re: [PATCH 1/6] KVM: PPC: Book3S PR: Ignore PMU SPRs
Quoted 10 lines · Paul Mackerras
Quoted 4 lines · Alexander Graf
When we expose a POWER8 CPU into the guest, it will start accessing PMU SPRs that we don't emulate. Just ignore accesses to them.
Signed-off-by Alexander Graf <[email protected]>This patch is OK as it stands, but in fact the architecture says that kernel accesses to unimplemented SPRs are mostly supposed to be no-ops rather than causing a trap (mostly == excluding mtspr to 0 or mfspr from 0, 4, 5 or 6). I have a patch to implement that, which I'll post.
I think what we want is a flag similar to x86 where we can force ignore unknown SPRs, but leave it at triggering an interrupt as default. We usually have to be at least aware of unknown SPRs and check that not implementing them is ok for the guest.
Debugging a program interrupt because of an unknown SPR is usually a lot easier than debugging a breaking guest because it was using the SPR as storage and we didn't back it by anything.
Alex
Quoted 20 lines · Alexander Graf
When running on a POWER8 host, we get away with running the guest as POWER7 and nothing falls apart.
However, when we start exposing POWER8 as guest CPU, guests will start using new abilities on POWER8 which we need to handle.
This patch set does a minimalistic approach to implementing those bits to make guests happy enough to run.
Alex
Alexander Graf (6):
KVM: PPC: Book3S PR: Ignore PMU SPRs
KVM: PPC: Book3S PR: Emulate TIR register
KVM: PPC: Book3S PR: Handle Facility interrupt and FSCR
KVM: PPC: Book3S PR: Expose TAR facility to guest
KVM: PPC: Book3S PR: Expose EBB registers
KVM: PPC: Book3S PR: Expose TM registers
Quoted 11 lines
arch/powerpc/include/asm/kvm_asm.h | 18 ++++--- arch/powerpc/include/asm/kvm_book3s_asm.h | 2 + arch/powerpc/include/asm/kvm_host.h | 3 ++ arch/powerpc/kernel/asm-offsets.c | 3 ++ arch/powerpc/kvm/book3s.c | 34 +++++++++++++ arch/powerpc/kvm/book3s_emulate.c | 53 ++++++++++++++++++++ arch/powerpc/kvm/book3s_hv.c | 30 ----------- arch/powerpc/kvm/book3s_pr.c | 82 +++++++++++++++++++++++++++++++ arch/powerpc/kvm/book3s_segment.S | 25 ++++++++++ 9 files changed, 212 insertions(+), 38 deletions(-)
I did most of this as part of
[RFC PATCH 01/10] KVM: PPC: BOOK3S: PR: Add POWER8 support
http://mid.gmane.org/[email protected]
Any reason why that is not picked up ? TM was the reason I didn't push the patchset again. I was not sure how to get all the TM details to work.
-aneesh
Quoted 33 lines · Aneesh Kumar K.V
Quoted 20 lines · Alexander Graf
When running on a POWER8 host, we get away with running the guest as POWER7 and nothing falls apart.
However, when we start exposing POWER8 as guest CPU, guests will start using new abilities on POWER8 which we need to handle.
This patch set does a minimalistic approach to implementing those bits to make guests happy enough to run.
Alex
Alexander Graf (6):
KVM: PPC: Book3S PR: Ignore PMU SPRs
KVM: PPC: Book3S PR: Emulate TIR register
KVM: PPC: Book3S PR: Handle Facility interrupt and FSCR
KVM: PPC: Book3S PR: Expose TAR facility to guest
KVM: PPC: Book3S PR: Expose EBB registers
KVM: PPC: Book3S PR: Expose TM registersQuoted 11 lines
arch/powerpc/include/asm/kvm_asm.h | 18 ++++--- arch/powerpc/include/asm/kvm_book3s_asm.h | 2 + arch/powerpc/include/asm/kvm_host.h | 3 ++ arch/powerpc/kernel/asm-offsets.c | 3 ++ arch/powerpc/kvm/book3s.c | 34 +++++++++++++ arch/powerpc/kvm/book3s_emulate.c | 53 ++++++++++++++++++++ arch/powerpc/kvm/book3s_hv.c | 30 ----------- arch/powerpc/kvm/book3s_pr.c | 82 +++++++++++++++++++++++++++++++ arch/powerpc/kvm/book3s_segment.S | 25 ++++++++++ 9 files changed, 212 insertions(+), 38 deletions(-)
Quoted 8 lines
I did most of this as part of
[RFC PATCH 01/10] KVM: PPC: BOOK3S: PR: Add POWER8 support
http://mid.gmane.org/[email protected]Any reason why that is not picked up ? TM was the reason I didn't push the patchset again. I was not sure how to get all the TM details to work.
Ugh, I guess I mostly discarded it as brainstorm patches because they were marked RFC :(
Alex
Quoted 39 lines · Alexander Graf
Quoted 38 lines · Aneesh Kumar K.V
Quoted 20 lines · Alexander Graf
When running on a POWER8 host, we get away with running the guest as POWER7 and nothing falls apart.
However, when we start exposing POWER8 as guest CPU, guests will start using new abilities on POWER8 which we need to handle.
This patch set does a minimalistic approach to implementing those bits to make guests happy enough to run.
Alex
Alexander Graf (6):
KVM: PPC: Book3S PR: Ignore PMU SPRs
KVM: PPC: Book3S PR: Emulate TIR register
KVM: PPC: Book3S PR: Handle Facility interrupt and FSCR
KVM: PPC: Book3S PR: Expose TAR facility to guest
KVM: PPC: Book3S PR: Expose EBB registers
KVM: PPC: Book3S PR: Expose TM registersQuoted 11 lines
arch/powerpc/include/asm/kvm_asm.h | 18 ++++--- arch/powerpc/include/asm/kvm_book3s_asm.h | 2 + arch/powerpc/include/asm/kvm_host.h | 3 ++ arch/powerpc/kernel/asm-offsets.c | 3 ++ arch/powerpc/kvm/book3s.c | 34 +++++++++++++ arch/powerpc/kvm/book3s_emulate.c | 53 ++++++++++++++++++++ arch/powerpc/kvm/book3s_hv.c | 30 ----------- arch/powerpc/kvm/book3s_pr.c | 82 +++++++++++++++++++++++++++++++ arch/powerpc/kvm/book3s_segment.S | 25 ++++++++++ 9 files changed, 212 insertions(+), 38 deletions(-)I did most of this as part of
[RFC PATCH 01/10] KVM: PPC: BOOK3S: PR: Add POWER8 support
http://mid.gmane.org/[email protected]
Quoted 7 lines
Quoted 3 lines
Any reason why that is not picked up ? TM was the reason I didn't push the patchset again. I was not sure how to get all the TM details to work.
Ugh, I guess I mostly discarded it as brainstorm patches because they were marked RFC :(
Do you want me to rework them ?. I guess facility unavailable part and TM part in this series are better than what I had. Rest all are more or less similar. Or you could cherry pick the SPR handling you haven't added yet from this series ?
-aneesh
Quoted 44 lines · Aneesh Kumar K.V
Quoted 42 lines · Alexander Graf
Quoted 41 lines · Aneesh Kumar K.V
Quoted 20 lines · Alexander Graf
When running on a POWER8 host, we get away with running the guest as POWER7 and nothing falls apart.
However, when we start exposing POWER8 as guest CPU, guests will start using new abilities on POWER8 which we need to handle.
This patch set does a minimalistic approach to implementing those bits to make guests happy enough to run.
Alex
Alexander Graf (6):
KVM: PPC: Book3S PR: Ignore PMU SPRs
KVM: PPC: Book3S PR: Emulate TIR register
KVM: PPC: Book3S PR: Handle Facility interrupt and FSCR
KVM: PPC: Book3S PR: Expose TAR facility to guest
KVM: PPC: Book3S PR: Expose EBB registers
KVM: PPC: Book3S PR: Expose TM registersQuoted 11 lines
arch/powerpc/include/asm/kvm_asm.h | 18 ++++--- arch/powerpc/include/asm/kvm_book3s_asm.h | 2 + arch/powerpc/include/asm/kvm_host.h | 3 ++ arch/powerpc/kernel/asm-offsets.c | 3 ++ arch/powerpc/kvm/book3s.c | 34 +++++++++++++ arch/powerpc/kvm/book3s_emulate.c | 53 ++++++++++++++++++++ arch/powerpc/kvm/book3s_hv.c | 30 ----------- arch/powerpc/kvm/book3s_pr.c | 82 +++++++++++++++++++++++++++++++ arch/powerpc/kvm/book3s_segment.S | 25 ++++++++++ 9 files changed, 212 insertions(+), 38 deletions(-)I did most of this as part of
[RFC PATCH 01/10] KVM: PPC: BOOK3S: PR: Add POWER8 support
http://mid.gmane.org/[email protected]Any reason why that is not picked up ? TM was the reason I didn't push the patchset again. I was not sure how to get all the TM details to work.
Quoted 7 lines
Quoted 3 lines
Ugh, I guess I mostly discarded it as brainstorm patches because they were marked RFC :(
Do you want me to rework them ?. I guess facility unavailable part and TM part in this series are better than what I had. Rest all are more or less similar. Or you could cherry pick the SPR handling you haven't added yet from this series ?
I personally refuse to apply patches that are marked RFC, since IMHO on those the author himself isn't sure he wants them applied yet :).
I'd say I'll just apply mine after another autotest run and then you rebase your things on top and fill the gaps with a real, non-RFC patch set.
Alex
Quoted 53 lines · Alexander Graf
Quoted 44 lines · Aneesh Kumar K.V
Quoted 42 lines · Alexander Graf
Quoted 41 lines · Aneesh Kumar K.V
Quoted 20 lines · Alexander Graf
When running on a POWER8 host, we get away with running the guest as POWER7 and nothing falls apart.
However, when we start exposing POWER8 as guest CPU, guests will start using new abilities on POWER8 which we need to handle.
This patch set does a minimalistic approach to implementing those bits to make guests happy enough to run.
Alex
Alexander Graf (6):
KVM: PPC: Book3S PR: Ignore PMU SPRs
KVM: PPC: Book3S PR: Emulate TIR register
KVM: PPC: Book3S PR: Handle Facility interrupt and FSCR
KVM: PPC: Book3S PR: Expose TAR facility to guest
KVM: PPC: Book3S PR: Expose EBB registers
KVM: PPC: Book3S PR: Expose TM registersQuoted 11 lines
arch/powerpc/include/asm/kvm_asm.h | 18 ++++--- arch/powerpc/include/asm/kvm_book3s_asm.h | 2 + arch/powerpc/include/asm/kvm_host.h | 3 ++ arch/powerpc/kernel/asm-offsets.c | 3 ++ arch/powerpc/kvm/book3s.c | 34 +++++++++++++ arch/powerpc/kvm/book3s_emulate.c | 53 ++++++++++++++++++++ arch/powerpc/kvm/book3s_hv.c | 30 ----------- arch/powerpc/kvm/book3s_pr.c | 82 +++++++++++++++++++++++++++++++ arch/powerpc/kvm/book3s_segment.S | 25 ++++++++++ 9 files changed, 212 insertions(+), 38 deletions(-)I did most of this as part of
[RFC PATCH 01/10] KVM: PPC: BOOK3S: PR: Add POWER8 support
http://mid.gmane.org/[email protected]Any reason why that is not picked up ? TM was the reason I didn't push the patchset again. I was not sure how to get all the TM details to work.
Quoted 7 lines
Quoted 3 lines
Ugh, I guess I mostly discarded it as brainstorm patches because they were marked RFC :(
Do you want me to rework them ?. I guess facility unavailable part and TM part in this series are better than what I had. Rest all are more or less similar. Or you could cherry pick the SPR handling you haven't added yet from this series ?
Quoted 5 lines
I personally refuse to apply patches that are marked RFC, since IMHO on those the author himself isn't sure he wants them applied yet :).
I'd say I'll just apply mine after another autotest run and then you rebase your things on top and fill the gaps with a real, non-RFC patch set.
Will do
-aneesh
Re: [PATCH 1/6] KVM: PPC: Book3S PR: Ignore PMU SPRs
In reply to Alexander GrafQuoted 12 lines · Alexander Graf
Quoted 10 lines · Paul Mackerras
Quoted 4 lines · Alexander Graf
When we expose a POWER8 CPU into the guest, it will start accessing PMU SPRs that we don't emulate. Just ignore accesses to them.
Signed-off-by Alexander Graf <[email protected]>This patch is OK as it stands, but in fact the architecture says that kernel accesses to unimplemented SPRs are mostly supposed to be no-ops rather than causing a trap (mostly == excluding mtspr to 0 or mfspr from 0, 4, 5 or 6). I have a patch to implement that, which I'll post.
Quoted 8 lines
I think what we want is a flag similar to x86 where we can force ignore unknown SPRs, but leave it at triggering an interrupt as default. We usually have to be at least aware of unknown SPRs and check that not implementing them is ok for the guest.
Debugging a program interrupt because of an unknown SPR is usually a lot easier than debugging a breaking guest because it was using the SPR as storage and we didn't back it by anything.
That has not been my experience, for accesses by the Linux kernel early in the boot process; usually we end up in a loop of ISI interrupts because the HPT isn't set up yet, with the original interrupt cause (and PC) lost long ago.
The Power ISA was changed in version 2.05 (POWER6) to specify that accesses to unimplemented SPRs by privileged code must be no-ops on server processors. Before that the architecture allowed either an illegal instruction interrupt or "boundedly undefined" behaviour (which would include a no-op).
So, if we're emulating POWERx for x >= 6, to be correct we need to do the no-op behaviour, even if we retain the option of making them trap for debugging purposes. Of course at the moment we basically never look at what specific CPU we're emulating, but maybe now we have to.
Regards,
Paul.
Re: [PATCH 1/6] KVM: PPC: Book3S PR: Ignore PMU SPRs
Quoted 31 lines · Paul Mackerras
Quoted 11 lines · Alexander Graf
Quoted 10 lines · Paul Mackerras
Quoted 4 lines · Alexander Graf
When we expose a POWER8 CPU into the guest, it will start accessing PMU SPRs that we don't emulate. Just ignore accesses to them.
Signed-off-by Alexander Graf <[email protected]>This patch is OK as it stands, but in fact the architecture says that kernel accesses to unimplemented SPRs are mostly supposed to be no-ops rather than causing a trap (mostly == excluding mtspr to 0 or mfspr from 0, 4, 5 or 6). I have a patch to implement that, which I'll post.
Quoted 8 lines
I think what we want is a flag similar to x86 where we can force ignore unknown SPRs, but leave it at triggering an interrupt as default. We usually have to be at least aware of unknown SPRs and check that not implementing them is ok for the guest.
Debugging a program interrupt because of an unknown SPR is usually a lot easier than debugging a breaking guest because it was using the SPR as storage and we didn't back it by anything.
That has not been my experience, for accesses by the Linux kernel early in the boot process; usually we end up in a loop of ISI interrupts because the HPT isn't set up yet, with the original interrupt cause (and PC) lost long ago.
The Power ISA was changed in version 2.05 (POWER6) to specify that accesses to unimplemented SPRs by privileged code must be no-ops on server processors. Before that the architecture allowed either an illegal instruction interrupt or "boundedly undefined" behaviour (which would include a no-op).
Quoted 4 lines
So, if we're emulating POWERx for x >= 6, to be correct we need to do the no-op behaviour, even if we retain the option of making them trap for debugging purposes. Of course at the moment we basically never look at what specific CPU we're emulating, but maybe now we have to.
I think it makes sense to have some more detailed knowledge of the target CPU we're modeling for other reasons, but for this we should just settle on either trapping or not trapping by default.
Finding the root cause of an ISI storm is easy when you run traces. Finding the root cause of a null pointer exception because Linux was trying to read from somewhere it mfspr()'d before requires quite a bit more knowledge of what's going on.
Alex
Re: [PATCH 6/6] KVM: PPC: Book3S PR: Expose TM registers
In reply to Alexander GrafQuoted 5 lines · Alexander Graf
POWER8 introduces transactional memory which brings along a number of new registers and MSR bits.
Implementing all of those is a pretty big headache, so for now let's at least emulate enough to make Linux's context switching code happy.
[snip]
arch/powerpc/kvm/book3s_pr.c static int kvmppc_handle_fac(struct kvm_vcpu *vcpu, ulong fac) · line 788
Quoted 2 lines
arch/powerpc/kvm/book3s_pr.c +1
-1-if (!(vcpu->arch.fscr & (1ULL << fac))) { +/* We get TM interrupts only when EBB is disabled? Sigh. */
This comment doesn't make sense to me. Not every reason code reported in the high bits of FSCR corresponds directly to an enable bit in FSCR. In fact, of the 7 defined reason codes in POWER8, only three correspond to an enable bit...
arch/powerpc/kvm/book3s_pr.c static int kvmppc_handle_fac(struct kvm_vcpu *vcpu, ulong fac) · line 789
Quoted 1 line
arch/powerpc/kvm/book3s_pr.c +1
-0+if ((fac !=FSCR_TM_LG ) && !(vcpu->arch.fscr & (1ULL << fac))) {
so this should really check explicitly for TAR, EBB or DSCR.
Paul.
Re: [PATCH 6/6] KVM: PPC: Book3S PR: Expose TM registers
Quoted 6 lines · Paul Mackerras
Quoted 5 lines · Alexander Graf
POWER8 introduces transactional memory which brings along a number of new registers and MSR bits.
Implementing all of those is a pretty big headache, so for now let's at least emulate enough to make Linux's context switching code happy.
Quoted 8 lines
[snip]
arch/powerpc/kvm/book3s_pr.c static int kvmppc_handle_fac(struct kvm_vcpu *vcpu, ulong fac) · line 788
Quoted 2 lines
arch/powerpc/kvm/book3s_pr.c +1
-1-if (!(vcpu->arch.fscr & (1ULL << fac))) { +/* We get TM interrupts only when EBB is disabled? Sigh. */ This comment doesn't make sense to me. Not every reason code reported in the high bits of FSCR corresponds directly to an enable bit in FSCR. In fact, of the 7 defined reason codes in POWER8, only three correspond to an enable bit...
Is there any documentation on which relate to what?
Alex
Quoted 9 lines
arch/powerpc/kvm/book3s_pr.c static int kvmppc_handle_fac(struct kvm_vcpu *vcpu, ulong fac) · line 789
Quoted 2 lines
arch/powerpc/kvm/book3s_pr.c +1
-0+if ((fac !=FSCR_TM_LG ) && !(vcpu->arch.fscr & (1ULL << fac))) {so this should really check explicitly for TAR, EBB or DSCR.
Paul.
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 6/6] KVM: PPC: Book3S PR: Expose TM registers
Quoted 10 lines · Alexander Graf
Quoted 8 lines · Paul Mackerras
Quoted 5 lines · Alexander Graf
POWER8 introduces transactional memory which brings along a number of new registers and MSR bits.
Implementing all of those is a pretty big headache, so for now let's at least emulate enough to make Linux's context switching code happy.
[snip]
Quoted 8 lines
Quoted 6 lines
arch/powerpc/kvm/book3s_pr.c static int kvmppc_handle_fac(struct kvm_vcpu *vcpu, ulong fac) · line 788
Quoted 2 lines
arch/powerpc/kvm/book3s_pr.c +1
-1-if (!(vcpu->arch.fscr & (1ULL << fac))) { +/* We get TM interrupts only when EBB is disabled? Sigh. */ This comment doesn't make sense to me. Not every reason code reported in the high bits of FSCR corresponds directly to an enable bit in FSCR. In fact, of the 7 defined reason codes in POWER8, only three correspond to an enable bit...
Is there any documentation on which relate to what?
Yes, Power ISA v2.07 book 3S section 6.2.10 describes the FSCR enable bits and the interruption cause field. There are 6 cause values defined, of which 3 correspond to enable bits in the FSCR, and the other 3 correspond to things enabled/disabled in MMCR0 (usermode PMC anb BHRB access) or MSR (TM stuff).
Paul.
Re: [PATCH 6/6] KVM: PPC: Book3S PR: Expose TM registers
Quoted 18 lines · Paul Mackerras
Quoted 17 lines · Alexander Graf
Quoted 14 lines · Paul Mackerras
Quoted 5 lines · Alexander Graf
POWER8 introduces transactional memory which brings along a number of new registers and MSR bits.
Implementing all of those is a pretty big headache, so for now let's at least emulate enough to make Linux's context switching code happy.
[snip]
Review
Quoted 2 lines
(quoted diff) +1
-1- if (!(vcpu->arch.fscr & (1ULL << fac))) { + /* We get TM interrupts only when EBB is disabled? Sigh. */This comment doesn't make sense to me. Not every reason code reported in the high bits of FSCR corresponds directly to an enable bit in FSCR. In fact, of the 7 defined reason codes in POWER8, only three correspond to an enable bit...
Quoted 7 lines
Quoted 1 line
Is there any documentation on which relate to what?
Yes, Power ISA v2.07 book 3S section 6.2.10 describes the FSCR enable bits and the interruption cause field. There are 6 cause values defined, of which 3 correspond to enable bits in the FSCR, and the other 3 correspond to things enabled/disabled in MMCR0 (usermode PMC anb BHRB access) or MSR (TM stuff).
I see. How's this?
Alex
commit a8e53f5f5e6c5d99363ad0d695a9ee520e1d262d
Author: Alexander Graf <[email protected]> Date: Tue Apr 29 17:54:40 2014 +0200
KVM: PPC: Book3S PR: Expose TM registers
POWER8 introduces transactional memory which brings along a number of new registers and MSR bits.
Implementing all of those is a pretty big headache, so for now let's at least emulate enough to make Linux's context switching code happy.
---
v1 -> v2:
- move to book3s_64 only section
- restrict to CONFIG_PPC_TRANSACTIONAL_MEM
v2 -> v3:
- check MSR.TM for TM enablement inside the guest
arch/powerpc/kvm/book3s_emulate.c +22 -0
@@ -451,6 +451,17 @@ int kvmppc_core_emulate_mtspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val)case SPRN_EBBRR : vcpu->arch.ebbrr = spr_val;break ; +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM +case SPRN_TFHAR : + vcpu->arch.tfhar = spr_val; +break ; +case SPRN_TEXASR : + vcpu->arch.texasr = spr_val; +break ; +case SPRN_TFIAR : + vcpu->arch.tfiar = spr_val; +break ; +#endif #endif case SPRN_ICTC :case SPRN_THRM1 :
@@ -572,6 +583,17 @@ int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_valcase SPRN_EBBRR : *spr_val = vcpu->arch.ebbrr;break ; +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM +case SPRN_TFHAR : + *spr_val = vcpu->arch.tfhar; +break ; +case SPRN_TEXASR : + *spr_val = vcpu->arch.texasr; +break ; +case SPRN_TFIAR : + *spr_val = vcpu->arch.tfiar; +break ; +#endif #endif case SPRN_THRM1 :case SPRN_THRM2 :
arch/powerpc/kvm/book3s_pr.c +19 -1
@@ -794,9 +794,27 @@ static void kvmppc_emulate_fac(struct kvm_vcpu *vcpu, ulong fac)/* Enable facilities (TAR, EBB, DSCR) for the guest */ static int kvmppc_handle_fac (struct kvm_vcpu *vcpu,ulong fac) { +bool guest_fac_enabled;BUG_ON (!cpu_has_feature (CPU_FTR_ARCH_207S )); -if (!(vcpu->arch.fscr & (1ULL << fac))) { +/* +* Not every facility is enabled by FSCR bits, check whether the +* guest has this facility enabled at all. +*/ +switch (fac) { +case FSCR_TAR_LG : +case FSCR_EBB_LG : + guest_fac_enabled = (vcpu->arch.fscr & (1ULL << fac)); +break ; +case FSCR_TM_LG : + guest_fac_enabled =kvmppc_get_msr (vcpu) &MSR_TM ; +break ; +default : + guest_fac_enabled = false; +break ; + } + +if (!guest_fac_enabled) {/* Facility not enabled by the guest */ kvmppc_trigger_fac_interrupt (vcpu, fac);return RESUME_GUEST ;