mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bean Huo <huobean@gmail.com>
To: Jens Wiklander <jens.wiklander@linaro.org>
Cc: avri.altman@wdc.com, bvanassche@acm.org, alim.akhtar@samsung.com,
	 jejb@linux.ibm.com, martin.petersen@oracle.com,
	can.guo@oss.qualcomm.com,  ulf.hansson@linaro.org,
	beanhuo@micron.com, linux-scsi@vger.kernel.org,
	 linux-kernel@vger.kernel.org, beanhuo@iokpp.de
Subject: Re: [PATCH v2 3/3] scsi: ufs: core: Add OP-TEE based RPMB driver for UFS devices
Date: Mon, 13 Oct 2025 14:04:23 +0200	[thread overview]
Message-ID: <a040353e95a67dc3bde09b5f3866aa628150c9db.camel@gmail.com> (raw)
In-Reply-To: <CAHUa44HdV8FJMayVg6TFz7oGZc1b6QntxMsUN8mdTV7pm7vkKQ@mail.gmail.com>

On Mon, 2025-10-13 at 10:21 +0200, Jens Wiklander wrote:
> Hi Bean,
> 
> 
> 
> On Wed, Oct 8, 2025 at 5:07 PM Bean Huo <huobean@gmail.com> wrote:
> > 
> > Jens,
> > 
> > I incorporated your suggestions in my v3 excpet these two:
> > 
> > 
> > On Wed, 2025-10-01 at 09:50 +0200, Jens Wiklander wrote:
> > > > diff --git a/drivers/ufs/core/Makefile b/drivers/ufs/core/Makefile
> > > > index cf820fa09a04..51e1867e524e 100644
> > > > --- a/drivers/ufs/core/Makefile
> > > > +++ b/drivers/ufs/core/Makefile
> > > > @@ -2,6 +2,7 @@
> > > > 
> > > >   obj-$(CONFIG_SCSI_UFSHCD)              += ufshcd-core.o
> > > >   ufshcd-core-y                          += ufshcd.o ufs-sysfs.o ufs-
> > > > mcq.o
> > > > +ufshcd-core-$(CONFIG_RPMB)             += ufs-rpmb.o
> > > 
> > > SCSI_UFSHCD might need the same trick ("depends on RPMB || !RPMB") in
> > > Kconfig as we have for MMC_BLOCK.
> > > 
> > > > 
> > When RPMB=m and SCSI_UFSHCD=y, the ufs-rpmb.o is compiled into the built-in
> > ufshcd-core, ufs-rpmb.c calls functions from the OP-TEE RPMB subsystem
> > module,
> > The kernel allows built-in code to reference module symbols (they become
> > runtime
> > dependencies, not link-time), please check, I tested.
> > 
> > > > 
> > > > 
> > > 
> > > > +
> > > > +       struct rpmb_descr descr = {
> > > > +               .type = RPMB_TYPE_UFS,
> > > 
> > > We'll need another type if the device uses the extended RPMB frame
> > > format. How about you clarify this, where RPMB_TYPE_UFS is defined to
> > > avoid confusion?
> > 
> > As ufs-bsg.c, we could use ARPMB_TYPE_UFS for UFS advanced RPMB frame, if it
> > is
> > RPMB, we take it as normal RPMB, the frame should be the same as MMC RPMB.
> 
> Isn't it a bit confusing to set the type to RPMB_TYPE_EMMC when it's
> actually a UFS RPMB, even if it's supposedly compatible enough?
> 

The RPMB data format is the same for both eMMC RPMB and standard UFS RPMB.
However, the application commands used to access RPMB differ — eMMC uses MMC
commands, while UFS uses SCSI commands.

Additionally, UFS RPMB supports more RPMB operations than eMMC RPMB. Therefore,
we need to distinguish between them:

RPMB_TYPE_EMMC for eMMC RPMB

RPMB_TYPE_UFS for standard UFS RPMB

ARPMB_TYPE_UFS for advanced UFS RPMB.


> While the frame format works, I'm concerned about the CID. It's
> essentially a namespace of its own for eMMC, and at least the OP-TEE
> implementation makes assumptions about the format by masking out the
> PRV (Product Revision) and CRC (CRC7 checksum) fields from the CID
> when deriving the RPMB key. For this to work reliably, the CID must be
> guaranteed to be unique per RPMB device.
> 
> From what I understand, for UFS, the serial number is only guaranteed
> to be unique if the manufacturer and the product name are taken into
> account. Combined, these fields can be much larger than 16 bytes, and
> we also have the partition number to consider.
> 
> By using RPMB_TYPE_UFS we can define a device ID tailored for UFS with
> all the fields we need. Thoughts?
> 

For certain memory vendors, the serial number is guaranteed to be unique among
all devices.

For partitions or regions, we have appended the region number to the end of the
CID — please check the patch for details.

Regarding improving CID uniqueness, we could include the OEM ID or product
number. However, this would make the CID longer than 16 bytes.



Kind regards,
Bean

> Cheers,
> Jens


  reply	other threads:[~2025-10-13 12:04 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-01  6:08 [PATCH v2 0/3] " Bean Huo
2025-10-01  6:08 ` [PATCH v2 1/3] rpmb: move rpmb_frame struct and constants to common header Bean Huo
2025-10-01  9:48   ` Avri Altman
2025-10-01 19:43   ` Bart Van Assche
2025-10-06 10:07   ` Jens Wiklander
2025-10-06 10:21   ` Ulf Hansson
2025-10-06 10:54     ` Bean Huo
2025-10-01  6:08 ` [PATCH v2 2/3] scsi: ufs: core: fix incorrect buffer duplication in ufshcd_read_string_desc() Bean Huo
2025-10-01 10:03   ` Avri Altman
2025-10-02  4:31     ` Bean Huo
2025-10-01 19:43   ` Bart Van Assche
2025-10-01  6:08 ` [PATCH v2 3/3] scsi: ufs: core: Add OP-TEE based RPMB driver for UFS devices Bean Huo
2025-10-01  7:50   ` Jens Wiklander
2025-10-02 13:37     ` Bean Huo
2025-10-08 15:07     ` Bean Huo
2025-10-13  8:21       ` Jens Wiklander
2025-10-13 12:04         ` Bean Huo [this message]
2025-10-13 12:22           ` Jens Wiklander
2025-10-13 15:42             ` Bean Huo
2025-10-13 15:53               ` Jens Wiklander
2025-10-23 11:32                 ` Bean Huo
2025-10-01 10:06   ` Avri Altman
2025-10-02 13:19     ` Bean Huo
2025-10-08 11:47     ` Bean Huo
2025-10-08 12:16       ` Avri Altman
2025-10-01 19:51   ` Bart Van Assche
2025-10-02 13:38     ` Bean Huo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a040353e95a67dc3bde09b5f3866aa628150c9db.camel@gmail.com \
    --to=huobean@gmail.com \
    --cc=alim.akhtar@samsung.com \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@iokpp.de \
    --cc=beanhuo@micron.com \
    --cc=bvanassche@acm.org \
    --cc=can.guo@oss.qualcomm.com \
    --cc=jejb@linux.ibm.com \
    --cc=jens.wiklander@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®