2011-03-17 08:54:14

by Michael S. Tsirkin

[permalink] [raw]
Subject: [PATCH] kvm: fix crash on irqfd deassign

irqfd in kvm used flush_work incorrectly:
it assumed that work scheduled previously can't run
after flush_work, but since kvm uses a non-reentrant
workqueue (by means of schedule_work)
we need flush_work_sync to get that guarantee.

Signed-off-by: Michael S. Tsirkin <[email protected]>
Reported-by: Jean-Philippe Menil <[email protected]>
Tested-by: Jean-Philippe Menil <[email protected]>
---

Note: this is needed for kernel 2.6.39 and earlier.

virt/kvm/eventfd.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 2ca4535..cdf51c9 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -90,7 +90,7 @@ irqfd_shutdown(struct work_struct *work)
* We know no new events will be scheduled at this point, so block
* until all previously outstanding events have completed
*/
- flush_work(&irqfd->inject);
+ flush_work_sync(&irqfd->inject);

/*
* It is now safe to release the object's resources
--
1.7.3.2.91.g446ac


2011-03-17 16:13:51

by Greg KH

[permalink] [raw]
Subject: Re: [stable] [PATCH] kvm: fix crash on irqfd deassign

On Thu, Mar 17, 2011 at 10:53:33AM +0200, Michael S. Tsirkin wrote:
> irqfd in kvm used flush_work incorrectly:
> it assumed that work scheduled previously can't run
> after flush_work, but since kvm uses a non-reentrant
> workqueue (by means of schedule_work)
> we need flush_work_sync to get that guarantee.
>
> Signed-off-by: Michael S. Tsirkin <[email protected]>
> Reported-by: Jean-Philippe Menil <[email protected]>
> Tested-by: Jean-Philippe Menil <[email protected]>
> ---
>
> Note: this is needed for kernel 2.6.39 and earlier.

This is not the correct way to submit patches for inclusion in the
stable kernel tree. Please read Documentation/stable_kernel_rules.txt
for how to do this properly.

thanks,

greg k-h

2011-03-18 13:21:29

by Michael S. Tsirkin

[permalink] [raw]
Subject: Re: [stable] [PATCH] kvm: fix crash on irqfd deassign

On Thu, Mar 17, 2011 at 09:13:08AM -0700, Greg KH wrote:
> On Thu, Mar 17, 2011 at 10:53:33AM +0200, Michael S. Tsirkin wrote:
> > irqfd in kvm used flush_work incorrectly:
> > it assumed that work scheduled previously can't run
> > after flush_work, but since kvm uses a non-reentrant
> > workqueue (by means of schedule_work)
> > we need flush_work_sync to get that guarantee.
> >
> > Signed-off-by: Michael S. Tsirkin <[email protected]>
> > Reported-by: Jean-Philippe Menil <[email protected]>
> > Tested-by: Jean-Philippe Menil <[email protected]>
> > ---
> >
> > Note: this is needed for kernel 2.6.39 and earlier.
>
> This is not the correct way to submit patches for inclusion in the
> stable kernel tree. Please read Documentation/stable_kernel_rules.txt
> for how to do this properly.
>
> thanks,
>
> greg k-h

What I missed is Cc: [email protected] in the text?
OK, thanks for the correction. Actually I forgot, Avi and Marcelo want
to handle stable patches for kvm themselves.
Avi, Marcelo, right?
So Greg, you can forget about this one for now.

Thanks,

--
MST

2011-03-22 12:37:57

by Avi Kivity

[permalink] [raw]
Subject: Re: [PATCH] kvm: fix crash on irqfd deassign

On 03/17/2011 10:53 AM, Michael S. Tsirkin wrote:
> irqfd in kvm used flush_work incorrectly:
> it assumed that work scheduled previously can't run
> after flush_work, but since kvm uses a non-reentrant
> workqueue (by means of schedule_work)
> we need flush_work_sync to get that guarantee.
>
> Signed-off-by: Michael S. Tsirkin<[email protected]>
> Reported-by: Jean-Philippe Menil<[email protected]>
> Tested-by: Jean-Philippe Menil<[email protected]>
> ---
>
> Note: this is needed for kernel 2.6.39 and earlier.
>

What about kvm.git master?

--
error compiling committee.c: too many arguments to function

2011-03-22 12:51:14

by Michael S. Tsirkin

[permalink] [raw]
Subject: Re: [PATCH] kvm: fix crash on irqfd deassign

On Tue, Mar 22, 2011 at 02:37:27PM +0200, Avi Kivity wrote:
> On 03/17/2011 10:53 AM, Michael S. Tsirkin wrote:
> >irqfd in kvm used flush_work incorrectly:
> >it assumed that work scheduled previously can't run
> >after flush_work, but since kvm uses a non-reentrant
> >workqueue (by means of schedule_work)
> >we need flush_work_sync to get that guarantee.
> >
> >Signed-off-by: Michael S. Tsirkin<[email protected]>
> >Reported-by: Jean-Philippe Menil<[email protected]>
> >Tested-by: Jean-Philippe Menil<[email protected]>
> >---
> >
> >Note: this is needed for kernel 2.6.39 and earlier.
> >
>
> What about kvm.git master?

Sorry about the confusion.

Clarification: this is needed on kvm.git master,
as well as 2.6.39 and earlier.

> --
> error compiling committee.c: too many arguments to function

2011-03-22 16:41:24

by Avi Kivity

[permalink] [raw]
Subject: Re: [PATCH] kvm: fix crash on irqfd deassign

On 03/17/2011 10:53 AM, Michael S. Tsirkin wrote:
> irqfd in kvm used flush_work incorrectly:
> it assumed that work scheduled previously can't run
> after flush_work, but since kvm uses a non-reentrant
> workqueue (by means of schedule_work)
> we need flush_work_sync to get that guarantee.
>

Applied, and queued for 2.6.39. Thanks.

--
error compiling committee.c: too many arguments to function