aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/include/asm/kvm_host.h4
-rw-r--r--arch/x86/kvm/svm.c8
-rw-r--r--arch/x86/kvm/vmx.c25
-rw-r--r--arch/x86/kvm/x86.c6
4 files changed, 14 insertions, 29 deletions
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 461d00a554e0..7930c294182a 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -729,8 +729,8 @@ struct kvm_x86_ops {
729 int (*nmi_allowed)(struct kvm_vcpu *vcpu); 729 int (*nmi_allowed)(struct kvm_vcpu *vcpu);
730 bool (*get_nmi_mask)(struct kvm_vcpu *vcpu); 730 bool (*get_nmi_mask)(struct kvm_vcpu *vcpu);
731 void (*set_nmi_mask)(struct kvm_vcpu *vcpu, bool masked); 731 void (*set_nmi_mask)(struct kvm_vcpu *vcpu, bool masked);
732 int (*enable_nmi_window)(struct kvm_vcpu *vcpu); 732 void (*enable_nmi_window)(struct kvm_vcpu *vcpu);
733 int (*enable_irq_window)(struct kvm_vcpu *vcpu); 733 void (*enable_irq_window)(struct kvm_vcpu *vcpu);
734 void (*update_cr8_intercept)(struct kvm_vcpu *vcpu, int tpr, int irr); 734 void (*update_cr8_intercept)(struct kvm_vcpu *vcpu, int tpr, int irr);
735 int (*vm_has_apicv)(struct kvm *kvm); 735 int (*vm_has_apicv)(struct kvm *kvm);
736 void (*hwapic_irr_update)(struct kvm_vcpu *vcpu, int max_irr); 736 void (*hwapic_irr_update)(struct kvm_vcpu *vcpu, int max_irr);
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 64d9bb9590e3..1e8616e304a7 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -3650,7 +3650,7 @@ static int svm_interrupt_allowed(struct kvm_vcpu *vcpu)
3650 return ret; 3650 return ret;
3651} 3651}
3652 3652
3653static int enable_irq_window(struct kvm_vcpu *vcpu) 3653static void enable_irq_window(struct kvm_vcpu *vcpu)
3654{ 3654{
3655 struct vcpu_svm *svm = to_svm(vcpu); 3655 struct vcpu_svm *svm = to_svm(vcpu);
3656 3656
@@ -3664,16 +3664,15 @@ static int enable_irq_window(struct kvm_vcpu *vcpu)
3664 svm_set_vintr(svm); 3664 svm_set_vintr(svm);
3665 svm_inject_irq(svm, 0x0); 3665 svm_inject_irq(svm, 0x0);
3666 } 3666 }
3667 return 0;
3668} 3667}
3669 3668
3670static int enable_nmi_window(struct kvm_vcpu *vcpu) 3669static void enable_nmi_window(struct kvm_vcpu *vcpu)
3671{ 3670{
3672 struct vcpu_svm *svm = to_svm(vcpu); 3671 struct vcpu_svm *svm = to_svm(vcpu);
3673 3672
3674 if ((svm->vcpu.arch.hflags & (HF_NMI_MASK | HF_IRET_MASK)) 3673 if ((svm->vcpu.arch.hflags & (HF_NMI_MASK | HF_IRET_MASK))
3675 == HF_NMI_MASK) 3674 == HF_NMI_MASK)
3676 return 0; /* IRET will cause a vm exit */ 3675 return; /* IRET will cause a vm exit */
3677 3676
3678 /* 3677 /*
3679 * Something prevents NMI from been injected. Single step over possible 3678 * Something prevents NMI from been injected. Single step over possible
@@ -3682,7 +3681,6 @@ static int enable_nmi_window(struct kvm_vcpu *vcpu)
3682 svm->nmi_singlestep = true; 3681 svm->nmi_singlestep = true;
3683 svm->vmcb->save.rflags |= (X86_EFLAGS_TF | X86_EFLAGS_RF); 3682 svm->vmcb->save.rflags |= (X86_EFLAGS_TF | X86_EFLAGS_RF);
3684 update_db_bp_intercept(vcpu); 3683 update_db_bp_intercept(vcpu);
3685 return 0;
3686} 3684}
3687 3685
3688static int svm_set_tss_addr(struct kvm *kvm, unsigned int addr) 3686static int svm_set_tss_addr(struct kvm *kvm, unsigned int addr)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 2c9d21e2d033..fcc1947db296 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -4514,39 +4514,28 @@ static bool nested_exit_on_nmi(struct kvm_vcpu *vcpu)
4514 PIN_BASED_NMI_EXITING; 4514 PIN_BASED_NMI_EXITING;
4515} 4515}
4516 4516
4517static int enable_irq_window(struct kvm_vcpu *vcpu) 4517static void enable_irq_window(struct kvm_vcpu *vcpu)
4518{ 4518{
4519 u32 cpu_based_vm_exec_control; 4519 u32 cpu_based_vm_exec_control;
4520 4520
4521 if (is_guest_mode(vcpu) && nested_exit_on_intr(vcpu))
4522 /*
4523 * We get here if vmx_interrupt_allowed() said we can't
4524 * inject to L1 now because L2 must run. The caller will have
4525 * to make L2 exit right after entry, so we can inject to L1
4526 * more promptly.
4527 */
4528 return -EBUSY;
4529
4530 cpu_based_vm_exec_control = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL); 4521 cpu_based_vm_exec_control = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL);
4531 cpu_based_vm_exec_control |= CPU_BASED_VIRTUAL_INTR_PENDING; 4522 cpu_based_vm_exec_control |= CPU_BASED_VIRTUAL_INTR_PENDING;
4532 vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, cpu_based_vm_exec_control); 4523 vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, cpu_based_vm_exec_control);
4533 return 0;
4534} 4524}
4535 4525
4536static int enable_nmi_window(struct kvm_vcpu *vcpu) 4526static void enable_nmi_window(struct kvm_vcpu *vcpu)
4537{ 4527{
4538 u32 cpu_based_vm_exec_control; 4528 u32 cpu_based_vm_exec_control;
4539 4529
4540 if (!cpu_has_virtual_nmis()) 4530 if (!cpu_has_virtual_nmis() ||
4541 return enable_irq_window(vcpu); 4531 vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) & GUEST_INTR_STATE_STI) {
4542 4532 enable_irq_window(vcpu);
4543 if (vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) & GUEST_INTR_STATE_STI) 4533 return;
4544 return enable_irq_window(vcpu); 4534 }
4545 4535
4546 cpu_based_vm_exec_control = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL); 4536 cpu_based_vm_exec_control = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL);
4547 cpu_based_vm_exec_control |= CPU_BASED_VIRTUAL_NMI_PENDING; 4537 cpu_based_vm_exec_control |= CPU_BASED_VIRTUAL_NMI_PENDING;
4548 vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, cpu_based_vm_exec_control); 4538 vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, cpu_based_vm_exec_control);
4549 return 0;
4550} 4539}
4551 4540
4552static void vmx_inject_irq(struct kvm_vcpu *vcpu) 4541static void vmx_inject_irq(struct kvm_vcpu *vcpu)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 738262595706..622312176f28 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -5976,11 +5976,9 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
5976 req_immediate_exit = true; 5976 req_immediate_exit = true;
5977 /* enable NMI/IRQ window open exits if needed */ 5977 /* enable NMI/IRQ window open exits if needed */
5978 else if (vcpu->arch.nmi_pending) 5978 else if (vcpu->arch.nmi_pending)
5979 req_immediate_exit = 5979 kvm_x86_ops->enable_nmi_window(vcpu);
5980 kvm_x86_ops->enable_nmi_window(vcpu) != 0;
5981 else if (kvm_cpu_has_injectable_intr(vcpu) || req_int_win) 5980 else if (kvm_cpu_has_injectable_intr(vcpu) || req_int_win)
5982 req_immediate_exit = 5981 kvm_x86_ops->enable_irq_window(vcpu);
5983 kvm_x86_ops->enable_irq_window(vcpu) != 0;
5984 5982
5985 if (kvm_lapic_enabled(vcpu)) { 5983 if (kvm_lapic_enabled(vcpu)) {
5986 /* 5984 /*