From: liulongfang <liulongfang@huawei.com>
To: <sashiko-reviews@lists.linux.dev>
Cc: <kvm@vger.kernel.org>
Subject: Re: [PATCH v3 3/3] hisi_acc_vfio_pci: reject live migration on 64KB page with QM_HW_V3 hardware
Date: Fri, 11 Sep 2026 16:02:14 +0800 [thread overview]
Message-ID: <7e77dab0-ede4-527c-e5ec-9056f48ecd73@huawei.com> (raw)
In-Reply-To: <20260831100023.0155B1F000E9@smtp.kernel.org>
On 2026/8/31 18:00, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] The patch completely breaks VFIO passthrough for this device on 64KB page hosts instead of gracefully falling back to generic operations.
> --
>
> commit e0bfdb6998df9e209e0b7358693ec17f21c25bfe
> Author: Longfang Liu <liulongfang@huawei.com>
>
> hisi_acc_vfio_pci: reject live migration on 64KB page with QM_HW_V3 hardware
>
> This commit aims to prevent security vulnerabilities and guest exceptions when
> combining QM_HW_V3 hardware with 64KB pages by disabling live migration. It
> returns -EINVAL during device initialization if the host page size exceeds
> 32KB.
>
>> diff --git a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c
>> index 4abed2e49986f..4f12cab96545e 100644
>> --- a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c
>> +++ b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c
>> @@ -1210,6 +1210,23 @@ static int hisi_acc_vf_qm_init(struct hisi_acc_vf_core_device *hisi_acc_vdev)
>> else
>> hisi_acc_vdev->drv_mode = HW_ACC_MIG_VF_CTRL;
>>
>> + /*
>> + * On VF_CTRL hardware, BAR2 holds 32KB functional + 32KB
>> + * migration registers. When the host page exceeds 32KB, the
>> + * two share one physical page and cannot be isolated by mmap.
>> + * Reject the open so QEMU fails cleanly at startup.
>> + */
>> + if (hisi_acc_vdev->drv_mode == HW_ACC_MIG_VF_CTRL) {
>> + resource_size_t func_len =
>> + pci_resource_len(vf_dev, VFIO_PCI_BAR2_REGION_INDEX) >> 1;
>> +
>> + if (func_len < PAGE_SIZE) {
>> + dev_err(&vf_dev->dev,
>> + "migration not supported on 64KB pages with QM_HW_V3\n");
>> + return -EINVAL;
>
> [Severity: High]
> Does returning an error here completely break VFIO passthrough for this device
> on 64KB page hosts?
>
> Since hisi_acc_vf_qm_init() is called during device open, returning an error
> causes the entire operation to fail. This results in users completely losing
> passthrough functionality for QM_HW_V3 devices on 64KB page hosts, rather
> than just having migration gracefully disabled.
>
> Could this be handled earlier in hisi_acc_vfio_pci_probe() instead?
>
> The driver currently assigns migration operations unconditionally:
>
> drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c:hisi_acc_vfio_pci_probe() {
> ...
> if (pf_qm && pf_qm->ver >= QM_HW_V3) {
> if (pdev->is_virtfn)
> ops = &hisi_acc_vfio_pci_migrn_ops;
> ...
> }
>
> If the 64KB page limitation was checked during probe and fell back to the
> generic ops instead, normal passthrough would continue to work correctly.
> The generic VFIO implementation safely maps the entire BAR2 region without
> KVM trap-and-emulate issues.
>
Our goal is precisely to disable live migration for passthrough on 64KB page systems.
Thanks
Longfang
>> + }
>> + }
>> +
>> if (hisi_acc_vdev->drv_mode == HW_ACC_MIG_PF_CTRL) {
>> /*
>> * On hardware platforms greater than QM_HW_V3, the migration function
>
next prev parent reply other threads:[~2026-09-11 8:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 9:09 [PATCH v3 0/3] hisi_acc_vfio_pci: fix three driver issues Longfang Liu
2026-08-31 9:09 ` [PATCH v3 1/3] hisi_acc_vfio_pci: fix live migration enable conditions for PF passthrough Longfang Liu
2026-08-31 9:35 ` sashiko-bot
2026-09-11 8:14 ` liulongfang
2026-09-11 17:37 ` Alex Williamson
2026-08-31 9:09 ` [PATCH v3 2/3] hisi_acc_vfio_pci: clear set_reset_flag after reset completed Longfang Liu
2026-08-31 9:46 ` sashiko-bot
2026-09-11 8:07 ` liulongfang
2026-08-31 9:09 ` [PATCH v3 3/3] hisi_acc_vfio_pci: reject live migration on 64KB page with QM_HW_V3 hardware Longfang Liu
2026-08-31 10:00 ` sashiko-bot
2026-09-11 8:02 ` liulongfang [this message]
2026-09-11 17:37 ` Alex Williamson
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=7e77dab0-ede4-527c-e5ec-9056f48ecd73@huawei.com \
--to=liulongfang@huawei.com \
--cc=kvm@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.