On Thu, Jul 23, 2020 at 04:12:20PM +0530, Ravi Bangoria wrote: > As per the PAPR, bit 0 of byte 64 in pa-features property indicates > availability of 2nd DAWR registers. i.e. If this bit is set, 2nd > DAWR is present, otherwise not. Use KVM_CAP_PPC_DAWR1 capability to > find whether kvm supports 2nd DAWR or nor. If it's supported, set > the pa-feature bit in guest DT so the guest kernel can support 2nd > DAWR. > > Signed-off-by: Ravi Bangoria <ravi.bangoria@xxxxxxxxxxxxx> > --- > hw/ppc/spapr.c | 33 +++++++++++++++++++++++++++++++++ > include/hw/ppc/spapr.h | 1 + > linux-headers/asm-powerpc/kvm.h | 4 ++++ > linux-headers/linux/kvm.h | 1 + > target/ppc/cpu.h | 2 ++ > target/ppc/kvm.c | 7 +++++++ > target/ppc/kvm_ppc.h | 6 ++++++ > target/ppc/translate_init.inc.c | 17 ++++++++++++++++- > 8 files changed, 70 insertions(+), 1 deletion(-) > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index 0ae293ec94..4416319363 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -252,6 +252,31 @@ static void spapr_dt_pa_features(SpaprMachineState *spapr, > /* 60: NM atomic, 62: RNG */ > 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, /* 60 - 65 */ > }; > + uint8_t pa_features_310[] = { 66, 0, > + /* 0: MMU|FPU|SLB|RUN|DABR|NX, 1: fri[nzpm]|DABRX|SPRG3|SLB0|PP110 */ > + /* 2: VPM|DS205|PPR|DS202|DS206, 3: LSD|URG, SSO, 5: LE|CFAR|EB|LSQ */ > + 0xf6, 0x1f, 0xc7, 0xc0, 0x80, 0xf0, /* 0 - 5 */ > + /* 6: DS207 */ > + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, /* 6 - 11 */ > + /* 16: Vector */ > + 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, /* 12 - 17 */ > + /* 18: Vec. Scalar, 20: Vec. XOR, 22: HTM */ > + 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, /* 18 - 23 */ > + /* 24: Ext. Dec, 26: 64 bit ftrs, 28: PM ftrs */ > + 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, /* 24 - 29 */ > + /* 30: MMR, 32: LE atomic, 34: EBB + ext EBB */ > + 0x80, 0x00, 0x80, 0x00, 0xC0, 0x00, /* 30 - 35 */ > + /* 36: SPR SO, 38: Copy/Paste, 40: Radix MMU */ > + 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, /* 36 - 41 */ > + /* 42: PM, 44: PC RA, 46: SC vec'd */ > + 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, /* 42 - 47 */ > + /* 48: SIMD, 50: QP BFP, 52: String */ > + 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, /* 48 - 53 */ > + /* 54: DecFP, 56: DecI, 58: SHA */ > + 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, /* 54 - 59 */ > + /* 60: NM atomic, 62: RNG, 64: DAWR1 */ > + 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, /* 60 - 65 */ > + }; > uint8_t *pa_features = NULL; > size_t pa_size; > > @@ -267,6 +292,10 @@ static void spapr_dt_pa_features(SpaprMachineState *spapr, > pa_features = pa_features_300; > pa_size = sizeof(pa_features_300); > } > + if (ppc_check_compat(cpu, CPU_POWERPC_LOGICAL_3_10, 0, cpu->compat_pvr)) { > + pa_features = pa_features_310; > + pa_size = sizeof(pa_features_310); > + } > if (!pa_features) { > return; > } > @@ -291,6 +320,10 @@ static void spapr_dt_pa_features(SpaprMachineState *spapr, > pa_features[40 + 2] &= ~0x80; /* Radix MMU */ > } > > + if (kvm_enabled() && kvmppc_has_cap_dawr1()) { > + pa_features[66] |= 0x80; > + } Nack. The guest visible platform must not depend on host capabilities because it makes a complete mess of migration. The machine type and properties of other devices need to define what the guest environment will be, then qemu can either provide it, or fail outright if KVM doesn't have the neccessary support. -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Attachment:
signature.asc
Description: PGP signature