All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/5] ufs: rpmb: route OP-TEE RPMB secure storage over UFS
@ 2026-07-22  6:07 Jorge Ramirez-Ortiz via U-Boot
  2026-07-22  6:07 ` [PATCH v2 1/5] ufs: decode string descriptors as UTF-16 big-endian Jorge Ramirez-Ortiz via U-Boot
                   ` (4 more replies)
  0 siblings, 5 replies; 22+ messages in thread
From: Jorge Ramirez-Ortiz via U-Boot @ 2026-07-22  6:07 UTC (permalink / raw)
  To: jorge.ramirez, neil.armstrong, trini, jens.wiklander,
	ilias.apalodimas, bhupesh.linux, n-francis, marek.vasut+renesas,
	shawn.lin, igor.belwon, yoshihiro.shimoda.uh, alchark,
	tuyen.dang.xa, padmarao.begari, macpaul.lin, jstephan, bb,
	j-mcarthur, venkyada, hayashi.kunihiko, dlechner
  Cc: u-boot

OP-TEE secure storage (CFG_RPMB_FS) relies on an RPMB partition, but
U-Boot's OP-TEE RPMB supplicant only speaks the legacy single-command
interface, which is bound to eMMC. SoCs that are UFS-only and have no
eMMC (for example the Qualcomm SA8775P) therefore cannot back OP-TEE
secure storage from U-Boot today. This series adds that support.

It introduces the transport-agnostic OP-TEE RPMB "subsystem" interface
(PROBE_RESET / PROBE_NEXT / FRAMES), where the normal world enumerates
the RPMB device and reports its kind, size and CID, then carries the
signed frames. The legacy eMMC supplicant is preserved unchanged, only
renamed to rpmb_legacy.c; the two are mutually exclusive via Kconfig
(SUPPORT_UFS_RPMB depends on !SUPPORT_EMMC_RPMB) because the OP-TEE
supplicant handles a single RPMB transport. The subsystem interface is
UFS-only for now; eMMC can be migrated onto it later as the legacy path
is retired.

On top of that it adds a UFS RPMB transport that moves JEDEC RPMB frames
to and from the RPMB Well-Known LUN using SCSI SECURITY PROTOCOL IN/OUT.
The per-region 16-byte CID is derived by BLAKE2b-hashing the exact
device-id string the Linux kernel builds (ufshcd_create_device_id()
plus a "-R<region>" suffix), so OP-TEE derives an RPMB key that matches
the one Linux would use.

The first patch is a standalone UFS descriptor fix the RPMB path depends
on (UTF-16BE string decoding); the transport patches also include a
power-on UNIT ATTENTION retry and a DMA-alignment bounce for the RPMB
WLUN.

Note: reading UFS descriptors reliably also requires the descriptor
data-segment cache-invalidation fix, which has already been posted and
merged separately, so this series is based on top of it.

Tested on the Qualcomm IQ-9075-EVK (SA8775P): OP-TEE with CFG_RPMB_FS
programs the RPMB key through U-Boot and reads/writes secure-storage
objects, with the derived CID matching the Linux UFS device_id ABI.

Dependencies:
Linux kernel:
 https://lore.kernel.org/linux-scsi/20260716083728.2226422-1-jorge.ramirez@oss.qualcomm.com/
Op-tee
 https://github.com/OP-TEE/optee_os/pull/7881

v2:
 - Squashed the standalone "retry SECURITY PROTOCOL on power-on UNIT
   ATTENTION" and "bounce unaligned frames through a DMA-aligned buffer"
   patches into the UFS RPMB transport patch; the series is now 5 patches.
 - Reused the existing ufshcd_read_desc_param() (now exported) for all
   descriptor reads instead of adding a new ufshcd_read_descriptor()
   wrapper.
 - Moved the SECURITY PROTOCOL IN/OUT opcodes to the generic SCSI header
   as SCSI_SECURITY_PROTOCOL_IN/OUT instead of private UFS defines.
 - Factored the UTF-16BE string-descriptor byte-swap into a
   ufshcd_str_desc_to_cpu() helper.
 - Dropped the ufs_rpmb_get_scsi_dev() wrapper; callers now use
   uclass_get_device(UCLASS_SCSI, ...) directly.

