[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 22/26] hw/pci-bridge: fix pcie root port's IO hints c
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 22/26] hw/pci-bridge: fix pcie root port's IO hints capability |
Date: |
Thu, 8 Feb 2018 21:09:17 +0200 |
From: Marcel Apfelbaum <address@hidden>
The gen_pcie_root_port mem-reserve and pref32-reserve properties are
defined as size (so uint64_t), but passed as uint32_t when building
the 'IO hints' vendor specific capability.
Passing 4G (or more) gets truncated and passed as a zero reservation.
Is not a huge issue since the guest firmware will always compare the
hints with the default value and take the maximum.
Fix it by passing the values as uint64_t and failing to init the
gen_pcie_root_port id invalid values are used.
Signed-off-by: Marcel Apfelbaum <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
include/hw/pci/pci_bridge.h | 4 ++--
hw/pci/pci_bridge.c | 24 +++++++++++++++++++-----
2 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/include/hw/pci/pci_bridge.h b/include/hw/pci/pci_bridge.h
index 9b44ffd..0347da5 100644
--- a/include/hw/pci/pci_bridge.h
+++ b/include/hw/pci/pci_bridge.h
@@ -135,8 +135,8 @@ typedef struct PCIBridgeQemuCap {
int pci_bridge_qemu_reserve_cap_init(PCIDevice *dev, int cap_offset,
uint32_t bus_reserve, uint64_t io_reserve,
- uint32_t mem_non_pref_reserve,
- uint32_t mem_pref_32_reserve,
+ uint64_t mem_non_pref_reserve,
+ uint64_t mem_pref_32_reserve,
uint64_t mem_pref_64_reserve,
Error **errp);
diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c
index b2e50c3..40a39f5 100644
--- a/hw/pci/pci_bridge.c
+++ b/hw/pci/pci_bridge.c
@@ -412,22 +412,36 @@ void pci_bridge_map_irq(PCIBridge *br, const char*
bus_name,
int pci_bridge_qemu_reserve_cap_init(PCIDevice *dev, int cap_offset,
uint32_t bus_reserve, uint64_t io_reserve,
- uint32_t mem_non_pref_reserve,
- uint32_t mem_pref_32_reserve,
+ uint64_t mem_non_pref_reserve,
+ uint64_t mem_pref_32_reserve,
uint64_t mem_pref_64_reserve,
Error **errp)
{
- if (mem_pref_32_reserve != (uint32_t)-1 &&
+ if (mem_pref_32_reserve != (uint64_t)-1 &&
mem_pref_64_reserve != (uint64_t)-1) {
error_setg(errp,
"PCI resource reserve cap: PREF32 and PREF64 conflict");
return -EINVAL;
}
+ if (mem_non_pref_reserve != (uint64_t)-1 &&
+ mem_non_pref_reserve >= (1ULL << 32)) {
+ error_setg(errp,
+ "PCI resource reserve cap: mem-reserve must be less than
4G");
+ return -EINVAL;
+ }
+
+ if (mem_pref_32_reserve != (uint64_t)-1 &&
+ mem_pref_32_reserve >= (1ULL << 32)) {
+ error_setg(errp,
+ "PCI resource reserve cap: pref32-reserve must be less
than 4G");
+ return -EINVAL;
+ }
+
if (bus_reserve == (uint32_t)-1 &&
io_reserve == (uint64_t)-1 &&
- mem_non_pref_reserve == (uint32_t)-1 &&
- mem_pref_32_reserve == (uint32_t)-1 &&
+ mem_non_pref_reserve == (uint64_t)-1 &&
+ mem_pref_32_reserve == (uint64_t)-1 &&
mem_pref_64_reserve == (uint64_t)-1) {
return 0;
}
--
MST
- [Qemu-devel] [PULL 11/26] pci-bridge/i82801b11: clear bridge registers on platform reset, (continued)
- [Qemu-devel] [PULL 11/26] pci-bridge/i82801b11: clear bridge registers on platform reset, Michael S. Tsirkin, 2018/02/08
- [Qemu-devel] [PULL 08/26] vhost: Clean out old vhost_set_memory and friends, Michael S. Tsirkin, 2018/02/08
- [Qemu-devel] [PULL 13/26] virtio-blk: enable multiple vectors when using multiple I/O queues, Michael S. Tsirkin, 2018/02/08
- [Qemu-devel] [PULL 12/26] pci/bus: let it has higher migration priority, Michael S. Tsirkin, 2018/02/08
- [Qemu-devel] [PULL 17/26] cryptodev-vhost-user: add crypto session handler, Michael S. Tsirkin, 2018/02/08
- [Qemu-devel] [PULL 16/26] cryptodev: add vhost support, Michael S. Tsirkin, 2018/02/08
- [Qemu-devel] [PULL 15/26] cryptodev: add vhost-user as a new cryptodev backend, Michael S. Tsirkin, 2018/02/08
- [Qemu-devel] [PULL 20/26] libvhost-user: Fix resource leak, Michael S. Tsirkin, 2018/02/08
- [Qemu-devel] [PULL 21/26] libvhost-user: Support across-memory-boundary access, Michael S. Tsirkin, 2018/02/08
- [Qemu-devel] [PULL 23/26] tests: acpi: fix FADT not being compared to reference table, Michael S. Tsirkin, 2018/02/08
- [Qemu-devel] [PULL 22/26] hw/pci-bridge: fix pcie root port's IO hints capability,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 25/26] acpi-test: update FADT, Michael S. Tsirkin, 2018/02/08
- [Qemu-devel] [PULL 19/26] virtio-balloon: unref the memory region before continuing, Michael S. Tsirkin, 2018/02/08
- [Qemu-devel] [PULL 18/26] cryptodev-vhost-user: set the key length, Michael S. Tsirkin, 2018/02/08
- [Qemu-devel] [PULL 24/26] lpc: drop pcie host dependency, Michael S. Tsirkin, 2018/02/08
- [Qemu-devel] [PULL 14/26] pci: removed the is_express field since a uniform interface was inserted, Michael S. Tsirkin, 2018/02/08
- [Qemu-devel] [PULL 26/26] virtio-balloon: include statistics of disk/file caches, Michael S. Tsirkin, 2018/02/08
- [Qemu-devel] [PULL 03/26] virtio: improve virtio devices initialization time, Michael S. Tsirkin, 2018/02/08
- Re: [Qemu-devel] [PULL 00/26] virtio, vhost, pci, pc: features, fixes and cleanups, Peter Maydell, 2018/02/09