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 5/5] s390/vfio-ap: Fix resource handling for rejected AQIC enable requests
Date: Thu, 3 Dec 2026 16:45:31 -0500 [thread overview]
Message-ID: <20261203214531.1395796-6-jjherne@linux.ibm.com> (raw)
In-Reply-To: <20261203214531.1395796-1-jjherne@linux.ibm.com>
When the guest enables interrupts, vfio_ap_irq_enable() pins the new NIB
page and registers the guest ISC, then issues PQAP(AQIC). The resources
are kept only if the hardware accepts the new NIB. Two cases are
handled wrongly:
* For any response other than NORMAL or OTHERWISE_CHANGED, the code
warned and called vfio_ap_irq_disable(). That issued PQAP(AQIC) with
ir=0 to the hardware, switching off the guest's working interrupts
even though only the new enable request had failed, and then freed
the previously saved NIB page and ISC. It also never released the
newly pinned page and registered ISC, so they leak.
* OTHERWISE_CHANGED (interrupts already enabled, or a prior
asynchronous request still completing) is not a failure, but was
logged as one.
Handle every response other than NORMAL the same way: release the newly
pinned NIB page and the newly registered ISC, and leave the previously
saved resources untouched. Do not disable interrupts in the hardware.
Log a failure only for responses other than NORMAL and
OTHERWISE_CHANGED. The status from PQAP(AQIC) is still returned to the
guest as is.
Also update the function and case comments to describe this.
Fixes: ec89b55e3bce ("s390: ap: implement PAPQ AQIC interception in kernel")
Cc: stable@vger.kernel.org
Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com>
---
drivers/s390/crypto/vfio_ap_ops.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
index 836551e9f65b..3a09a93c09eb 100644
--- a/drivers/s390/crypto/vfio_ap_ops.c
+++ b/drivers/s390/crypto/vfio_ap_ops.c
@@ -440,6 +440,10 @@ static int ensure_nib_shared(unsigned long addr)
* Register the guest ISC to GIB interface and retrieve the
* host ISC to issue the host side PQAP/AQIC
*
+ * The newly pinned NIB and registered ISC are saved in *q only if ap_aqic()
+ * returns AP_RESPONSE_NORMAL. Otherwise they are released and the previously
+ * saved NIB and ISC are left untouched.
+ *
* status.response_code may be set to AP_RESPONSE_INVALID_ADDRESS in case the
* vfio_pin_pages or kvm_s390_gisc_register failed.
*
@@ -524,21 +528,24 @@ static struct ap_queue_status vfio_ap_irq_enable(struct vfio_ap_queue *q,
q->saved_isc = isc;
break;
case AP_RESPONSE_OTHERWISE_CHANGED:
- /* We could not modify IRQ settings: clear new configuration */
+ default:
+ /*
+ * We could not modify IRQ settings: release the new configuration.
+ * Keep the previously saved configuration: for most responses the
+ * queue is still operational and the hardware may still be using it.
+ * If the queue is not operational the saved resources are released
+ * by the reset/unassign/remove paths.
+ */
ret = kvm_s390_gisc_unregister(kvm, isc);
if (ret)
VFIO_AP_DBF_WARN("%s: kvm_s390_gisc_unregister: rc=%d isc=%d, apqn=%#04x\n",
__func__, ret, isc, q->apqn);
vfio_unpin_pages(&q->matrix_mdev->vdev, nib, 1);
break;
- default:
- pr_warn("%s: apqn %04x: response: %02x\n", __func__, q->apqn,
- status.response_code);
- vfio_ap_irq_disable(q);
- break;
}
- if (status.response_code != AP_RESPONSE_NORMAL) {
+ if (status.response_code != AP_RESPONSE_NORMAL &&
+ status.response_code != AP_RESPONSE_OTHERWISE_CHANGED) {
VFIO_AP_DBF_WARN("%s: PQAP(AQIC) failed with status=%#02x: "
"zone=%#x, ir=%#x, gisc=%#x, f=%#x,"
"gisa=%#x, isc=%#x, apqn=%#04x\n",
--
2.56.1
prev parent reply other threads:[~2026-12-03 21:45 UTC|newest]
Thread overview: 6+ 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 21:45 ` [PATCH 2/5] s390/vfio-ap: bound the wait for queue reset verification Jason J. Herne
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 21:45 ` [PATCH 4/5] s390/vfio-ap: clear matrix_mdev link for queues not reset on unassign Jason J. Herne
2026-12-03 21:45 ` Jason J. Herne [this message]
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-6-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®