KVM: PPC: Book3SHV: Enable support for ISA v3.1 guests
authorAlistair Popple <alistair@popple.id.au>
Tue, 2 Jun 2020 05:53:25 +0000 (15:53 +1000)
committerPaul Mackerras <paulus@ozlabs.org>
Tue, 21 Jul 2020 05:38:03 +0000 (15:38 +1000)
Adds support for emulating ISAv3.1 guests by adding the appropriate PCR
and FSCR bits.

Signed-off-by: Alistair Popple <alistair@popple.id.au>
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
arch/powerpc/include/asm/reg.h
arch/powerpc/kvm/book3s_hv.c

index 88e6c78..28311e5 100644 (file)
 #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__
index 6bf6664..d64a2dc 100644 (file)
@@ -342,13 +342,18 @@ static void kvmppc_set_pvr_hv(struct kvm_vcpu *vcpu, u32 pvr)
        vcpu->arch.pvr = pvr;
 }
 
+/* Dummy value used in computing PCR value below */
+#define PCR_ARCH_31    (PCR_ARCH_300 << 1)
+
 static int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, u32 arch_compat)
 {
        unsigned long host_pcr_bit = 0, guest_pcr_bit = 0;
        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;
@@ -374,6 +379,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 +2326,7 @@ static int kvmppc_core_vcpu_create_hv(struct kvm_vcpu *vcpu)
         * to trap and then we emulate them.
         */
        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))