All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86emul: ignore XOP.W for TBM insns in 32-bit mode
@ 2026-11-24 13:32 Jan Beulich
  2026-11-24 16:50 ` Andrew Cooper
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2026-11-24 13:32 UTC (permalink / raw)
  To: xen-devel@lists.xenproject.org
  Cc: Andrew Cooper, Teddy Astie, Roger Pau Monné

Quoting 1179d51dcb7d ("x86emul: ignore VEX.W for BMI{1,2} insns in 32-bit
mode"):
"While result values and other status flags are unaffected as long as we
 can ignore the case of registers having their upper 32 bits non-zero
 outside of 64-bit mode, EFLAGS.SF may obtain a wrong value when we
 mistakenly re-execute the original insn with VEX.W set.

 Note that guest the memory access, if any, is correctly carried out as
 32-bit regardless of VEX.W. The emulator-local memory operand will be
 accessed as a 64-bit quantity, but it is pre-initialised to zero so no
 internal state can leak."

The same applies to XOP-encoded integer insns.

Fixes: c4afd683f95c ("x86emul: support TBM insns")
Reported-by: Roger Pau Monné <roger.pau@amd.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -8027,6 +8027,8 @@ x86_emulate(
         *pxop = vex;
         pxop->b = 1;
         pxop->r = 1;
+        if ( !mode_64bit() )
+            pxop->w = 0;
         pxop->reg = 0xf; /* rAX */
         buf[3] = b;
         buf[4] = (modrm & 0x38) | 0x01; /* r/m=(%rCX) */
@@ -8136,6 +8138,8 @@ x86_emulate(
         *pxop = vex;
         pxop->b = 1;
         pxop->r = 1;
+        if ( !mode_64bit() )
+            pxop->w = 0;
         buf[3] = b;
         buf[4] = 0x09; /* reg=rCX r/m=(%rCX) */
         *(uint32_t *)(buf + 5) = imm1;


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] x86emul: ignore XOP.W for TBM insns in 32-bit mode
  2026-11-24 13:32 [PATCH] x86emul: ignore XOP.W for TBM insns in 32-bit mode Jan Beulich
@ 2026-11-24 16:50 ` Andrew Cooper
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cooper @ 2026-11-24 16:50 UTC (permalink / raw)
  To: Jan Beulich, xen-devel@lists.xenproject.org
  Cc: Andrew Cooper, Teddy Astie, Roger Pau Monné

On 24/11/2026 1:32 pm, Jan Beulich wrote:
> Quoting 1179d51dcb7d ("x86emul: ignore VEX.W for BMI{1,2} insns in 32-bit
> mode"):
> "While result values and other status flags are unaffected as long as we
>  can ignore the case of registers having their upper 32 bits non-zero
>  outside of 64-bit mode, EFLAGS.SF may obtain a wrong value when we
>  mistakenly re-execute the original insn with VEX.W set.
>
>  Note that guest the memory access, if any, is correctly carried out as
>  32-bit regardless of VEX.W. The emulator-local memory operand will be
>  accessed as a 64-bit quantity, but it is pre-initialised to zero so no
>  internal state can leak."
>
> The same applies to XOP-encoded integer insns.
>
> Fixes: c4afd683f95c ("x86emul: support TBM insns")
> Reported-by: Roger Pau Monné <roger.pau@amd.com>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-24 16:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 13:32 [PATCH] x86emul: ignore XOP.W for TBM insns in 32-bit mode Jan Beulich
2026-11-24 16:50 ` Andrew Cooper

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.