]> git.ipfire.org Git - people/arne_f/kernel.git/commitdiff
kvm/svm: Setup MCG_CAP on AMD properly
authorBorislav Petkov <bp@suse.de>
Sun, 26 Mar 2017 21:51:24 +0000 (23:51 +0200)
committerRadim Krčmář <rkrcmar@redhat.com>
Fri, 7 Apr 2017 14:49:00 +0000 (16:49 +0200)
MCG_CAP[63:9] bits are reserved on AMD. However, on an AMD guest, this
MSR returns 0x100010a. More specifically, bit 24 is set, which is simply
wrong. That bit is MCG_SER_P and is present only on Intel. Thus, clean
up the reserved bits in order not to confuse guests.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/svm.c

index 5fba70646c327941d231ab6dfa459e8a8536a115..1b203abf76e1e60a75819be391e44e3cb7e0a28e 100644 (file)
@@ -5256,6 +5256,12 @@ static inline void avic_post_state_restore(struct kvm_vcpu *vcpu)
        avic_handle_ldr_update(vcpu);
 }
 
+static void svm_setup_mce(struct kvm_vcpu *vcpu)
+{
+       /* [63:9] are reserved. */
+       vcpu->arch.mcg_cap &= 0x1ff;
+}
+
 static struct kvm_x86_ops svm_x86_ops __ro_after_init = {
        .cpu_has_kvm_support = has_svm,
        .disabled_by_bios = is_disabled,
@@ -5367,6 +5373,7 @@ static struct kvm_x86_ops svm_x86_ops __ro_after_init = {
        .pmu_ops = &amd_pmu_ops,
        .deliver_posted_interrupt = svm_deliver_avic_intr,
        .update_pi_irte = svm_update_pi_irte,
+       .setup_mce = svm_setup_mce,
 };
 
 static int __init svm_init(void)