On Tue, Jun 2, 2020 at 3:55 PM Alistair Popple <alistair@xxxxxxxxxxxx> wrote: > > Adds support for emulating ISAv3.1 guests by adding the appropriate PCR > and FSCR bits. > > Signed-off-by: Alistair Popple <alistair@xxxxxxxxxxxx> > --- > arch/powerpc/include/asm/reg.h | 1 + > arch/powerpc/kvm/book3s_hv.c | 11 ++++++++--- > 2 files changed, 9 insertions(+), 3 deletions(-) > > diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h > index 773f76402392..d77040d0588a 100644 > --- a/arch/powerpc/include/asm/reg.h > +++ b/arch/powerpc/include/asm/reg.h > @@ -1348,6 +1348,7 @@ > #define PVR_ARCH_206p 0x0f100003 > #define PVR_ARCH_207 0x0f000004 > #define PVR_ARCH_300 0x0f000005 > +#define PVR_ARCH_31 0x0f000006 > > /* Macros for setting and retrieving special purpose registers */ > #ifndef __ASSEMBLY__ > diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c > index 93493f0cbfe8..359bb2ed43e1 100644 > --- a/arch/powerpc/kvm/book3s_hv.c > +++ b/arch/powerpc/kvm/book3s_hv.c > @@ -345,7 +345,7 @@ static void kvmppc_set_pvr_hv(struct kvm_vcpu *vcpu, u32 pvr) > } > > /* Dummy value used in computing PCR value below */ > -#define PCR_ARCH_300 (PCR_ARCH_207 << 1) > +#define PCR_ARCH_31 (PCR_ARCH_300 << 1) > > static int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, u32 arch_compat) > { > @@ -353,7 +353,9 @@ static int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, u32 arch_compat) > struct kvmppc_vcore *vc = vcpu->arch.vcore; > > /* We can (emulate) our own architecture version and anything older */ > - if (cpu_has_feature(CPU_FTR_ARCH_300)) > + if (cpu_has_feature(CPU_FTR_ARCH_31)) > + host_pcr_bit = PCR_ARCH_31; > + else if (cpu_has_feature(CPU_FTR_ARCH_300)) > host_pcr_bit = PCR_ARCH_300; > else if (cpu_has_feature(CPU_FTR_ARCH_207S)) > host_pcr_bit = PCR_ARCH_207; > @@ -379,6 +381,9 @@ static int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, u32 arch_compat) > case PVR_ARCH_300: > guest_pcr_bit = PCR_ARCH_300; > break; > + case PVR_ARCH_31: > + guest_pcr_bit = PCR_ARCH_31; > + break; > default: > return -EINVAL; > } > @@ -2318,7 +2323,7 @@ static int kvmppc_core_vcpu_create_hv(struct kvm_vcpu *vcpu) > * to trap and then we emulate them. > */ The comment above this: "... * Set the default HFSCR for the guest from the host value. * This value is only used on POWER9..." would need to be updated. > vcpu->arch.hfscr = HFSCR_TAR | HFSCR_EBB | HFSCR_PM | HFSCR_BHRB | > - HFSCR_DSCR | HFSCR_VECVSX | HFSCR_FP; > + HFSCR_DSCR | HFSCR_VECVSX | HFSCR_FP | HFSCR_PREFIX; > if (cpu_has_feature(CPU_FTR_HVMODE)) { > vcpu->arch.hfscr &= mfspr(SPRN_HFSCR); > if (cpu_has_feature(CPU_FTR_P9_TM_HV_ASSIST)) > -- > 2.20.1 >