Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/pci_emul.c
Show First 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | |||||
static uint64_t pci_emul_iobase; | static uint64_t pci_emul_iobase; | ||||
static uint64_t pci_emul_membase32; | static uint64_t pci_emul_membase32; | ||||
static uint64_t pci_emul_membase64; | static uint64_t pci_emul_membase64; | ||||
static uint64_t pci_emul_memlim64; | static uint64_t pci_emul_memlim64; | ||||
#define PCI_EMUL_IOBASE 0x2000 | #define PCI_EMUL_IOBASE 0x2000 | ||||
#define PCI_EMUL_IOLIMIT 0x10000 | #define PCI_EMUL_IOLIMIT 0x10000 | ||||
#define PCI_EMUL_MEMBASE32 0xC0000000 | |||||
#define PCI_EMUL_ECFG_BASE 0xE0000000 /* 3.5GB */ | #define PCI_EMUL_ECFG_BASE 0xE0000000 /* 3.5GB */ | ||||
#define PCI_EMUL_ECFG_SIZE (MAXBUSES * 1024 * 1024) /* 1MB per bus */ | #define PCI_EMUL_ECFG_SIZE (MAXBUSES * 1024 * 1024) /* 1MB per bus */ | ||||
SYSRES_MEM(PCI_EMUL_ECFG_BASE, PCI_EMUL_ECFG_SIZE); | SYSRES_MEM(PCI_EMUL_ECFG_BASE, PCI_EMUL_ECFG_SIZE); | ||||
#define PCI_EMUL_MEMLIMIT32 PCI_EMUL_ECFG_BASE | #define PCI_EMUL_MEMLIMIT32 PCI_EMUL_ECFG_BASE | ||||
static struct pci_devemu *pci_emul_finddev(const char *name); | static struct pci_devemu *pci_emul_finddev(const char *name); | ||||
static void pci_lintr_route(struct pci_devinst *pi); | static void pci_lintr_route(struct pci_devinst *pi); | ||||
▲ Show 20 Lines • Show All 1,026 Lines • ▼ Show 20 Lines | init_pci(struct vmctx *ctx) | ||||
nvlist_t *nvl; | nvlist_t *nvl; | ||||
const char *emul; | const char *emul; | ||||
size_t lowmem; | size_t lowmem; | ||||
uint64_t cpu_maxphysaddr, pci_emul_memresv64; | uint64_t cpu_maxphysaddr, pci_emul_memresv64; | ||||
u_int regs[4]; | u_int regs[4]; | ||||
int bus, slot, func, error; | int bus, slot, func, error; | ||||
pci_emul_iobase = PCI_EMUL_IOBASE; | pci_emul_iobase = PCI_EMUL_IOBASE; | ||||
pci_emul_membase32 = vm_get_lowmem_limit(ctx); | pci_emul_membase32 = PCI_EMUL_MEMBASE32; | ||||
markj: This limit is fixed in libvmmapi. Wouldn't it be cleaner to assert that it is using the value… | |||||
Done Inline ActionsDecreasing the lowmem_limit shouldn't hurt. However, bhyve should always use 0xC0000000 as membase32 because OVMF uses it too. corvink: Decreasing the lowmem_limit shouldn't hurt. However, bhyve should always use 0xC0000000 as… | |||||
do_cpuid(0x80000008, regs); | do_cpuid(0x80000008, regs); | ||||
cpu_maxphysaddr = 1ULL << (regs[0] & 0xff); | cpu_maxphysaddr = 1ULL << (regs[0] & 0xff); | ||||
if (cpu_maxphysaddr > VM_MAXUSER_ADDRESS_LA48) | if (cpu_maxphysaddr > VM_MAXUSER_ADDRESS_LA48) | ||||
cpu_maxphysaddr = VM_MAXUSER_ADDRESS_LA48; | cpu_maxphysaddr = VM_MAXUSER_ADDRESS_LA48; | ||||
pci_emul_memresv64 = cpu_maxphysaddr / 4; | pci_emul_memresv64 = cpu_maxphysaddr / 4; | ||||
/* | /* | ||||
* Max power of 2 that is less then | * Max power of 2 that is less then | ||||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | for (bus = 0; bus < MAXBUSES; bus++) { | ||||
} | } | ||||
} | } | ||||
lpc_pirq_routed(); | lpc_pirq_routed(); | ||||
/* | /* | ||||
* The guest physical memory map looks like the following: | * The guest physical memory map looks like the following: | ||||
* [0, lowmem) guest system memory | * [0, lowmem) guest system memory | ||||
* [lowmem, lowmem_limit) memory hole (may be absent) | * [lowmem, lowmem_limit) memory hole (may be absent) | ||||
* [lowmem_limit, 0xE0000000) PCI hole (32-bit BAR allocation) | * [lowmem_limit, 0xC0000000) Graphics Stolen Memory (may be absent) | ||||
* [0xC0000000, 0xE0000000) PCI hole (32-bit BAR allocation) | |||||
* [0xE0000000, 0xF0000000) PCI extended config window | * [0xE0000000, 0xF0000000) PCI extended config window | ||||
* [0xF0000000, 4GB) LAPIC, IOAPIC, HPET, firmware | * [0xF0000000, 4GB) LAPIC, IOAPIC, HPET, firmware | ||||
* [4GB, 4GB + highmem) | * [4GB, 4GB + highmem) | ||||
*/ | */ | ||||
/* | /* | ||||
* Accesses to memory addresses that are not allocated to system | * Accesses to memory addresses that are not allocated to system | ||||
* memory or PCI devices return 0xff's. | * memory or PCI devices return 0xff's. | ||||
▲ Show 20 Lines • Show All 1,151 Lines • Show Last 20 Lines |
This limit is fixed in libvmmapi. Wouldn't it be cleaner to assert that it is using the value we want, rather than just assuming?