]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - arch/x86/kvm/svm.c
x86/bugs, KVM: Extend speculation control for VIRT_SPEC_CTRL
[mirror_ubuntu-artful-kernel.git] / arch / x86 / kvm / svm.c
index 091925faa36a9df74a508942d3e6a2a2ccb90b8f..ce546cb07cebf23b6e0d1e436004170d69aaf570 100644 (file)
@@ -177,6 +177,12 @@ struct vcpu_svm {
        u64 next_rip;
 
        u64 spec_ctrl;
+       /*
+        * Contains guest-controlled bits of VIRT_SPEC_CTRL, which will be
+        * translated into the appropriate L2_CFG bits on the host to
+        * perform speculative control.
+        */
+       u64 virt_spec_ctrl;
 
        u64 host_user_msrs[NR_HOST_SAVE_USER_MSRS];
        struct {
@@ -1579,6 +1585,9 @@ static void svm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
        u32 dummy;
        u32 eax = 1;
 
+       svm->spec_ctrl = 0;
+       svm->virt_spec_ctrl = 0;
+
        if (!init_event) {
                svm->vcpu.arch.apic_base = APIC_DEFAULT_PHYS_BASE |
                                           MSR_IA32_APICBASE_ENABLE;
@@ -4902,7 +4911,7 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
        local_irq_enable();
 
        /* SMB: Don't care about ibrs_inuse but rely on guest value */
-       x86_spec_ctrl_set_guest(svm->spec_ctrl);
+       x86_spec_ctrl_set_guest(svm->spec_ctrl, svm->virt_spec_ctrl);
 
        asm volatile (
                "push %%" _ASM_BP "; \n\t"
@@ -5008,7 +5017,7 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
 #endif
 #endif
 
-       x86_spec_ctrl_restore_host(svm->spec_ctrl);
+       x86_spec_ctrl_restore_host(svm->spec_ctrl, svm->virt_spec_ctrl);
 
        reload_tss(vcpu);