git: 3a6dbe77c39d - main - nvme: Byte-swap the nsid in the Get/Set Features command builders
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 09 Nov 2026 19:14:07 UTC
The branch main has been updated by ken:
URL: https://cgit.FreeBSD.org/src/commit/?id=3a6dbe77c39d3a88b6092cfcaa820fc727d1e61d
commit 3a6dbe77c39d3a88b6092cfcaa820fc727d1e61d
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-09 18:59:12 +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>
---
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 ca87cdd25abe..e3b8f1f9ced4 100644
--- a/sys/dev/nvme/nvme.h
+++ b/sys/dev/nvme/nvme.h
@@ -2323,7 +2323,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);
@@ -2336,7 +2336,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);