* [PATCH 0/2] Fix lock errors in VDUSE suspend feature
@ 2026-06-11 13:38 Eugenio Pérez
2026-06-11 13:38 ` [PATCH 1/2] vduse: fix not releasing taken semaphore in vduse_dev_queue_irq_work Eugenio Pérez
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Eugenio Pérez @ 2026-06-11 13:38 UTC (permalink / raw)
To: Michael S . Tsirkin
Cc: Maxime Coquelin, Stefano Garzarella, Jason Wang,
Eugenio Pérez, Xuan Zhuo, Laurent Vivier, virtualization,
linux-kernel, Cindy Lu, Yongji Xie
Fix wrong ordering at taking semaphore after spinlock and convert the spinlock
take and release into guards, so they are not lost after a return.
This series goes on top of https://lore.kernel.org/lkml/20260610083452.477759-1-eperezma@redhat.com/
---
It would be great if these can be squashed.
Eugenio Pérez (2):
vduse: fix not releasing taken semaphore in vduse_dev_queue_irq_work
vduse: not take the device semaphore while holding vq spinlock
drivers/vdpa/vdpa_user/vduse_dev.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
--
2.54.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] vduse: fix not releasing taken semaphore in vduse_dev_queue_irq_work
2026-06-11 13:38 [PATCH 0/2] Fix lock errors in VDUSE suspend feature Eugenio Pérez
@ 2026-06-11 13:38 ` Eugenio Pérez
2026-06-11 13:38 ` [PATCH 2/2] vduse: not take the device semaphore while holding vq spinlock Eugenio Pérez
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Eugenio Pérez @ 2026-06-11 13:38 UTC (permalink / raw)
To: Michael S . Tsirkin
Cc: Maxime Coquelin, Stefano Garzarella, Jason Wang,
Eugenio Pérez, Xuan Zhuo, Laurent Vivier, virtualization,
linux-kernel, Cindy Lu, Yongji Xie
If dev->suspended the function returns not relasing the semaphore, so
the only solution to be able to use the device is to reset again from
userspace. Convert the semaphore functions to the equivalent guard() to
avoid it.
Fixes: 6c141c034c1b ("vduse: Add suspend")
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
drivers/vdpa/vdpa_user/vduse_dev.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c
index 0500da043761..86bd3116eda7 100644
--- a/drivers/vdpa/vdpa_user/vduse_dev.c
+++ b/drivers/vdpa/vdpa_user/vduse_dev.c
@@ -1281,21 +1281,16 @@ static int vduse_dev_queue_irq_work(struct vduse_dev *dev,
{
int ret = -EINVAL;
- down_read(&dev->rwsem);
- if (dev->suspended)
+ guard(rwsem_read)(&dev->rwsem);
+ if (dev->suspended || !(dev->status & VIRTIO_CONFIG_S_DRIVER_OK))
return ret;
- if (!(dev->status & VIRTIO_CONFIG_S_DRIVER_OK))
- goto unlock;
-
ret = 0;
if (irq_effective_cpu == IRQ_UNBOUND)
queue_work(vduse_irq_wq, irq_work);
else
queue_work_on(irq_effective_cpu,
vduse_irq_bound_wq, irq_work);
-unlock:
- up_read(&dev->rwsem);
return ret;
}
--
2.54.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] vduse: not take the device semaphore while holding vq spinlock
2026-06-11 13:38 [PATCH 0/2] Fix lock errors in VDUSE suspend feature Eugenio Pérez
2026-06-11 13:38 ` [PATCH 1/2] vduse: fix not releasing taken semaphore in vduse_dev_queue_irq_work Eugenio Pérez
@ 2026-06-11 13:38 ` Eugenio Pérez
2026-06-11 14:12 ` [PATCH 0/2] Fix lock errors in VDUSE suspend feature Michael S. Tsirkin
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Eugenio Pérez @ 2026-06-11 13:38 UTC (permalink / raw)
To: Michael S . Tsirkin
Cc: Maxime Coquelin, Stefano Garzarella, Jason Wang,
Eugenio Pérez, Xuan Zhuo, Laurent Vivier, virtualization,
linux-kernel, Cindy Lu, Yongji Xie
It's an invalid lock pattern, so take them reversely.
This also makes the lock ordering coherent with vduse_dev_reset.
Fixes: e4a249d15eb2 ("vduse: Fix error around jumping over a __cleanup() variable")
Fixes: 6c141c034c1b ("vduse: Add suspend")
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
drivers/vdpa/vdpa_user/vduse_dev.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c
index 86bd3116eda7..2c1cafea6536 100644
--- a/drivers/vdpa/vdpa_user/vduse_dev.c
+++ b/drivers/vdpa/vdpa_user/vduse_dev.c
@@ -561,14 +561,14 @@ static int vduse_vdpa_set_vq_address(struct vdpa_device *vdpa, u16 idx,
static void vduse_vq_kick(struct vduse_virtqueue *vq)
{
- guard(spinlock)(&vq->kick_lock);
- if (!vq->ready)
- return;
-
guard(rwsem_read)(&vq->dev->rwsem);
if (vq->dev->suspended)
return;
+ guard(spinlock)(&vq->kick_lock);
+ if (!vq->ready)
+ return;
+
if (vq->kickfd)
eventfd_signal(vq->kickfd);
else
--
2.54.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] Fix lock errors in VDUSE suspend feature
2026-06-11 13:38 [PATCH 0/2] Fix lock errors in VDUSE suspend feature Eugenio Pérez
2026-06-11 13:38 ` [PATCH 1/2] vduse: fix not releasing taken semaphore in vduse_dev_queue_irq_work Eugenio Pérez
2026-06-11 13:38 ` [PATCH 2/2] vduse: not take the device semaphore while holding vq spinlock Eugenio Pérez
@ 2026-06-11 14:12 ` Michael S. Tsirkin
2026-06-11 14:14 ` Michael S. Tsirkin
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Michael S. Tsirkin @ 2026-06-11 14:12 UTC (permalink / raw)
To: Eugenio Pérez
Cc: Maxime Coquelin, Stefano Garzarella, Jason Wang, Xuan Zhuo,
Laurent Vivier, virtualization, linux-kernel, Cindy Lu,
Yongji Xie
On Thu, Jun 11, 2026 at 03:38:04PM +0200, Eugenio Pérez wrote:
> Fix wrong ordering at taking semaphore after spinlock and convert the spinlock
> take and release into guards, so they are not lost after a return.
>
> This series goes on top of https://lore.kernel.org/lkml/20260610083452.477759-1-eperezma@redhat.com/
And vduse: Fix error around jumping over a __cleanup() variable
does it obliviate that?
> ---
> It would be great if these can be squashed.
>
> Eugenio Pérez (2):
> vduse: fix not releasing taken semaphore in vduse_dev_queue_irq_work
> vduse: not take the device semaphore while holding vq spinlock
>
> drivers/vdpa/vdpa_user/vduse_dev.c | 17 ++++++-----------
> 1 file changed, 6 insertions(+), 11 deletions(-)
>
> --
> 2.54.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] Fix lock errors in VDUSE suspend feature
2026-06-11 13:38 [PATCH 0/2] Fix lock errors in VDUSE suspend feature Eugenio Pérez
` (2 preceding siblings ...)
2026-06-11 14:12 ` [PATCH 0/2] Fix lock errors in VDUSE suspend feature Michael S. Tsirkin
@ 2026-06-11 14:14 ` Michael S. Tsirkin
2026-06-11 14:46 ` Michael S. Tsirkin
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Michael S. Tsirkin @ 2026-06-11 14:14 UTC (permalink / raw)
To: Eugenio Pérez
Cc: Maxime Coquelin, Stefano Garzarella, Jason Wang, Xuan Zhuo,
Laurent Vivier, virtualization, linux-kernel, Cindy Lu,
Yongji Xie
On Thu, Jun 11, 2026 at 03:38:04PM +0200, Eugenio Pérez wrote:
> Fix wrong ordering at taking semaphore after spinlock and convert the spinlock
> take and release into guards, so they are not lost after a return.
>
> This series goes on top of https://lore.kernel.org/lkml/20260610083452.477759-1-eperezma@redhat.com/
> ---
> It would be great if these can be squashed.
if you want that then just send v4.
>
> Eugenio Pérez (2):
> vduse: fix not releasing taken semaphore in vduse_dev_queue_irq_work
> vduse: not take the device semaphore while holding vq spinlock
>
> drivers/vdpa/vdpa_user/vduse_dev.c | 17 ++++++-----------
> 1 file changed, 6 insertions(+), 11 deletions(-)
>
> --
> 2.54.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] Fix lock errors in VDUSE suspend feature
2026-06-11 13:38 [PATCH 0/2] Fix lock errors in VDUSE suspend feature Eugenio Pérez
` (3 preceding siblings ...)
2026-06-11 14:14 ` Michael S. Tsirkin
@ 2026-06-11 14:46 ` Michael S. Tsirkin
2026-06-11 14:49 ` Michael S. Tsirkin
2026-06-11 14:53 ` Michael S. Tsirkin
6 siblings, 0 replies; 8+ messages in thread
From: Michael S. Tsirkin @ 2026-06-11 14:46 UTC (permalink / raw)
To: Eugenio Pérez
Cc: Maxime Coquelin, Stefano Garzarella, Jason Wang, Xuan Zhuo,
Laurent Vivier, virtualization, linux-kernel, Cindy Lu,
Yongji Xie
On Thu, Jun 11, 2026 at 03:38:04PM +0200, Eugenio Pérez wrote:
> Fix wrong ordering at taking semaphore after spinlock and convert the spinlock
> take and release into guards, so they are not lost after a return.
>
> This series goes on top of https://lore.kernel.org/lkml/20260610083452.477759-1-eperezma@redhat.com/
does not apply there.
> ---
> It would be great if these can be squashed.
>
> Eugenio Pérez (2):
> vduse: fix not releasing taken semaphore in vduse_dev_queue_irq_work
> vduse: not take the device semaphore while holding vq spinlock
>
> drivers/vdpa/vdpa_user/vduse_dev.c | 17 ++++++-----------
> 1 file changed, 6 insertions(+), 11 deletions(-)
>
> --
> 2.54.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] Fix lock errors in VDUSE suspend feature
2026-06-11 13:38 [PATCH 0/2] Fix lock errors in VDUSE suspend feature Eugenio Pérez
` (4 preceding siblings ...)
2026-06-11 14:46 ` Michael S. Tsirkin
@ 2026-06-11 14:49 ` Michael S. Tsirkin
2026-06-11 14:53 ` Michael S. Tsirkin
6 siblings, 0 replies; 8+ messages in thread
From: Michael S. Tsirkin @ 2026-06-11 14:49 UTC (permalink / raw)
To: Eugenio Pérez
Cc: Maxime Coquelin, Stefano Garzarella, Jason Wang, Xuan Zhuo,
Laurent Vivier, virtualization, linux-kernel, Cindy Lu,
Yongji Xie
On Thu, Jun 11, 2026 at 03:38:04PM +0200, Eugenio Pérez wrote:
> Fix wrong ordering at taking semaphore after spinlock and convert the spinlock
> take and release into guards, so they are not lost after a return.
>
> This series goes on top of https://lore.kernel.org/lkml/20260610083452.477759-1-eperezma@redhat.com/
You mean
20260610-vduse_vq_kick-fix-guard-usage-v1-1-0ce02c08006e@kernel.org
actually
> ---
> It would be great if these can be squashed.
>
> Eugenio Pérez (2):
> vduse: fix not releasing taken semaphore in vduse_dev_queue_irq_work
> vduse: not take the device semaphore while holding vq spinlock
>
> drivers/vdpa/vdpa_user/vduse_dev.c | 17 ++++++-----------
> 1 file changed, 6 insertions(+), 11 deletions(-)
>
> --
> 2.54.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] Fix lock errors in VDUSE suspend feature
2026-06-11 13:38 [PATCH 0/2] Fix lock errors in VDUSE suspend feature Eugenio Pérez
` (5 preceding siblings ...)
2026-06-11 14:49 ` Michael S. Tsirkin
@ 2026-06-11 14:53 ` Michael S. Tsirkin
6 siblings, 0 replies; 8+ messages in thread
From: Michael S. Tsirkin @ 2026-06-11 14:53 UTC (permalink / raw)
To: Eugenio Pérez
Cc: Maxime Coquelin, Stefano Garzarella, Jason Wang, Xuan Zhuo,
Laurent Vivier, virtualization, linux-kernel, Cindy Lu,
Yongji Xie
On Thu, Jun 11, 2026 at 03:38:04PM +0200, Eugenio Pérez wrote:
> Fix wrong ordering at taking semaphore after spinlock and convert the spinlock
> take and release into guards, so they are not lost after a return.
>
> This series goes on top of https://lore.kernel.org/lkml/20260610083452.477759-1-eperezma@redhat.com/
> ---
> It would be great if these can be squashed.
ok i figured out the confusion. squashed
>
> Eugenio Pérez (2):
> vduse: fix not releasing taken semaphore in vduse_dev_queue_irq_work
> vduse: not take the device semaphore while holding vq spinlock
>
> drivers/vdpa/vdpa_user/vduse_dev.c | 17 ++++++-----------
> 1 file changed, 6 insertions(+), 11 deletions(-)
>
> --
> 2.54.0
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-06-11 14:53 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-11 13:38 [PATCH 0/2] Fix lock errors in VDUSE suspend feature Eugenio Pérez
2026-06-11 13:38 ` [PATCH 1/2] vduse: fix not releasing taken semaphore in vduse_dev_queue_irq_work Eugenio Pérez
2026-06-11 13:38 ` [PATCH 2/2] vduse: not take the device semaphore while holding vq spinlock Eugenio Pérez
2026-06-11 14:12 ` [PATCH 0/2] Fix lock errors in VDUSE suspend feature Michael S. Tsirkin
2026-06-11 14:14 ` Michael S. Tsirkin
2026-06-11 14:46 ` Michael S. Tsirkin
2026-06-11 14:49 ` Michael S. Tsirkin
2026-06-11 14:53 ` Michael S. Tsirkin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox