Index: usr.sbin/bhyve/pci_nvme.c =================================================================== --- usr.sbin/bhyve/pci_nvme.c +++ usr.sbin/bhyve/pci_nvme.c @@ -85,6 +85,9 @@ #define NVME_IOSLOTS 8 +/* The NVMe spec defines bits 13:4 in BAR0 as reserved */ +#define NVME_MMIO_SPACE_MIN (1 << 14) + #define NVME_QUEUES 16 #define NVME_MAX_QENTRIES 2048 @@ -1847,9 +1850,18 @@ pci_set_cfgdata8(pi, PCIR_PROGIF, PCIP_STORAGE_NVM_ENTERPRISE_NVMHCI_1_0); - /* allocate size of nvme registers + doorbell space for all queues */ - pci_membar_sz = sizeof(struct nvme_registers) + - 2*sizeof(uint32_t)*(sc->max_queues + 1); + /* + * Allocate size of NVMe registers + doorbell space for all queues. + * + * Note that the specification defines bits 13:4 as reserved + * (i.e. 0). Most operating systems do not enforce this requirement, + * but Windows appears to check this and will refuse to start the + * device if these bits are set. + */ + pci_membar_sz = MAX( + sizeof(struct nvme_registers) + + 2 * sizeof(uint32_t) * (sc->max_queues + 1), + NVME_MMIO_SPACE_MIN); DPRINTF(("nvme membar size: %u\r\n", pci_membar_sz));