Re: [PATCH v3 2/2] x86/tdx: Fix zero-extension for 32-bit port I/O
From: Edgecombe, Rick P
Date: Wed May 27 2026 - 11:51:40 EST
On Wed, 2026-05-27 at 13:05 +0100, Kiryl Shutsemau (Meta) wrote:
> + /*
> + * IN writes the result into a sub-register of RAX. Only the
> + * 32-bit form zero-extends; the smaller forms leave the upper
> + * bits untouched:
> + *
> + * insn dest size bits written bits preserved
> + * inb AL 1 RAX[ 7: 0] RAX[63: 8]
> + * inw AX 2 RAX[15: 0] RAX[63:16]
> + * inl EAX 4 RAX[63: 0] (none, zero-extended)
We are working on getting the GHCI spec amended to clarify who is supposed to do
this zero-extending and masking, host or guest. For this and the similar
tdvmcalls. The process involves getting all VMMs in agreement.
Today I think the spec doesn't say to *not* do it, so I think it is reasonable
to merge this, but there is some small risk of complications depending on how
that discussion goes.
> + *
> + * 'mask' only covers the low 'size' bytes, which is exactly the
> + * range affected for size 1 and 2. For size 4 the write also
> + * clears RAX[63:32], so widen the clear-mask.
> + */