Skip to content

Commit 4cb4ade

Browse files
apopplepaulusmack
authored andcommitted
KVM: PPC: Book3SHV: Enable support for ISA v3.1 guests
Adds support for emulating ISAv3.1 guests by adding the appropriate PCR and FSCR bits. Signed-off-by: Alistair Popple <[email protected]> Reported-by: kbuild test robot <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent b3a9e3b commit 4cb4ade

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

arch/powerpc/include/asm/reg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,7 @@
13541354
#define PVR_ARCH_206p 0x0f100003
13551355
#define PVR_ARCH_207 0x0f000004
13561356
#define PVR_ARCH_300 0x0f000005
1357+
#define PVR_ARCH_31 0x0f000006
13571358

13581359
/* Macros for setting and retrieving special purpose registers */
13591360
#ifndef __ASSEMBLY__

arch/powerpc/kvm/book3s_hv.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,13 +342,18 @@ static void kvmppc_set_pvr_hv(struct kvm_vcpu *vcpu, u32 pvr)
342342
vcpu->arch.pvr = pvr;
343343
}
344344

345+
/* Dummy value used in computing PCR value below */
346+
#define PCR_ARCH_31 (PCR_ARCH_300 << 1)
347+
345348
static int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, u32 arch_compat)
346349
{
347350
unsigned long host_pcr_bit = 0, guest_pcr_bit = 0;
348351
struct kvmppc_vcore *vc = vcpu->arch.vcore;
349352

350353
/* We can (emulate) our own architecture version and anything older */
351-
if (cpu_has_feature(CPU_FTR_ARCH_300))
354+
if (cpu_has_feature(CPU_FTR_ARCH_31))
355+
host_pcr_bit = PCR_ARCH_31;
356+
else if (cpu_has_feature(CPU_FTR_ARCH_300))
352357
host_pcr_bit = PCR_ARCH_300;
353358
else if (cpu_has_feature(CPU_FTR_ARCH_207S))
354359
host_pcr_bit = PCR_ARCH_207;
@@ -374,6 +379,9 @@ static int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, u32 arch_compat)
374379
case PVR_ARCH_300:
375380
guest_pcr_bit = PCR_ARCH_300;
376381
break;
382+
case PVR_ARCH_31:
383+
guest_pcr_bit = PCR_ARCH_31;
384+
break;
377385
default:
378386
return -EINVAL;
379387
}
@@ -2318,7 +2326,7 @@ static int kvmppc_core_vcpu_create_hv(struct kvm_vcpu *vcpu)
23182326
* to trap and then we emulate them.
23192327
*/
23202328
vcpu->arch.hfscr = HFSCR_TAR | HFSCR_EBB | HFSCR_PM | HFSCR_BHRB |
2321-
HFSCR_DSCR | HFSCR_VECVSX | HFSCR_FP;
2329+
HFSCR_DSCR | HFSCR_VECVSX | HFSCR_FP | HFSCR_PREFIX;
23222330
if (cpu_has_feature(CPU_FTR_HVMODE)) {
23232331
vcpu->arch.hfscr &= mfspr(SPRN_HFSCR);
23242332
if (cpu_has_feature(CPU_FTR_P9_TM_HV_ASSIST))

0 commit comments

Comments
 (0)