From: Tushar Dave <tdave@nvidia.com>
To: qemu-devel@nongnu.org
Cc: alwilliamson@nvidia.com, jgg@nvidia.com, skolothumtho@nvidia.com,
qemu-arm@nongnu.org, peter.maydell@linaro.org, mst@redhat.com,
marcel.apfelbaum@gmail.com, devel@edk2.groups.io
Subject: [RFC PATCH 7/8] hw/arm/virt: add pcie-mmio-window machine property
Date: Fri, 8 May 2026 13:37:16 -0500 [thread overview]
Message-ID: <20260508183717.193630-8-tdave@nvidia.com> (raw)
In-Reply-To: <20260508183717.193630-1-tdave@nvidia.com>
Introduce a machine property to explicitly set the high PCIe MMIO
window as BASE:SIZE, and apply it in the high memory map.
Usage:
-machine pcie-mmio-window=0x400000000000:0x400000000000
When using the fixed-bars property to assign guest physical
addresses to PCI BARs, those addresses must fall within the
machine's MMIO64 window. The default aperture may be too small
or not cover the required range.
This property allows the aperture to be resized or repositioned
so that all fixed BAR addresses are accessible to the guest.
Signed-off-by: Tushar Dave <tdave@nvidia.com>
---
hw/arm/virt.c | 87 ++++++++++++++++++++++++++++++++++++++++++-
include/hw/arm/virt.h | 2 +
2 files changed, 87 insertions(+), 2 deletions(-)
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index ec0d8475ca..55f41c7e46 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -1915,8 +1915,31 @@ static void virt_set_high_memmap(VirtMachineState *vms,
for (i = VIRT_LOWMEMMAP_LAST; i < ARRAY_SIZE(extended_memmap); i++) {
region_enabled = virt_get_high_memmap_enabled(vms, i);
- region_base = ROUND_UP(base, extended_memmap[i].size);
- region_size = extended_memmap[i].size;
+
+ if (i == VIRT_HIGH_PCIE_MMIO && vms->override_pcie_mmio_size) {
+ region_base = vms->override_pcie_mmio_base;
+ region_size = vms->override_pcie_mmio_size;
+
+ /* Check for overlap with prior high regions */
+ if (region_base < base) {
+ error_report("pcie-mmio-window base 0x%" PRIx64 " overlaps "
+ "high memory layout (must be >= 0x%" PRIx64 ")",
+ (uint64_t)region_base, (uint64_t)base);
+ exit(1);
+ }
+ /* Must not exceed the PA space */
+ if (region_base + region_size > BIT_ULL(pa_bits)) {
+ error_report("pcie-mmio-window [0x%" PRIx64 ", 0x%" PRIx64 ") "
+ "exceeds %d-bit PA space",
+ (uint64_t)region_base,
+ (uint64_t)(region_base + region_size),
+ pa_bits);
+ exit(1);
+ }
+ } else {
+ region_base = ROUND_UP(base, extended_memmap[i].size);
+ region_size = extended_memmap[i].size;
+ }
vms->memmap[i].base = region_base;
vms->memmap[i].size = region_size;
@@ -3004,6 +3027,60 @@ static void virt_set_gic_version(Object *obj, const char *value, Error **errp)
}
}
+static char *virt_get_pcie_mmio_window(Object *obj, Error **errp)
+{
+ VirtMachineState *vms = VIRT_MACHINE(obj);
+
+ if (!vms->override_pcie_mmio_size) {
+ return g_strdup("");
+ }
+ return g_strdup_printf("0x%" PRIx64 ":0x%" PRIx64,
+ (uint64_t)vms->override_pcie_mmio_base,
+ (uint64_t)vms->override_pcie_mmio_size);
+}
+
+static void virt_set_pcie_mmio_window(Object *obj, const char *value, Error **errp)
+{
+ VirtMachineState *vms = VIRT_MACHINE(obj);
+ uint64_t base = 0, size = 0;
+ const char *endptr;
+ int ret;
+
+ if (!value || !*value) {
+ return;
+ }
+
+ ret = qemu_strtou64(value, &endptr, 0, &base);
+ if (ret || base == 0) {
+ error_setg(errp, "pcie-mmio-window base must be a positive number");
+ return;
+ }
+ if (*endptr != ':' || !*(endptr + 1)) {
+ error_setg(errp, "pcie-mmio-window expects BASE:SIZE");
+ return;
+ }
+
+ ret = qemu_strtou64(endptr + 1, NULL, 0, &size);
+ if (ret || size == 0) {
+ error_setg(errp, "pcie-mmio-window size must be a positive number");
+ return;
+ }
+
+ if (!is_power_of_2(size)) {
+ error_setg(errp, "pcie-mmio-window size 0x%" PRIx64 " must be a power of 2",
+ (uint64_t)size);
+ return;
+ }
+ if (base % size != 0) {
+ error_setg(errp, "pcie-mmio-window base 0x%" PRIx64 " must be aligned to size 0x%" PRIx64,
+ (uint64_t)base, (uint64_t)size);
+ return;
+ }
+
+ vms->override_pcie_mmio_base = base;
+ vms->override_pcie_mmio_size = size;
+}
+
static char *virt_get_iommu(Object *obj, Error **errp)
{
VirtMachineState *vms = VIRT_MACHINE(obj);
@@ -3582,6 +3659,12 @@ static void virt_machine_class_init(ObjectClass *oc, const void *data)
"Set the IOMMU type. "
"Valid values are none and smmuv3");
+ object_class_property_add_str(oc, "pcie-mmio-window",
+ virt_get_pcie_mmio_window,
+ virt_set_pcie_mmio_window);
+ object_class_property_set_description(oc, "pcie-mmio-window",
+ "Override the high PCIe MMIO window as BASE:SIZE");
+
object_class_property_add_bool(oc, "default-bus-bypass-iommu",
virt_get_default_bus_bypass_iommu,
virt_set_default_bus_bypass_iommu);
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
index 5fcbd1c76f..410df857c7 100644
--- a/include/hw/arm/virt.h
+++ b/include/hw/arm/virt.h
@@ -187,6 +187,8 @@ struct VirtMachineState {
MemoryRegion *sysmem;
MemoryRegion *secure_sysmem;
bool pci_preserve_config;
+ hwaddr override_pcie_mmio_base;
+ hwaddr override_pcie_mmio_size;
};
#define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM)
--
2.34.1
next prev parent reply other threads:[~2026-05-08 20:43 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 18:37 [RFC PATCH 0/8] hw/arm/virt, hw/pci: PCI pre-enumeration and fixed BAR allocation Tushar Dave
2026-05-08 18:37 ` [RFC PATCH 1/8] hw/pci: add fixed-bars property to allow fixed BAR addresses Tushar Dave
2026-05-08 18:37 ` [RFC PATCH 2/8] hw/pci: enumerate PCI bus and program bridge bus numbers Tushar Dave
2026-05-08 18:37 ` [RFC PATCH 3/8] hw/pci: introduce allocator for fixed BAR placement Tushar Dave
2026-05-08 18:37 ` [RFC PATCH 4/8] hw/pci: pack remaining BARs and update bridge windows Tushar Dave
2026-05-08 18:37 ` [RFC PATCH 5/8] hw/pci: allocate remaining BARs for buses without fixed BARs Tushar Dave
2026-05-08 18:37 ` [RFC PATCH 6/8] hw/pci: finalize bridge prefetch windows after BAR allocation Tushar Dave
2026-05-08 18:37 ` Tushar Dave [this message]
2026-05-08 18:37 ` [RFC PATCH 8/8] hw/arm/virt: add pci-pre-enum machine property Tushar Dave
2026-05-11 7:46 ` [RFC PATCH 0/8] hw/arm/virt, hw/pci: PCI pre-enumeration and fixed BAR allocation Peter Maydell
2026-05-11 12:26 ` Jason Gunthorpe
2026-05-11 18:38 ` Mohamed Mediouni
2026-05-11 20:28 ` Jason Gunthorpe
2026-05-11 9:09 ` Michael S. Tsirkin
2026-05-11 18:10 ` Tushar Dave
2026-05-11 22:09 ` Michael S. Tsirkin
2026-05-11 11:43 ` [edk2-devel] " Ard Biesheuvel
2026-05-12 17:25 ` Tushar Dave
2026-05-12 23:06 ` Alex Williamson
2026-05-12 23:12 ` Michael S. Tsirkin
2026-05-12 23:57 ` Alex Williamson
2026-05-13 11:36 ` Jason Gunthorpe
2026-05-13 14:25 ` Ard Biesheuvel
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=20260508183717.193630-8-tdave@nvidia.com \
--to=tdave@nvidia.com \
--cc=alwilliamson@nvidia.com \
--cc=devel@edk2.groups.io \
--cc=jgg@nvidia.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=skolothumtho@nvidia.com \
/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.