Skip to content

Commit

Permalink
KVM: VMX: Unregister posted interrupt wakeup handler on hardware unsetup
Browse files Browse the repository at this point in the history
commit ec5a491 upstream.

Unregister KVM's posted interrupt wakeup handler during unsetup so that a
spurious interrupt that arrives after kvm_intel.ko is unloaded doesn't
call into freed memory.

Fixes: bf9f6ac ("KVM: Update Posted-Interrupts Descriptor when vCPU is blocked")
Cc: stable@vger.kernel.org
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20211009001107.3936588-3-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
sean-jc authored and gregkh committed Nov 18, 2021
1 parent b4a4c9d commit 2f65b76
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions arch/x86/kvm/vmx/vmx.c
Expand Up @@ -7586,6 +7586,8 @@ static void vmx_migrate_timers(struct kvm_vcpu *vcpu)

static void hardware_unsetup(void)
{
kvm_set_posted_intr_wakeup_handler(NULL);

if (nested)
nested_vmx_hardware_unsetup();

Expand Down Expand Up @@ -7877,8 +7879,6 @@ static __init int hardware_setup(void)
vmx_x86_ops.request_immediate_exit = __kvm_request_immediate_exit;
}

kvm_set_posted_intr_wakeup_handler(pi_wakeup_handler);

kvm_mce_cap_supported |= MCG_LMCE_P;

if (pt_mode != PT_MODE_SYSTEM && pt_mode != PT_MODE_HOST_GUEST)
Expand All @@ -7900,6 +7900,9 @@ static __init int hardware_setup(void)
r = alloc_kvm_area();
if (r)
nested_vmx_hardware_unsetup();

kvm_set_posted_intr_wakeup_handler(pi_wakeup_handler);

return r;
}

Expand Down

0 comments on commit 2f65b76

Please sign in to comment.