All of lore.kernel.org
 help / color / mirror / Atom feed
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 4/5] hw/arm/virt: validate fixed BARs and preserve the PCI configuration
Date: Mon, 23 Nov 2026 16:11:04 -0600	[thread overview]
Message-ID: <20261123221105.37029-5-tdave@nvidia.com> (raw)
In-Reply-To: <20261123221105.37029-1-tdave@nvidia.com>

Validate the fixed BAR configuration with fixed_bars_check() and set
pci_fixed_bar_supported to allow the fixed-bar-N properties on the virt
machine.

Fixed BAR placement requires the guest to preserve the PCI resource
configuration established by firmware, preventing the fixed BAR
addresses from being reassigned during guest boot. ACPI provides
this through the PCI boot configuration preservation mechanism
(_DSM function 5).

Reject fixed BAR configuration if firmware is not loaded or ACPI
is disabled, since PCI boot configuration preservation cannot
otherwise be guaranteed.

Signed-off-by: Tushar Dave <tdave@nvidia.com>
---
 hw/arm/virt.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 0b11f7e328..dc487f9ea0 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -94,6 +94,7 @@
 #include "hw/cxl/cxl_host.h"
 #include "qemu/guest-random.h"
 #include "hw/watchdog/sbsa_gwdt.h"
+#include "hw/pci/pci-fixed-bar.h"
 
 static GlobalProperty arm_virt_compat_defaults[] = {
     { TYPE_VIRTIO_IOMMU_PCI, "aw-bits", "48" },
@@ -2451,6 +2452,22 @@ void virt_machine_done(Notifier *notifier, void *data)
                                        vms->memmap[VIRT_PLATFORM_BUS].size,
                                        vms->irqmap[VIRT_PLATFORM_BUS]);
     }
+    if (fixed_bars_check(vms->memmap[VIRT_PCIE_MMIO].base,
+                         vms->memmap[VIRT_PCIE_MMIO].size,
+                         vms->memmap[VIRT_HIGH_PCIE_MMIO].base,
+                         vms->highmem_mmio ?
+                         vms->memmap[VIRT_HIGH_PCIE_MMIO].size : 0,
+                         &error_fatal)) {
+        if (!(vms->bootinfo.firmware_loaded && virt_is_acpi_enabled(vms))) {
+            error_report("fixed-bar: fixed BAR placement requires firmware "
+                         "and ACPI to preserve the PCI boot configuration, "
+                         "otherwise these BAR assignments could be "
+                         "reassigned later with no protection");
+            exit(1);
+        }
+        vms->pci_preserve_config = true;
+    }
+
     if (arm_load_dtb(info->dtb_start, info, info->dtb_limit, as, ms, cpu) < 0) {
         exit(1);
     }
@@ -4203,6 +4220,7 @@ static void virt_machine_class_init(ObjectClass *oc, const void *data)
     hc->unplug_request = virt_machine_device_unplug_request_cb;
     hc->unplug = virt_machine_device_unplug_cb;
     mc->nvdimm_supported = true;
+    mc->pci_fixed_bar_supported = true;
     mc->smp_props.clusters_supported = true;
 
     /* Supported caches */
-- 
2.34.1



  parent reply	other threads:[~2026-11-23 22:12 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 ` Tushar Dave [this message]
2026-11-23 22:11 ` [PATCH v3 5/5] hw/arm/virt: add highmem-mmio-base property Tushar Dave

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-5-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.