[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <febcd8bb-0a47-4c3c-8fda-fb13012aee31@redhat.com>
Date: Fri, 14 Nov 2025 00:34:28 +0100
From: Paolo Bonzini <pbonzini@...hat.com>
To: "Chang S. Bae" <chang.seok.bae@...el.com>, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: seanjc@...gle.com, chao.gao@...el.com, zhao1.liu@...el.com
Subject: Re: [PATCH RFC v1 16/20] KVM: x86: Decode REX2 prefix in the emulator
On 11/14/25 00:30, Chang S. Bae wrote:
> On 11/11/2025 9:55 AM, Paolo Bonzini wrote:
>> On 11/10/25 19:01, Chang S. Bae wrote:
>>>
>>> case 0x40 ... 0x4f: /* REX */
>>> if (mode != X86EMUL_MODE_PROT64)
>>> goto done_prefixes;
>>> + if (ctxt->rex_prefix == REX2_PREFIX)
>>> + break;
>>> ctxt->rex_prefix = REX_PREFIX;
>>> ctxt->rex.raw = 0x0f & ctxt->b;
>>> continue;
>>> + case 0xd5: /* REX2 */
>>> + if (mode != X86EMUL_MODE_PROT64)
>>> + goto done_prefixes;
>> Here you should also check
>>
>> if (ctxt->rex_prefix == REX_PREFIX) {
>> ctxt->rex_prefix = REX2_INVALID;
>> goto done_prefixes;
>> }
>
> You're right. Section 3.1.2.1 states:
> | A REX prefix (0x4*) immediately preceding the REX2 prefix is not
> | allowed and triggers #UD.
>
> Now I think REX2_INVALID would just add another condition to handle
> later. Instead, for such invalid case, it might be simpler to mark the
> opcode as undefined and jump all the way after the lookup. See the diff
> -- please let me know if you dislike it.
Yes, I also thought it was unnecessary but waited until we merged the
respective patches.
Paolo
Powered by blists - more mailing lists