From nobody Mon Aug 10 02:31:28 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 4hJJfS64lpz6pVJ3 for ; Mon, 10 Aug 2026 02:31:28 +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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hJJfS2htQz40SF for ; Mon, 10 Aug 2026 02:31:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1786329088; 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=l2xUy1xKPi2cIMSfPqkUmNxjtuUrC/y1HPVIZyMo5HM=; b=w4yFHq7HRpmWubntp0jrBloSP/ni8Lpi/MGCQ/LxNqeNS3xgXxsIcq95RjvukhWnEUoJbJ ThJBzlSPDax4vycTXlNJirlYtjOflV/Pgsi/KYOW3HF38C5xU56o2qzxopzi/EGFVYuGfe 8c1Qk78DfTkaRkXaKaHASpUnqFjY/tFwNVHqgvGHUFdG+nuGVTxBuRy46VRkspzrcPk5S5 LJupy7hAKh+rj5BVP3A39zIPrPPbx3Fswr5hFZT0MjLw086XFX/JiWU9gNCQTe9+pVND4q yvxznUQ1s8rpXhDDhMK4/azza2bzMPj0gQSaqpmghFrbzHcOLMELV5zsgDI09Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1786329088; a=rsa-sha256; cv=none; b=hGMD5wwKQJh0nXxdEuo3xL8afmHX7eyNiDbjpiQASrjCz9LWIvMNER4+DOGLb/cnNLYqz7 zMSumrO+ik8f69Gi3m/O0CnG/SdMxNpDpRt+K6YOpK5TVWkRBPwuRELPqwbHkob4CaAjot luIx4RsBVNmB/li7Vatx2wI5nlgNS+xZNnxfPIeh7aaWYZ51mseEZDnp8ixdcxtGGvWt5L kI2ep8YpI6Brip/+7L9ENUrlj+qCo0FCn7glt1PPbxOJokH4FUAoty1NJojnAJUd+WLbeb gjqqmBlzhjzxg0vu/gGC6ZQwBWuCHfSSvN+Al9E8rckXeJ3F9ft4ItwnqsLPVQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1786329088; 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=l2xUy1xKPi2cIMSfPqkUmNxjtuUrC/y1HPVIZyMo5HM=; b=Oc5/N4ZGNuCxNCLz0B4T47ijutZZnadOwJ7NpV99GkFN0W9ch0TCUCAgqftTyAMI/yKbM1 nHYzIT3bfpH3igL4OFu1hDI3uMORKT9NbA/fz8eSnSGWMjdDFMnXHKwNxZiHZQ5tVRcH19 N5fU4/ha5+7Ysc2svK4eTyssVaUMSEk9se6x3T2LsdZgNqnEMYTcaLRRfB7AWGS56BaFip IQdCkPJbbaXfUyDZ5kv0Pni52Zt5Ci+QGdRok82qwTs9EqVvoLPe0NlkSEtGTRop5H/IAM dbGGYl0Ba/mYIESA/zf8desgMnLAmHYKN8fwRg1N85CHb3obkziIIfWZEibINA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hJJfS1NtfzqjT for ; Mon, 10 Aug 2026 02:31:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1e22f by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 10 Aug 2026 02:31:28 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jaeyoon Choi Subject: git: 50a00f10d830 - main - ufshci: byte-swap big-endian UPIU fields List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: 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: jaeyoon X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 50a00f10d830119ed54f5bce1b34533f3a09325e Auto-Submitted: auto-generated Date: Mon, 10 Aug 2026 02:31:28 +0000 Message-Id: <6a793800.1e22f.3ce11e46@gitrepo.freebsd.org> The branch main has been updated by jaeyoon: URL: https://cgit.FreeBSD.org/src/commit/?id=50a00f10d830119ed54f5bce1b34533f3a09325e commit 50a00f10d830119ed54f5bce1b34533f3a09325e Author: Jaeyoon Choi AuthorDate: 2026-08-10 01:46:50 +0000 Commit: Jaeyoon Choi CommitDate: 2026-08-10 02:28:52 +0000 ufshci: byte-swap big-endian UPIU fields The UPIU wire fields are big-endian. The task management and query builders wrote host-order values into them. The completion paths also read the results back without conversion. On a little-endian host an ABORT_TASK carried a swapped task tag and LUN, a query carried a swapped length, and attribute reads returned swapped values. Tolerant devices masked most of the damage. Convert with htobe*/be*toh at the wire boundary, as ufshci_sim.c already does for its fields. Sponsored by: Samsung Electronics Reviewed by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D58664 --- sys/dev/ufshci/ufshci_ctrlr_cmd.c | 10 +++++----- sys/dev/ufshci/ufshci_dev.c | 2 +- sys/dev/ufshci/ufshci_req_queue.c | 13 +++++++------ 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/sys/dev/ufshci/ufshci_ctrlr_cmd.c b/sys/dev/ufshci/ufshci_ctrlr_cmd.c index 2e85cfa4b5b0..faeb6f98c942 100644 --- a/sys/dev/ufshci/ufshci_ctrlr_cmd.c +++ b/sys/dev/ufshci/ufshci_ctrlr_cmd.c @@ -29,9 +29,9 @@ ufshci_ctrlr_cmd_send_task_mgmt_request(struct ufshci_controller *ctrlr, UFSHCI_UPIU_TRANSACTION_CODE_TASK_MANAGEMENT_REQUEST; upiu->header.lun = lun; upiu->header.ext_iid_or_function = function; - upiu->input_param1 = lun; - upiu->input_param2 = task_tag; - upiu->input_param3 = iid; + upiu->input_param1 = htobe32(lun); + upiu->input_param2 = htobe32(task_tag); + upiu->input_param3 = htobe32(iid); error = ufshci_ctrlr_submit_task_mgmt_request(ctrlr, req); if (error) @@ -87,8 +87,8 @@ ufshci_ctrlr_cmd_send_query_request(struct ufshci_controller *ctrlr, upiu->idn = param.type; upiu->index = param.index; upiu->selector = param.selector; - upiu->value_64 = param.value; - upiu->length = param.desc_size; + upiu->value_64 = htobe64(param.value); + upiu->length = htobe16(param.desc_size); error = ufshci_ctrlr_submit_transfer_request(ctrlr, req); if (error) diff --git a/sys/dev/ufshci/ufshci_dev.c b/sys/dev/ufshci/ufshci_dev.c index db7a8c564a29..454572f966d5 100644 --- a/sys/dev/ufshci/ufshci_dev.c +++ b/sys/dev/ufshci/ufshci_dev.c @@ -192,7 +192,7 @@ ufshci_dev_read_attribute(struct ufshci_controller *ctrlr, return (ENXIO); } - *value = status.cpl.response_upiu.query_response_upiu.value_64; + *value = be64toh(status.cpl.response_upiu.query_response_upiu.value_64); return (0); } diff --git a/sys/dev/ufshci/ufshci_req_queue.c b/sys/dev/ufshci/ufshci_req_queue.c index d8d86070c18c..db96d13fad24 100644 --- a/sys/dev/ufshci/ufshci_req_queue.c +++ b/sys/dev/ufshci/ufshci_req_queue.c @@ -484,6 +484,7 @@ ufshci_abort_complete(void *arg, const struct ufshci_completion *status, bool error) { struct ufshci_tracker *tr = arg; + uint32_t output_param1; /* * We still need to check the active tracker array, to cover race where @@ -508,12 +509,12 @@ ufshci_abort_complete(void *arg, const struct ufshci_completion *status, ufshci_req_queue_manual_complete_tracker(tr, UFSHCI_DESC_ABORTED, UFSHCI_RESPONSE_CODE_GENERAL_FAILURE); - if ((status->response_upiu.task_mgmt_response_upiu - .output_param1 == - UFSHCI_TASK_MGMT_SERVICE_RESPONSE_FUNCTION_COMPLETE) || - (status->response_upiu.task_mgmt_response_upiu - .output_param1 == - UFSHCI_TASK_MGMT_SERVICE_RESPONSE_FUNCTION_SUCCEEDED)) { + output_param1 = be32toh( + status->response_upiu.task_mgmt_response_upiu.output_param1); + if (output_param1 == + UFSHCI_TASK_MGMT_SERVICE_RESPONSE_FUNCTION_COMPLETE || + output_param1 == + UFSHCI_TASK_MGMT_SERVICE_RESPONSE_FUNCTION_SUCCEEDED) { ufshci_printf(tr->hwq->ctrlr, "Warning: the abort task request completed \ successfully, but the original task is still incomplete.");