aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/vmx.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kvm/vmx.c')
-rw-r--r--arch/x86/kvm/vmx.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 3dec126aa302..051dab74e4e9 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -51,6 +51,7 @@
51#include <asm/apic.h> 51#include <asm/apic.h>
52#include <asm/irq_remapping.h> 52#include <asm/irq_remapping.h>
53#include <asm/mmu_context.h> 53#include <asm/mmu_context.h>
54#include <asm/microcode.h>
54#include <asm/nospec-branch.h> 55#include <asm/nospec-branch.h>
55 56
56#include "trace.h" 57#include "trace.h"
@@ -3226,6 +3227,11 @@ static inline bool vmx_feature_control_msr_valid(struct kvm_vcpu *vcpu,
3226 return !(val & ~valid_bits); 3227 return !(val & ~valid_bits);
3227} 3228}
3228 3229
3230static int vmx_get_msr_feature(struct kvm_msr_entry *msr)
3231{
3232 return 1;
3233}
3234
3229/* 3235/*
3230 * Reads an msr value (of 'msr_index') into 'pdata'. 3236 * Reads an msr value (of 'msr_index') into 'pdata'.
3231 * Returns 0 on success, non-0 otherwise. 3237 * Returns 0 on success, non-0 otherwise.
@@ -4485,7 +4491,8 @@ static int vmx_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
4485 vmcs_set_bits(SECONDARY_VM_EXEC_CONTROL, 4491 vmcs_set_bits(SECONDARY_VM_EXEC_CONTROL,
4486 SECONDARY_EXEC_DESC); 4492 SECONDARY_EXEC_DESC);
4487 hw_cr4 &= ~X86_CR4_UMIP; 4493 hw_cr4 &= ~X86_CR4_UMIP;
4488 } else 4494 } else if (!is_guest_mode(vcpu) ||
4495 !nested_cpu_has2(get_vmcs12(vcpu), SECONDARY_EXEC_DESC))
4489 vmcs_clear_bits(SECONDARY_VM_EXEC_CONTROL, 4496 vmcs_clear_bits(SECONDARY_VM_EXEC_CONTROL,
4490 SECONDARY_EXEC_DESC); 4497 SECONDARY_EXEC_DESC);
4491 4498
@@ -5765,6 +5772,7 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
5765 vmx->rmode.vm86_active = 0; 5772 vmx->rmode.vm86_active = 0;
5766 vmx->spec_ctrl = 0; 5773 vmx->spec_ctrl = 0;
5767 5774
5775 vcpu->arch.microcode_version = 0x100000000ULL;
5768 vmx->vcpu.arch.regs[VCPU_REGS_RDX] = get_rdx_init_val(); 5776 vmx->vcpu.arch.regs[VCPU_REGS_RDX] = get_rdx_init_val();
5769 kvm_set_cr8(vcpu, 0); 5777 kvm_set_cr8(vcpu, 0);
5770 5778
@@ -9452,7 +9460,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
9452 * being speculatively taken. 9460 * being speculatively taken.
9453 */ 9461 */
9454 if (vmx->spec_ctrl) 9462 if (vmx->spec_ctrl)
9455 wrmsrl(MSR_IA32_SPEC_CTRL, vmx->spec_ctrl); 9463 native_wrmsrl(MSR_IA32_SPEC_CTRL, vmx->spec_ctrl);
9456 9464
9457 vmx->__launched = vmx->loaded_vmcs->launched; 9465 vmx->__launched = vmx->loaded_vmcs->launched;
9458 asm( 9466 asm(
@@ -9587,11 +9595,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
9587 * If the L02 MSR bitmap does not intercept the MSR, then we need to 9595 * If the L02 MSR bitmap does not intercept the MSR, then we need to
9588 * save it. 9596 * save it.
9589 */ 9597 */
9590 if (!msr_write_intercepted(vcpu, MSR_IA32_SPEC_CTRL)) 9598 if (unlikely(!msr_write_intercepted(vcpu, MSR_IA32_SPEC_CTRL)))
9591 rdmsrl(MSR_IA32_SPEC_CTRL, vmx->spec_ctrl); 9599 vmx->spec_ctrl = native_read_msr(MSR_IA32_SPEC_CTRL);
9592 9600
9593 if (vmx->spec_ctrl) 9601 if (vmx->spec_ctrl)
9594 wrmsrl(MSR_IA32_SPEC_CTRL, 0); 9602 native_wrmsrl(MSR_IA32_SPEC_CTRL, 0);
9595 9603
9596 /* Eliminate branch target predictions from guest mode */ 9604 /* Eliminate branch target predictions from guest mode */
9597 vmexit_fill_RSB(); 9605 vmexit_fill_RSB();
@@ -11199,7 +11207,12 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch)
11199 if (ret) 11207 if (ret)
11200 return ret; 11208 return ret;
11201 11209
11202 if (vmcs12->guest_activity_state == GUEST_ACTIVITY_HLT) 11210 /*
11211 * If we're entering a halted L2 vcpu and the L2 vcpu won't be woken
11212 * by event injection, halt vcpu.
11213 */
11214 if ((vmcs12->guest_activity_state == GUEST_ACTIVITY_HLT) &&
11215 !(vmcs12->vm_entry_intr_info_field & INTR_INFO_VALID_MASK))
11203 return kvm_vcpu_halt(vcpu); 11216 return kvm_vcpu_halt(vcpu);
11204 11217
11205 vmx->nested.nested_run_pending = 1; 11218 vmx->nested.nested_run_pending = 1;
@@ -12290,6 +12303,7 @@ static struct kvm_x86_ops vmx_x86_ops __ro_after_init = {
12290 .vcpu_put = vmx_vcpu_put, 12303 .vcpu_put = vmx_vcpu_put,
12291 12304
12292 .update_bp_intercept = update_exception_bitmap, 12305 .update_bp_intercept = update_exception_bitmap,
12306 .get_msr_feature = vmx_get_msr_feature,
12293 .get_msr = vmx_get_msr, 12307 .get_msr = vmx_get_msr,
12294 .set_msr = vmx_set_msr, 12308 .set_msr = vmx_set_msr,
12295 .get_segment_base = vmx_get_segment_base, 12309 .get_segment_base = vmx_get_segment_base,