From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 57B8B344D91 for ; Wed, 15 Jul 2026 21:43:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784151815; cv=none; b=lCFgImX3Lvwva1lcTcYG7bLOqUVJYff8+hlOSPdpJZFCF4k1hqa3Xe1rwVwPIxhQV+7F9TFBRbLQJedCj+Mm6RXiAlduKQpmgV0r8Qt8vQihDbGWVUG6pDmnyVMY/nfSh5jonzMFZS7E11dbqr5avo71DuFmu3BYC5tCBeeKfxc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784151815; c=relaxed/simple; bh=ydesc48nFZN4QYKxkYYCcJd6lszzjzByE6lV+3I5Mfs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=g8e/Tjxy8owMaxcG77XEUhQuCXGPF+Rp+PFDmVbqKQZAKvqjyX8viz/G5q9a+fbwXUT7Fggakon7QBLajLnGZwRIrLm/QiOS5a+4RY14oEXGyWw9q0rCiYfOlYIsaTSFPRiBQjRVkpBZJsYcGLDrQyyMCTIXRPyZLeNUUoMgZjU= 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=cQRUIiDj; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=JX2y+0/+; arc=none smtp.client-ip=205.220.168.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="cQRUIiDj"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="JX2y+0/+" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66FKPgoQ477279 for ; Wed, 15 Jul 2026 21:43:33 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=kqzd4g9UykK7dMt3kOtTRxoaEwoOgQlKy8d 2xlJaY6Q=; b=cQRUIiDjPr0f+/aBODRJ7Mbe/mu7SCg7WktgfrWXl2WAl9K8r9p aCqBNWBbfOH+dKcXQl2C9dA1EEkWInsPh+ihNSJ9QhsmZ7eHyPp/LDu0xmg4FxR7 I7ZpCj4278Bbf1SeR1Pke01d659VVAhe0q4ls6gqRiXQuxZowUNQc9SbF7RfF+bG 72lWdXhXr7etNihawUOlLbdzxPgGO0m5jMyI20IzL+LoeLguC/Q7FAkTR0zH8RAa N2XNKAQ3wR0N6oHT7FmYcpExS0OfW3TPE1b+0brqKhc81QhpdWjAnRfmvc5SrLo5 QjlsPOiihCe5aMPykKpIEDk/1/Roii1ay0A== Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4feehv8vc3-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 15 Jul 2026 21:43:33 +0000 (GMT) Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-51c20762d21so33916981cf.0 for ; Wed, 15 Jul 2026 14:43:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1784151812; x=1784756612; 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=kqzd4g9UykK7dMt3kOtTRxoaEwoOgQlKy8d2xlJaY6Q=; b=JX2y+0/+lok1pH4NW5LonpxVGE3QDhgIciG8MYbQ29R3gdMHoYkhosoH+ZnKC0PnSR 32tHQcAtp0KcDnG9zKcog7Lug++hb/gQGa7on/HRMffsG6aOQCBAOGYssZgn+0b+l5Zh Q4kYBiWjpdjv7I/6Df35Bn57ATTwErGB79awFwXAD/oHLEPRMBxu2VZmBninhqm2tYnH p0PXGF17bM79EngZrYa1U7oHlGzwHF1llFKg+FbtBq66TNaU6EW3ig1Lg1E7g5krEyZC JFuq9+1Wiey1ovq5B9gyYPl51Co3db90e10pQOA/d9p/+gtU9JkpjWsfQn/SagzbJWoA 0Mkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784151812; x=1784756612; 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=kqzd4g9UykK7dMt3kOtTRxoaEwoOgQlKy8d2xlJaY6Q=; b=p4+4S/NtyewYuafwc8yJlnZdofc7QqLbHy18GHyZf9jM74vbi310PJEZpkKqxozy1z dJRweFzPQ5GjKP359YtVuhYsEslw/q0Gq8hQR1yXcBY1kUbMLJjrTPtWuepMF31G06X9 gxGndO31XGpJWFlWKN8IueRZ/v/7IFSO7OIM/Uo/sQJhYlZ6VXKA+ofz6hTU2DbVdS1y +A9p/HzSjpJUfZF2bwCPZsZqnIYM03E2XjDiVcgFLHmOfBfnn2FHXzAG0JTGDPZeusLO owy/ITYUhbiDUa+SkSfKrrAdZQb0PG6yyok2jG+ojfiUltWBmyg0FmOFbsLWz3JQaMLN RJug== X-Forwarded-Encrypted: i=1; AHgh+RqwNILoPclu/2hKnx04GMg7P0bv2TKuUZe8AwqstfR5EUP49NYbsovajk0pG1S9XFr4kLZPIMAVJP44Kto=@vger.kernel.org X-Gm-Message-State: AOJu0YxEZBYtznVfpd6hS6fvZGv9KDlONCFQuso41UtHEXS4AjUNLJVe JH+TtoZIM2FNqPv0XlnZdFSDt6RTuhZstlozgFNzjPDl0V1vLRdDkdwxJH6j2hPwgzFFFRBmvuj Z/TMAVGTkflux6/hhX96C/tAX6eW0GWLrXtHeZ5T8mzyCtHY2IVe8LOZ8qy7KBq6IlHQ= X-Gm-Gg: AfdE7ckd2umICoE8l0lZ66e0YZbQqd4wKHXqWlzFjWWtTTcJ25L0i/kyDBPUztIID4u zOek+2cPuTq6WjsJNl26V5igWx+ToLSdNwAtAW85pRXkDYI7ivXPBCUvmlWfvQ5MuSiZI1Jpdxt 4yCCyefhebvlYx/jtQti6rGb0X6RaRgRP+MF3DMU8FTYLhv+1cpDQF+1dX0Jg58PpkmPTTyY2XS YUEbsfHuREaJyY7Fqg4mnjM0SwAt9sGacv1ceaSwf7U9mIEneF4aCw8s8wI5CoKMtur5ep/qoVD aviOq/ycOdIpik7auPgG7b3sFiLtfR93nTgUrnWmvXYrSELqcQnhgi3IzPR2ehcp+mcJ2K+/Lbt imKjmK0iw4RNcPDRpRksgA5vmD3i/IKOI9QXkROFY7rvSuf8DiHs= X-Received: by 2002:a05:622a:5a12:b0:51a:8c99:1f14 with SMTP id d75a77b69052e-51cbf27f4femr186098681cf.67.1784151812381; Wed, 15 Jul 2026 14:43:32 -0700 (PDT) X-Received: by 2002:a05:622a:5a12:b0:51a:8c99:1f14 with SMTP id d75a77b69052e-51cbf27f4femr186098411cf.67.1784151811951; Wed, 15 Jul 2026 14:43:31 -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-49541eb7372sm14200775e9.13.2026.07.15.14.43.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 14:43:31 -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: ufs: rpmb: make RPMB usable with OP-TEE key derivation Date: Wed, 15 Jul 2026 23:39:14 +0200 Message-ID: <20260715214327.1933560-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-Authority-Analysis: v=2.4 cv=ZpDd7d7G c=1 sm=1 tr=0 ts=6a57ff05 cx=c_pps a=mPf7EqFMSY9/WdsSgAYMbA==:117 a=2lELrtOEK2EaG96G7mOeag==:17 a=RAioF0-LDSMA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_K5XuSEh1TEqbUxoQ0s3:22 a=EIJ3WXMgmfCyFXXGMWUA:9 a=dawVfQjAaf238kedN5IG:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE1MDIxNyBTYWx0ZWRfX8vLVWm2n3X5O /kGTqS4OmxqZBh8T8DXBlF5TqxZTweHeZnVy3yYtdKCF/mZQ8tjw9G/nwCusvPZv1hhOfQwtSgN zzYhKfZwfpBZZi28oFVA7h+fxxLBVn6eBw4iEBKO5VTKlimDkJWsUDu0RNrG0KEPm7pV/hZ1iH3 OZLdpMzFxzys9MrYu/LM0AUjt4Amex/nCe0Kqf7W9lOaQ2CiItsViC26dRyt9BL3nwHDa1XiBV9 C6nwXNzBVs1srQ5LPQihlUfz0XfDxm8KegNVATO1T32owQoaFECdFU0AndXQEchkqm2f0GDs2zG 0VegA6mpuEuwsX6lrodxj2zoHA/5mT+sHiixLM4u9YT+mgg+23edYndr46p/047ZyKBIqREKhvh r48Gp6SihohhGj0DOQkic38HUAVxzidzFEIk/RT3bVeBN3WMv2yiLzPldQwkOvAN5+UbvfT8nIB A1DjvyR8QtiDzoxhQ2w== X-Proofpoint-GUID: nJM625sBUHBEyCw-S_vDOG46CQX2zxYW X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE1MDIxNyBTYWx0ZWRfX2JTRDpXsRItC vc69uwckbTaxmCR46gHDP232LYRvQHM32Vccg2iuOG2aL1pMl+VIKoKWX3h8hc8SEVhjiy59ijE zOnQVshgnQWV7xk6h1OIqZA2Q0+cQ9c= X-Proofpoint-ORIG-GUID: nJM625sBUHBEyCw-S_vDOG46CQX2zxYW 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-15_05,2026-07-15_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 spamscore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 adultscore=0 suspectscore=0 clxscore=1015 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607150217 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). 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/Kconfig | 1 + drivers/ufs/core/ufs-rpmb.c | 41 ++++++++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-)