git: ac678b4aaf1e - main - bhyve nvme: Fix Identify Namespace, NSID=ffffffff

From: Chuck Tuffli <chuck_at_FreeBSD.org>
Date: Sat, 29 Jan 2022 23:15:50 UTC
The branch main has been updated by chuck:

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

commit ac678b4aaf1e852aa033906eabee7322d985c810
Author:     Chuck Tuffli <chuck@FreeBSD.org>
AuthorDate: 2022-01-30 07:11:14 +0000
Commit:     Chuck Tuffli <chuck@FreeBSD.org>
CommitDate: 2022-01-30 07:11:14 +0000

    bhyve nvme: Fix Identify Namespace, NSID=ffffffff
    
    If the NVMe Controller doesn't support Namespace Management, it should
    return "Invalid Namespace or Format" when the Host request Identify
    Namespace with the global NSID value.
    
    Fixes UNH IOL 16.0 Test 9.1, Case 6
    
    Reviewed by:    imp, allanjude
    Tested by:      jason@tubnor.net
    MFC after:      1 month
    Differential Revision:  https://reviews.freebsd.org/D33578
---
 usr.sbin/bhyve/pci_nvme.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/usr.sbin/bhyve/pci_nvme.c b/usr.sbin/bhyve/pci_nvme.c
index 1034fe532892..8cd3a949f916 100644
--- a/usr.sbin/bhyve/pci_nvme.c
+++ b/usr.sbin/bhyve/pci_nvme.c
@@ -1482,6 +1482,12 @@ nvme_opc_identify(struct pci_nvme_softc* sc, struct nvme_command* command,
 
 	switch (command->cdw10 & 0xFF) {
 	case 0x00: /* return Identify Namespace data structure */
+		/* Global NS only valid with NS Management */
+		if (command->nsid == NVME_GLOBAL_NAMESPACE_TAG) {
+			pci_nvme_status_genc(&status,
+			    NVME_SC_INVALID_NAMESPACE_OR_FORMAT);
+			break;
+		}
 		nvme_prp_memcpy(sc->nsc_pi->pi_vmctx, command->prp1,
 		    command->prp2, (uint8_t *)&sc->nsdata, sizeof(sc->nsdata),
 		    NVME_COPY_TO_PRP);