Skip to content

Commit 7d61123

Browse files
ssuthiku-amdbonzini
authored andcommitted
KVM: SVM: Disable AVIC before setting V_IRQ
The commit 64b5bd2 ("KVM: nSVM: ignore L1 interrupt window while running L2 with V_INTR_MASKING=1") introduced a WARN_ON, which checks if AVIC is enabled when trying to set V_IRQ in the VMCB for enabling irq window. The following warning is triggered because the requesting vcpu (to deactivate AVIC) does not get to process APICv update request for itself until the next #vmexit. WARNING: CPU: 0 PID: 118232 at arch/x86/kvm/svm/svm.c:1372 enable_irq_window+0x6a/0xa0 [kvm_amd] RIP: 0010:enable_irq_window+0x6a/0xa0 [kvm_amd] Call Trace: kvm_arch_vcpu_ioctl_run+0x6e3/0x1b50 [kvm] ? kvm_vm_ioctl_irq_line+0x27/0x40 [kvm] ? _copy_to_user+0x26/0x30 ? kvm_vm_ioctl+0xb3e/0xd90 [kvm] ? set_next_entity+0x78/0xc0 kvm_vcpu_ioctl+0x236/0x610 [kvm] ksys_ioctl+0x8a/0xc0 __x64_sys_ioctl+0x1a/0x20 do_syscall_64+0x58/0x210 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Fixes by sending APICV update request to all other vcpus, and immediately update APIC for itself. Signed-off-by: Suravee Suthikulpanit <[email protected]> Link: https://lkml.org/lkml/2020/5/2/167 Fixes: 64b5bd2 ("KVM: nSVM: ignore L1 interrupt window while running L2 with V_INTR_MASKING=1") Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 54163a3 commit 7d61123

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

arch/x86/kvm/x86.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8060,6 +8060,7 @@ EXPORT_SYMBOL_GPL(kvm_vcpu_update_apicv);
80608060
*/
80618061
void kvm_request_apicv_update(struct kvm *kvm, bool activate, ulong bit)
80628062
{
8063+
struct kvm_vcpu *except;
80638064
unsigned long old, new, expected;
80648065

80658066
if (!kvm_x86_ops.check_apicv_inhibit_reasons ||
@@ -8084,7 +8085,17 @@ void kvm_request_apicv_update(struct kvm *kvm, bool activate, ulong bit)
80848085
trace_kvm_apicv_update_request(activate, bit);
80858086
if (kvm_x86_ops.pre_update_apicv_exec_ctrl)
80868087
kvm_x86_ops.pre_update_apicv_exec_ctrl(kvm, activate);
8087-
kvm_make_all_cpus_request(kvm, KVM_REQ_APICV_UPDATE);
8088+
8089+
/*
8090+
* Sending request to update APICV for all other vcpus,
8091+
* while update the calling vcpu immediately instead of
8092+
* waiting for another #VMEXIT to handle the request.
8093+
*/
8094+
except = kvm_get_running_vcpu();
8095+
kvm_make_all_cpus_request_except(kvm, KVM_REQ_APICV_UPDATE,
8096+
except);
8097+
if (except)
8098+
kvm_vcpu_update_apicv(except);
80888099
}
80898100
EXPORT_SYMBOL_GPL(kvm_request_apicv_update);
80908101

0 commit comments

Comments
 (0)