From nobody Mon Nov 16 21:00:45 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 4jT0dB0K0fz70wfg for ; Mon, 16 Nov 2026 21:00:46 +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 4jT0d95ypsz4ChJ for ; Mon, 16 Nov 2026 21:00:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794862845; 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=frc0AEwc1c1NZXN5pqoIrzqq2Rrpy/IHIKkYuR4Lt8A=; b=rRseGwysVnvM/J9gtjdXjNecmy453P7OmODNxTSi4jz6fb4Z+u1fy6HMae9LpZcWIzV0Nf B8yCp/ARtLX72ZFAAZaH22ICDo9Zpu7tP766GYBPqSM+Jmzsr2su2EWlHTsFnUKZKOsD+9 wWTnQ34G3j7+4I4HzreZIrJOHe0mFODAiIylyB7Ef5H1Xp7wGUlZ61McrdQoVVFY2LM2XV KXlMhlUKfQzM0nk1rk44otedm8RBPF/GcFb7HogTRvLoJZVGWReS1QSbKFzNEBzcTGrzpm kg7b5sOlleWrWkFSJ5iuARXMnmuNq9pZCeYmXeFfGPUQwRlyIKJjdmFk6Xi8Kg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794862845; b=ufICb7PuWqj+HdsXu5vU1dL5F89oFkooZrNzp7ZYuFC6eMY2O8/v7hrV7iuZQZeFpxUyhX Ib0qb5z9LMpKXPht+BEa2qm5fUJmmdEbcDPyx03UuEhC/cYiQghYAeTdfbNWMsRZWjd9Va xdC8C6cuWXpPlnlWEl0W1aIZjN0Rx5d5etxUpIDQtymZEeud2nf+4ybbaeUH5zSiWdOgzN oD1oxQgjw1oXuhdMVST4hxDhodv6D0V/a8IZCokDJMLDQxLbc0xHhPpJ2PnKp/sIvJ4L+s 3dqWytv5/PWkU3ax6s0gcJksNezqVr4yKYvujLxNuEuSL1POr44WWR9xglXeqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794862845; 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=frc0AEwc1c1NZXN5pqoIrzqq2Rrpy/IHIKkYuR4Lt8A=; b=OMtosAL6ohuzMaOXW0RyyAi6Z2h+Ik3GuEGnsfwBgTtATcEyyKdTKTgKoBHgiDYriGZ8N5 5Bj8Y75izoTBfPHrVC4FqiZj7vGPIqhAa0Ms4luroZ11sWkrzpiuHwlAHjC1H5/6j646Nj 5UdRB6bQ+rSrOQMYfedqJ3pMl965kun4wyeENZ2O0FvOy0Gm83b92cKXkoG8GTPNX4qm1N 6YZJDTVtv1QXzxGj126triQchOlB7ZzY5vPNXUpvJZgamsFUcr7oKD4lO1R5kJb+wuUns7 tmgB90ufzBQSM5gcIu48v8ulWmkCrS9ynXbQRyB3mn8vY4YMTh2DkfUaDJubbQ== 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 4jT0d94vthz18vv for ; Mon, 16 Nov 2026 21:00:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 9681 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 16 Nov 2026 21:00:45 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kenneth D. Merry Subject: git: 9fa9eea4896d - stable/15 - 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/15 X-Git-Reftype: branch X-Git-Commit: 9fa9eea4896d55b88e48cddac110c2ca2a274b10 Auto-Submitted: auto-generated Date: Mon, 16 Nov 2026 21:00:45 +0000 Message-Id: <6afb6efd.9681.118e3e63@gitrepo.freebsd.org> The branch stable/15 has been updated by ken: URL: https://cgit.FreeBSD.org/src/commit/?id=9fa9eea4896d55b88e48cddac110c2ca2a274b10 commit 9fa9eea4896d55b88e48cddac110c2ca2a274b10 Author: Kenneth D. Merry AuthorDate: 2026-11-09 18:47:01 +0000 Commit: Kenneth D. Merry CommitDate: 2026-11-16 16:12:47 +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 a239498901d1..1bad4702b027 100644 --- a/sys/cam/nvme/nvme_all.c +++ b/sys/cam/nvme/nvme_all.c @@ -319,16 +319,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 fede596d4b74..58115b69fcdd 100644 --- a/sys/cam/nvme/nvme_all.h +++ b/sys/cam/nvme/nvme_all.h @@ -78,8 +78,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,