From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7F4F30F92D for ; Fri, 30 Jan 2026 14:49:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.218.48 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769784568; cv=pass; b=YoecfvY9427ALzGEMOMrktSsTnYp4RQmcpp12HrKpgyTTa/erGzbR7RVKQmhZEiXpoQFzizzD+qACYTsHhuCGA01cROKxhpYgqnWa46X14QqcnocK+iLMYH9owtfpXTW9o3G9lenKNJydFbAEkbFUXBThwt2k5NCx/Ib1GuWJ4E= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769784568; c=relaxed/simple; bh=t4RRHGhKC9qO704K4djE/1HbC4sMRGVkjqlOcgIBrdY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=uss1oJRs4jKsf4GXdW56vp1r0i2lkel3kQBgnlMedWMzg5MN+M8OIzhwlXO02AcPvOWv26G+79cR0FiLa3kQtXy2Y5PtPGT2Vpxlx1MRLQA9rVEg9fo0fQ9f3Q8ZPsKBw7iWEMkSNxJ7sPt7QiaL5nHHegUaN7kX0KP9Kuap9xg= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=flipper.net; spf=pass smtp.mailfrom=flipper.net; dkim=pass (2048-bit key) header.d=flipper.net header.i=@flipper.net header.b=9O4q55gZ; arc=pass smtp.client-ip=209.85.218.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=flipper.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flipper.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flipper.net header.i=@flipper.net header.b="9O4q55gZ" Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-b8869cd7bb1so361218266b.1 for ; Fri, 30 Jan 2026 06:49:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1769784565; cv=none; d=google.com; s=arc-20240605; b=gm1vU9cxZu248HhZPg849HESSg6A+ARblvQi3AZLqcl0iYqwTuphH7HNYNRANy5A8K O8R0I9iU/w/kv/rNVt6HSPA1A3lIkWcGZIJfhOEz+jL2MTFinUtenlpKQ0qC0tXgH9L9 9AUt0euWs93wmpiEbqMQ//WgSe8Mn9bMavb1bgROhWZYg/e4rnpweo9zNtdt8zOSv0MO M/8AfXDz4B4xTdgPYMRIwfdhDiYoyuFcsLfkYWzZC3OsT5zfQDxgg9M8b9I5p9Tnoe5S 1Yt0sKbHtP/yaC4w7Ex89+LjsEg6vASit5LxG5NrOjxgDoKE6KLYFeGSAEsEU8ZYvuoP dFsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=x6T4fm8App9HWL62KcSJuniw6LuHUvq2dfOPNBe2zag=; fh=kgC3XCvE/ZqZd8HOav19/+J/P3LfQQJOBqiW25Urb4w=; b=JjOEswXUswqQYZaNcUcJjXOm+IwJvwcpyEZ+LE4sgAb2B3t3yfDg4OXFf5trLVcv8A ugKd0rdC4AvP0NLeXO8SWLPDmGFOOPlQHSJ9M3MyJMgHgk2N9/BrpdqyN0+fbbU2CeY3 wjkpUUApB+06n/YbWC3/KL641uVRLbNxQR40fxijTSILfdUoMg+r3LdU7pwmoBConn12 VJ41xNriOoW2RcWrGWW1FCF8GgsaIIg7bcPDY/WR9050MWjf2QR46ybmZs3kSGzKGDWH mV0aAjZRW8HZLhY918OsWahp8doYYw8ivPVgMyb+fZU1ZEcCDiCm7kjVgLHKWeq918gx efdw==; darn=vger.kernel.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flipper.net; s=google; t=1769784565; x=1770389365; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=x6T4fm8App9HWL62KcSJuniw6LuHUvq2dfOPNBe2zag=; b=9O4q55gZ48tBmbH5KulEm2lX+1IWxcoaUuNjUC8wFx2wrrTKdHh1E7i+flosSMwiml JqnPzetZ8i5fvY+EDYO/9VRCjj1CGDAuJdaTY4o55kaRxt5QsDJMQ8nBGdTxb/UCMXBc drP251s4Q4Co9sX6ZmLA+0TWm4F1lJbR1xJ+YFlwHHmPB75ze14THmhsYovFoSKB/8tM fnk2G0XIZ7HdH7c7+sF+bSz7Dn15KhsjssvjgQ1LkQ3Dwx5uzQL+tspBMPj65CUD0U8N 4XYT6V/x/m5Glj2jLIfJMLSN7qlCFYQwusloUfxBrgNNZmREtEiC4iRld+2dS5wxnAuH wonw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769784565; x=1770389365; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=x6T4fm8App9HWL62KcSJuniw6LuHUvq2dfOPNBe2zag=; b=kzagzlpuJyeIC3yBdbETfNJXVVrWkFNW7JSDPWNUiadCHD87dNXA8zZTtN8jfZTpRh Kzsglr5WLhjrrHdHJzXbh9Zm/svC+jcJzY3o2CNNKTHoYjQh0bGZug8Hrd9Yx3Vkn5mr C3lRhxTloshxNS+t/pOsbMWoBcmGyxtHXSWXy1WxZ/IsOiOKQLMaQ5Mh/ctouQQVvFrj rZ24du2nlcE2SV1WJBsB6aZn+bh9Aa1jBL6lfg/8XDcIpobcyY+b3F/UFoPS6CgbGIsY i3EHNq3QjUvE2CP6vTLFzXgdF7jg64VdNqaedLmoYbJeXcY0diKsOOmfvmnsisA+jesk hTyw== X-Forwarded-Encrypted: i=1; AJvYcCVhr2XD6f/q1tJj8hLXxIlek8FmKhlLjfITtBWPE29Oh0mEYmNGBFi6BsMMYATMO1k2BYZ18hUokUcj0TA=@vger.kernel.org X-Gm-Message-State: AOJu0Yw/0c7ZqkxX07+E/LvnrSYB/WddTpDYQ3wFokQGOe318fIi42p8 XUQprqGaqZiqFV3vYuyTU+stD9F1gMNq7RqyepI8rYOZyECvKLvxWdhFubPJeOnHlEf3+cbV3eb qDEDe00VxwVyIi90U6J7XIZENhJW9e+OHhtHnylUabg== X-Gm-Gg: AZuq6aI728SLMaAxDlVoTHpLsTlg1mq1kbv/ePSahOH4MWsgxzGBlN2QYVMWsWm4pkE jYMR1HJfQfq+LNcnLc1DZxHlqvBw2cJfsgMfBBgGgVZzLgHyx55hziZs+2qGI0m/94wGQIK/JPI ZCWkFY9Jo7DYUhaNIZIU4hBhy0Vqh33TyVbUE4zKYLWNyqWOkuVH0dcw7cgLJJjuYqnC8PHy5r7 1BPAAzaRtZMYunN1G3LLMiiInMdcTgEMOvGAX+uoin+6mVKZjypsfddhnJ5nNuodHJUU1dbAPbM JTZe2a85knsnXn3pv8LhZ6E9MsLl X-Received: by 2002:a17:906:4785:b0:b87:2c88:ce40 with SMTP id a640c23a62f3a-b8dff6073d9mr215693166b.27.1769784565271; Fri, 30 Jan 2026 06:49:25 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20260129-ufs-rpmb-v1-1-691534ab723f@flipper.net> <8149b8cb5a7b36a1543ca05666f33a6373674e0e.camel@gmail.com> In-Reply-To: From: Alexey Charkov Date: Fri, 30 Jan 2026 18:49:14 +0400 X-Gm-Features: AZwV_QiavZVaj1w9rZNPzvcULQmPuISNIJXVnTsDwBtZZh2I1Sg-X-NvmZQE7LI Message-ID: Subject: Re: [PATCH] scsi: ufs: core: Fix RPMB region size detection for UFS 2.2 To: Bean Huo Cc: Alim Akhtar , Avri Altman , Bart Van Assche , "James E.J. Bottomley" , "Martin K. Petersen" , Bean Huo , Can Guo , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Jan 30, 2026 at 2:26=E2=80=AFPM Bean Huo wrote: > > On Thu, 2026-01-29 at 21:10 +0400, Alexey Charkov wrote: > > On Thu, Jan 29, 2026 at 8:53=E2=80=AFPM Bean Huo wr= ote: > > > > > > On Thu, 2026-01-29 at 11:38 +0400, Alexey Charkov wrote: > > > > + hba->dev_info.rpmb_region_size[0] =3D > > > > + 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 uni= ts */ > > > > + } > > > > } > > > > > > Hi Alexey, > > > > > > thanks for your fix, I didn't notice there is UFS 2.x on the market w= hich > > > 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 uni= t > > > descriptor, but > > > > > > > > > The calculation can overflow for larger RPMB regions (>32MB): > > > - A u8 can only represent up to 255 =C3=97 128KB =3D ~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. Good point, thanks Bean! Will amend in v2. Best regards, Alexey