From: Tushar Dave <tdave@nvidia.com>
To: qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org, peter.maydell@linaro.org, mst@redhat.com,
marcel@redhat.com, devel@edk2.groups.io, alwilliamson@nvidia.com,
jgg@nvidia.com, skolothumtho@nvidia.com, ardb@kernel.org,
kraxel@redhat.com, clg@redhat.com, tdave@nvidia.com
Subject: [PATCH v3 5/5] hw/arm/virt: add highmem-mmio-base property
Date: Mon, 23 Nov 2026 16:11:05 -0600 [thread overview]
Message-ID: <20261123221105.37029-6-tdave@nvidia.com> (raw)
In-Reply-To: <20261123221105.37029-1-tdave@nvidia.com>
Add a highmem-mmio-base property to override the base of the virt
machine's high PCIe MMIO window, alongside the existing
highmem-mmio-size:
-machine virt,highmem-mmio-base=<addr>,highmem-mmio-size=<size>
Some PCI devices require MMIO resources to be placed within a
specific address range that cannot be satisfied by the default
placement. The configured base is validated to be non-zero, aligned
to highmem-mmio-size, non-overlapping with the existing high memory
layout, and within the configured physical address space.
Document the property in docs/system/arm/virt.rst.
Signed-off-by: Tushar Dave <tdave@nvidia.com>
---
docs/system/arm/virt.rst | 4 +++
hw/arm/virt.c | 64 +++++++++++++++++++++++++++++++++++++++-
2 files changed, 67 insertions(+), 1 deletion(-)
diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst
index 5f6dd17978..7ae51bee13 100644
--- a/docs/system/arm/virt.rst
+++ b/docs/system/arm/virt.rst
@@ -152,6 +152,10 @@ highmem-mmio-size
Set the high memory region size for PCI MMIO. Must be a power of 2 and
greater than or equal to the default size (512G).
+highmem-mmio-base
+ Set the high memory region base for PCI MMIO. Must be non-zero and
+ aligned to ``highmem-mmio-size``.
+
gic-version
Specify the version of the Generic Interrupt Controller (GIC) to provide.
Valid values are:
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index dc487f9ea0..ab34d1ab05 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -2522,14 +2522,40 @@ static void virt_set_high_memmap(VirtMachineState *vms,
hwaddr base, int pa_bits)
{
hwaddr region_base, region_size;
+ hwaddr pa_limit = BIT_ULL(pa_bits);
bool *region_enabled, fits;
int i;
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 && extended_memmap[i].base) {
+ region_base = extended_memmap[i].base;
+
+ if (region_base < base) {
+ error_report("highmem-mmio-base 0x%"PRIx64" overlaps prior "
+ "high memory layout (must be >= 0x%"PRIx64")",
+ region_base, base);
+ exit(1);
+ }
+ if (region_base % region_size != 0) {
+ error_report("highmem-mmio-base 0x%"PRIx64" must be "
+ "aligned to highmem-mmio-size 0x%"PRIx64,
+ region_base, region_size);
+ exit(1);
+ }
+ if (region_base >= pa_limit ||
+ region_size > pa_limit - region_base) {
+ error_report("highmem-mmio-base 0x%"PRIx64" + "
+ "highmem-mmio-size 0x%"PRIx64" exceeds %d-bit "
+ "PA space", region_base, region_size, pa_bits);
+ exit(1);
+ }
+ } else {
+ region_base = ROUND_UP(base, region_size);
+ }
+
vms->memmap[i].base = region_base;
vms->memmap[i].size = region_size;
@@ -3430,6 +3456,33 @@ static void virt_set_highmem_mmio_size(Object *obj, Visitor *v,
extended_memmap[VIRT_HIGH_PCIE_MMIO].size = size;
}
+static void virt_get_highmem_mmio_base(Object *obj, Visitor *v,
+ const char *name, void *opaque,
+ Error **errp)
+{
+ uint64_t base = extended_memmap[VIRT_HIGH_PCIE_MMIO].base;
+
+ visit_type_size(v, name, &base, errp);
+}
+
+static void virt_set_highmem_mmio_base(Object *obj, Visitor *v,
+ const char *name, void *opaque,
+ Error **errp)
+{
+ uint64_t base;
+
+ if (!visit_type_size(v, name, &base, errp)) {
+ return;
+ }
+
+ if (base == 0) {
+ error_setg(errp, "highmem-mmio-base cannot be 0");
+ return;
+ }
+
+ extended_memmap[VIRT_HIGH_PCIE_MMIO].base = base;
+}
+
static char *virt_get_msi(Object *obj, Error **errp)
{
VirtMachineState *vms = VIRT_MACHINE(obj);
@@ -4297,6 +4350,15 @@ static void virt_machine_class_init(ObjectClass *oc, const void *data)
"Set the high memory region size "
"for PCI MMIO");
+ object_class_property_add(oc, "highmem-mmio-base", "size",
+ &size_type_info,
+ virt_get_highmem_mmio_base,
+ virt_set_highmem_mmio_base,
+ NULL, NULL);
+ object_class_property_set_description(oc, "highmem-mmio-base",
+ "Set the high memory region base "
+ "for PCI MMIO");
+
object_class_property_add(oc, "virtio-mmio-transports", "uint8",
&uint8_type_info,
virt_get_virtio_transports,
--
2.34.1
prev parent reply other threads:[~2026-11-23 22:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 22:11 [PATCH v3 0/5] hw/pci, hw/arm/virt: fixed PCI BAR placement Tushar Dave
2026-11-23 22:11 ` [PATCH v3 1/5] hw/pci: introduce PCI fixed BAR properties Tushar Dave
2026-11-23 22:11 ` [PATCH v3 2/5] hw/pci: add validation for fixed BAR configuration Tushar Dave
2026-11-23 22:11 ` [PATCH v3 3/5] hw/pci: describe fixed BARs with an Enhanced Allocation capability Tushar Dave
2026-11-23 22:11 ` [PATCH v3 4/5] hw/arm/virt: validate fixed BARs and preserve the PCI configuration Tushar Dave
2026-11-23 22:11 ` Tushar Dave [this message]
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=20261123221105.37029-6-tdave@nvidia.com \
--to=tdave@nvidia.com \
--cc=alwilliamson@nvidia.com \
--cc=ardb@kernel.org \
--cc=clg@redhat.com \
--cc=devel@edk2.groups.io \
--cc=jgg@nvidia.com \
--cc=kraxel@redhat.com \
--cc=marcel@redhat.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.