Re: [PATCH v2 2/2] x86/tdx: Fix zero-extension for 32-bit port I/O
From: Sean Christopherson
Date: Wed May 13 2026 - 09:06:30 EST
On Tue, May 12, 2026, H. Peter Anvin wrote:
> On May 12, 2026 6:14:13 PM PDT, Dave Hansen <dave.hansen@xxxxxxxxx> wrote:
> >On 4/28/26 05:56, Kiryl Shutsemau (Meta) wrote:
> >> + if (size == 4)
> >> + regs->ax = 0;
> >> + else
> >> + regs->ax &= ~mask;
> >
> >I haven't thought about this _that_ much, but this feels wrong. Why is
> >is 4 so special cased?
> >
> >Also, what _are_ the limits on the registers that 'in' can be used on?
> >
> >RAX - n/a, no 64-bit I/O
> >EAX - size=4
> >AX - size=2
> >AH - n/a no encoding for inb
> >AL - size=1
> >
> >I'd find this much easier to grasp if there was a nice table of what the
> >registers, sizes, and masks ended up being usable. As usual, x86 is
> >"fun" here.
>
> Because zero extension only applies to dwords.
>
> x86-64 has three subregisters per GPR:
Aren't there four? The fourth being 31:0, which is the one that is zero-extended
and so "clobbers" 63:32.
> Bits 7-0
> Bits 15-8
> Bits 63-16
I assume you mean 15:0? 63:16 isn't addressable. And these are the ones that
aren't zero-extended, i.e. don't "clobber" other bits.