All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Anthony Krowiak" <akrowiak@linux.ibm.com>,
	linux-s390@vger.kernel.org, kvm@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 v9 07/15] s390/vfio-ap: File ops called to save the vfio device migration state
Date: Tue, 13 Oct 2026 15:59:10 +0000	[thread overview]
Message-ID: <sashiko-outbox-170075@kernel.org> (raw)
In-Reply-To: <20261013153219.3534306-8-akrowiak@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] s390/vfio-ap: Undefined hardware state is used when TAPQ returns an async error
--

commit 449bfb4f03a8737bf9d26180f1c9b9cb38b82556
Author: Anthony Krowiak <akrowiak@linux.ibm.com>

s390/vfio-ap: File ops called to save the vfio device migration state

This commit implements the read callback function to save the state of the
vfio-ap device during migration. It copies the guest's AP configuration
information, including queue hardware information, to userspace.

> diff --git a/drivers/s390/crypto/vfio_ap_migration.c b/drivers/s390/crypto/vfio_ap_migration.c
> index bbd007c06a776..cf3f95e2846cb 100644
> --- a/drivers/s390/crypto/vfio_ap_migration.c
> +++ b/drivers/s390/crypto/vfio_ap_migration.c
[ ... ]
> +static int get_hardware_info_for_queue(const char *mdev_name,
> +				       struct ap_tapq_hwinfo *hwinfo,
> +				       unsigned long apqn)
> +{
> +	struct ap_queue_status status;
> +
> +	status = ap_tapq(apqn, hwinfo);
> +
> +	switch (status.response_code) {
> +	case AP_RESPONSE_NORMAL:
[ ... ]
> +	default:
> +		/*
> +		 * Without a pending async error, the tapq info should be
> +		 * available
> +		 */
> +		if (status.async)
> +			return 0;

[Severity: Medium]
When the ap_tapq function returns with an async error (status.async == 1),
both the response code and the hardware information returned in general
register 2 (hwinfo->value) are undefined.

Since we return 0 (success) here, does this cause the caller to save garbage
data into the migration stream?

Looking at the caller:

vfio_ap_store_queue_info()
    ret = get_hardware_info_for_queue(..., &source_hwinfo, ...);
    if (ret)
        return ret;
    ap_config->qinfo[num_queues].data = source_hwinfo.value;

If get_hardware_info_for_queue returns 0 when status.async is true,
source_hwinfo.value could contain uninitialized data that is then stored into
the ap_config and migrated to userspace.

Should this return an error when an async error is pending so that we don't
migrate uninitialized state data to the destination host?

> +
> +		pr_err_ratelimited("vfio_ap_mdev %s:Failed to get hwinfo for queue %02lx.%04lx: TAPQ rc=%d",
> +				   mdev_name, AP_QID_CARD(apqn), AP_QID_QUEUE(apqn),
> +				   status.response_code);
> +		return -EIO;
> +	}
> +}
[ ... ]

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

  reply	other threads:[~2026-10-13 15:59 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13 15:32 [PATCH v9 00/15] s390/vfio-ap: Add live guest migration support Anthony Krowiak
2026-10-13 15:32 ` [PATCH v9 01/15] s390/vfio-ap: Provide function to get the number of queues assigned to mdev Anthony Krowiak
2026-10-13 15:38   ` sashiko-bot
2026-10-13 15:32 ` [PATCH v9 02/15] s390/vfio-ap: Data structures for facilitating vfio device migration Anthony Krowiak
2026-10-13 15:40   ` sashiko-bot
2026-10-13 15:32 ` [PATCH v9 03/15] s390/vfio-ap: Functions to initialize/release vfio device migration data Anthony Krowiak
2026-10-13 15:47   ` sashiko-bot
2026-10-13 15:32 ` [PATCH v9 04/15] s390/vfio-ap: Reset migration state in VFIO_DEVICE_RESET ioctl handler Anthony Krowiak
2026-10-13 15:50   ` sashiko-bot
2026-10-13 15:32 ` [PATCH v9 05/15] s390/vfio-ap: Callback to get/set vfio device mig state during guest migration Anthony Krowiak
2026-10-13 15:48   ` sashiko-bot
2026-10-13 15:32 ` [PATCH v9 06/15] s390/vfio-ap: Transition guest migration state from STOP to STOP_COPY Anthony Krowiak
2026-10-13 15:55   ` sashiko-bot
2026-10-13 15:32 ` [PATCH v9 07/15] s390/vfio-ap: File ops called to save the vfio device migration state Anthony Krowiak
2026-10-13 15:59   ` sashiko-bot [this message]
2026-10-13 15:32 ` [PATCH v9 08/15] s390/vfio-ap: Transition device migration state from STOP to RESUMING Anthony Krowiak
2026-10-13 16:00   ` sashiko-bot
2026-10-13 15:32 ` [PATCH v9 09/15] s390/vfio-ap: Prepare lock helpers and matrix init for cross-file use Anthony Krowiak
2026-10-13 16:00   ` sashiko-bot
2026-10-13 15:32 ` [PATCH v9 10/15] s390/vfio-ap: Add method to set a new guest AP configuration Anthony Krowiak
2026-10-13 16:03   ` sashiko-bot
2026-10-13 15:32 ` [PATCH v9 11/15] s390/vfio-ap: File ops called to resume the vfio device migration Anthony Krowiak
2026-10-13 16:14   ` sashiko-bot
2026-10-13 15:32 ` [PATCH v9 12/15] s390/vfio-ap: Transition device migration state to from/to STOP Anthony Krowiak
2026-10-13 16:08   ` sashiko-bot
2026-10-13 15:32 ` [PATCH v9 13/15] s390/vfio-ap: Callback to get the size of data to be migrated during guest migration Anthony Krowiak
2026-10-13 16:10   ` sashiko-bot
2026-10-13 15:32 ` [PATCH v9 14/15] s390/vfio-ap: Add 'migratable' feature to sysfs 'features' attribute Anthony Krowiak
2026-10-13 16:12   ` sashiko-bot
2026-10-13 15:32 ` [PATCH v9 15/15] s390/vfio-ap: Add live guest migration chapter to vfio-ap.rst Anthony Krowiak
2026-10-13 16:10   ` 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-170075@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=akrowiak@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --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 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.