Skip to content

Commit 79eabbb

Browse files
committed
Merge: KVM: x86: make KVM_REQ_NMI request iff NMI pending for vcpu
MR: https://gitlab.com/redhat/rhel/src/kernel/rhel-9/-/merge_requests/1338 JIRA: https://issues.redhat.com/browse/RHEL-2815 commit 6231c9e Author: Prasad Pandit <pjp@fedoraproject.org> Date: Wed Jan 3 13:23:43 2024 +0530 KVM: x86: make KVM_REQ_NMI request iff NMI pending for vcpu kvm_vcpu_ioctl_x86_set_vcpu_events() routine makes 'KVM_REQ_NMI' request for a vcpu even when its 'events->nmi.pending' is zero. Ex: qemu_thread_start kvm_vcpu_thread_fn qemu_wait_io_event qemu_wait_io_event_common process_queued_cpu_work do_kvm_cpu_synchronize_post_init/_reset kvm_arch_put_registers kvm_put_vcpu_events (cpu, level=[2|3]) This leads vCPU threads in QEMU to constantly acquire & release the global mutex lock, delaying the guest boot due to lock contention. Add check to make KVM_REQ_NMI request only if vcpu has NMI pending. Fixes: bdedff2 ("KVM: x86: Route pending NMIs from userspace through process_nmi()") Cc: stable@vger.kernel.org Signed-off-by: Prasad Pandit <pjp@fedoraproject.org> Link: https://lore.kernel.org/r/20240103075343.549293-1-ppandit@redhat.com Signed-off-by: Sean Christopherson <seanjc@google.com> Closes RHEL-2815 Signed-off-by: Prasad Pandit <ppandit@redhat.com> Approved-by: Vitaly Kuznetsov <vkuznets@redhat.com> Approved-by: Marcelo Tosatti <mtosatti@redhat.com> Merged-by: Scott Weaver <scweaver@redhat.com>
2 parents 72c3f04 + 274c2c0 commit 79eabbb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/x86/kvm/x86.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5402,7 +5402,8 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
54025402
if (events->flags & KVM_VCPUEVENT_VALID_NMI_PENDING) {
54035403
vcpu->arch.nmi_pending = 0;
54045404
atomic_set(&vcpu->arch.nmi_queued, events->nmi.pending);
5405-
kvm_make_request(KVM_REQ_NMI, vcpu);
5405+
if (events->nmi.pending)
5406+
kvm_make_request(KVM_REQ_NMI, vcpu);
54065407
}
54075408
static_call(kvm_x86_set_nmi_mask)(vcpu, events->nmi.masked);
54085409

0 commit comments

Comments
 (0)