Re: [PATCH 08/10] KVM: x86: Refactor REX prefix handling in instruction emulation

From: Chang S. Bae
Date: Mon Nov 17 2025 - 14:57:25 EST


On 11/13/2025 4:36 PM, Paolo Bonzini wrote:
From: "Chang S. Bae" <chang.seok.bae@xxxxxxxxx>

Restructure how to represent and interpret REX fields, preparing
for handling of both REX2 and VEX.

REX uses the upper four bits of a single byte as a fixed identifier,
and the lower four bits containing the data. VEX and REX2 extends this so
that the first byte identifies the prefix and the rest encode additional
bits; and while VEX only has the same four data bits as REX, eight zero
bits are a valid value for the data bits of REX2. So, stop storing the
REX byte as-is. Instead, store only the low bits of the REX prefix and
track separately whether a REX-like prefix was used.

No functional changes intended.

Signed-off-by: Chang S. Bae <chang.seok.bae@xxxxxxxxx>
Message-ID: <20251110180131.28264-11-chang.seok.bae@xxxxxxxxx>
[Extracted from APX series; removed bitfields and REX2-specific default. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>

Thanks for the incorporation!