From: Anthony Krowiak <akrowiak@linux.ibm.com>
To: Matthew Rosato <mjrosato@linux.ibm.com>,
linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
kvm@vger.kernel.org
Cc: jjherne@linux.ibm.com, borntraeger@de.ibm.com,
pasic@linux.ibm.com, alex@shazbot.org, kwankhede@nvidia.com,
fiuczy@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com,
imbrenda@linux.ibm.com, agordeev@linux.ibm.com,
hca@linux.ibm.com, gor@linux.ibm.com, stable@vger.kernel.org
Subject: Re: [PATCH 1/4] s390/vfio-ap: Fix leak of pinned NIB and registered NISC in vfio_ap_irq_enable()
Date: Mon, 24 Aug 2026 15:39:15 -0400 [thread overview]
Message-ID: <4bc189fa-ade2-46a9-a749-c9c8067f347a@linux.ibm.com> (raw)
In-Reply-To: <adecc2df-d2c2-48d6-a80a-c84ab9779322@linux.ibm.com>
On 8/24/26 12:57 PM, Matthew Rosato wrote:
> On 8/24/26 9:58 AM, Anthony Krowiak wrote:
>> The vfio_ap_irq_enable() function executes the PQAP(AQIC) instruction to
>> enable interrupts for an AP queue. A switch statement is used to examine
>> the status response code returned from the instruction to determine
>> whether it succeeded or failed and react accordingly. For the default case,
>> the vfio_ap_irq_disable function is invoked to disable interrupts for the
>> queue and clean up the AQIC resources (i.e., unpin the NIB and unregister
>> the NISC). There are a number of problems with this:
>>
>> 1. Neither the q->saved_iova nor q->saved_isc has been set, so the
>> AQIC resources - assuming those values have been previously set - will
>> be the NIB and NISC resources from a prior call; the NIB and NISC from
>> the current call are therefore leaked.
>>
>> 2. Interrupts may never have been enabled. Sending a disable instruction to
>> a queue that the hardware just told you is in a bad state (CHECKSTOPPED,
>> DECONFIGURED, Q_NOT_AVAIL) is at best wasted work and at worst generates
>> a further WARN_ONCE from inside vfio_ap_irq_disable's own default.
>>
>> 3. The hardware just rejected the new ap_aqic() enable attempt with an
>> unexpected status. Disabling a previously-working IRQ config - assuming
>> that is even possible - as a reaction to a failed enable attempt does
>> not make sense; it is actively destructive, tearing down something that
>> was working for no valid reason.
>>
>> The fix is to unregister the NISC and an unpin the NIB in the default case
>> of the switch statement.
>>
>> Fixes: ec89b55e3bce7 ("s390: ap: implement PAPQ AQIC interception in kernel")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Anthony Krowiak <akrowiak@linux.ibm.com>
>> ---
>> drivers/s390/crypto/vfio_ap_ops.c | 11 ++++++++---
>> 1 file changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
>> index 940c0ff668be..a46bf381ab72 100644
>> --- a/drivers/s390/crypto/vfio_ap_ops.c
>> +++ b/drivers/s390/crypto/vfio_ap_ops.c
>> @@ -503,9 +503,14 @@ static struct ap_queue_status vfio_ap_irq_enable(struct vfio_ap_queue *q,
>> 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);
>> + pr_warn("%s: PQAP(AQIC) failed with response code %02x for apqn %04x\n",
>> + __func__, status.response_code, q->apqn);
> LGTM, except Sashiko mentions the pr_warn here that you are updating has
> a pre-existing issue.
>
> Since you're touching it already, do you think it makes sense to switch
> to pr_warn_ratelimited with this patch?
Since this is a pre-existing problem not introduced with this patch and
there is
likewise another related problem not introduced by this patch, I am
going to
post a separated series with fixes to those two related issues.
>
>> + /* We could not modify IRQ settings: clear new configuration */
>> + 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;
>> }
>>
next prev parent reply other threads:[~2026-08-24 19:39 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 13:58 [PATCH 0/4] Fix pre-existing bugs in vfio_ap device driver Anthony Krowiak
2026-08-24 13:58 ` [PATCH 1/4] s390/vfio-ap: Fix leak of pinned NIB and registered NISC in vfio_ap_irq_enable() Anthony Krowiak
2026-08-24 16:57 ` Matthew Rosato
2026-08-24 19:26 ` Anthony Krowiak
2026-08-24 19:39 ` Anthony Krowiak [this message]
2026-08-24 19:56 ` Matthew Rosato
2026-08-24 20:56 ` Anthony Krowiak
2026-08-24 21:03 ` Anthony Krowiak
2026-08-24 13:58 ` [PATCH 2/4] s390/vfio-ap: Fix failure to release IRQ notification eventfd contexts Anthony Krowiak
2026-08-24 17:04 ` Matthew Rosato
2026-08-24 13:58 ` [PATCH 3/4] s390/vfio-ap: Fix unbounded loop in apq_reset_check() Anthony Krowiak
2026-08-24 17:04 ` Matthew Rosato
2026-08-24 19:54 ` Anthony Krowiak
2026-08-24 20:08 ` Anthony Krowiak
2026-08-24 13:58 ` [PATCH 4/4] s390/vfio-ap: Use AP_DOMAINS for adm_add bitmap size in vfio_ap_mdev_cfg_add() Anthony Krowiak
2026-08-24 15:03 ` Jason J. Herne
2026-08-24 17:04 ` Matthew Rosato
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=4bc189fa-ade2-46a9-a749-c9c8067f347a@linux.ibm.com \
--to=akrowiak@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=alex@shazbot.org \
--cc=borntraeger@de.ibm.com \
--cc=fiuczy@linux.ibm.com \
--cc=frankja@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=jjherne@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=kwankhede@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mjrosato@linux.ibm.com \
--cc=pasic@linux.ibm.com \
--cc=pbonzini@redhat.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®