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
210 struct kvm_shared_msrs *locals210 struct kvm_shared_msrs *locals
211 = container_of(urn, struct kvm_shared_msrs, urn);211 = container_of(urn, struct kvm_shared_msrs, urn);
212 struct kvm_shared_msr_values *values;212 struct kvm_shared_msr_values *values;
213 unsigned long flags;
213 214
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);
214 for (slot = 0; slot < shared_msrs_global.nr; ++slot) {225 for (slot = 0; slot < shared_msrs_global.nr; ++slot) {
215 values = &locals->values[slot];226 values = &locals->values[slot];
216 if (values->host != values->curr) {227 if (values->host != values->curr) {
@@ -218,8 +229,6 @@ static void kvm_on_user_return(struct user_return_notifier *urn) · 1 unmodified line
218 values->curr = values->host;229 values->curr = values->host;
219 }230 }
220 }231 }
221 locals->registered = false;
222 user_return_notifier_unregister(urn);
223}232}
224 233
225static void shared_msr_update(unsigned slot, u32 msr)234static 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