|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen stable-4.20] x86emul: Zero-extend the XOP0A and MOV B8+r immediates when decoding
commit 95f8cd150504494abdcecf798f17c477e0c99c43
Author: Stephen Cheng <stephen.cheng@xxxxxxxxxx>
AuthorDate: Wed Nov 25 14:43:06 2026 +0100
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Nov 25 14:43:06 2026 +0100
x86emul: Zero-extend the XOP0A and MOV B8+r immediates when decoding
The decoder sign-extends the 32-bit immediate of the XOP0A insns
(BEXTR, LWPINS, LWPVAL), but this immediate is unsigned. It also
sign-extends the 32-bit immediate of MOV B8+r without REX.W, while with
REX.W the low half is already zero-extended to build the 64-bit
immediate. In 64-bit mode MOV r32,imm32 zero-extends into the full
register. Emulation uses only the low bits, so only
x86_insn_immediate() returns a wrong value. No current caller reads it
for these insns.
Zero-extend the XOP0A immediate, as commit aa6070d2c840 ("x86emul:
Zero-extend unsigned 8-bit immediates when decoding") did for the 0F,
0F3A and XOP08 maps. For MOV B8+r, zero-extend the 32-bit immediate,
and keep only the fetch of the high half in the REX.W path. The 16-bit
form is left alone, like the 8-bit form (B0+r) and other insns' 16-bit
immediates.
Fixes: 653cae725cea ("x86/32on64: use generic instruction decoding for call
gate emulation")
Requested-by: Jan Beulich <jbeulich@xxxxxxxx>
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Stephen Cheng <stephen.cheng@xxxxxxxxxx>
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
master commit: 669be2d1608c92089ad9ba8787e59b301bf90bdb
master date: 2026-11-19 10:38:24 +0100
---
xen/arch/x86/x86_emulate/decode.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/xen/arch/x86/x86_emulate/decode.c
b/xen/arch/x86/x86_emulate/decode.c
index c08f53b867..43cec2d328 100644
--- a/xen/arch/x86/x86_emulate/decode.c
+++ b/xen/arch/x86/x86_emulate/decode.c
@@ -682,9 +682,12 @@ decode_onebyte(struct x86_emulate_state *s,
break;
case 0xb8 ... 0xbf: /* mov imm{16,32,64},r{16,32,64} */
+ if ( s->op_bytes == 2 )
+ break;
+ /* Like the 32-bit register write, the immediate is zero-extended. */
+ s->imm1 &= 0xffffffffU;
if ( s->op_bytes == 8 ) /* Fetch more bytes to obtain imm64. */
- s->imm1 = ((uint32_t)s->imm1 |
- ((uint64_t)insn_fetch_type(uint32_t) << 32));
+ s->imm1 |= (uint64_t)insn_fetch_type(uint32_t) << 32;
break;
case 0xd4: /* aam */
@@ -1826,10 +1829,14 @@ int x86emul_decode(struct x86_emulate_state *s,
s->simd_size = ext8f08_table[b].simd_size;
break;
+ case ext_8f0a:
+ /* All immediates in this encoding space are unsigned ones. */
+ s->imm1 &= 0xffffffffU;
+ break;
+
case ext_map5:
case ext_map6:
case ext_8f09:
- case ext_8f0a:
break;
default:
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.20
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |