Re: [PATCH 1/2] x86/tdx: Fix off-by-one in port I/O handling

From: Kiryl Shutsemau

Date: Wed Apr 01 2026 - 04:44:29 EST


On Tue, Mar 31, 2026 at 02:57:32PM -0700, Kuppuswamy Sathyanarayanan wrote:
> Hi Kirill,
>
> On 3/31/2026 4:24 AM, Kiryl Shutsemau (Meta) wrote:
> > handle_in() and handle_out() in arch/x86/coco/tdx/tdx.c use:
> >
> > u64 mask = GENMASK(BITS_PER_BYTE * size, 0);
> >
> > GENMASK(h, l) includes bit h. For size=1 (INB), this produces
> > GENMASK(8, 0) = 0x1FF (9 bits) instead of GENMASK(7, 0) = 0xFF (8
> > bits). The mask is one bit too wide for all I/O sizes.
> >
> > Fix the mask calculation.
> >
> > Fixes: 03149948832a ("x86/tdx: Port I/O: Add runtime hypercalls")
> > Reported-by: Borys Tsyrulnikov <tsyrulnikov.borys@xxxxxxxxx>
> > Signed-off-by: Kiryl Shutsemau (Meta) <kas@xxxxxxxxxx>
> > Cc: stable@xxxxxxxxxxxxxxx
> > ---
>
> LGTM. Can you include a link to the bug report or related discussion in
> the commit log? It will help understand the impact of this issue.

Link: https://lore.kernel.org/all/CAKw_Dz96rfSQc6Rn+9QBcUFHhmkK+9zu+P=bxowfZwxrATCBRg@xxxxxxxxxxxxxx/

It is relevant for both.

--
Kiryl Shutsemau / Kirill A. Shutemov