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 08B3E35959 for ; Mon, 20 Jul 2026 09:16:25 +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=1784538988; cv=none; b=sxPqU2UDH389CCcz4p9BaAB1q0FiwqmNeyTtA9w1rVbsIsCMKOA8oSb+YzosA51itHv9dzvW1G3IolkEmHKqi9FpCua9fh4I/Up84S27jhsxST+l/k8zsgpEN4WJAqY4hs9jE+qnES9sPNrr2v49GdXz6u4Z9ix9pZmNJuu+yD4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784538988; c=relaxed/simple; bh=hLiCu8CHxsjmDrs7lAbwH45NEdiNScRL3OPRtwTkJ1E=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Pg3EDmQpsST9gQ1mHiUrAROcS5jQBDXLXL7MjJ4HsKAhMtv7JjzgWvbVEcXiLaUeVJFFeAsfmxpb/Nr3cTgbSb5YjtJaokeKcbKm7WgPwlC+csctq9fIQVcOsk6/iSEuE64Rt/mBxNcnxhq0GpjPA43Zrt5+qXUZXwo2GK1WPk0= 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=TNtwNbP+; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=HmQbQo2R; 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="TNtwNbP+"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="HmQbQo2R" Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66K771FR1896192 for ; Mon, 20 Jul 2026 09:16:19 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=9oQcZnrPsmef5DW7iw5TAiJvQJixC0ZK8rq xshwGSUk=; b=TNtwNbP+NawTBo0Ywm4izTjT/gxS8EdVYFoOHHgav0s3XmMiHVY kuVp8fQxwUG8ll0mqHEQo1L7dgt0aFzVpcxyg42hfSLCVsluAGS5BWXsBhEbmyiT xIzGuzAT486xL+SzY3dCkMj9MwNReYHxZx1PfT2gLJv87R0vpXKMSbeoBPBj9WzK Qv3oNjrN0NNUnhsMTr8Syf9xBQtHmCmWFtVD1AWuibpjqGTzbh3HKZ75aUoQA81d QvkvpTKviJHVF8gOZKfF76IHte9xaRoHeEr4AJYju82vhgWG0Xs2jJPlHE8CmyL8 fWREVsqfdGIgONOiECSmu+t6QPESbBRCbSg== Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fhf0krkuj-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 20 Jul 2026 09:16:19 +0000 (GMT) Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-520a00c7a03so96633881cf.1 for ; Mon, 20 Jul 2026 02:16:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1784538979; x=1785143779; 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=9oQcZnrPsmef5DW7iw5TAiJvQJixC0ZK8rqxshwGSUk=; b=HmQbQo2Rc0LJw8tM3vtTm2qpHDpqBavo+X782SUYcm+VW5Ftmz0PuM4Sa6vNm2LiY+ 2c9ZxshtNPp/J5OThjsQsSy80WzeHBB8LLXM9RdQ/0/PthMOBVylpV+XOxlzD46zC36H uNfHRAaenz5IBDuNL3xuALaXL4ujjQ6Uo+G7PeSqU4amD4Y8ShP/hgEAT9Mt6XtDvx+1 ZxV9vQNr9YAEXn2rHFChhSZkSan8lvD8kFEQw0/eZAV4ClWV3dLAHamcEMuxt4QxSu4L hy34dI/p+vqzsvNXxkYjDRf+F3gw4XU0nabv8aJcxHu4PGtytH2Gs5/0W84y6ZHu2JJL 39LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784538979; x=1785143779; 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=9oQcZnrPsmef5DW7iw5TAiJvQJixC0ZK8rqxshwGSUk=; b=rHvnuslP38PluTNgmm+8CgxMTDcmPQLfDxVkvkS0U0Q8VQF/bzLb21He52Bcom8Hwu 6p4vA7PmneB7t5p3pErgqVD3EVUAEJBhpuH+E88OdtH1yEtECL4uM0gK4ELJDq31/2z/ YNRbGIi9sKloVOJgCeS7wjPWgfXctvW7v7jBCGBIg0idMFb/ywipoGzbmg1a+ycT9mkS IK4nlWx5axXU5FTxti62HA7g3WrsCiv5u0gyvN5l++vzKociPiKHx6V7c+qtlfpYnniU yhL3TmwUIEm9pvlUJTusHfCjipIMs6M6bY76AJQEG5w0jrbjwcm6iXBVNo5Ht+8FCprA z6yQ== X-Forwarded-Encrypted: i=1; AHgh+RojRhsW1jANXWhO+4aJxHnnltYRCnZUsZqGjKuVcA6L88YT6YDZnRFKcoVDCniL7eOlLnXvrGWjC0jDRwQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzGlKUGIsN8PCNCZSj9c7XvN1qCK8St0Wmi0RTnLo7NZ3cl64AK 7uxRchZyvpn2038in2u5EI98r1rOZ2bxo/E+swkbZ2kK1+N+Q/m2hI1ltO7yy+Q9i9YyVMUB/4w A4AunICxM72cXyTR/vT4LCi/rI4V++nUxhQowaCvC8fSEf99Cs3tSFgfkvVJTnbm5W4M= X-Gm-Gg: AfdE7cmaGVLMGJC2XZGZUmASaTvjT56Ud66NqefVmG1wKkeeMKUka0rH2XL4vXf/d2Y 0L0GsKXKo3nZv0dPD+nzYlebOs7ngb58SssqfthA+0Z7+VwK4xfsh6gZltWKnLuX4R94R0C1xXm DTzUgSWd5tF7V+xiCz2zpMjARHVeFjCwWlb1q5fipItB9K6fXrFXgyYtcjSOt0FloiNIuOP5F5W +PtVMyTFcCg4u7GkftM8OJxiNKma26MfaVu7z7Xy4ecghwQ4jgQk8Try5qdGP2VlxrMTAKadZal zi44M5V5DJ3/nkFCiaVTgwP3e2meT0FTG9hF99yaKAO4xKaiqLMbILthICB9i00CKpLBgAPNZI7 +3OwbFaOpChvowwuSm8eX6iFPBb+03qzFjS5TNLiLUsFrNH/wpDs= X-Received: by 2002:ac8:5705:0:b0:51c:24a:ea6b with SMTP id d75a77b69052e-5213c8e3425mr118751801cf.4.1784538978600; Mon, 20 Jul 2026 02:16:18 -0700 (PDT) X-Received: by 2002:ac8:5705:0:b0:51c:24a:ea6b with SMTP id d75a77b69052e-5213c8e3425mr118751471cf.4.1784538978050; Mon, 20 Jul 2026 02:16:18 -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-49563969482sm12331985e9.3.2026.07.20.02.16.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 02:16:17 -0700 (PDT) From: Jorge Ramirez-Ortiz To: jorge.ramirez@oss.qualcomm.com, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com, alim.akhtar@samsung.com, avri.altman@wdc.com, bvanassche@acm.org, can.guo@oss.qualcomm.com, beanhuo@micron.com Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.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: Mon, 20 Jul 2026 11:16:09 +0200 Message-ID: <20260720091614.544968-1-jorge.ramirez@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-ORIG-GUID: TtpmhlvGrn84f4ypyiEKeYB5rxkbrkAf X-Proofpoint-Spam-Info: AW1haW4tMjYwNzIwMDEwMiBTYWx0ZWRfX1XfNDmViohBL HoAjjC4lWkNIR60FxnyFeUN4F0hS46fuLioTVEoNCmxSWT234O0j2JOWXIBB2q5HRcMko1SX8oL w9gx0rF4jN070SFz4iutExxbSlJoVvA= X-Authority-Analysis: v=2.4 cv=G58s1dk5 c=1 sm=1 tr=0 ts=6a5de763 cx=c_pps a=JbAStetqSzwMeJznSMzCyw==:117 a=2lELrtOEK2EaG96G7mOeag==:17 a=RAioF0-LDSMA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=_EMmJvYMAAAA:8 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=NEAV23lmAAAA:8 a=EIJ3WXMgmfCyFXXGMWUA:9 a=qcg49hLlgF0N60+LroqrWnV/Vu4=:19 a=uxP6HrT_eTzRwkO_Te1X:22 a=emCv1hD2LFd8cNRmW21v:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIwMDEwMiBTYWx0ZWRfX9cr5zuILzhhb 0GbuGIiKa5zUQ9xpdHt6Fg4rASZ2ugmImh8Xvul/FrfYduxt1ztKBp5EVXtpM6bc5CT9qunynLC eI91xWU4R7klYHjSlvaQMvRTZMM7MzRoUNUnB6GY8CQ2BRcq16XQrykbYibK2ZKTg3Hog7u7hfk wkxG6e+HP5C+3xec7E9DxINN0lvzHmr6LRijNADVFDIZXEaLnGC/lKpobx0o2lFsGURcACkl1F2 OuzT8RufoyRQqBYnx0/Tu8wgGtbNHd9PjkN0Tnwizyz8hB3sQx1qRjErsBJlxKu7HzBJONj3xkk Q6cYXfDyT3FqL7ezkGMc//QeTnbTA4nJC3COQbhgLch+yBRlI/uWfAavPmo1HmsXNnVBhUfv+Es 5jvKjTWZDNHP/qWsUHiUQw/EiH/446O5/qHZGkMevxQujhCLa1F/baQ2H4JUztLZsMC9LWXqsXC m2TyBlBMiR8UD7QyMMA== X-Proofpoint-GUID: TtpmhlvGrn84f4ypyiEKeYB5rxkbrkAf 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-20_01,2026-07-17_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 clxscore=1015 spamscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607200102 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 Dependencies: U-boot: https://lore.kernel.org/u-boot/20260720085202.537019-1-jorge.ramirez@oss.qualcomm.com/T/#mc423eb4dcf8a15849077029e4f7c1913bb7d8873 OP-TEE: https://github.com/OP-TEE/optee_os/pull/7881 v2: * ufs: rpmb: replace blake2s with blake2b so that the same support can be added to u-boot (CRYPTO_LIB_BLAKE2B) * added links to U-boot and OP-TEE changes. 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