From: "Chang S. Bae" <chang.seok.bae@intel.com>
To: <sashiko-reviews@lists.linux.dev>
Cc: <kvm@vger.kernel.org>
Subject: Re: [PATCH v8 11/20] KVM: x86: Handle EGPR index and REX2-incompatible opcodes
Date: Thu, 1 Oct 2026 19:59:32 +0000 [thread overview]
Message-ID: <b2b947fc-d63f-48eb-bc8b-0bf2b3e8a496@intel.com> (raw)
In-Reply-To: <20260930214736.1FC1E1F00899@smtp.kernel.org>
On 9/30/2026 2:47 PM, sashiko-bot@kernel.org wrote:
>
> Should these string instructions (ins/outs) include the NoRex2 flag?
...
> Does pushf also need the NoRex2 flag ...
...
> Since x87 FPU instructions do not support REX2 prefixes, should they
> have the NoRex2 flag here to ensure they raise #UD?
...
> Does hlt need the NoRex2 flag since it takes no operands?
...
>> @@ -5001,6 +5012,13 @@ int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len, int
>> opcode = opcode_table[ctxt->b];
>> }
>>
>> + /*
>> + * Instructions marked with NoRex2 ignore a legacy REX prefix, but #UD
>> + * should be raised when prefixed with REX2.
>> + */
>> + if (opcode.flags & NoRex2 && ctxt->rex_prefix == REX2_PREFIX)
>> + opcode.flags = Undefined;
>> +
>
> [Severity: High]
> Does evaluating opcode.flags & NoRex2 here occur too early?
>
> Since this check precedes the while (ctxt->d & GroupMask) loop that
> expands opcode groups, will nested group instructions (like monitor,
> mwait, or vmcall) bypass this check and fail to raise #UD when given
> a REX2 prefix?
The byte following a REX2 prefix is interpreted as the opcode. The
emulator then handles it as a legacy instruction, including raising #UD
where required, rather than suppressing #UD merely because of being
REX2-prefixed.
The flag intentionally marks the reserved opcode ranges defined by the
specification:
* Legacy map 0: rows 0x4*, 0x7*, 0xA*, 0xE*
* Legacy map 1: rows 0x3*, 0x8*
This was also pointed out in the previouss discussion:
https://lore.kernel.org/kvm/6bdc1a64-0304-4845-a36c-5f309b0b40e0@intel.com/
Thanks,
Chang
next prev parent reply other threads:[~2026-10-01 20:26 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 21:07 [PATCH v8 00/20] KVM: x86: Enable APX for guests Chang S. Bae
2026-09-30 21:07 ` [PATCH v8 01/20] KVM: x86: Extend VCPU registers for EGPRs Chang S. Bae
2026-09-30 21:07 ` [PATCH v8 02/20] KVM: VMX: Save guest EGPRs in VCPU cache Chang S. Bae
2026-09-30 21:56 ` sashiko-bot
2026-10-01 19:57 ` Chang S. Bae
2026-09-30 21:07 ` [PATCH v8 03/20] KVM: x86: Support APX state for XSAVE ABI Chang S. Bae
2026-09-30 21:57 ` sashiko-bot
2026-10-01 19:58 ` Chang S. Bae
2026-09-30 21:07 ` [PATCH v8 04/20] KVM: VMX: Refactor VMX instruction information access Chang S. Bae
2026-09-30 21:07 ` [PATCH v8 05/20] KVM: VMX: Refactor instruction information decoding Chang S. Bae
2026-09-30 21:07 ` [PATCH v8 06/20] KVM: VMX: Remove unused control-register access defines Chang S. Bae
2026-09-30 21:07 ` [PATCH v8 07/20] KVM: VMX: Refactor register index retrieval from exit qualification Chang S. Bae
2026-09-30 21:07 ` [PATCH v8 08/20] KVM: VMX: Support instruction information extension Chang S. Bae
2026-09-30 21:52 ` sashiko-bot
2026-10-01 19:58 ` Chang S. Bae
2026-09-30 21:07 ` [PATCH v8 09/20] KVM: nVMX: Propagate extended instruction information Chang S. Bae
2026-09-30 21:52 ` sashiko-bot
2026-10-01 19:58 ` Chang S. Bae
2026-09-30 21:07 ` [PATCH v8 10/20] KVM: x86: Support EGPR accessing and tracking for emulator Chang S. Bae
2026-09-30 21:07 ` [PATCH v8 11/20] KVM: x86: Handle EGPR index and REX2-incompatible opcodes Chang S. Bae
2026-09-30 21:47 ` sashiko-bot
2026-10-01 19:59 ` Chang S. Bae [this message]
2026-09-30 21:07 ` [PATCH v8 12/20] KVM: x86: Support REX2-prefixed opcode decode Chang S. Bae
2026-09-30 21:54 ` sashiko-bot
2026-10-01 19:59 ` Chang S. Bae
2026-09-30 21:07 ` [PATCH v8 13/20] KVM: x86: Reject EVEX-prefixed instructions Chang S. Bae
2026-09-30 21:07 ` [PATCH v8 14/20] KVM: x86: Move KVM_SUPPORTED_{XCR0,XSS} into kvm_x86_vendor_init() Chang S. Bae
2026-09-30 21:07 ` [PATCH v8 15/20] KVM: x86: Guard valid XCR0.APX settings Chang S. Bae
2026-09-30 21:07 ` [PATCH v8 16/20] KVM: x86: Add APX to supported XCR0 Chang S. Bae
2026-09-30 21:07 ` [PATCH v8 17/20] KVM: x86: Expose APX foundation feature to userspace Chang S. Bae
2026-09-30 21:07 ` [PATCH v8 18/20] KVM: x86: Expose APX sub-features " Chang S. Bae
2026-09-30 21:43 ` sashiko-bot
2026-10-01 20:00 ` Chang S. Bae
2026-09-30 21:07 ` [PATCH v8 19/20] KVM: x86: selftests: Add APX state and ABI test Chang S. Bae
2026-09-30 21:48 ` sashiko-bot
2026-10-01 19:59 ` Chang S. Bae
2026-09-30 21:07 ` [PATCH v8 20/20] KVM: x86: selftests: Add APX state handling and XCR0 sanity checks Chang S. Bae
2026-10-01 20:29 ` [PATCH v8 00/20] KVM: x86: Enable APX for guests Chang S. Bae
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b2b947fc-d63f-48eb-bc8b-0bf2b3e8a496@intel.com \
--to=chang.seok.bae@intel.com \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.