diff options
author | Ignacio Alvarado <ikalvarado@google.com> | 2016-11-04 12:15:55 -0700 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2017-02-23 03:51:01 +0000 |
commit | b2decb623a42f21e5fe878fe3f9e612e06b62106 (patch) | |
tree | 37f60cbf7ba5f0733764c26980f696ff8438c2fb /arch | |
parent | ec50d221bbe0f21832ebd2073ff2889484e0d9f8 (diff) | |
download | linux-stable-b2decb623a42f21e5fe878fe3f9e612e06b62106.tar.gz linux-stable-b2decb623a42f21e5fe878fe3f9e612e06b62106.tar.bz2 linux-stable-b2decb623a42f21e5fe878fe3f9e612e06b62106.zip |
KVM: Disable irq while unregistering user notifier
commit 1650b4ebc99da4c137bfbfc531be4a2405f951dd upstream.
Function user_notifier_unregister should be called only once for each
registered user notifier.
Function kvm_arch_hardware_disable can be executed from an IPI context
which could cause a race condition with a VCPU returning to user mode
and attempting to unregister the notifier.
Signed-off-by: Ignacio Alvarado <ikalvarado@google.com>
Fixes: 18863bdd60f8 ("KVM: x86 shared msr infrastructure")
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kvm/x86.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index fc73c12d488b..4408aee8236d 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -172,7 +172,18 @@ static void kvm_on_user_return(struct user_return_notifier *urn) struct kvm_shared_msrs *locals = container_of(urn, struct kvm_shared_msrs, urn); struct kvm_shared_msr_values *values; + unsigned long flags; + /* + * Disabling irqs at this point since the following code could be + * interrupted and executed through kvm_arch_hardware_disable() + */ + local_irq_save(flags); + if (locals->registered) { + locals->registered = false; + user_return_notifier_unregister(urn); + } + local_irq_restore(flags); for (slot = 0; slot < shared_msrs_global.nr; ++slot) { values = &locals->values[slot]; if (values->host != values->curr) { @@ -180,8 +191,6 @@ static void kvm_on_user_return(struct user_return_notifier *urn) values->curr = values->host; } } - locals->registered = false; - user_return_notifier_unregister(urn); } static void shared_msr_update(unsigned slot, u32 msr) |