Linux s390 Architecture development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jason J. Herne" <jjherne@linux.ibm.com>, linux-s390@vger.kernel.org
Cc: "Heiko Carstens" <hca@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>
Subject: Re: [PATCH 4/5] s390/vfio-ap: clear matrix_mdev link for queues not reset on unassign
Date: Thu, 03 Dec 2026 22:02:52 +0000	[thread overview]
Message-ID: <sashiko-outbox-248726@kernel.org> (raw)
In-Reply-To: <20261203214531.1395796-5-jjherne@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] s390/vfio-ap: unreset unlink clears matrix_mdev with live AQIC
  state
--

commit 53e525cdd277ac2c49c6360db65bfb03dbc20712
Author: Jason J. Herne <jjherne@linux.ibm.com>

s390/vfio-ap: clear matrix_mdev link for queues not reset on unassign

This commit clears q->matrix_mdev when unassigning an adapter or domain
for queues not in shadow_apcb, and releases their AQIC resources first if
they are no longer in matrix_dev->info.

> diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
> index d460337e365f2..836551e9f65be 100644
> --- a/drivers/s390/crypto/vfio_ap_ops.c
> +++ b/drivers/s390/crypto/vfio_ap_ops.c
> @@ -1173,6 +1173,22 @@ static struct vfio_ap_queue
>  	return q;
>  }
>  
> +/*
> + * Unlink a queue that is not being reset. If it is no longer in the host's AP
> + * configuration it is gone, but vfio_ap_mdev_remove_queue() can't release its
> + * AQIC resources once the mdev link is cleared, so release them here.
> + */
> +static void vfio_ap_unlink_mdev_fr_unreset_queue(struct vfio_ap_queue *q)
> +{
> +	if (!test_bit_inv(AP_QID_CARD(q->apqn),
> +			  (unsigned long *)matrix_dev->info.apm) ||
> +	    !test_bit_inv(AP_QID_QUEUE(q->apqn),
> +			  (unsigned long *)matrix_dev->info.aqm))
> +		vfio_ap_free_aqic_resources(q);
> +
> +	vfio_ap_unlink_mdev_fr_queue(q);
> +}

[Severity: High]
Can this clear q->matrix_mdev while the queue still holds live AQIC
resources and armed hardware interrupts?

A queue filtered out of shadow_apcb (for example, when a sibling queue on
the same adapter is unbound) stays in qtable.queues and matrix_dev->info.
Because handle_pqap() does not check shadow_apcb, a guest can still run
PQAP(AQIC) on it to pin a NIB page, register a GISC, and arm interrupts.

Unassigning the adapter or domain then drops the queue from qtable.queues
and clears q->matrix_mdev without resetting it.  Hardware interrupts stay
armed against the guest's NIB and GISA, and the orphaned NIB pin causes
vfio_dma_do_unmap() to hit BUG_ON(++retries > 10) on DMA unmap.

On the other branch where matrix_dev->info is clear, if the host re-adds
the adapter before ap_scan_bus() removes the queue and the guest enables
AQIC via handle_pqap(), vfio_ap_free_aqic_resources() unpins the NIB page
without disabling hardware interrupts.

Resetting any queue with active AQIC state before clearing q->matrix_mdev,
or rejecting queues outside shadow_apcb in handle_pqap(), would avoid
leaving armed interrupts behind.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203214531.1395796-1-jjherne@linux.ibm.com?part=4

  reply	other threads:[~2026-12-03 22:02 UTC|newest]

Thread overview: 11+ 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-03 21:45 ` [PATCH 2/5] s390/vfio-ap: bound the wait for queue reset verification Jason J. Herne
2026-12-03 22:08   ` sashiko-bot
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 [this message]
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=sashiko-outbox-248726@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=jjherne@linux.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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