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 1/5] s390/vfio-ap: Prevent passing unreset queues
Date: Thu, 03 Dec 2026 22:08:17 +0000	[thread overview]
Message-ID: <sashiko-outbox-248730@kernel.org> (raw)
In-Reply-To: <20261203214531.1395796-2-jjherne@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] s390/vfio-ap: _queue_passable() permanently blocks recovered
  adapters
- [Low] s390/vfio-ap: missing Fixes tag for commit 65e05ec252a9
--

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

> s390/vfio-ap: Prevent passing unreset queues
>
> vfio_ap_mdev_reset_queues() and _queue_passable() use q->reset_status
> to decide whether a queue was reset and may be passed to a guest.
> apq_reset_check() can leave the status from the initial ZAPQ (usually
> AP_RESPONSE_NORMAL) in place when the reset is not confirmed, so an
> unreset queue looks reset. Fix the cases where this happens:
>
>  - TAPQ returns an invalid response code (-EIO), or
>    AP_RESPONSE_Q_NOT_AVAIL (-ENODEV, e.g. ZAPQ rc 00 then TAPQ rc 01):
>    the worker returns without saving the TAPQ status. Save it. In the
>    -EIO case the AQIC resources are still intentionally leaked, since
>    it is unknown whether the queue can still write to the NIB. Not
>    saving the status on -EIO predates the DECONFIGURED and
>    CHECKSTOPPED handling below.
>
>  - AP_RESPONSE_DECONFIGURED and AP_RESPONSE_CHECKSTOPPED are treated
>    as success by apq_status_check(), but neither confirms a zeroize:
>    all status bits are zero for these codes and a checkstop resets the
>    queue rather than zeroizing it. Return -ENODEV for them so the
>    worker frees the AQIC resources (the queue can no longer write to
>    the NIB) and saves the status.
>
> Make _queue_passable() accept only AP_RESPONSE_NORMAL, so deconfigured
> and checkstopped queues are no longer passed to a guest. This drops
> the earlier policy of passing such queues through to avoid possible
> data leaks.
>
> Fixes: c51f8c6bb5c8 ("s390/vfio-ap: allow deconfigured queue to be passed through to a guest")
> Fixes: dd174833e44e ("s390/vfio-ap: remove upper limit on wait for queue reset to complete")
> Fixes: a681226c675c ("s390/vfio-ap: handle hardware checkstop state on queue reset operation")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com>

[Severity: Low]
Since this also fixes the -ENODEV path in apq_reset_check() returning
without saving the TAPQ status for AP_RESPONSE_Q_NOT_AVAIL, should this
include:

  Fixes: 65e05ec252a9 ("s390/vfio-ap: fix KVM GISC and page leak when queue removed from host config")

> diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
> index 373ce574c4319..10430b9446dbb 100644
> --- a/drivers/s390/crypto/vfio_ap_ops.c
> +++ b/drivers/s390/crypto/vfio_ap_ops.c
> @@ -694,8 +694,6 @@ static bool _queue_passable(struct vfio_ap_queue *q)
>  
>  	switch (q->reset_status.response_code) {
>  	case AP_RESPONSE_NORMAL:
> -	case AP_RESPONSE_DECONFIGURED:
> -	case AP_RESPONSE_CHECKSTOPPED:
>  		return true;
>  	default:
>  		return false;

[Severity: High]
Can rejecting AP_RESPONSE_DECONFIGURED and AP_RESPONSE_CHECKSTOPPED here
permanently block a recovered adapter from being passed to a guest?

If a queue reset runs while an adapter is deconfigured (for example in
vfio_ap_mdev_unset_kvm()), q->reset_status records AP_RESPONSE_DECONFIGURED.
When the adapter comes back online, ap_scan_domains() updates the ap_queue
in place without re-probing it or triggering vfio_ap_on_cfg_changed().

Later assigning the adapter via assign_adapter_store() links the existing
vfio_ap_queue without retrying a reset, so vfio_ap_mdev_filter_matrix() sees
the stale status and clears the APID from shadow_apcb.apm.  Unassigning also
skips the reset because the APID is already clear in shadow_apcb.apm.

The same happens after checkstop recovery, leaving a healthy adapter
unusable for guests until the queue is manually unbound and rebound from
vfio_ap.  Should vfio_ap retry resetting queues with a non-normal
reset_status when linking or filtering them?

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

  reply	other threads:[~2026-12-03 22:08 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 [this message]
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
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-248730@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