From nobody Mon Nov 09 19:14: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 4jNfbV0Flrz70LJH for ; Mon, 09 Nov 2026 19:14:14 +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 4jNfbT5sTSz4TQy for ; Mon, 09 Nov 2026 19:14:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794251653; 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=W3d4FeJeo8/G1oSQhcvcVrY9baa7tK1re4hYHqN4z0Y=; b=NxseLQt2GLpNoKO0YpTcrsqL0pgfoxCVy03ppRmEpR03X/Pq9MUUterFG+kYQVgkYVUQzF McjbQ0lmX9j9QmMb01pjpT4dAgT83ohSdrGaYX9wYT+wWWLVZJnY6TiSrG2vJ/L6vBRTgY IKa8xxT4f6GP0KvYvgQvF4CWAe9L8oAVpuOGpbaVlM0DdWb2QoCgigM7c2q2miEPcpPnKZ yrJ4+C40RT0Jk/Fwv/UUjbmoU4hz0Mgcnl1e6n9s2up3K9pw3L6EPIi4OSj2zmHLJMJW9t 6iwD0BsCqh+0RBbZZyfbhUxQQru7w3/aZwDzN3Tk+krZlhJijjmiKKv3xlGY4g== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794251653; b=NCgIpi7kLCxC9sY/1MBxAPnq3/tXE0P/54kwJWWLQ4kvjWvt7r74jQTfXYmSBVmmtKA91V m1sJq/NHgxvsyJ+psJq0atnFLAp5V7bkNiZmvwoAZPAAnn5DQS0WLaV6yUq27xjI2KTcyB jzexwksYC7dKp19mi2R/IM9GD6+OJ4qwr2lwUoeJVmgTGiSzwQ113ucmMj1H863aTFWgii cnsN4sHSets/6O+aGO/pyebb3sXmF1FG/uuOy/09NuCVDEVNdOZR0zKwyqZsLo0XJUCjfb JPn6IVwTvriKVQnjf/cFFhWGIoA5HFoyw9lCHx9B3kO4g4Y6X4CQooWxMqHqZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794251653; 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=W3d4FeJeo8/G1oSQhcvcVrY9baa7tK1re4hYHqN4z0Y=; b=U6HYAhvMybUxiCasSbUKLmcSYmQsmDDr/AyYeKp1dN6STaQ6bshKL0sB3kLTQ0V+dQ/OQP nqnceDZZMTPEqPT6kt7gn2RzuStJ+CsvqXwFRNbzGBvQXIf9NV4O6l6IeSmvLhHbknOsW4 rfRa9Rcbn5VXE7G3TQ6LSNIpaIUtsDkN1pFijqEs9JGGsUj4+IK0N37ojRmaQKRmAkZwfV ryAO5miwo/3RUcTT40QBA9dhs95zDPnZZie2Mv6sd9cRfvgZC5N4OI7666OZc6Te6vIzT8 h5FM44K+CkK2FIA53gR685v2hClA3qayWDI7S3+cwDOUqgTfC6dbAAHwkB+U5Q== 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 4jNfbT5XrWzv5y for ; Mon, 09 Nov 2026 19:14:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id e4e7 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 09 Nov 2026 19:14:13 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kenneth D. Merry Subject: git: 2dd34affca4d - main - 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 Sender: owner-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/main X-Git-Reftype: branch X-Git-Commit: 2dd34affca4d1041b8f6f58bb24c45f29b720430 Auto-Submitted: auto-generated Date: Mon, 09 Nov 2026 19:14:13 +0000 Message-Id: <6af21b85.e4e7.2819975b@gitrepo.freebsd.org> The branch main has been updated by ken: URL: https://cgit.FreeBSD.org/src/commit/?id=2dd34affca4d1041b8f6f58bb24c45f29b720430 commit 2dd34affca4d1041b8f6f58bb24c45f29b720430 Author: Kenneth D. Merry AuthorDate: 2026-11-09 18:47:01 +0000 Commit: Kenneth D. Merry CommitDate: 2026-11-09 18:59:13 +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 --- 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,