git: 6a901f5e3686 - stable/14 - nvme: Fix the data length in the Reservation Report command builder

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

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

commit 6a901f5e36869c71b3ffbbea13fdc34cb7716e5d
Author:     Kenneth D. Merry <ken@FreeBSD.org>
AuthorDate: 2026-11-09 18:46:58 +0000
Commit:     Kenneth D. Merry <ken@FreeBSD.org>
CommitDate: 2026-11-16 21:00:06 +0000

    nvme: Fix the data length in the Reservation Report command builder
    
    nvme_ns_resv_report_cmd() put its length argument, which callers
    supply in bytes, directly into cdw10.  The NUMD field is a 0's
    based count of dwords, so the command asked the controller to
    transfer nearly four times the size of the supplied data buffer.
    In practice controllers limit the transfer to the length described
    by the PRP entries, which is why this worked in testing, but the
    command was incorrect.
    
    Convert the byte count to a 0's based dword count in the builder.
    
    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 86b9d629c68f6dc63543b9c0a6da6c96c857f3bc)
---
 sys/dev/nvme/nvme.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/dev/nvme/nvme.h b/sys/dev/nvme/nvme.h
index 658461096b0a..350c7502259d 100644
--- a/sys/dev/nvme/nvme.h
+++ b/sys/dev/nvme/nvme.h
@@ -2121,7 +2121,8 @@ void	nvme_ns_resv_report_cmd(struct nvme_command *cmd, uint32_t nsid,
 {
 	cmd->opc = NVME_OPC_RESERVATION_REPORT;
 	cmd->nsid = htole32(nsid);
-	cmd->cdw10 = htole32(length);
+	/* NUMD is a 0's based count of dwords; length is in bytes. */
+	cmd->cdw10 = htole32(length / 4 - 1);
 	cmd->cdw11 = htole32(report_type);
 }