[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging-4.21] x86emul: ignore XOP.W for TBM insns in 32-bit mode



commit c803dfdaaebb5ec4e5101b8f5733faa0b6b12cd2
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Wed Nov 25 14:40:22 2026 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Nov 25 14:40:22 2026 +0100

    x86emul: ignore XOP.W for TBM insns in 32-bit mode
    
    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@xxxxxxx>
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    master commit: c5ccc2fac9aa8a80827fac055003358ff4a435fe
    master date: 2026-11-25 09:45:05 +0100
---
 xen/arch/x86/x86_emulate/x86_emulate.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c 
b/xen/arch/x86/x86_emulate/x86_emulate.c
index 6712e39fef..fb9b7dcefc 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -7942,6 +7942,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) */
@@ -8051,6 +8053,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;
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.21



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.