From: Bean Huo <huobean@gmail.com>
To: Alexey Charkov <alchark@flipper.net>
Cc: Alim Akhtar <alim.akhtar@samsung.com>,
Avri Altman <avri.altman@wdc.com>,
Bart Van Assche <bvanassche@acm.org>,
"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Bean Huo <beanhuo@micron.com>, Can Guo <can.guo@oss.qualcomm.com>,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] scsi: ufs: core: Fix RPMB region size detection for UFS 2.2
Date: Fri, 30 Jan 2026 11:26:13 +0100 [thread overview]
Message-ID: <ad7e2d0e5b219b4b2ef2aa7ab342513a2c66171f.camel@gmail.com> (raw)
In-Reply-To: <CAKTNdwG=He3iJ8cPo4fFbcEwQQRrt_SGzoviMhi2a3kMXAO8hA@mail.gmail.com>
On Thu, 2026-01-29 at 21:10 +0400, Alexey Charkov wrote:
> On Thu, Jan 29, 2026 at 8:53 PM Bean Huo <huobean@gmail.com> wrote:
> >
> > On Thu, 2026-01-29 at 11:38 +0400, Alexey Charkov wrote:
> > > + hba->dev_info.rpmb_region_size[0] =
> > > + get_unaligned_be64(desc_buf
> > > + +
> > > RPMB_UNIT_DESC_PARAM_LOGICAL_BLK_COUNT)
> > > + <<
> > > desc_buf[RPMB_UNIT_DESC_PARAM_LOGICAL_BLK_SIZE]
> > > + >> 17; /* convert to 128 kBytes units */
> > > + }
> > > }
> >
> > Hi Alexey,
> >
> > thanks for your fix, I didn't notice there is UFS 2.x on the market which
> > will
> > use UFS OP-TEE RPMB framework.
>
> Hi Bean, it turns out many of the UFS modules for Rockchip RK3576
> based devices are 2.2. I'm poking around the OP-TEE support on that
> platform, and discovered that the existing driver didn't see the RPMB
> at all, spent quite a bit of time trying to figure it out before
> spotting the difference between the two spec versions :)
>
> > here is potential u8 Overflow, since for the UFS3.x+, it is u8 in unit
> > descriptor, but
> >
> >
> > The calculation can overflow for larger RPMB regions (>32MB):
> > - A u8 can only represent up to 255 × 128KB = ~32MB
> > - The shift result is assigned directly without bounds checking
>
> The spec says it can only be up to 16MB maximum (see section 12.4.3.1
> RPMB Resources), so it should always fit. Happy to add a comment about
> that.
>
> Best regards,
> Alexey
Hi Alexey,
Thanks for the clarification on the 16MB RPMB limit - that addresses the
overflow concern.
In your above operation, why not use SZ_128K to avoid the magic number?
BTW, please update your comment.
Kind regards,
Bean
next prev parent reply other threads:[~2026-01-30 10:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-29 7:38 Alexey Charkov
2026-01-29 16:53 ` Bean Huo
2026-01-29 17:10 ` Alexey Charkov
2026-01-30 10:26 ` Bean Huo [this message]
2026-01-30 14:49 ` Alexey Charkov
2026-02-04 8:37 ` Bean Huo
2026-02-05 8:32 ` Alexey Charkov
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=ad7e2d0e5b219b4b2ef2aa7ab342513a2c66171f.camel@gmail.com \
--to=huobean@gmail.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=alchark@flipper.net \
--cc=alim.akhtar@samsung.com \
--cc=avri.altman@wdc.com \
--cc=beanhuo@micron.com \
--cc=bvanassche@acm.org \
--cc=can.guo@oss.qualcomm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=stable@vger.kernel.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®