KVM: PPC: Book3S HV: Ensure MSR[HV] is always clear in guest MSR
authorNicholas Piggin <npiggin@gmail.com>
Mon, 12 Apr 2021 01:48:45 +0000 (11:48 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 12 Apr 2021 03:36:24 +0000 (13:36 +1000)
Rather than clear the HV bit from the MSR at guest entry, make it clear
that the hypervisor does not allow the guest to set the bit.

The HV clear is kept in guest entry for now, but a future patch will
warn if it is set.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Acked-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210412014845.1517916-13-npiggin@gmail.com
arch/powerpc/kvm/book3s_hv_builtin.c
arch/powerpc/kvm/book3s_hv_nested.c

index 41cb03d..7a0e33a 100644 (file)
@@ -662,8 +662,8 @@ static void kvmppc_end_cede(struct kvm_vcpu *vcpu)
 
 void kvmppc_set_msr_hv(struct kvm_vcpu *vcpu, u64 msr)
 {
-       /* Guest must always run with ME enabled. */
-       msr = msr | MSR_ME;
+       /* Guest must always run with ME enabled, HV disabled. */
+       msr = (msr | MSR_ME) & ~MSR_HV;
 
        /*
         * Check for illegal transactional state bit combination
index fb03085..60724f6 100644 (file)
@@ -344,8 +344,8 @@ long kvmhv_enter_nested_guest(struct kvm_vcpu *vcpu)
        vcpu->arch.nested_vcpu_id = l2_hv.vcpu_token;
        vcpu->arch.regs = l2_regs;
 
-       /* Guest must always run with ME enabled. */
-       vcpu->arch.shregs.msr = vcpu->arch.regs.msr | MSR_ME;
+       /* Guest must always run with ME enabled, HV disabled. */
+       vcpu->arch.shregs.msr = (vcpu->arch.regs.msr | MSR_ME) & ~MSR_HV;
 
        sanitise_hv_regs(vcpu, &l2_hv);
        restore_hv_regs(vcpu, &l2_hv);