Jorge Ramirez-Ortiz (5):
  ufs: decode string descriptors as UTF-16 big-endian
  ufs: add RPMB transport over SCSI SECURITY PROTOCOL
  ufs: derive the per-region RPMB CID and size for OP-TEE
  optee: rename rpmb.c to rpmb_legacy.c
  optee: implement the RPMB subsystem interface for UFS

 drivers/tee/optee/Makefile               |   3 +-
 drivers/tee/optee/optee_msg_supplicant.h |   8 +
 drivers/tee/optee/optee_private.h        |  41 +++
 drivers/tee/optee/rpmb.c                 | 215 ++++++----------
 drivers/tee/optee/rpmb_legacy.c          | 193 ++++++++++++++
 drivers/tee/optee/supplicant.c           |   9 +
 drivers/ufs/Kconfig                      |  13 +
 drivers/ufs/Makefile                     |   1 +
 drivers/ufs/ufs-rpmb.c                   | 309 +++++++++++++++++++++++
 drivers/ufs/ufs-uclass.c                 |  25 +-
 drivers/ufs/ufs.h                        |   9 +
 include/scsi.h                           |   2 +
 include/ufs.h                            |  12 +
 13 files changed, 692 insertions(+), 148 deletions(-)
 create mode 100644 drivers/tee/optee/rpmb_legacy.c
 create mode 100644 drivers/ufs/ufs-rpmb.c


base-commit: ece349ade2973e220f524ce59e59711cc919263f
-- 
2.54.0


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2026-07-23  8:48 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-22  6:07 [PATCH v2 0/5] ufs: rpmb: route OP-TEE RPMB secure storage over UFS Jorge Ramirez-Ortiz via U-Boot
2026-07-22  6:07 ` [PATCH v2 1/5] ufs: decode string descriptors as UTF-16 big-endian Jorge Ramirez-Ortiz via U-Boot
2026-07-22  6:07 ` [PATCH v2 2/5] ufs: add RPMB transport over SCSI SECURITY PROTOCOL Jorge Ramirez-Ortiz via U-Boot
2026-07-22  6:07 ` [PATCH v2 3/5] ufs: derive the per-region RPMB CID and size for OP-TEE Jorge Ramirez-Ortiz via U-Boot
2026-07-22  8:33   ` Neil Armstrong (Linaro) via U-Boot
2026-07-22  9:47     ` Jorge Ramirez via U-Boot
2026-07-22  6:07 ` [PATCH v2 4/5] optee: rename rpmb.c to rpmb_legacy.c Jorge Ramirez-Ortiz via U-Boot
2026-07-22  8:27   ` Neil Armstrong (Linaro) via U-Boot
2026-07-22  9:46     ` Jorge Ramirez via U-Boot
2026-07-22 12:23       ` Jorge Ramirez via U-Boot
2026-07-22 12:33       ` Peter Robinson via U-Boot
2026-07-22 13:10         ` Neil Armstrong via U-Boot
2026-07-22 14:35           ` Jorge Ramirez via U-Boot
2026-07-23  8:48             ` Neil Armstrong
2026-07-22  6:07 ` [PATCH v2 5/5] optee: implement the RPMB subsystem interface for UFS Jorge Ramirez-Ortiz via U-Boot
2026-07-22  8:31   ` Neil Armstrong (Linaro) via U-Boot
2026-07-22 14:12     ` Jorge Ramirez via U-Boot
2026-07-22 15:43       ` Neil Armstrong via U-Boot
2026-07-22 18:12         ` Jorge Ramirez via U-Boot
2026-07-22 18:44           ` Jorge Ramirez via U-Boot
2026-07-23  7:33             ` Neil Armstrong
2026-07-23  8:01               ` Jorge Ramirez via U-Boot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.