]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
KVM: x86: fix Xen hypercall page msr handling
authorJoao Martins <joao.m.martins@oracle.com>
Wed, 13 Jun 2018 10:10:37 +0000 (06:10 -0400)
committerJoao Martins <joao.m.martins@oracle.com>
Wed, 20 Feb 2019 17:30:52 +0000 (12:30 -0500)
Xen usually places its MSR at 0x4000000 or 0x4000200 depending on
whether it is running in viridian mode or not. Note that this is not
ABI guaranteed, so it is possible for Xen to advertise the MSR some
place else.

Given the way xen_hvm_config() is handled, if the former address is
selected, this will conflict with HyperV's MSR
(HV_X64_MSR_GUEST_OS_ID) which uses the same address.

Given that the MSR location is arbitrary, move the xen_hvm_config()
handling to the top of kvm_set_msr_common() before falling through.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
arch/x86/kvm/x86.c

index 65e4559eef2fc8589e0a4277077e766ceead3994..47360a4b0d42e60e1a783c98c77a78a9da76c6cf 100644 (file)
@@ -2429,6 +2429,9 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
        u32 msr = msr_info->index;
        u64 data = msr_info->data;
 
+       if (msr && (msr == vcpu->kvm->arch.xen_hvm_config.msr))
+               return xen_hvm_config(vcpu, data);
+
        switch (msr) {
        case MSR_AMD64_NB_CFG:
        case MSR_IA32_UCODE_WRITE:
@@ -2644,8 +2647,6 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
                vcpu->arch.msr_misc_features_enables = data;
                break;
        default:
-               if (msr && (msr == vcpu->kvm->arch.xen_hvm_config.msr))
-                       return xen_hvm_config(vcpu, data);
                if (kvm_pmu_is_valid_msr(vcpu, msr))
                        return kvm_pmu_set_msr(vcpu, msr_info);
                if (!ignore_msrs) {