From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B93AB39D3DA for ; Thu, 16 Jul 2026 08:37:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784191059; cv=none; b=mu+LSAJ1Ra/CSfmmSzc9YcIrs2veMOGdCPFyzQKWCAtbN/deMv4iuuOwxJ8vuEChiIS7ytvJRsgu/kiQa2NeihXwsuS7e8A8LcvPfLP59xCDvV+ShlMyv1lGTv5BKX1oKC4bUOYFQnYLRP+EnHtjLif6x3FZkvJP4ndf+HaFVFs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784191059; c=relaxed/simple; bh=DFUmG7barH67047rlslm7AUbisk/Fbm3Y0Olr4q+NdQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=D/Vx75PkeHej+6bKbmsJqvh1cMdJMi8nwMom2EVkg9/pgL1Mx3D0qMYZ3uDfwJixuz8rbAOkEo0YTA9ZIzLfZ8sEnlUzsWSCcgxUP+52NkU9bk8aYCv+g7vaNZcIAo7Z9bfTaM4j2dmia3IyvsREvakwj/kMCyQ4VMiGwcAi12Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=SLPmVk2L; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=NndB+kfa; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="SLPmVk2L"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="NndB+kfa" Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66G7DviK2115242 for ; Thu, 16 Jul 2026 08:37:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=qcppdkim1; bh=aSKnOaJDl8e+I17N0jewdcxP1Pjy4BPpkit SoVF0jVA=; b=SLPmVk2Lsc4coujiqO6sa0hT2S1yFA1OspJ6aypmFgErB/CfCvr M0cJtG8bnSe2G4EHHNhz406e8YBSxpGPvhKmfEgMXHm3kBD9MTHomtrkExQNEBLY LzJc5FB62msy0knD1vgp+YyWRkkUPANL/frzp3SVipnJUvamixPFCL7+OE6cg72h hEQL0vdOKZgshXl+FybhI1587OVUF2jdHLiimV9H4VaRALabubsOfHUE8LTdBpHd /96sUp/8GHDiXnpz6MfI7+vWvP4zDSmznidU2cEwXg/CsYMfIXTq0Y94OFy78UG4 EmDzcsfn5AZ6AIatdgol5yp610V/W0sEy/g== Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4feeg1jv1n-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 16 Jul 2026 08:37:36 +0000 (GMT) Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-8eb8914e651so58783926d6.3 for ; Thu, 16 Jul 2026 01:37:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1784191056; x=1784795856; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=aSKnOaJDl8e+I17N0jewdcxP1Pjy4BPpkitSoVF0jVA=; b=NndB+kfaYXof2F9wbN+NWkxJh+uQznXA6l+JVOwOGJQuQ39bv8XrJKdBMhcYQFAACo 25gZ2Ksx1pO9xSaAJLNMpvJPmh2QIptVC08ho4H074TiJsTYW8RC3tv1GDA2o3HVG5Ht 0jGVc84bnJd1IVmEFuYSi6di8PtiNVb4nl74UDzdOXPjtMpEdPuRwIbfyVaDkCTfqESd pEN26NONK7LHMQUFte9ADggr+Fxt2QFfW/uTCzzDKUIpP5Q7m9dRVx53kqTT/UOVTv3J sFL7edUjnSRSZXAwCDxSg2Z6dk3XxdnFm+eGsCn2J9xv4TAH6fuTALdJ8NUUOiidjjWP fKEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784191056; x=1784795856; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=aSKnOaJDl8e+I17N0jewdcxP1Pjy4BPpkitSoVF0jVA=; b=kkORpCGQjdHcIcUKkFB9J2CZ5H0aBEwwFJOsdqtZIv0BIY0c8g57cCIzhLcALhPgDU R1NpVN6P2Qh0OwOE3+YS6XxSTTNWluazeYWQCQhyutVHDHnbGY0tdCR2ljjcHw51DiGR vCMgmmjDSsqhpiJ9XPnYq8FkUI05KN+ccbH17ecwX6iNp07q1LUVyrdhZRUXYtdA9qja JY875LLSVLQAg310dsoLZOXfr91IMC9JSF6DG0T2DvNLUQJUe6dxPgr0h3WITN0Ycy2J F0CGePLa/KFLyO1UdwlBMcnKrsWwh1JLf4shYVyb6puBCH7Ia9WS+x0+HQIUM2RG5//l 8vHA== X-Gm-Message-State: AOJu0YxhnY9ZHpf6/h+boyMYUipOIGRavgX2Y9sYtafDHIrN8huVfi0G XW6uquN4FFOQiuj2Ki8XG1Vkmq56zp4z2UFfMKRCwV8xm1NKYOU+JGqgBeKszAjl+WLbRGbzDSJ jEGzVEFd+SN/HHaFuvHIg/Hh45MuiiWbP6TUnSQgd4J4q7DyHP5yX6Z6VomxI9BS9 X-Gm-Gg: AfdE7ckfK9s3lJJBKTK59fqM89nHXcccbnMiYVNFtHteeaJmE9F+9cgkvqYBz/9Lz0A vItkiAQoRNUzD5VTECbl7ZxzpVbJD8nKCeIPuZeO8O8PP0Qiu3VijWFkYgKVQnEzLNJQ+Zn4c62 L9zoyD+AZaOykqrSRpKBZWetQsvI7n0kRCIkGdZPugxzH6byqo37XgQ00nVQYVefe1S01jQpzR0 fj0E+JMMfpTwDOUG/25iuw7+yQLVwvAPUn4gt6s3A8XZ9gQRFZjGFj7xY7oYmIfbtIQ7Z39epPG 4Hc30x0q5Dzc+FmmrPgrMplVbLKIjgtIEWW9s/l4kcJ1ywcp+sshgvBPJ/dN1dAIbdgQT/4Ho9z rLqla1RaMA5cl+oV2KyOEl0MDcXQrs5dfTsbpGpZ3drsd8Pwbuok= X-Received: by 2002:ac8:5994:0:b0:51c:147d:9bec with SMTP id d75a77b69052e-51cbf0dff64mr201887461cf.6.1784191055825; Thu, 16 Jul 2026 01:37:35 -0700 (PDT) X-Received: by 2002:ac8:5994:0:b0:51c:147d:9bec with SMTP id d75a77b69052e-51cbf0dff64mr201887321cf.6.1784191055428; Thu, 16 Jul 2026 01:37:35 -0700 (PDT) Received: from trex (182.red-79-144-196.dynamicip.rima-tde.net. [79.144.196.182]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49541e94e7asm43614295e9.12.2026.07.16.01.37.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2026 01:37:34 -0700 (PDT) From: Jorge Ramirez-Ortiz To: jorge.ramirez@oss.qualcomm.com, alim.akhtar@samsung.com, avri.altman@wdc.com, bvanassche@acm.org, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com, beanhuo@micron.com, can.guo@oss.qualcomm.com Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, op-tee@lists.trustedfirmware.org, jenswi@kernel.org, sumit.garg@oss.qualcomm.com Subject: [PATCH v1 0/2] ufs: rpmb: make RPMB usable with OP-TEE key derivation Date: Thu, 16 Jul 2026 10:37:18 +0200 Message-ID: <20260716083728.2226422-1-jorge.ramirez@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE2MDA4NyBTYWx0ZWRfX39r4nADbLFv7 kxRUlUhpVgSkLEkFKjSPkk+gSLn7JfcYaAX+GGkGdqeMswQ9TKRHP/G8hhEo0o/JIMxxQgE5cYC vw57SPKQ9a63GsKkXtY+fLMwjUP+zaGbDy91kJNvpRT4WXpelpdKpuLHWZ0gNG5R/y8dQKr/vIx SFXrCHDuZnioYM47nY7PFIeR8sMaqox2NAnDkCtAvsY6nZatZE9cXQvHw+JOB/DANciL2IUK2Kt +lgf6y9F3tiKRWXBw443+BjKEK42KUZ/qL8B2qOYNnHV7WOciV0g+4eZUf6LfHqws6JiO1Lzv+Y k9sLuhYIMTOL8qpVjj87UPjkoa+/1qgPg9j4pqDldMNV9GQYGUBpvVEK9doe9XmSAOi43EF3Eoj YF3l7YjcL6ThKn+QLSRXQV6u91E5GI0E+lWWBnHe92PuHfvgsEDU0pkWpHoV4Gvb/G1nHjoVNl1 hf52mK6ObbUYoYd7tMw== X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE2MDA4NyBTYWx0ZWRfX/CWRKiR601tL 8Hgel06maYdipubMUfRyHfAGreq23RwfbdN/w8QdE6ms8/a9xR/+9VAPvPLASHrN8mnt1IzRwaf qegJZ7dQGtBgNRfTQhsIJAd4jPqSrCs= X-Proofpoint-GUID: w7o0ABd6ymrM66eqJGOBORThNCJkYvaH X-Proofpoint-ORIG-GUID: w7o0ABd6ymrM66eqJGOBORThNCJkYvaH X-Authority-Analysis: v=2.4 cv=SsOgLvO0 c=1 sm=1 tr=0 ts=6a589850 cx=c_pps a=oc9J++0uMp73DTRD5QyR2A==:117 a=2lELrtOEK2EaG96G7mOeag==:17 a=RAioF0-LDSMA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=_EMmJvYMAAAA:8 a=EIJ3WXMgmfCyFXXGMWUA:9 a=qcg49hLlgF0N60+LroqrWnV/Vu4=:19 a=iYH6xdkBrDN1Jqds4HTS:22 a=emCv1hD2LFd8cNRmW21v:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-16_03,2026-07-15_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 bulkscore=0 malwarescore=0 spamscore=0 impostorscore=0 adultscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607160087 This series makes UFS RPMB work out of the box with an OP-TEE that implements the standard eMMC RPMB key-derivation flow, without requiring any fundamental changes on the OP-TEE side. RPMB provides an authenticated, replay-protected storage area whose security relies on a secret authentication key. In our setup that key is never exposed to the kernel: OP-TEE derives it in the secure world from its hardware-unique key and a device identifier (dev_id) that the RPMB core hands down. OP-TEE's implementation targets eMMC, where dev_id is the 16-byte eMMC CID, and both the fixed length and the raw-CID layout are baked into its key derivation. Two things stand in the way of reusing that same, unmodified OP-TEE flow for UFS RPMB: 1. On a cold boot the very first frame sent to the RPMB well-known LU comes back with a power-on UNIT ATTENTION (ASC 0x29), which the SCSI core reports rather than retries. RPMB has no earlier guaranteed access that could clear the condition first, so RPMB fails on every power cycle. Patch 1 asks the SCSI core to retry the power-on UNIT ATTENTION on the RPMB WLUN. 2. The UFS RPMB id is "-R", which is variable length and longer than 16 bytes. Passing it verbatim would tie the derived key to a length OP-TEE does not expect and diverge from the fixed eMMC CID ABI. Patch 2 hashes it into a fixed 16-byte dev_id with blake2s, keeping the key stable and unique per region while matching the eMMC CID layout OP-TEE relies on. The hash algorithm and input string are thus part of the key-derivation ABI and must stay stable. With both patches, UFS RPMB is functional from the first access after a cold boot and derives keys through the existing eMMC-style OP-TEE flow, (requires minimal OP-TEE changes pending on the CID proposal done here). Tested on IQ-9075 with Open Firmware [1], pending OP-TEE changes [1]https://ldts.github.io/qcom-buildroot v1: * ufs: rpmb: retry power-on UNIT ATTENTION on the RPMB WLUN: - fix using uses SCMD_FAILURE_ASC_ANY to retry any Unit Attention - fix unused variable * ufs: rpmb: use a fixed-length RPMB dev_id - fix selecting a non-existent Kconfig symbol Jorge Ramirez-Ortiz (2): ufs: rpmb: retry power-on UNIT ATTENTION on the RPMB WLUN ufs: rpmb: use a fixed-length RPMB dev_id drivers/ufs/core/ufs-rpmb.c | 39 ++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) -- 2.54.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.trustedfirmware.org (lists.trustedfirmware.org [18.214.241.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DD344C4450A for ; Thu, 16 Jul 2026 08:37:45 +0000 (UTC) Received: from lists.trustedfirmware.org (localhost [127.0.0.1]) by lists.trustedfirmware.org (Postfix) with ESMTP id E507C44F0B for ; Thu, 16 Jul 2026 08:37:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.trustedfirmware.org; s=2024; t=1784191065; bh=DFUmG7barH67047rlslm7AUbisk/Fbm3Y0Olr4q+NdQ=; h=To:Subject:Date:CC:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From:Reply-To:From; b=BmyFdIdMizQltOzT8jeAkYu/VQ19mVJ3x+un/eCiMLqOghi2dItGExS7xnLdY+Dum WQEpwnGX25kXE0Vs7841KhBgDBsfjUAnL8dTBYLpH3jRSDBMrGrOo7FuyTh6nHdW2/ 6wqvwc7fdTTJ4CP2+9oio8ZkweV6cFUH5Uo9WlHCzZ34npMsdPrkcy76u5v4jhcxK4 KzUh4b/mu0Cjg+czBwfnMe/uBLQ8FF/hyymgpLkjUXYp8Ei3xz33I9DtvUAJMtjlJW 0Ksrvs6CUdMUhux6JPTN3dVAh1qEGjjQGZPxVVzScNAL0c05vmrKo7P+FcrPDZdl8L Y9iAK0rFDRgYg== Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lists.trustedfirmware.org (Postfix) with ESMTPS id 5869C44D55 for ; Thu, 16 Jul 2026 08:37:37 +0000 (UTC) Authentication-Results: lists.trustedfirmware.org; dkim=pass (2048-bit key; unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=SLPmVk2L; dkim=pass (2048-bit key; unprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=HeHbbrHg; dkim-atps=neutral Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66G7DUW31892191 for ; Thu, 16 Jul 2026 08:37:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=qcppdkim1; bh=aSKnOaJDl8e+I17N0jewdcxP1Pjy4BPpkit SoVF0jVA=; b=SLPmVk2Lsc4coujiqO6sa0hT2S1yFA1OspJ6aypmFgErB/CfCvr M0cJtG8bnSe2G4EHHNhz406e8YBSxpGPvhKmfEgMXHm3kBD9MTHomtrkExQNEBLY LzJc5FB62msy0knD1vgp+YyWRkkUPANL/frzp3SVipnJUvamixPFCL7+OE6cg72h hEQL0vdOKZgshXl+FybhI1587OVUF2jdHLiimV9H4VaRALabubsOfHUE8LTdBpHd /96sUp/8GHDiXnpz6MfI7+vWvP4zDSmznidU2cEwXg/CsYMfIXTq0Y94OFy78UG4 EmDzcsfn5AZ6AIatdgol5yp610V/W0sEy/g== Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fecnybexq-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 16 Jul 2026 08:37:36 +0000 (GMT) Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-51c1c7f135bso57839691cf.0 for ; Thu, 16 Jul 2026 01:37:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1784191056; x=1784795856; darn=lists.trustedfirmware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=aSKnOaJDl8e+I17N0jewdcxP1Pjy4BPpkitSoVF0jVA=; b=HeHbbrHgyRIR8BMAftPDeAz2OywFMxhbDf/Gt6BkQLgVETART3RLzXW2HPAtc+xj5X CfvvfNcy8q8DRyWsbIyNok41Xdl7/afcd2ZlQ15ycgYWBk0QHe457bHUr5d+hph7jrAl PcGq98yyo/RCHi8eAk+0ngVtlK41UTIxAqXiFiD2rEat5mH39KUwRenQem3ddf3mRZJN 0S020dKHboHnWyKxU6Aw9w/dmR8W+NQgqJd29xMSNxAFxob+r80fD9xpMPWI/n2LpC6N lklhDQw3tCMth9nrCe6mlSTQXSjhiG4eq7mAX9+U9Uq2B6Urzk+utz6p7D9CbMpJ8UUK ZWNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784191056; x=1784795856; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=aSKnOaJDl8e+I17N0jewdcxP1Pjy4BPpkitSoVF0jVA=; b=dnL3LKr7EdpvN1e41tacugCzqCMK3wsv/ERrsrjdKIFLh4Ab3ch/+yXDWrUyvSu8iG S0h7z8u7hxdnRqTL1phbqszWeOo1BSnDUkXrWFzOWdc5qNiBK4p6lqIILFkp8dlnyaDZ 2JXUl5MEFUmM6LA2y1x9nhdhdpp5UYgrC+3+TnsOH/A9LkUg9u4EqVB3Neh8eDF4mJsR wYJOaZofSzgjniiurPcxKfp7QkDDEQvGjvGPUk76zacN85FFWc9a1StkuEPo/aQokI0l IvG+ZB1R37e/+lBg3wW6BBjLxHPKCGTR6j0kFU4Q7jlL8QvV5YZhbf1u81kTfQb6Gard 82BA== X-Forwarded-Encrypted: i=1; AHgh+RqedAtSR9+4RNlt4ulRREenje/Gd7AjHEgT4kPbLlbf9/U5G34kIVq+I0VIpZ9t5A2WPNIqtVI=@lists.trustedfirmware.org X-Gm-Message-State: AOJu0YxE0jI66K1klqDCkflwxdDv1o8FB/qTHrPw3fs1ba0QjHjwJxQh 0XTxc+VaBr5gzffU1n4YPzSOY3n/Myc43oVuQS+j+gxTTDqHW1rZTk3H+mv/2D6eAHgzVFDCFxa QmqqIUzQbA9aiBOj9vNFYQltUepm40YbvtBLLKSUDU7KU4ROH3lBxbmqUGM0tO6jOotbJExep X-Gm-Gg: AfdE7cmFlpSkvccAFfaHE7S1UxObnAQ3ACTWqlwr0b9Kk8zyiZVQEaz49wOoxWyJ6hC 262SdHPMj8dmMu0t28j7/2wRMbcNru47MP/qoWmQSu5Xj1CdtM4oKIKBLMLoi83GcOvxsCdWQdq nUgYUx863eaROPW8NlTjedQvAsxyLvrsWgrVaEzKDgB3nUUyeH61HHvNtSm9jGPfcLItXEXRcn2 tkNFHXPV0uYBdf9uRhh/RcDX7SwF2vOfHKFiLi/cgAjnLFgQtatAqQXtaBWCfjvuynTxtAZpaAW tQoSBrEwPsc89r9+cN1oxi+CSONk3bktfLx5DF14vCIUWrMqlt8QQGSQ+nCBTxZSx0O+8IXd3LY hKijJyrhf65kJckoIH6b7WJ/j6hYADDuuxzWGBBobeFq8hZqUmeI= X-Received: by 2002:ac8:5994:0:b0:51c:147d:9bec with SMTP id d75a77b69052e-51cbf0dff64mr201887551cf.6.1784191055839; Thu, 16 Jul 2026 01:37:35 -0700 (PDT) X-Received: by 2002:ac8:5994:0:b0:51c:147d:9bec with SMTP id d75a77b69052e-51cbf0dff64mr201887321cf.6.1784191055428; Thu, 16 Jul 2026 01:37:35 -0700 (PDT) Received: from trex (182.red-79-144-196.dynamicip.rima-tde.net. [79.144.196.182]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49541e94e7asm43614295e9.12.2026.07.16.01.37.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2026 01:37:34 -0700 (PDT) To: jorge.ramirez@oss.qualcomm.com, alim.akhtar@samsung.com, avri.altman@wdc.com, bvanassche@acm.org, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com, beanhuo@micron.com, can.guo@oss.qualcomm.com Subject: [PATCH v1 0/2] ufs: rpmb: make RPMB usable with OP-TEE key derivation Date: Thu, 16 Jul 2026 10:37:18 +0200 Message-ID: <20260716083728.2226422-1-jorge.ramirez@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE2MDA4NyBTYWx0ZWRfX2ZsxasOJvloS pksCgOlaU1fSUQ0bcE4hhOcFQkbbEICA0/Fqmi4JSkpB7N9k75iVMvjg4Em5JLvz79dJQxhMUXR rJbIZZNhLZzWJtm8bjnM+RuRotepaoY= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE2MDA4NyBTYWx0ZWRfX25wYmiHAOmka DTEwX7sPtoQXJO7rXHhRdOuxHmkWavdhBVD/D4jfTXPAZqo8NdN+173PPBMRyYwWTztu/RLsPh3 sikMwstU2WfjQLdnGD9/DIHUIncNbPMxTDNVeA/xwmGfzim5gRvI8ZhL4DdyLmxEQ8ujJcZpGLY OTI1ydwngcm+6Ve5qZTJAIa5ap8kIuCgJ2AziEfHKfF2GX5HNfDGvnn1pgi7s8d7/5756ZL1O+K wHRKYu3Szki1HUFDvisQKk4GaqdnLL9sL6QrnyNqsdJLrlkrrD6o3OzDHOYCAdDNbodLm+NBksj 6j9Cbjs5yuNyUJYubSaq/mFUNPKSw5BDEcTlquXd99yHr+ekjorsFCBHBZOWpmSpW+Zu7DiRSXg ErUgkYM4yBz3nKzitPtNbvtNrMMk+u1LszSLTVrRGhzNO2V61Pg2Q7RJcfoBpMNi8KF0fbZdBeE dhGRQ4mH8OnfURLuhEw== X-Proofpoint-ORIG-GUID: Z8Exf3MENBPDWquzU91pncG5Z6cZN7fW X-Authority-Analysis: v=2.4 cv=Lt2iDHdc c=1 sm=1 tr=0 ts=6a589850 cx=c_pps a=EVbN6Ke/fEF3bsl7X48z0g==:117 a=2lELrtOEK2EaG96G7mOeag==:17 a=RAioF0-LDSMA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yx91gb_oNiZeI1HMLzn7:22 a=_EMmJvYMAAAA:8 a=EIJ3WXMgmfCyFXXGMWUA:9 a=qcg49hLlgF0N60+LroqrWnV/Vu4=:19 a=a_PwQJl-kcHnX1M80qC6:22 a=emCv1hD2LFd8cNRmW21v:22 X-Proofpoint-GUID: Z8Exf3MENBPDWquzU91pncG5Z6cZN7fW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-16_03,2026-07-15_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 impostorscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 adultscore=0 spamscore=0 suspectscore=0 clxscore=1015 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607160087 X-Rspamd-Action: no action X-Spamd-Result: default: False [-1.01 / 15.00]; BAYES_HAM(-2.91)[99.61%]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; DMARC_POLICY_ALLOW(-0.50)[qualcomm.com,reject]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[qualcomm.com:s=qcppdkim1,oss.qualcomm.com:s=google]; R_SPF_ALLOW(-0.20)[+ip4:205.220.180.131]; RCVD_IN_DNSWL_LOW(-0.10)[205.220.180.131:from]; MIME_GOOD(-0.10)[text/plain]; FROM_EQ_ENVFROM(0.00)[]; DWL_DNSWL_BLOCKED(0.00)[qualcomm.com:dkim]; RCVD_TLS_LAST(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCPT_COUNT_TWELVE(0.00)[13]; TO_DN_NONE(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[op-tee@lists.trustedfirmware.org]; RCVD_VIA_SMTP_AUTH(0.00)[]; ALIAS_RESOLVED(0.00)[]; NEURAL_HAM(-0.00)[-0.999]; ASN(0.00)[asn:22843, ipnet:205.220.180.0/24, country:US]; DKIM_TRACE(0.00)[qualcomm.com:+,oss.qualcomm.com:+]; RCVD_IN_DNSWL_NONE(0.00)[209.85.160.197:received]; FROM_HAS_DN(0.00)[] X-Rspamd-Server: lists.trustedfirmware.org X-Rspamd-Queue-Id: 5869C44D55 X-Spamd-Bar: - Message-ID-Hash: PJAWCUR7PT3X35Y6TOB4UQLPHQIHEVEE X-Message-ID-Hash: PJAWCUR7PT3X35Y6TOB4UQLPHQIHEVEE X-MailFrom: jorge.ramirez@oss.qualcomm.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-op-tee.lists.trustedfirmware.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, op-tee@lists.trustedfirmware.org, jenswi@kernel.org, sumit.garg@oss.qualcomm.com X-Mailman-Version: 3.3.5 Precedence: list List-Id: Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Jorge Ramirez-Ortiz via OP-TEE Reply-To: Jorge Ramirez-Ortiz This series makes UFS RPMB work out of the box with an OP-TEE that implements the standard eMMC RPMB key-derivation flow, without requiring any fundamental changes on the OP-TEE side. RPMB provides an authenticated, replay-protected storage area whose security relies on a secret authentication key. In our setup that key is never exposed to the kernel: OP-TEE derives it in the secure world from its hardware-unique key and a device identifier (dev_id) that the RPMB core hands down. OP-TEE's implementation targets eMMC, where dev_id is the 16-byte eMMC CID, and both the fixed length and the raw-CID layout are baked into its key derivation. Two things stand in the way of reusing that same, unmodified OP-TEE flow for UFS RPMB: 1. On a cold boot the very first frame sent to the RPMB well-known LU comes back with a power-on UNIT ATTENTION (ASC 0x29), which the SCSI core reports rather than retries. RPMB has no earlier guaranteed access that could clear the condition first, so RPMB fails on every power cycle. Patch 1 asks the SCSI core to retry the power-on UNIT ATTENTION on the RPMB WLUN. 2. The UFS RPMB id is "-R", which is variable length and longer than 16 bytes. Passing it verbatim would tie the derived key to a length OP-TEE does not expect and diverge from the fixed eMMC CID ABI. Patch 2 hashes it into a fixed 16-byte dev_id with blake2s, keeping the key stable and unique per region while matching the eMMC CID layout OP-TEE relies on. The hash algorithm and input string are thus part of the key-derivation ABI and must stay stable. With both patches, UFS RPMB is functional from the first access after a cold boot and derives keys through the existing eMMC-style OP-TEE flow, (requires minimal OP-TEE changes pending on the CID proposal done here). Tested on IQ-9075 with Open Firmware [1], pending OP-TEE changes [1]https://ldts.github.io/qcom-buildroot v1: * ufs: rpmb: retry power-on UNIT ATTENTION on the RPMB WLUN: - fix using uses SCMD_FAILURE_ASC_ANY to retry any Unit Attention - fix unused variable * ufs: rpmb: use a fixed-length RPMB dev_id - fix selecting a non-existent Kconfig symbol Jorge Ramirez-Ortiz (2): ufs: rpmb: retry power-on UNIT ATTENTION on the RPMB WLUN ufs: rpmb: use a fixed-length RPMB dev_id drivers/ufs/core/ufs-rpmb.c | 39 ++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) -- 2.54.0