[PATCH 4/5] target/i386/tcg: allow VEX in 16-bit protected mode

Paolo Bonzini posted 5 patches 1 month ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Zhao Liu <zhao1.liu@intel.com>, Richard Henderson <richard.henderson@linaro.org>, Eduardo Habkost <eduardo@habkost.net>
[PATCH 4/5] target/i386/tcg: allow VEX in 16-bit protected mode
Posted by Paolo Bonzini 1 month ago
VEX is only forbidden in real and vm86 mode; 16-bit protected mode supports
it for some unfathomable reason.

Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/tcg/decode-new.c.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.c.inc
index f662364c600..243df7e3735 100644
--- a/target/i386/tcg/decode-new.c.inc
+++ b/target/i386/tcg/decode-new.c.inc
@@ -2875,7 +2875,7 @@ static void disas_insn(DisasContext *s, CPUState *cpu)
          * VEX prefixes cannot be used except in 32-bit mode.
          * Otherwise the instruction is LES or LDS.
          */
-        if (CODE32(s) && !VM86(s)) {
+        if (PE(s) && !VM86(s)) {
             static const int pp_prefix[4] = {
                 0, PREFIX_DATA, PREFIX_REPZ, PREFIX_REPNZ
             };
-- 
2.52.0
Re: [PATCH 4/5] target/i386/tcg: allow VEX in 16-bit protected mode
Posted by Richard Henderson 1 month ago
On 1/8/26 02:13, Paolo Bonzini wrote:
> VEX is only forbidden in real and vm86 mode; 16-bit protected mode supports
> it for some unfathomable reason.
> 
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   target/i386/tcg/decode-new.c.inc | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.c.inc
> index f662364c600..243df7e3735 100644
> --- a/target/i386/tcg/decode-new.c.inc
> +++ b/target/i386/tcg/decode-new.c.inc
> @@ -2875,7 +2875,7 @@ static void disas_insn(DisasContext *s, CPUState *cpu)
>            * VEX prefixes cannot be used except in 32-bit mode.
>            * Otherwise the instruction is LES or LDS.
>            */
> -        if (CODE32(s) && !VM86(s)) {
> +        if (PE(s) && !VM86(s)) {
>               static const int pp_prefix[4] = {
>                   0, PREFIX_DATA, PREFIX_REPZ, PREFIX_REPNZ
>               };

With the comment updated as you say,

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~
Re: [PATCH 4/5] target/i386/tcg: allow VEX in 16-bit protected mode
Posted by BALATON Zoltan 1 month ago
On Wed, 7 Jan 2026, Paolo Bonzini wrote:
> VEX is only forbidden in real and vm86 mode; 16-bit protected mode supports
> it for some unfathomable reason.
>
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> target/i386/tcg/decode-new.c.inc | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.c.inc
> index f662364c600..243df7e3735 100644
> --- a/target/i386/tcg/decode-new.c.inc
> +++ b/target/i386/tcg/decode-new.c.inc
> @@ -2875,7 +2875,7 @@ static void disas_insn(DisasContext *s, CPUState *cpu)
>          * VEX prefixes cannot be used except in 32-bit mode.

Does this comment need updating too?

Regards,
BALATON Zoltan

>          * Otherwise the instruction is LES or LDS.
>          */
> -        if (CODE32(s) && !VM86(s)) {
> +        if (PE(s) && !VM86(s)) {
>             static const int pp_prefix[4] = {
>                 0, PREFIX_DATA, PREFIX_REPZ, PREFIX_REPNZ
>             };
>
Re: [PATCH 4/5] target/i386/tcg: allow VEX in 16-bit protected mode
Posted by Paolo Bonzini 1 month ago
On 1/7/26 16:57, BALATON Zoltan wrote:
> On Wed, 7 Jan 2026, Paolo Bonzini wrote:
>> VEX is only forbidden in real and vm86 mode; 16-bit protected mode 
>> supports
>> it for some unfathomable reason.
>>
>> Cc: qemu-stable@nongnu.org
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>> target/i386/tcg/decode-new.c.inc | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/ 
>> decode-new.c.inc
>> index f662364c600..243df7e3735 100644
>> --- a/target/i386/tcg/decode-new.c.inc
>> +++ b/target/i386/tcg/decode-new.c.inc
>> @@ -2875,7 +2875,7 @@ static void disas_insn(DisasContext *s, CPUState 
>> *cpu)
>>          * VEX prefixes cannot be used except in 32-bit mode.
> 
> Does this comment need updating too?

Good catch, it should be "Bits 6-7 of the first byte must be set except 
in 64-bit mode".

Paolo

> 
> Regards,
> BALATON Zoltan
> 
>>          * Otherwise the instruction is LES or LDS.
>>          */
>> -        if (CODE32(s) && !VM86(s)) {
>> +        if (PE(s) && !VM86(s)) {
>>             static const int pp_prefix[4] = {
>>                 0, PREFIX_DATA, PREFIX_REPZ, PREFIX_REPNZ
>>             };
>>
> 
>