From ec0efe34dd486359d57bc1e792a0e4f9280f66d7 Mon Sep 17 00:00:00 2001 From: Chuck Tuffli Date: Tue, 16 Aug 2022 09:14:43 -0700 Subject: [PATCH] bhyve nvme: Fix reported SANICAP value The NVMe specification only allows Controllers compliant with the revision 1.3 and earlier specification to report a value of 0x0 in the No-Deallocate Modifies Media After Sanitize (NODMMAS) field. For our revision 1.4 Controller, report that media is not modified after Sanitize as the implementation does not implement Sanitize. Fixes UNH Test 1.1.2 Reviewed by: jhb MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D36192 --- usr.sbin/bhyve/pci_nvme.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/usr.sbin/bhyve/pci_nvme.c b/usr.sbin/bhyve/pci_nvme.c index 70ae22c71a3..7701d0b932e 100644 --- a/usr.sbin/bhyve/pci_nvme.c +++ b/usr.sbin/bhyve/pci_nvme.c @@ -560,6 +560,10 @@ pci_nvme_init_ctrldata(struct pci_nvme_softc *sc) cd->wctemp = 0x0157; cd->cctemp = 0x0157; + /* SANICAP must not be 0 for Revision 1.4 and later NVMe Controllers */ + cd->sanicap = (NVME_CTRLR_DATA_SANICAP_NODMMAS_NO << + NVME_CTRLR_DATA_SANICAP_NODMMAS_SHIFT); + cd->sqes = (6 << NVME_CTRLR_DATA_SQES_MAX_SHIFT) | (6 << NVME_CTRLR_DATA_SQES_MIN_SHIFT); cd->cqes = (4 << NVME_CTRLR_DATA_CQES_MAX_SHIFT) |