Re: [PATCH 15/15] KVM: Fix racy in kvm_free_assigned_irq

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Amit Shah
Date: Sunday, December 28, 2008 - 10:42 pm

On Sun, Dec 28, 2008 at 07:24:02PM +0800, Sheng Yang wrote:

At the time of developing that code, this was my observation:

I see from the call chain kvm_put_kvm->...->kvm_arch_destroy_vm, no locks are 
taken to actually destroy the vm. We can't be in ioctls, sure. But shouldn't 
the mutex be taken to ensure there's nothing else going on while destroying?

At least with the workqueue model, we could be called asynchronously in kernel 
context and I would have held the mutex and about to inject interrupts while 
everything is being wiped off underneath. However, the workqueue model tries 
its best to schedule the work on the same CPU, though we can't use that 
guarantee to ensure things will be fine.

---
So I had to get a ref to the current vm till we had any pending work scheduled. I think I put in comments in the code, but sadly most of my comments we stripped out before the merge.

Amit
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/15] Device assignment & MSI enhancement, Sheng Yang, (Thu Dec 25, 2:09 am)
[PATCH 06/15] KVM: Improve MSI dispatch function, Sheng Yang, (Thu Dec 25, 2:09 am)
[PATCH 08/15] KVM: Merge MSI handling to kvm_set_irq, Sheng Yang, (Thu Dec 25, 2:09 am)
[PATCH 09/15] KVM: Split IOAPIC structure, Sheng Yang, (Thu Dec 25, 2:09 am)
[PATCH 13/15] KVM: bit ops for deliver_bitmap, Sheng Yang, (Thu Dec 25, 2:09 am)
[PATCH 14/15] KVM: Using kfifo for irq recording, Sheng Yang, (Thu Dec 25, 2:09 am)
[PATCH 15/15] KVM: Fix racy in kvm_free_assigned_irq, Sheng Yang, (Thu Dec 25, 2:09 am)
[PATCH 15/15] KVM: Fix racy in kvm_free_assigned_irq, Sheng Yang, (Thu Dec 25, 7:30 pm)
Re: [PATCH 15/15] KVM: Fix racy in kvm_free_assigned_irq, Marcelo Tosatti, (Sat Dec 27, 1:06 pm)
Re: [PATCH 15/15] KVM: Fix racy in kvm_free_assigned_irq, Marcelo Tosatti, (Sat Dec 27, 1:15 pm)
Re: [PATCH 15/15] KVM: Fix racy in kvm_free_assigned_irq, Amit Shah, (Sun Dec 28, 10:42 pm)
Re: [PATCH 15/15] KVM: Fix racy in kvm_free_assigned_irq, Marcelo Tosatti, (Mon Dec 29, 8:20 am)
Re: [PATCH 15/15] KVM: Fix racy in kvm_free_assigned_irq, Marcelo Tosatti, (Tue Dec 30, 9:45 am)
Re: [PATCH 15/15] KVM: Fix racy in kvm_free_assigned_irq, Marcelo Tosatti, (Thu Jan 1, 5:10 pm)