On Wed, 2022-04-06 at 10:32 -0700, Bart Van Assche wrote:
> > It's the SCSI BSG driver, in fact, we don't have a dedicated UFS
> > RPMB
> > driver in the kernel. RPMB is a well known LU, we are using
> > userspace
> > tools to issue SCSI commands directly to the UFS RPMB LU via
> > ioctl()
> > from the BSG device node in the /dev/sg/ folder.
> >
> > Here is the BSG part of the code in the userspace tools:
> >
> > io_hdr_v4.guard = 'Q';
> > io_hdr_v4.protocol = BSG_PROTOCOL_SCSI;
> > io_hdr_v4.subprotocol = BSG_SUB_PROTOCOL_SCSI_CMD;
> > io_hdr_v4.response = (__u64)sense_buffer;
> > io_hdr_v4.max_response_len = SENSE_BUFF_LEN;
> > io_hdr_v4.request_len = cmd_len;
> > io_hdr_v4.request = (__u64)cdb;
> >
> >
> >
> >
> > ioctl(fd, SG_IO, &io_hdr_v4))
>
> Hi Bean,
>
> I'm not sure where the above comes from? The Android RPMB client uses
> slightly different code. Additionally, the retry loop around the
> submission of SG/IO commands is very important. See also the
> check_sg_io_hdr() call in send_ufs_rpmb_req(). See also
> https://cs.android.com/android/platform/superproject/+/master:system/core/trusty/storage/proxy/rpmb.c
>
>
Bart,
It is from the ufs-utils.
So, do you vote to add the UFS RPMB driver based on this new framework
to resolve this conflict?
Kind regards,
Bean
> Thanks,
>
> Bart.
On 4/6/22 11:12, Bean Huo wrote:
> It is from the ufs-utils.
>
> So, do you vote to add the UFS RPMB driver based on this new framework
> to resolve this conflict?
Are any applications using the RPMB code from ufs-utils? It seems to me
that the ufs-utils code doe not handle SCSI unit attentions correctly.
If a POWER ON unit attention is received as reply to a SECURITY PROTOCOL
OUT transaction, the write counter should be reread instead of retrying
the SECURITY PROTOCOL OUT command with the same write counter.
Regarding adding a UFS RPMB driver: that seems useful to me since
multiple applications make use of the UFS RPMB functionality. My
understanding is that currently storageproxyd multiplexes UFS RPMB
accesses in Android.
Thanks,
Bart.
On Wed, 2022-04-06 at 13:20 -0700, Bart Van Assche wrote:
> On 4/6/22 11:12, Bean Huo wrote:
> > It is from the ufs-utils.
> >
> > So, do you vote to add the UFS RPMB driver based on this new
> > framework
> > to resolve this conflict?
>
> Are any applications using the RPMB code from ufs-utils? It seems to
> me
> that the ufs-utils code doe not handle SCSI unit attentions
> correctly.
> If a POWER ON unit attention is received as reply to a SECURITY
> PROTOCOL
> OUT transaction, the write counter should be reread instead of
> retrying
> the SECURITY PROTOCOL OUT command with the same write counter.
>
Not much sure how customers use this tool, based on my little
information from the field, the customer developed their own RPMB code
in the application. Here utils code is good example for them to study
and verify RPMB functinalities.
> Regarding adding a UFS RPMB driver: that seems useful to me since
> multiple applications make use of the UFS RPMB functionality. My
> understanding is that currently storageproxyd multiplexes UFS RPMB
> accesses in Android.
>
I have the same opinion with you, if we have an unified RPMB access
interface, and adding RPMB driver in the kernel, thus is better to
manage RPMB.
Kind regards,
Bean
> Thanks,
>
> Bart.