summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bhyve
diff options
context:
space:
mode:
authorneel <neel@FreeBSD.org>2013-04-17 02:03:12 +0000
committerneel <neel@FreeBSD.org>2013-04-17 02:03:12 +0000
commit3ab51705b73c481b6bc76e733f494db7fa6f31fd (patch)
tree00a6d6f55c3aaee149260e508698171dcd29bded /usr.sbin/bhyve
parent10282201983e9d7cdb91548695c81132fe1bcc64 (diff)
downloadFreeBSD-src-3ab51705b73c481b6bc76e733f494db7fa6f31fd.zip
FreeBSD-src-3ab51705b73c481b6bc76e733f494db7fa6f31fd.tar.gz
Setup accesses to the memory hole below 4GB to return all 1's on read and
consume all writes without any side effects. Obtained from: NetApp
Diffstat (limited to 'usr.sbin/bhyve')
-rw-r--r--usr.sbin/bhyve/pci_emul.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/usr.sbin/bhyve/pci_emul.c b/usr.sbin/bhyve/pci_emul.c
index 713e197..1abb69c 100644
--- a/usr.sbin/bhyve/pci_emul.c
+++ b/usr.sbin/bhyve/pci_emul.c
@@ -88,8 +88,6 @@ static struct lirqinfo {
SET_DECLARE(pci_devemu_set, struct pci_devemu);
-static uint32_t pci_hole_startaddr;
-
static uint64_t pci_emul_iobase;
static uint64_t pci_emul_membase32;
static uint64_t pci_emul_membase64;
@@ -977,13 +975,12 @@ init_pci(struct vmctx *ctx)
struct mem_range memp;
struct pci_devemu *pde;
struct slotinfo *si;
+ size_t lowmem;
int slot, func;
int error;
- pci_hole_startaddr = vm_get_lowmem_limit(ctx);
-
pci_emul_iobase = PCI_EMUL_IOBASE;
- pci_emul_membase32 = pci_hole_startaddr;
+ pci_emul_membase32 = vm_get_lowmem_limit(ctx);
pci_emul_membase64 = PCI_EMUL_MEMBASE64;
for (slot = 0; slot < MAXSLOTS; slot++) {
@@ -1010,14 +1007,23 @@ init_pci(struct vmctx *ctx)
lirq[15].li_generic = 1;
/*
- * Setup the PCI hole to return 0xff's when accessed in a region
- * with no devices
+ * The guest physical memory map looks like the following:
+ * [0, lowmem) guest system memory
+ * [lowmem, lowmem_limit) memory hole (may be absent)
+ * [lowmem_limit, 4GB) PCI hole (32-bit BAR allocation)
+ * [4GB, 4GB + highmem)
+ *
+ * Accesses to memory addresses that are not allocated to system
+ * memory or PCI devices return 0xff's.
*/
+ error = vm_get_memory_seg(ctx, 0, &lowmem);
+ assert(error == 0);
+
memset(&memp, 0, sizeof(struct mem_range));
memp.name = "PCI hole";
memp.flags = MEM_F_RW;
- memp.base = pci_hole_startaddr;
- memp.size = (4ULL * 1024 * 1024 * 1024) - pci_hole_startaddr;
+ memp.base = lowmem;
+ memp.size = (4ULL * 1024 * 1024 * 1024) - lowmem;
memp.handler = pci_emul_fallback_handler;
error = register_mem_fallback(&memp);
OpenPOWER on IntegriCloud