Skip to content

s390/cio: Harden pmcw/schib handling for dnv=0

Vineeth Vijayan linux-s390 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3s390/cio: Fix cio_update_schib() to not cache invalid schibdrivers/s390/cio/cio.c+7 -40 replies
2/3s390/cio: Check pmcw.dnv before pmcw.ena in I/O entry pointsdrivers/s390/cio/device_ops.c+12 -00 replies
3/3s390/cio: Guard PMCW field accesses with dnv checkdrivers/s390/cio/chp.c drivers/s390/cio/device.c drivers/s390/cio/device_fsm.c +2 more+21 -50 replies

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchPeter Oberparleiter
1/3R-b
2/3R-b
3/3R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/3] s390/cio: Harden pmcw/schib handling for dnv=0

For I/O subchannels, pmcw.dnv must be validated before relying on any other PMCW or SCHIB fields.
Two issues exist today:
- Some I/O entry points check pmcw.ena without first verifying that pmcw.dnv is set.
- cio_update_schib() updates the cached SCHIB before validating pmcw.dnv, allowing an stsch result with dnv=0 to leave stale or undefined data in sch->schib.

This can trigger spurious, non-fatal error messages in the guest kernel log when a virtio device is being detached.

Fix this by validating pmcw.dnv before updating the cached SCHIB. Also clear the cached SCHIB when stsch succeeds but returns dnv=0, ensuring that stale state is not retained.

Additionally, add pmcw.dnv checks before pmcw.ena checks in I/O entry points and return -ENODEV when no device is present. Guard remaining direct accesses to cached PMCW fields, such as chpid[] and pam, to ensure they are only evaluated when the SCHIB contents are valid.
This was reported and discussed at:

Vineeth Vijayan (3):
s390/cio: Fix cio_update_schib() to not cache invalid schib s390/cio: Check pmcw.dnv before pmcw.ena in I/O entry points s390/cio: Guard PMCW field accesses with dnv check

 drivers/s390/cio/chp.c          |  3 +++
 drivers/s390/cio/cio.c          | 11 +++++++----
 drivers/s390/cio/device.c       |  9 +++++----
 drivers/s390/cio/device_fsm.c   |  3 +++
 drivers/s390/cio/device_ops.c   | 21 +++++++++++++++++++++
 drivers/s390/cio/vfio_ccw_fsm.c |  2 +-
 6 files changed, 40 insertions(+), 9 deletions(-)
Signature · 1 line
2.53.0