[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 05/23] q35: Fix incorrect values for PCIEXBAR masks
From: |
Joel Upham |
Subject: |
[PATCH v1 05/23] q35: Fix incorrect values for PCIEXBAR masks |
Date: |
Tue, 20 Jun 2023 13:24:39 -0400 |
There are two small issues in PCIEXBAR address mask handling:
- wrong bit positions for address mask bits (see PCIEXBAR description
in Q35 datasheet)
- incorrect usage of 64ADR_MASK
Due to this, attempting to write a valid PCIEXBAR address may cause it to
shift to another address, causing memory layout corruption where emulated
MMIO regions may overlap real (passed through) MMIO ranges. Fix this
by providing correct values.
I included the xen_enabled() check as I did not want to impact current
use cases that are not xen related (if they are not seeing a problem).
Signed-off-by: Alexey Gerasimenko <x1917x@xxxxxxxxx>
Signed-off-by: Joel Upham <jupham125@gmail.com>
---
hw/pci-host/q35.c | 16 +++++++++++++---
include/hw/pci-host/q35.h | 4 ++--
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index fe5fc0f47c..1fe4e5a5c9 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -37,6 +37,7 @@
#include "qapi/error.h"
#include "qapi/visitor.h"
#include "qemu/module.h"
+#include "sysemu/xen.h"
/****************************************************************************
* Q35 host
@@ -324,12 +325,21 @@ static void mch_update_pciexbar(MCHPCIState *mch)
break;
case MCH_HOST_BRIDGE_PCIEXBAR_LENGTH_128M:
length = 128 * 1024 * 1024;
- addr_mask |= MCH_HOST_BRIDGE_PCIEXBAR_128ADMSK |
- MCH_HOST_BRIDGE_PCIEXBAR_64ADMSK;
+ if (!xen_enabled()) {
+ addr_mask |= MCH_HOST_BRIDGE_PCIEXBAR_128ADMSK |
+ MCH_HOST_BRIDGE_PCIEXBAR_64ADMSK;
+ } else {
+ addr_mask |= MCH_HOST_BRIDGE_PCIEXBAR_128ADMSK;
+ }
break;
case MCH_HOST_BRIDGE_PCIEXBAR_LENGTH_64M:
length = 64 * 1024 * 1024;
- addr_mask |= MCH_HOST_BRIDGE_PCIEXBAR_64ADMSK;
+ if (!xen_enabled()) {
+ addr_mask |= MCH_HOST_BRIDGE_PCIEXBAR_64ADMSK;
+ } else {
+ addr_mask |= MCH_HOST_BRIDGE_PCIEXBAR_64ADMSK |
+ MCH_HOST_BRIDGE_PCIEXBAR_128ADMSK;
+ }
break;
case MCH_HOST_BRIDGE_PCIEXBAR_LENGTH_RVD:
qemu_log_mask(LOG_GUEST_ERROR, "Q35: Reserved PCIEXBAR LENGTH\n");
diff --git a/include/hw/pci-host/q35.h b/include/hw/pci-host/q35.h
index e89329c51e..441cce6ccd 100644
--- a/include/hw/pci-host/q35.h
+++ b/include/hw/pci-host/q35.h
@@ -105,8 +105,8 @@ struct Q35PCIHost {
#define MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT 0xb0000000
#define MCH_HOST_BRIDGE_PCIEXBAR_MAX (0x10000000) /* 256M */
#define MCH_HOST_BRIDGE_PCIEXBAR_ADMSK Q35_MASK(64, 35, 28)
-#define MCH_HOST_BRIDGE_PCIEXBAR_128ADMSK ((uint64_t)(1 << 26))
-#define MCH_HOST_BRIDGE_PCIEXBAR_64ADMSK ((uint64_t)(1 << 25))
+#define MCH_HOST_BRIDGE_PCIEXBAR_128ADMSK ((uint64_t)(1 << 27))
+#define MCH_HOST_BRIDGE_PCIEXBAR_64ADMSK ((uint64_t)(1 << 26))
#define MCH_HOST_BRIDGE_PCIEXBAR_LENGTH_MASK ((uint64_t)(0x3 << 1))
#define MCH_HOST_BRIDGE_PCIEXBAR_LENGTH_256M ((uint64_t)(0x0 << 1))
#define MCH_HOST_BRIDGE_PCIEXBAR_LENGTH_128M ((uint64_t)(0x1 << 1))
--
2.34.1
- [PATCH v1 17/23] xen/pt: add Resizable BAR PCIe Extended Capability descriptor and sizing, (continued)
- [PATCH v1 17/23] xen/pt: add Resizable BAR PCIe Extended Capability descriptor and sizing, Joel Upham, 2023/06/20
- [PATCH v1 12/23] xen/pt: allow to hide PCIe Extended Capabilities, Joel Upham, 2023/06/20
- [PATCH v1 15/23] xen/pt: add AER PCIe Extended Capability descriptor and sizing, Joel Upham, 2023/06/20
- [PATCH v1 18/23] xen/pt: add VC/VC9/MFVC PCIe Extended Capabilities descriptors and sizing, Joel Upham, 2023/06/20
- [PATCH v1 20/23] xen platform: unplug ahci object, Joel Upham, 2023/06/20
- [PATCH v1 02/23] pc/q35: Apply PCI bus BSEL property for Xen PCI device hotplug, Joel Upham, 2023/06/20
- [PATCH v1 03/23] q35/acpi/xen: Provide ACPI PCI hotplug interface for Xen on Q35, Joel Upham, 2023/06/20
- [PATCH v1 04/23] q35/xen: Add Xen platform device support for Q35, Joel Upham, 2023/06/20
- [PATCH v1 05/23] q35: Fix incorrect values for PCIEXBAR masks,
Joel Upham <=
- [PATCH v1 11/23] xen/pt: handle PCIe Extended Capabilities Next register, Joel Upham, 2023/06/20
- [PATCH v1 14/23] xen/pt: add fixed-size PCIe Extended Capabilities descriptors, Joel Upham, 2023/06/20
- [PATCH v1 16/23] xen/pt: add descriptors and size calculation for RCLD/ACS/PMUX/DPA/MCAST/TPH/DPC PCIe Extended Capabilities, Joel Upham, 2023/06/20
- [PATCH v1 19/23] xen/pt: Fake capability id, Joel Upham, 2023/06/20
- [PATCH v1 22/23] qdev-monitor/pt: bypass root device check, Joel Upham, 2023/06/20
- [PATCH v1 09/23] xen/pt: Xen PCIe passthrough support for Q35: bypass PCIe topology check, Joel Upham, 2023/06/20
- [PATCH v1 08/23] xen/pt: determine the legacy/PCIe mode for a passed through device, Joel Upham, 2023/06/20
- [PATCH v1 21/23] pc/q35: setup q35 for xen, Joel Upham, 2023/06/20
- [PATCH v1 23/23] s3 support: enabling s3 with q35, Joel Upham, 2023/06/20