History

KVM: Disable irq while unregistering user notifier

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.

Ignacio Alvarado committed 10 years ago

Commit 1650b4e1 parent 8b953441 file · +11 −2Browse files

Unified · Split

arch/x86/kvm/x86.c+11−2
@@ -210,7 +210,18 @@ static void kvm_on_user_return(struct user_return_notifier *urn) · 209 unmodified lines
210210 struct kvm_shared_msrs *locals
211211 = container_of(urn, struct kvm_shared_msrs, urn);
212212 struct kvm_shared_msr_values *values;
213+ unsigned long flags;
213214
215+ /*
216+ * Disabling irqs at this point since the following code could be
217+ * interrupted and executed through kvm_arch_hardware_disable()
218+ */
219+ local_irq_save(flags);
220+ if (locals->registered) {
221+ locals->registered = false;
222+ user_return_notifier_unregister(urn);
223+ }
224+ local_irq_restore(flags);
214225 for (slot = 0; slot < shared_msrs_global.nr; ++slot) {
215226 values = &locals->values[slot];
216227 if (values->host != values->curr) {
@@ -218,8 +229,6 @@ static void kvm_on_user_return(struct user_return_notifier *urn) · 1 unmodified line
218229 values->curr = values->host;
219230 }
220231 }
221− locals->registered = false;
222− user_return_notifier_unregister(urn);
223232 }
224233
225234 static void shared_msr_update(unsigned slot, u32 msr)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t