Skip to contentSkip to conversation

vfio/ccw: Remove WARN_ON during shutdown

PATCH Applied Eric Farman 4 participants 5 messages Feb 10, 2023 – Feb 12, 2023

Subsystems (4)
lore
Share & tools
lore

Eric Farman

author maintainer
#0 lore raw

PATCH 1/1 vfio/ccw: Remove WARN_ON during shutdown

The logic in vfio_ccw_sch_shutdown() always assumed that the input subchannel would point to a vfio_ccw_private struct, without checking that one exists. The blamed commit put in a check for this scenario, to prevent the possibility of a missing private.

The trouble is that check was put alongside a WARN_ON(), presuming that such a scenario would be a cause for concern. But this can be triggered by binding a subchannel to vfio-ccw, and rebooting the system before starting the mdev (via "mdevctl start" or similar) or after stopping it. In those cases, shutdown doesn't need to worry because either the private was never allocated, or it was cleaned up by vfio_ccw_mdev_remove().

Remove the WARN_ON() piece of this check, since there are plausible scenarios where private would be NULL in this path.

Fixes 9e6f07cd1eaa ("vfio/ccw: create a parent struct")
---
 drivers/s390/cio/vfio_ccw_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/cio/vfio_ccw_drv.c +1 -1
index 54aba7cceb33..ff538a086fc7 100644
@@ -225,7 +225,7 @@ static void vfio_ccw_sch_shutdown(struct subchannel *sch)
 	struct vfio_ccw_parent *parent = dev_get_drvdata(&sch->dev);
 	struct vfio_ccw_private *private = dev_get_drvdata(&parent->dev);
 
-	if (WARN_ON(!private))
+	if (!private)
 		return;
 
 	vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_CLOSE);
Signature · 1 line
2.37.2
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Eric Farman

The logic in vfio_ccw_sch_shutdown() always assumed that the input subchannel would point to a vfio_ccw_private struct, without checking that one exists. The blamed commit put in a check for this scenario, to prevent the possibility of a missing private.

The trouble is that check was put alongside a WARN_ON(), presuming that such a scenario would be a cause for concern. But this can be triggered by binding a subchannel to vfio-ccw, and rebooting the system before starting the mdev (via "mdevctl start" or similar) or after stopping it. In those cases, shutdown doesn't need to worry because either the private was never allocated, or it was cleaned up by vfio_ccw_mdev_remove().

Quoted 5 lines

Remove the WARN_ON() piece of this check, since there are plausible scenarios where private would be NULL in this path.

Fixes 9e6f07cd1eaa ("vfio/ccw: create a parent struct")

The other ops in vfio_ccw_sch_driver look OK in that they quietly tolerate this scenario -- with .irq being an exception but the rationale and what we log there makes sense to me (we shouldn't get an interrupt on a disabled subchannel) plus it's only a debug log not a WARN.

#2 lore raw
In reply to Eric Farman
Quoted 27 lines · On Fri, 10 Feb 2023 18:42:27 +0100 Eric Farman <[email protected]> wrote:

The logic in vfio_ccw_sch_shutdown() always assumed that the input subchannel would point to a vfio_ccw_private struct, without checking that one exists. The blamed commit put in a check for this scenario, to prevent the possibility of a missing private.

The trouble is that check was put alongside a WARN_ON(), presuming that such a scenario would be a cause for concern. But this can be triggered by binding a subchannel to vfio-ccw, and rebooting the system before starting the mdev (via "mdevctl start" or similar) or after stopping it. In those cases, shutdown doesn't need to worry because either the private was never allocated, or it was cleaned up by vfio_ccw_mdev_remove().

Remove the WARN_ON() piece of this check, since there are plausible scenarios where private would be NULL in this path.

Fixes 9e6f07cd1eaa ("vfio/ccw: create a parent struct")
---
 drivers/s390/cio/vfio_ccw_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/cio/vfio_ccw_drv.c +0 -0
index 54aba7cceb33..ff538a086fc7 100644

drivers/s390/cio/vfio_ccw_drv.c static void vfio_ccw_sch_shutdown(struct subchannel *sch) · line 231

Quoted 8 lines
drivers/s390/cio/vfio_ccw_drv.c +1 -1
@@ -225,7 +225,7 @@ static void vfio_ccw_sch_shutdown(struct subchannel *sch)
 	struct vfio_ccw_parent *parent = dev_get_drvdata(&sch->dev);
 	struct vfio_ccw_private *private = dev_get_drvdata(&parent->dev);
 
-	if (WARN_ON(!private))
+	if (!private)
 		return;
 
 	vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_CLOSE);

