git: ffc15b5c86fc - stable/15 - nvme: Byte-swap the nsid in the Get/Set Features command builders

From: Kenneth D. Merry <ken_at_FreeBSD.org>
Date: Mon, 16 Nov 2026 21:00:39 UTC
The branch stable/15 has been updated by ken:

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

commit ffc15b5c86fce773b484d016be493e6f495081c6
Author:     Kenneth D. Merry <ken@FreeBSD.org>
AuthorDate: 2026-11-09 18:46:57 +0000
Commit:     Kenneth D. Merry <ken@FreeBSD.org>
CommitDate: 2026-11-16 16:12:33 +0000

    nvme: Byte-swap the nsid in the Get/Set Features command builders
    
    nvme_admin_get_feature_cmd() and nvme_admin_set_feature_cmd() stored
    the namespace ID in the command without converting it to little
    endian, unlike the other command building functions.  Any caller
    passing a non-zero namespace ID would send the wrong namespace ID on
    big endian machines.
    
    Reported by:    llm-postcr
    Fixes:          7a9e4375316b
    MFC after:      1 week
    Sponsored by:   Spectra Logic
    Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
    
    (cherry picked from commit 3a6dbe77c39d3a88b6092cfcaa820fc727d1e61d)
---
 sys/dev/nvme/nvme.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/dev/nvme/nvme.h b/sys/dev/nvme/nvme.h
index 34135075bdda..b5f2815eeff3 100644
--- a/sys/dev/nvme/nvme.h
+++ b/sys/dev/nvme/nvme.h
@@ -2254,7 +2254,7 @@ static inline
 void	nvme_admin_get_feature_cmd(struct nvme_command *cmd, uint32_t nsid,
     int sel, uint8_t feature, uint32_t cdw11, int uuid_idx) {
 	cmd->opc = NVME_OPC_GET_FEATURES;
-	cmd->nsid = nsid;
+	cmd->nsid = htole32(nsid);
 	cmd->cdw10 = htole32(((sel & 0x7) << 8) | feature);
 	cmd->cdw11 = htole32(cdw11);
 	cmd->cdw14 = htole32(uuid_idx & 0x7f);
@@ -2267,7 +2267,7 @@ void	nvme_admin_set_feature_cmd(struct nvme_command *cmd, uint32_t nsid,
     uint32_t cdw13, uint32_t cdw14, uint32_t cdw15)
 {
 	cmd->opc = NVME_OPC_SET_FEATURES;
-	cmd->nsid = nsid;
+	cmd->nsid = htole32(nsid);
 	cmd->cdw10 = htole32(((sv & 0x1) << 31) | feature);
 	cmd->cdw11 = htole32(cdw11);
 	cmd->cdw12 = htole32(cdw12);