From nobody Mon Nov 16 21:01:13 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jT0dj5fzVz70wp3 for ; Mon, 16 Nov 2026 21:01:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jT0dj3dwFz4DKL for ; Mon, 16 Nov 2026 21:01:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794862873; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZE7HqSa576ThHnjmpqmNbXDJZPDLiHT31ajl78VeM1I=; b=QO+RxGU+ROisyVLhcGOBA+aHwWaqeDCyK77oV14n2eA8iDqOw0aezK+ax9WEdZ+xhTYfhm LklKbF6v9yYPZz0RCuB2EHIvi9cYHHsW9KcMWYo7KOMXPUMvBEDjdba5cbtXCifq22N0kE lMCNLculw3sU/ZPO/EM7HVrf41jvDttihIwiBLHaX/2Sb6ZQuUuyBadPM4UB/PofZGhW4o Qb4E7yt7ypimvLv3ojjzb+atpvf66VKHzckh4WB+Uv/YXEKpgg+cM5MTBw5xCT2PCc3dw5 x10acGeqAT/RxOcVtSy1VwEmuYzki9qLAG8NtfoMFcLpIkD3ArFd/iH0BeJXVA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794862873; b=bZZ68FGLIZ+ckSEQBWMAphKZj6QU2V4iNLUHj9947ABN/Qp88qd5qt0PVlOVUZuYhL/OFv gEZ3G/DaeqCF1RRQoiuxXCeTKjgSoD0rgba4vUMl+sxnn3d7rmBWl4lgp9akAUK2WD3PwJ 1mKlK5DdNFrfXLzMsfMUm3yH0wgKpVgQQF2gQnvYGZIpijCDntclAemC+IgPwEoRdHjAHt 7pQLICy0xUlYnuQn4acdkv6t6WtNbkvqPQnbzY580p3SyT7M+FGdzMdbiIfEXoHxLheLES u5Q6Ym9n8w1WjYqWZOZgZty6UYpgJcci3UWT586rc3V5gOARTQJpJh2xYqc8Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794862873; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZE7HqSa576ThHnjmpqmNbXDJZPDLiHT31ajl78VeM1I=; b=Fadi3hyl6cXZewTVFm5Rc9HjkEINnT6h2OTnW0lYbmRYBW4A15yMOlx7vlazLz2VV7d2c2 1O3txNYi8HxoeFv67r/SgIccqry1rajXLdFIeFyTD22zhZnlUo0xsaOy2ib8wwziahA7wU QLarjhQLyw93NKXQ5hREF7L/mPcZDX6iDl3a2vHCP4bY+Yo7vnYqVjkU2HIvzkRaUpv7Ig FsxhUiLpyW6tnObsHDC+ueEqJc5MaMalNF3T6Jwc71YqQ2LmekCqXY/edhwBz5c6gyzgKE i65qWRlnMTDEGVrTHzlh4xwO71/0w4Sd3NkVsmVbrM2H8I77ZzwieNamms8tMA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jT0dj0QZrz19cL for ; Mon, 16 Nov 2026 21:01:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 946c by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 16 Nov 2026 21:01:13 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kenneth D. Merry Subject: git: 9bd048b18ab8 - stable/14 - camcontrol: Fix extended host identifier retrieval List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ken X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 9bd048b18ab81b6b96df05a4b112cbdf68064ece Auto-Submitted: auto-generated Date: Mon, 16 Nov 2026 21:01:13 +0000 Message-Id: <6afb6f19.946c.574ba861@gitrepo.freebsd.org> The branch stable/14 has been updated by ken: URL: https://cgit.FreeBSD.org/src/commit/?id=9bd048b18ab81b6b96df05a4b112cbdf68064ece commit 9bd048b18ab81b6b96df05a4b112cbdf68064ece Author: Kenneth D. Merry AuthorDate: 2026-11-09 18:47:01 +0000 Commit: Kenneth D. Merry CommitDate: 2026-11-16 21:00:07 +0000 camcontrol: Fix extended host identifier retrieval The Get Features command for the host identifier always requested the 64-bit form (cdw11 EXHID=0), but the decoding logic sized the identifier from the controller's CTRATT extended host identifier capability bit, or always treated it as 128 bits when -U was given. On a controller supporting the extended host identifier, the printed value did not match what was requested from the controller. Fetch the controller data before issuing the command, request the extended form when the controller supports it, and decode the form that was requested. Reject -U when the controller only supports 64-bit host identifiers, since an 8 byte value cannot be shown as a UUID. sys/cam/nvme/nvme_all.c, sys/cam/nvme/nvme_all.h: Add an exhid argument to nvme_get_feature_hostid(), matching nvme_set_feature_hostid(), and set the EXHID bit in cdw11 from it. sbin/camcontrol/nvfeature.c: Fetch the controller data and determine the host identifier size before issuing the Get Features command, request only as many bytes as the identifier holds, and decode the identifier in the form it was requested. Reject -U on controllers without extended host identifier support. Reported by: llm-postcr Fixes: 9814633f631b Fixes: 6eae951cd51b MFC after: 1 week Sponsored by: Spectra Logic Co-authored-by: Claude Fable 5 (cherry picked from commit 2dd34affca4d1041b8f6f58bb24c45f29b720430) --- sbin/camcontrol/nvfeature.c | 55 ++++++++++++++++++++++++++++----------------- sys/cam/nvme/nvme_all.c | 9 ++++++-- sys/cam/nvme/nvme_all.h | 5 +++-- 3 files changed, 44 insertions(+), 25 deletions(-) diff --git a/sbin/camcontrol/nvfeature.c b/sbin/camcontrol/nvfeature.c index f288365657f9..ee018f277d60 100644 --- a/sbin/camcontrol/nvfeature.c +++ b/sbin/camcontrol/nvfeature.c @@ -208,8 +208,7 @@ nvfeature_print_caps(union ccb *ccb, const char *msg) } static int -nvfeature_print_hostid(struct cam_device *device, uint8_t *hostid, - int sel, int output_uuid) +nvfeature_print_hostid(uint8_t *hostid, int sel, int exhid, int output_uuid) { int error = 0; char *hostid_str = NULL; @@ -226,16 +225,7 @@ nvfeature_print_hostid(struct cam_device *device, uint8_t *hostid, goto bailout; } } else { - int exhid; struct sbuf *hostid_sbuf; - struct nvme_controller_data cdata; - - error = nvme_get_data(device, CDAI_TYPE_NVME_CNTRL, - &cdata, sizeof(cdata)); - if (error != 0) { - goto bailout; - } - exhid = cdata.ctratt & NVME_CD_CTRATT_EXHID; hostid_sbuf = sbuf_new(NULL, NULL, 64, SBUF_FIXEDLEN); if (hostid_sbuf == NULL) { @@ -265,9 +255,11 @@ nvmefeature_get_hostid(struct cam_device *device, int sel, int verbosemode, int timeout) { union ccb *ccb = NULL; + struct nvme_controller_data cdata; uint8_t hostid[16]; uint8_t *data = NULL; uint32_t datalen = 0; + int exhid = 0; int error = 0; if (! nvfeature_validate_select(sel)) { @@ -275,28 +267,49 @@ nvmefeature_get_hostid(struct cam_device *device, int sel, int verbosemode, goto bailout; } - ccb = cam_getccb(device); - if (ccb == NULL) { - warnx("%s: error allocating CCB", __func__); - error = 1; - goto bailout; - } - CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->csio); - /* Getting capabilities does not output as uuid nor * is the data buffer (hostid) used/needed */ if (sel == NVME_FEAT_SEL_CAPABILITIES) { output_uuid = 0; } else { + /* + * Request and decode the form of the host identifier + * (64-bit or extended 128-bit) that the controller + * supports. + */ + error = nvme_get_data(device, CDAI_TYPE_NVME_CNTRL, &cdata, + sizeof(cdata)); + if (error != 0) + goto bailout; + exhid = (cdata.ctratt & NVME_CD_CTRATT_EXHID) ? 1 : 0; + + if (output_uuid == 1 && exhid == 0) { + warnx("%s: -U requires a 128-bit host identifier, " + "which this controller does not support", + __func__); + error = 1; + goto bailout; + } + bzero(hostid, sizeof(hostid)); data = hostid; - datalen = sizeof(hostid); + datalen = exhid ? 16 : 8; + } + + ccb = cam_getccb(device); + if (ccb == NULL) { + warnx("%s: error allocating CCB", __func__); + error = 1; + goto bailout; } + CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->csio); + nvme_get_feature_hostid(/*nvmeio*/ &ccb->nvmeio, /*retries*/ retry_count, /*cbfcnp*/ NULL, /*sel*/ sel, + /*exhid*/ exhid, /*uuid_idx*/ 0, /*hostid*/ data, /*dxfer_len*/ datalen, @@ -322,7 +335,7 @@ nvmefeature_get_hostid(struct cam_device *device, int sel, int verbosemode, if (sel == NVME_FEAT_SEL_CAPABILITIES) { error = nvfeature_print_caps(ccb, "Host ID capabilities:"); } else { - error = nvfeature_print_hostid(device, hostid, sel, + error = nvfeature_print_hostid(hostid, sel, exhid, output_uuid); } diff --git a/sys/cam/nvme/nvme_all.c b/sys/cam/nvme/nvme_all.c index 10346a71b5ff..33e9846fbb03 100644 --- a/sys/cam/nvme/nvme_all.c +++ b/sys/cam/nvme/nvme_all.c @@ -359,16 +359,21 @@ nvme_set_feature(struct ccb_nvmeio *nvmeio, uint32_t retries, void nvme_get_feature_hostid(struct ccb_nvmeio *nvmeio, uint32_t retries, void (*cbfcnp)(struct cam_periph *, union ccb *), - int sel, int uuid_idx, uint8_t *data_ptr, + int sel, int exhid, int uuid_idx, uint8_t *data_ptr, uint32_t dxfer_len, uint32_t timeout) { + uint32_t cdw11 = 0; + + if (exhid) + cdw11 = 0x01; + nvme_get_feature(/*nvmeio*/ nvmeio, /*retries*/ retries, /*cbfcnp*/ cbfcnp, /*nsid*/ 0, /*sel*/ sel, /*feature*/ NVME_FEAT_HOST_IDENTIFIER, - /*cdw11*/ 0, + /*cdw11*/ cdw11, /*uuid_idx*/ uuid_idx, /*data_ptr*/ data_ptr, /*dxfer_len*/ dxfer_len, diff --git a/sys/cam/nvme/nvme_all.h b/sys/cam/nvme/nvme_all.h index ecfa167fb2d1..1a4f0999b3cc 100644 --- a/sys/cam/nvme/nvme_all.h +++ b/sys/cam/nvme/nvme_all.h @@ -80,8 +80,9 @@ void nvme_set_feature(struct ccb_nvmeio *nvmeio, uint32_t retries, uint32_t timeout); void nvme_get_feature_hostid(struct ccb_nvmeio *nvmeio, uint32_t retries, void (*cbfcnp)(struct cam_periph *, union ccb *), - int sel, int uuid_idx, uint8_t *data_ptr, - uint32_t dxfer_len, uint32_t timeout); + int sel, int exhid, int uuid_idx, + uint8_t *data_ptr, uint32_t dxfer_len, + uint32_t timeout); void nvme_set_feature_hostid(struct ccb_nvmeio *nvmeio, uint32_t retries, void (*cbfcnp)(struct cam_periph *, union ccb *), int sv, int exhid, uint8_t *data_ptr,