I see I'm on the To: line here, is this intended to go through the vfio tree rather than s390? Thanks,

Alex

author maintainer
#3 lore raw
Quoted 45 lines · Alex Williamson
Quoted 33 lines · On Fri, 10 Feb 2023 18:42:27 +0100 Eric Farman <[email protected]> wrote:

The logic in vfio_ccw_sch_shutdown() always assumed that the input subchannel would point to a vfio_ccw_private struct, without checking
that one exists. The blamed commit put in a check for this scenario,
to prevent the possibility of a missing private.

The trouble is that check was put alongside a WARN_ON(), presuming that such a scenario would be a cause for concern. But this can be triggered by binding a subchannel to vfio-ccw, and rebooting the system before starting the mdev (via "mdevctl start" or similar) or after stopping it. In those cases, shutdown doesn't need to worry because either the private was never allocated, or it was cleaned up by vfio_ccw_mdev_remove().

Remove the WARN_ON() piece of this check, since there are plausible scenarios where private would be NULL in this path.

Fixes 9e6f07cd1eaa ("vfio/ccw: create a parent struct")

---
 drivers/s390/cio/vfio_ccw_drv.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/cio/vfio_ccw_drv.c +0 -0
index 54aba7cceb33..ff538a086fc7 100644
@@ -225,7 +225,7 @@ static void vfio_ccw_sch_shutdown(struct
 subchannel *sch)

        struct vfio_ccw_parent *parent = dev_get_drvdata(&sch-

Quoted 1 line

dev);

Quoted 8 lines

        struct vfio_ccw_private *private = dev_get_drvdata(&parent-

Quoted 1 line

dev);


-       if (WARN_ON(!private))
+       if (!private)
                return;

        vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_CLOSE);

Quoted 3 lines

I see I'm on the To: line here, is this intended to go through the vfio
tree rather than s390?

Either way. I put you as "to" as the blamed commit went via vfio, but I could ask Heiko or Vasili to take it if that's easier.

Eric

maintainer Applied
#4 lore raw
Quoted 27 lines · Eric Farman
Quoted 26 lines · Alex Williamson
Quoted 23 lines · On Fri, 10 Feb 2023 18:42:27 +0100 Eric Farman <[email protected]> wrote:

The logic in vfio_ccw_sch_shutdown() always assumed that the input subchannel would point to a vfio_ccw_private struct, without checking
that one exists. The blamed commit put in a check for this scenario,
to prevent the possibility of a missing private.

The trouble is that check was put alongside a WARN_ON(), presuming that such a scenario would be a cause for concern. But this can be triggered by binding a subchannel to vfio-ccw, and rebooting the system before starting the mdev (via "mdevctl start" or similar) or after stopping it. In those cases, shutdown doesn't need to worry because either the private was never allocated, or it was cleaned up by vfio_ccw_mdev_remove().

Remove the WARN_ON() piece of this check, since there are plausible scenarios where private would be NULL in this path.

Fixes 9e6f07cd1eaa ("vfio/ccw: create a parent struct")

---
 drivers/s390/cio/vfio_ccw_drv.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)

...

Quoted 6 lines
Quoted 3 lines

I see I'm on the To: line here, is this intended to go through the vfio
tree rather than s390?

Either way. I put you as "to" as the blamed commit went via vfio, but I could ask Heiko or Vasili to take it if that's easier.

I picked it up, so it will go via s390. Thanks!