]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
bhyve: Fix NVMe BAR size calculation
authorchuck <chuck@FreeBSD.org>
Fri, 5 Apr 2019 16:54:16 +0000 (16:54 +0000)
committerchuck <chuck@FreeBSD.org>
Fri, 5 Apr 2019 16:54:16 +0000 (16:54 +0000)
commitff894081f2ef5a54af077b1c7fc8d93f2118667e
tree06c001e8810ccb2208858d288b6e6150bdb98902
parent2a6eaf86a20ed5b53bd1395b20cb7ce9757f2c51
bhyve: Fix NVMe BAR size calculation

The NVMe specification defines bits 13:4 of BAR0 as Reserved (i.e. 0x0).
Most drivers do not enforce this, but the Windows NVMe driver does and
will refuse to start the device (i.e. error 10) if any of these bits are
set.

The current BAR size calculation tries to minimize the amount of memory
the device reserves by scaling the BAR size by the maximum number of
queues supported by the device. But unless the device supports a large
number of queue pairs (over 1536), it will reserve too little memory.

The fix is to allocate a minimum of 16K bytes for BAR0.

Tested on Windows Server 2016 and 2019

Reviewed by: imp (mentor), araujo, jhb, bhyve
Approved by: imp (mentor), bhyve (jhb)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D19676
usr.sbin/bhyve/pci_nvme.c