From: "Jason J. Herne" <jjherne@linux.ibm.com>
To: linux-s390@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, akrowiak@linux.ibm.com,
borntraeger@linux.ibm.com, agordeev@linux.ibm.com,
gor@linux.ibm.com, hca@linux.ibm.com, mjrosato@linux.ibm.com,
frankja@linux.ibm.com, imbrenda@linux.ibm.com,
jrossi@linux.ibm.com, stable@vger.kernel.org
Subject: [PATCH 2/5] s390/vfio-ap: bound the wait for queue reset verification
Date: Thu, 3 Dec 2026 16:45:28 -0500 [thread overview]
Message-ID: <20261203214531.1395796-3-jjherne@linux.ibm.com> (raw)
In-Reply-To: <20261203214531.1395796-1-jjherne@linux.ibm.com>
apq_reset_check() TAPQ polls the queue until reset/zeroize is confirmed.
Commit dd174833e44e ("s390/vfio-ap: remove upper limit on wait for queue
reset to complete") removed the time limit, because the architecture
defines no upper bound for a RAPQ/ZAPQ and giving up early and freeing the
AQIC resources could let a still-active queue write to a reused NIB page.
That left the loop with no exit if the reset never completes. This can
happen when TAPQ keeps returning a busy/reset-in-progress response, or
when the ZAPQ is repeatedly rejected with reset-in-progress or
state-change-in-progress (or the queue keeps reporting an asynchronous
association failure) and is reissued on every pass. The work item then
spins forever, and anything that flushes it, such as
vfio_ap_mdev_reset_queues() and vfio_ap_mdev_reset_qlist(), waits
forever with it.
Give up after 2 seconds. A timeout does not confirm the queue was
reset, so do not free the AQIC resources, which leaks the pinned NIB page
rather than risk a write to memory that has been reused.
Record the last TAPQ status in q->reset_status, substituting
AP_RESPONSE_BUSY if it was AP_RESPONSE_NORMAL, so the queue is not
considered passable and the reset callers report -EIO.
This keeps the original safety property (never free resources for a queue
whose reset is unconfirmed) while removing the hang.
Fixes: dd174833e44e ("s390/vfio-ap: remove upper limit on wait for queue reset to complete")
Cc: stable@vger.kernel.org
Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com>
---
drivers/s390/crypto/vfio_ap_ops.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
index 10430b9446db..fba6f256ce77 100644
--- a/drivers/s390/crypto/vfio_ap_ops.c
+++ b/drivers/s390/crypto/vfio_ap_ops.c
@@ -31,6 +31,7 @@
#define AP_QUEUE_IN_USE "in use"
#define AP_RESET_INTERVAL 20 /* Reset sleep interval (20ms) */
+#define VFIOAP_RESET_TIMEOUT 2000 /* Max wait for reset to complete (2s) */
static int vfio_ap_mdev_reset_queues(struct ap_matrix_mdev *matrix_mdev);
static int vfio_ap_mdev_reset_qlist(struct list_head *qlist);
@@ -1974,6 +1975,20 @@ static void apq_reset_check(struct work_struct *reset_work)
q = container_of(reset_work, struct vfio_ap_queue, reset_work);
memcpy(&status, &q->reset_status, sizeof(status));
while (true) {
+ if (elapsed >= VFIOAP_RESET_TIMEOUT) {
+ /*
+ * Reset timed out. The queue could still be active so
+ * leak AQIC resources rather than risk wild DMA write.
+ */
+ pr_warn_ratelimited("Reset timed out for APQN %02x.%04x: leaking NIB page to prevent host crash\n",
+ AP_QID_CARD(q->apqn),
+ AP_QID_QUEUE(q->apqn));
+ memcpy(&q->reset_status, &status, sizeof(status));
+ if (!q->reset_status.response_code)
+ /* Record BUSY status so queue is not passable. */
+ q->reset_status.response_code = AP_RESPONSE_BUSY;
+ return;
+ }
msleep(AP_RESET_INTERVAL);
elapsed += AP_RESET_INTERVAL;
status = ap_tapq(q->apqn, NULL);
--
2.56.1
next prev parent reply other threads:[~2026-12-03 21:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 21:45 [PATCH 0/5] s390/vfio-ap: Fixes for queue reset and AQIC handling Jason J. Herne
2026-12-03 21:45 ` [PATCH 1/5] s390/vfio-ap: Prevent passing unreset queues Jason J. Herne
2026-12-03 22:08 ` sashiko-bot
2026-12-04 17:08 ` Anthony Krowiak
2026-12-03 21:45 ` Jason J. Herne [this message]
2026-12-03 22:08 ` [PATCH 2/5] s390/vfio-ap: bound the wait for queue reset verification sashiko-bot
2026-12-04 18:12 ` Anthony Krowiak
2026-12-03 21:45 ` [PATCH 3/5] s390/vfio-ap: Hold a private NIB page reference when a reset is unconfirmed Jason J. Herne
2026-12-03 22:14 ` sashiko-bot
2026-12-03 21:45 ` [PATCH 4/5] s390/vfio-ap: clear matrix_mdev link for queues not reset on unassign Jason J. Herne
2026-12-03 22:02 ` sashiko-bot
2026-12-03 21:45 ` [PATCH 5/5] s390/vfio-ap: Fix resource handling for rejected AQIC enable requests Jason J. Herne
2026-12-03 22:14 ` [PATCH 0/5] s390/vfio-ap: Fixes for queue reset and AQIC handling sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261203214531.1395796-3-jjherne@linux.ibm.com \
--to=jjherne@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=akrowiak@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=frankja@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=jrossi@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mjrosato@linux.ibm.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.