From: Tomita Moeko <tomitamoeko@gmail.com>
To: "Alex Williamson" <alex.williamson@redhat.com>,
"Cédric Le Goater" <clg@redhat.com>,
"Tomita Moeko" <tomitamoeko@gmail.com>
Cc: qemu-devel@nongnu.org, "Corvin Köhne" <c.koehne@beckhoff.com>
Subject: [PATCH v3 2/9] vfio/igd: Always emulate ASLS (OpRegion) register
Date: Tue, 6 May 2025 01:02:58 +0800 [thread overview]
Message-ID: <20250505170305.23622-3-tomitamoeko@gmail.com> (raw)
In-Reply-To: <20250505170305.23622-1-tomitamoeko@gmail.com>
ASLS register represents the base address of OpRegion, and it is
programmed with HPA. In IGD passthrough scenario, it needs to be
reprogrammed with GPA by guest firmware. To prevent guest accessing
wrong memory range, ASLS should always be emulated and cleared.
In GVT-g scenario, emulating ASLS is unnecessary as access is handled
by kvmgt backend [1].
[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/i915/gvt/cfg_space.c?h=v6.14#n295
Signed-off-by: Tomita Moeko <tomitamoeko@gmail.com>
---
hw/vfio/igd.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c
index e06484c911..b1fce76f72 100644
--- a/hw/vfio/igd.c
+++ b/hw/vfio/igd.c
@@ -182,10 +182,6 @@ static bool vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev,
trace_vfio_pci_igd_opregion_enabled(vdev->vbasedev.name);
- pci_set_long(vdev->pdev.config + IGD_ASLS, 0);
- pci_set_long(vdev->pdev.wmask + IGD_ASLS, ~0);
- pci_set_long(vdev->emulated_config_bits + IGD_ASLS, ~0);
-
return true;
}
@@ -584,7 +580,15 @@ static bool vfio_pci_igd_config_quirk(VFIOPCIDevice *vdev, Error **errp)
if ((vdev->features & VFIO_FEATURE_ENABLE_IGD_LPC) &&
!vfio_pci_igd_setup_lpc_bridge(vdev, errp)) {
goto error;
- }
+ }
+
+ /*
+ * ASLS (OpRegion address) is read-only, emulated
+ * It contains HPA, guest firmware need to reprogram it with GPA.
+ */
+ pci_set_long(vdev->pdev.config + IGD_ASLS, 0);
+ pci_set_long(vdev->pdev.wmask + IGD_ASLS, ~0);
+ pci_set_long(vdev->emulated_config_bits + IGD_ASLS, ~0);
/*
* Allow user to override dsm size using x-igd-gms option, in multiples of
--
2.47.2
next prev parent reply other threads:[~2025-05-05 17:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-05 17:02 [PATCH v3 0/9] vfio/igd: Detect IGD by OpRegion and enable OpRegion automatically Tomita Moeko
2025-05-05 17:02 ` [PATCH v3 1/9] vfio/igd: Restrict legacy mode to Gen6-9 devices Tomita Moeko
2025-05-05 17:02 ` Tomita Moeko [this message]
2025-05-05 17:02 ` [PATCH v3 3/9] vfio/igd: Detect IGD device by OpRegion Tomita Moeko
2025-05-05 17:03 ` [PATCH v3 4/9] vfio/igd: Check vendor and device ID on GVT-g mdev Tomita Moeko
2025-05-05 17:03 ` [PATCH v3 5/9] vfio/igd: Check OpRegion support " Tomita Moeko
2025-05-05 17:03 ` [PATCH v3 6/9] vfio/igd: Enable OpRegion by default Tomita Moeko
2025-05-05 17:03 ` [PATCH v3 7/9] vfio/igd: Allow overriding GMS with 0xf0 to 0xfe on Gen9+ Tomita Moeko
2025-05-05 17:03 ` [PATCH v3 8/9] vfio/igd: Only emulate GGC register when x-igd-gms is set Tomita Moeko
2025-05-05 17:03 ` [PATCH v3 9/9] vfio/igd: Remove generation limitation for IGD passthrough Tomita Moeko
2025-05-05 20:58 ` [PATCH v3 0/9] vfio/igd: Detect IGD by OpRegion and enable OpRegion automatically Cédric Le Goater
2025-05-06 6:58 ` Cédric Le Goater
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=20250505170305.23622-3-tomitamoeko@gmail.com \
--to=tomitamoeko@gmail.com \
--cc=alex.williamson@redhat.com \
--cc=c.koehne@beckhoff.com \
--cc=clg@redhat.com \
--cc=qemu-devel@nongnu.org \
/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;
as well as URLs for NNTP newsgroup(s).