git: eae02d959363 - stable/13 - bhyve nvme: Fix Identify Namespace, NSID=ffffffff

From: Chuck Tuffli <chuck_at_FreeBSD.org>
Date: Mon, 21 Feb 2022 21:58:05 UTC
The branch stable/13 has been updated by chuck:

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

commit eae02d959363fc575b1727ed23e6f1542802d551
Author:     Chuck Tuffli <chuck@FreeBSD.org>
AuthorDate: 2022-01-30 07:11:14 +0000
Commit:     Chuck Tuffli <chuck@FreeBSD.org>
CommitDate: 2022-02-22 03:28:39 +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
    
    (cherry picked from commit ac678b4aaf1e852aa033906eabee7322d985c810)
---
 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 ba05871f21a1..291d6676f7ce 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);