From: Anthony Krowiak <akrowiak@linux.ibm.com>
To: sashiko-reviews@lists.linux.dev, 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>,
Jason Herne <jjherne@linux.ibm.com>,
Matthew Rosato <mjrosato@linux.ibm.com>
Subject: Re: [PATCH v10 03/15] s390/vfio-ap: Functions to initialize/release vfio device migration data
Date: Mon, 26 Oct 2026 10:04:24 -0400 [thread overview]
Message-ID: <b544c525-f13e-4fde-a98a-3e41f1827ca3@linux.ibm.com> (raw)
In-Reply-To: <sashiko-outbox-183045@kernel.org>
On 10/23/26 2:09 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] s390/vfio-ap: ap_is_se_guest() checks host in vfio_ap_init_migration_data()
> --
>
> commit 79c297f4ef408f423e0eed3174df28dca4e407f2
> Author: Anthony Krowiak <akrowiak@linux.ibm.com>
>
> s390/vfio-ap: Functions to initialize/release vfio device migration data
>
> This patch adds helper functions to allocate, initialize, and release the
> vfio_ap_migration_data structure and its associated migration file state
> when a vfio_ap mediated device is opened, closed, or released.
>
>> diff --git a/drivers/s390/crypto/vfio_ap_migration.c b/drivers/s390/crypto/vfio_ap_migration.c
>> index f01a37e4c418f..ba86a1afbb332 100644
>> --- a/drivers/s390/crypto/vfio_ap_migration.c
>> +++ b/drivers/s390/crypto/vfio_ap_migration.c
> [ ... ]
>
>> +int vfio_ap_init_migration_data(struct ap_matrix_mdev *matrix_mdev)
>> +{
>> + struct vfio_ap_migration_data *mig_data;
>> +
>> + lockdep_assert_held(&matrix_dev->mdevs_lock);
>> +
>> + /*
>> + * Live guest migration is not supported for SE guests, so there is no
>> + * need to initialize the migration data.
>> + */
>> + if (ap_is_se_guest())
>> + return 0;
> [Severity: Medium]
> Does ap_is_se_guest() check the right entity here when called via
> vfio_ap_mdev_open_device() -> vfio_ap_init_migration_data()?
>
> In drivers/s390/crypto/ap_bus.c, ap_is_se_guest() is defined as:
>
> bool ap_is_se_guest(void)
> {
> return is_prot_virt_guest() && ap_sb_available();
> }
>
> That helper checks whether the currently running kernel itself is executing as
> a Protected Virtualization (Secure Execution) guest, rather than checking
> whether the target KVM guest attached to the mediated device is an SE guest.
> Because vfio_ap runs on the KVM host where is_prot_virt_guest() is false,
> ap_is_se_guest() will always evaluate to false here and matrix_mdev->mig_data
> will still be allocated and initialized for SE guests.
>
> Additionally, vfio_ap_init_migration_data() is called from
> vfio_ap_mdev_open_device() when userspace first opens the VFIO device (and
> before vfio_ap_mdev_set_kvm() sets matrix_mdev->kvm), whereas an s390 KVM
> guest only transitions into Protected Virtualization mode later when the guest
> executes DIAG 308 subcode 8 or 10. Can the SE guest check be performed when a
> migration state transition is requested via kvm_s390_pv_is_protected(), rather
> than during device open?
It is true that ap_is_se_guest() checks only whether the host kernel
itself is
running as a Secure Execution guest; it does not check whether the KVM
guest
attached to the mdev is protected. However, when the host kernel is an
SE guest,
the AP hardware queues are bound to that SE host under UV control. The
AP queue
state on an SE host is protected memory and cannot be extracted and
transmitted
to a destination host, so live guest migration of vfio-ap devices is not
possible from such a host regardless of whether any particular KVM guest is
also running under SE. The ap_is_se_guest() guard in
vfio_ap_setup_vfio_device_migration() and vfio_ap_init_migration_data() is
checking the right entity for the right reason.
The existing uses of ap_is_se_guest() in ap_queue.c (e.g. the secure binding
path) follow the same pattern — they gate AP subsystem behavior on the
host's
own SE status, not on any KVM guest's status. The features_show()
function in
vfio_ap_drv.c omits the migration feature token on SE hosts for the same
reason.
>
next prev parent reply other threads:[~2026-10-26 14:04 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 17:43 [PATCH v10 00/15] s390/vfio-ap: Add live guest migration support Anthony Krowiak
2026-10-23 17:43 ` [PATCH v10 01/15] s390/vfio-ap: Provide function to get the number of queues assigned to mdev Anthony Krowiak
2026-10-23 17:43 ` [PATCH v10 02/15] s390/vfio-ap: Data structures for facilitating vfio device migration Anthony Krowiak
2026-10-23 17:43 ` [PATCH v10 03/15] s390/vfio-ap: Functions to initialize/release vfio device migration data Anthony Krowiak
2026-10-23 18:09 ` sashiko-bot
2026-10-26 14:04 ` Anthony Krowiak [this message]
2026-10-24 7:11 ` kernel test robot
2026-10-26 14:08 ` Anthony Krowiak
2026-10-23 17:43 ` [PATCH v10 04/15] s390/vfio-ap: Reset migration state in VFIO_DEVICE_RESET ioctl handler Anthony Krowiak
2026-10-23 17:43 ` [PATCH v10 05/15] s390/vfio-ap: Callback to get/set vfio device mig state during guest migration Anthony Krowiak
2026-10-23 17:43 ` [PATCH v10 06/15] s390/vfio-ap: Transition guest migration state from STOP to STOP_COPY Anthony Krowiak
2026-10-23 17:43 ` [PATCH v10 07/15] s390/vfio-ap: File ops called to save the vfio device migration state Anthony Krowiak
2026-10-23 18:10 ` sashiko-bot
2026-10-23 17:43 ` [PATCH v10 08/15] s390/vfio-ap: Transition device migration state from STOP to RESUMING Anthony Krowiak
2026-10-23 17:43 ` [PATCH v10 09/15] s390/vfio-ap: Prepare lock helpers and matrix init for cross-file use Anthony Krowiak
2026-10-23 17:43 ` [PATCH v10 10/15] s390/vfio-ap: File ops called to resume the vfio device migration Anthony Krowiak
2026-10-23 18:15 ` sashiko-bot
2026-10-23 17:43 ` [PATCH v10 11/15] s390/vfio-ap: Transition device migration state to from/to STOP Anthony Krowiak
2026-10-23 18:13 ` sashiko-bot
2026-10-23 17:43 ` [PATCH v10 12/15] s390/vfio-ap: Callback to get the size of data to be migrated during guest migration Anthony Krowiak
2026-10-23 17:43 ` [PATCH v10 13/15] s390/vfio-ap: Set up for vfio-ap device migration Anthony Krowiak
2026-10-23 18:14 ` sashiko-bot
2026-10-23 17:43 ` [PATCH v10 14/15] s390/vfio-ap: Add 'migration' feature to sysfs 'features' attribute Anthony Krowiak
2026-10-23 18:06 ` sashiko-bot
2026-10-23 17:43 ` [PATCH v10 15/15] s390/vfio-ap: Add live guest migration chapter to vfio-ap.rst Anthony Krowiak
2026-10-23 18:09 ` 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=b544c525-f13e-4fde-a98a-3e41f1827ca3@linux.ibm.com \
--to=akrowiak@linux.ibm.com \
--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=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mjrosato@linux.ibm.com \
--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