aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorvin Köhne <CorvinK@beckhoff.com>2022-01-03 13:19:39 +0000
committerEmmanuel Vadot <manu@FreeBSD.org>2022-01-03 15:32:55 +0000
commit7d55d295086e0f568b42c89604fad3e47633b2ed (patch)
tree8297ba0a609f2e6f22b963414e4e06640cf74d0d
parent8ec366ec6c943550a011effe50bc73e3875f8ead (diff)
downloadsrc-7d55d295086e0f568b42c89604fad3e47633b2ed.tar.gz
src-7d55d295086e0f568b42c89604fad3e47633b2ed.zip
bhyve: add more slop to 64 bit BARs
Bhyve allocates small 64 bit BARs below 4 GB and generates ACPI tables based on this allocation. If the guest decides to relocate those BARs above 4 GB, it could lead to mismatching ACPI tables. Especially when using OVMF with enabled bus enumeration it could cause issues. OVMF relocates all 64 bit BARs above 4 GB. The guest OS may be unable to recover from this situation and disables some PCI devices because their BARs are located outside of the MMIO space reported by ACPI. Avoid this situation by giving the guest more space for relocating BARs. Let's be paranoid. The available space for BARs below 4 GB is 512 MB large. Use a slop of 512 MB. It'll allow the guest to relocate all BARs below 4 GB to an address above 4 GB. We could run into issues when we exceeding the memlimit above 4 GB. However, this space has a size of 32 GB. Even when using many PCI device with large BARs like framebuffer or when using multiple PCI busses, it's very unlikely that we run out of space due to the large slop. Additionally, this situation will occur on startup and not at runtime which is much better. Reviewed by: markj MFC after: 2 weeks Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D33118
-rw-r--r--usr.sbin/bhyve/pci_emul.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/usr.sbin/bhyve/pci_emul.c b/usr.sbin/bhyve/pci_emul.c
index 867ea0638d83..82580b7d6931 100644
--- a/usr.sbin/bhyve/pci_emul.c
+++ b/usr.sbin/bhyve/pci_emul.c
@@ -1218,7 +1218,8 @@ pci_ecfg_base(void)
}
#define BUSIO_ROUNDUP 32
-#define BUSMEM_ROUNDUP (1024 * 1024)
+#define BUSMEM32_ROUNDUP (1024 * 1024)
+#define BUSMEM64_ROUNDUP (512 * 1024 * 1024)
int
init_pci(struct vmctx *ctx)
@@ -1320,14 +1321,14 @@ init_pci(struct vmctx *ctx)
pci_emul_iobase = roundup2(pci_emul_iobase, BUSIO_ROUNDUP);
bi->iolimit = pci_emul_iobase;
- pci_emul_membase32 += BUSMEM_ROUNDUP;
+ pci_emul_membase32 += BUSMEM32_ROUNDUP;
pci_emul_membase32 = roundup2(pci_emul_membase32,
- BUSMEM_ROUNDUP);
+ BUSMEM32_ROUNDUP);
bi->memlimit32 = pci_emul_membase32;
- pci_emul_membase64 += BUSMEM_ROUNDUP;
+ pci_emul_membase64 += BUSMEM64_ROUNDUP;
pci_emul_membase64 = roundup2(pci_emul_membase64,
- BUSMEM_ROUNDUP);
+ BUSMEM64_ROUNDUP);
bi->memlimit64 = pci_emul_membase64;
}