Skip to content

Commit f3380ca

Browse files
Wanpeng Libonzini
authored andcommitted
KVM: nVMX: Fix nested vmexit ack intr before load vmcs01
An external interrupt will cause a vmexit with reason "external interrupt" when L2 is running. L1 will pick up the interrupt through vmcs12 if L1 set the ack interrupt bit. Commit 77b0f5d (KVM: nVMX: Ack and write vector info to intr_info if L1 asks us to) retrieves the interrupt that belongs to L1 before vmcs01 is loaded. This will lead to problems in the next patch, which would write to SVI of vmcs02 instead of vmcs01 (SVI of vmcs02 doesn't make sense because L2 runs without APICv). Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Tested-by: Liu, RongrongX <rongrongx.liu@intel.com> Tested-by: Felipe Reyes <freyes@suse.com> Fixes: 77b0f5d Cc: stable@vger.kernel.org Signed-off-by: Wanpeng Li <wanpeng.li@linux.intel.com> [Move tracepoint as well. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 25a2150 commit f3380ca

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎arch/x86/kvm/vmx.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8754,6 +8754,8 @@ static void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 exit_reason,
87548754
prepare_vmcs12(vcpu, vmcs12, exit_reason, exit_intr_info,
87558755
exit_qualification);
87568756

8757+
vmx_load_vmcs01(vcpu);
8758+
87578759
if ((exit_reason == EXIT_REASON_EXTERNAL_INTERRUPT)
87588760
&& nested_exit_intr_ack_set(vcpu)) {
87598761
int irq = kvm_cpu_get_interrupt(vcpu);
@@ -8769,8 +8771,6 @@ static void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 exit_reason,
87698771
vmcs12->vm_exit_intr_error_code,
87708772
KVM_ISA_VMX);
87718773

8772-
vmx_load_vmcs01(vcpu);
8773-
87748774
vm_entry_controls_init(vmx, vmcs_read32(VM_ENTRY_CONTROLS));
87758775
vm_exit_controls_init(vmx, vmcs_read32(VM_EXIT_CONTROLS));
87768776
vmx_segment_cache_clear(vmx);

0 commit comments

Comments
 (0)