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 03/15] s390/vfio-ap: Functions to initialize/release vfio device migration data
Date: Tue, 13 Oct 2026 15:47:03 +0000 [thread overview]
Message-ID: <sashiko-outbox-170040@kernel.org> (raw)
In-Reply-To: <20261013153219.3534306-4-akrowiak@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] s390/vfio-ap: Data race on matrix_dev->info during mdev init
--
commit 61bb5cee71d03ac3e82343abe74a853a264da523
Author: Anthony Krowiak <akrowiak@linux.ibm.com>
s390/vfio-ap: Functions to initialize/release vfio device migration data
Provides the functions that initialize and release the data structures
used during live guest migration.
> diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
> index 01439f0ca42ab..6829e423b5a46 100644
> --- a/drivers/s390/crypto/vfio_ap_ops.c
> +++ b/drivers/s390/crypto/vfio_ap_ops.c
> @@ -782,18 +782,30 @@ static bool vfio_ap_mdev_filter_matrix(struct ap_matrix_mdev *matrix_mdev,
>
> static int vfio_ap_mdev_init_dev(struct vfio_device *vdev)
> {
> - struct ap_matrix_mdev *matrix_mdev =
> - container_of(vdev, struct ap_matrix_mdev, vdev);
> + struct ap_matrix_mdev *matrix_mdev;
>
> + mutex_lock(&matrix_dev->mdevs_lock);
> + matrix_mdev = container_of(vdev, struct ap_matrix_mdev, vdev);
> matrix_mdev->mdev = to_mdev_device(vdev->dev);
> vfio_ap_matrix_init(&matrix_dev->info, &matrix_mdev->matrix);
[Severity: Medium]
Could this result in a data race on matrix_dev->info?
The modified vfio_ap_mdev_init_dev() reads matrix_dev->info via
vfio_ap_matrix_init() while holding only matrix_dev->mdevs_lock.
However, vfio_ap_on_cfg_changed() updates matrix_dev->info via memcpy()
while holding only matrix_dev->guests_lock:
drivers/s390/crypto/vfio_ap_ops.c:vfio_ap_on_cfg_changed() {
...
memcpy(&matrix_dev->info, cur_cfg_info, sizeof(*cur_cfg_info));
...
}
Since memcpy() is not atomic and the two functions acquire different locks,
can a concurrent AP configuration change cause vfio_ap_mdev_init_dev()
to read a torn or partially updated ap_config_info struct, potentially
leading to incorrect apm_max, aqm_max, or adm_max values?
Note that follow-up patches in the series do not resolve this lock mismatch.
> matrix_mdev->pqap_hook = handle_pqap;
> vfio_ap_matrix_init(&matrix_dev->info, &matrix_mdev->shadow_apcb);
> hash_init(matrix_mdev->qtable.queues);
> + mutex_unlock(&matrix_dev->mdevs_lock);
>
> return 0;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261013153219.3534306-1-akrowiak@linux.ibm.com?part=3
next prev parent reply other threads:[~2026-10-13 15:47 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 [this message]
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
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-170040@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox