git: 29f50a83cc52 - stable/13 - bhyve nvme: Fix Namespace Specific Set Features

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

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

commit 29f50a83cc524d42340fffc9972e84f9f58fc33b
Author:     Chuck Tuffli <chuck@FreeBSD.org>
AuthorDate: 2022-01-30 07:06:23 +0000
Commit:     Chuck Tuffli <chuck@FreeBSD.org>
CommitDate: 2022-02-22 03:25:34 +0000

    bhyve nvme: Fix Namespace Specific Set Features
    
    Return an error if the feature specified in Set Features is Namespace
    specific but the Namespace ID uses the Global Namespace tag.
    
    Fixes UNH Test 1.2.7
    
    (cherry picked from commit 62d47feceba8d457f5a28691cfbed5b90ede30b6)
---
 usr.sbin/bhyve/pci_nvme.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/usr.sbin/bhyve/pci_nvme.c b/usr.sbin/bhyve/pci_nvme.c
index 0ce26f0adfee..e1de57c26e84 100644
--- a/usr.sbin/bhyve/pci_nvme.c
+++ b/usr.sbin/bhyve/pci_nvme.c
@@ -1660,6 +1660,11 @@ nvme_opc_set_features(struct pci_nvme_softc *sc, struct nvme_command *command,
 	}
 	feat = &sc->feat[fid];
 
+	if (feat->namespace_specific && (nsid == NVME_GLOBAL_NAMESPACE_TAG)) {
+		pci_nvme_status_genc(&compl->status, NVME_SC_INVALID_FIELD);
+		return (1);
+	}
+
 	if (!feat->namespace_specific &&
 	    !((nsid == 0) || (nsid == NVME_GLOBAL_NAMESPACE_TAG))) {
 		pci_nvme_status_tc(&compl->status, NVME_SCT_COMMAND_SPECIFIC,