git: ec0efe34dd48 - main - bhyve nvme: Fix reported SANICAP value

From: Chuck Tuffli <chuck_at_FreeBSD.org>
Date: Tue, 16 Aug 2022 16:17:21 UTC
The branch main has been updated by chuck:

URL: https://cgit.FreeBSD.org/src/commit/?id=ec0efe34dd486359d57bc1e792a0e4f9280f66d7

commit ec0efe34dd486359d57bc1e792a0e4f9280f66d7
Author:     Chuck Tuffli <chuck@FreeBSD.org>
AuthorDate: 2022-08-16 16:14:43 +0000
Commit:     Chuck Tuffli <chuck@FreeBSD.org>
CommitDate: 2022-08-16 16:14:43 +0000

    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 70ae22c71a37..7701d0b932ee 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) |