Mostly x86 fixes for 2025-01-13
The following changes since commit cf3e71d8fc8ba681266759bb6cb2e45a45983e3e:
Merge tag 'single-binary-20260112' of https://github.com/philmd/qemu into staging (2026-01-13 11:51:18 +1100)
are available in the Git repository at:
https://gitlab.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to a24f045228271391b5c5064ebf049e1f50b6d712:
rust: Update Cargo.lock (2026-01-13 10:54:28 +0100)
----------------------------------------------------------------
* target/i386/tcg fixes
* hw/i386/kvm: fix PIRQ bounds check in xen_physdev_map_pirq()
----------------------------------------------------------------
Paolo Bonzini (5):
target/i386/tcg: do not leave non-arithmetic flags in CC_SRC after PUSHF target/i386/tcg: remove dead code
target/i386/tcg: do not mark all SSE instructions as unaligned target/i386/tcg: mask addresses for VSIB
target/i386/tcg: allow VEX in 16-bit protected mode
Vulnerability Report (1):
hw/i386/kvm: fix PIRQ bounds check in xen_physdev_map_pirq()
Zhao Liu (1):
rust: Update Cargo.lock
target/i386/ops_sse.h | 16 ++++++++-------- target/i386/tcg/decode-new.h | 2 ++ target/i386/tcg/ops_sse_header.h.inc | 8 ++++---- hw/i386/kvm/xen_evtchn.c | 2 +- target/i386/tcg/cc_helper.c | 4 +++- target/i386/tcg/translate.c | 3 --- target/i386/tcg/decode-new.c.inc | 21 ++++++++++----------- target/i386/tcg/emit.c.inc | 20 ++++++++++---------- rust/Cargo.lock | 5 +++-- 9 files changed, 41 insertions(+), 40 deletions(-)
Signature · 1 line
2.52.0
[PULL 1/7] target/i386/tcg: do not leave non-arithmetic flags in CC_SRC after PUSHF
The value that is pushed by PUSHF is the full EFLAGS, while CC_OP_EFLAGS only wants arithmetic flags in CC_SRC. To avoid this, follow what other helpers do and set CC_SRC/CC_OP directly in helper_read_eflags. This is basically free and fixes an issue booting Windows 3.11.
--- target/i386/tcg/cc_helper.c | 4 +++- target/i386/tcg/emit.c.inc | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-)
target/i386/tcg/cc_helper.c +3 -1
@@ -414,7 +414,9 @@ target_ulong helper_read_eflags(CPUX86State *env) {uint32_t eflags; - eflags =cpu_cc_compute_all (env); +CC_SRC = eflags =cpu_cc_compute_all (env); +CC_OP =CC_OP_EFLAGS ; + eflags |= (env->df &DF_MASK ); eflags |= env->eflags & ~(VM_MASK |RF_MASK );return eflags;
target/i386/tcg/emit.c.inc +1 -2
@@ -3253,8 +3253,7 @@ static void gen_PUSHF(DisasContext *s, X86DecodedInsn *decode) gen_update_cc_op(s); gen_helper_read_eflags(s->T0, tcg_env); gen_push_v(s, s->T0); - decode->cc_src = s->T0; - decode->cc_op = CC_OP_EFLAGS; + assume_cc_op(s, CC_OP_EFLAGS); } static MemOp gen_shift_count(DisasContext *s, X86DecodedInsn *decode,
Signature · 1 line
2.52.0
[PULL 3/7] target/i386/tcg: do not mark all SSE instructions as unaligned
In reply to Paolo BonziniIf the vex_special field was not initialized, it was considered to be X86_VEX_SSEUnaligned (whose value was zero). Add a new value to fix that.
--- target/i386/tcg/decode-new.h | 2 ++ target/i386/tcg/decode-new.c.inc | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-)
target/i386/tcg/decode-new.h +2 -0
@@ -242,6 +242,8 @@ typedef enum X86InsnSpecial {* section of the manual. */ typedef enum X86VEXSpecial { + X86_VEX_None, + /* Legacy SSE instructions that allow unaligned operands */ X86_VEX_SSEUnaligned,
target/i386/tcg/decode-new.c.inc +7 -4
@@ -1068,15 +1068,15 @@ static void decode_0F10(DisasContext *s, CPUX86State *env, X86OpEntry *entry, ui static void decode_0F11(DisasContext *s, CPUX86State *env, X86OpEntry *entry, uint8_t *b) { static const X86OpEntry opcodes_0F11_reg[4] = { - X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex4), /* MOVUPS */ - X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex4), /* MOVUPD */ + X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex4_unal), /* MOVUPS */ + X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex4_unal), /* MOVUPD */ X86_OP_ENTRY3(VMOVSS, W,x, H,x, V,x, vex5), X86_OP_ENTRY3(VMOVLPx, W,x, H,x, V,q, vex5), /* MOVSD */ }; static const X86OpEntry opcodes_0F11_mem[4] = { - X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex4), /* MOVUPS */ - X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex4), /* MOVUPD */ + X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex4_unal), /* MOVUPS */ + X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex4_unal), /* MOVUPD */ X86_OP_ENTRY3(VMOVSS_st, M,ss, None,None, V,x, vex5), X86_OP_ENTRY3(VMOVLPx_st, M,sd, None,None, V,x, vex5), /* MOVSD */ };
@@ -2624,6 +2624,9 @@ static bool validate_vex(DisasContext *s, X86DecodedInsn *decode) X86OpEntry *e = &decode->e; switch (e->vex_special) { + case X86_VEX_None: + break; + case X86_VEX_REPScalar: /* * Instructions which differ between 00/66 and F2/F3 in the
Signature · 1 line
2.52.0
[PULL 4/7] target/i386/tcg: mask addresses for VSIB
In reply to Paolo BonziniVSIB can have either 32-bit or 64-bit addresses, pass a constant mask to the helper and apply it before the load.
--- target/i386/ops_sse.h | 16 ++++++++-------- target/i386/tcg/ops_sse_header.h.inc | 8 ++++---- target/i386/tcg/emit.c.inc | 17 +++++++++-------- 3 files changed, 21 insertions(+), 20 deletions(-)
target/i386/ops_sse.h +8 -8
@@ -2362,42 +2362,42 @@ void glue(helper_vpmaskmovq, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) }void glue (helper_vpgatherdd ,SUFFIX )(CPUX86State *env, -Reg *d,Reg *v,Reg *s,target_ulong a0,unsigned scale) +Reg *d,Reg *v,Reg *s,target_ulong a0,unsigned scale,target_ulong amask) {int i;for (i =0 ; i < (2 <<SHIFT ); i++) {if (v->L (i) >>31 ) {target_ulong addr = a0 + ((target_ulong )(int32_t )s->L (i) << scale); - d->L (i) =cpu_ldl_data_ra (env, addr,GETPC ()); + d->L (i) =cpu_ldl_data_ra (env, addr & amask,GETPC ()); } v->L (i) =0 ; } }void glue (helper_vpgatherdq ,SUFFIX )(CPUX86State *env, -Reg *d,Reg *v,Reg *s,target_ulong a0,unsigned scale) +Reg *d,Reg *v,Reg *s,target_ulong a0,unsigned scale,target_ulong amask) {int i;for (i =0 ; i < (1 <<SHIFT ); i++) {if (v->Q (i) >>63 ) {target_ulong addr = a0 + ((target_ulong )(int32_t )s->L (i) << scale); - d->Q (i) =cpu_ldq_data_ra (env, addr,GETPC ()); + d->Q (i) =cpu_ldq_data_ra (env, addr & amask,GETPC ()); } v->Q (i) =0 ; } }void glue (helper_vpgatherqd ,SUFFIX )(CPUX86State *env, -Reg *d,Reg *v,Reg *s,target_ulong a0,unsigned scale) +Reg *d,Reg *v,Reg *s,target_ulong a0,unsigned scale,target_ulong amask) {int i;for (i =0 ; i < (1 <<SHIFT ); i++) {if (v->L (i) >>31 ) {target_ulong addr = a0 + ((target_ulong )(int64_t )s->Q (i) << scale); - d->L (i) =cpu_ldl_data_ra (env, addr,GETPC ()); + d->L (i) =cpu_ldl_data_ra (env, addr & amask,GETPC ()); } v->L (i) =0 ; }
@@ -2408,14 +2408,14 @@ void glue(helper_vpgatherqd, SUFFIX)(CPUX86State *env, }void glue (helper_vpgatherqq ,SUFFIX )(CPUX86State *env, -Reg *d,Reg *v,Reg *s,target_ulong a0,unsigned scale) +Reg *d,Reg *v,Reg *s,target_ulong a0,unsigned scale,target_ulong amask) {int i;for (i =0 ; i < (1 <<SHIFT ); i++) {if (v->Q (i) >>63 ) {target_ulong addr = a0 + ((target_ulong )(int64_t )s->Q (i) << scale); - d->Q (i) =cpu_ldq_data_ra (env, addr,GETPC ()); + d->Q (i) =cpu_ldq_data_ra (env, addr & amask,GETPC ()); } v->Q (i) =0 ; }
target/i386/tcg/ops_sse_header.h.inc +4 -4
@@ -388,10 +388,10 @@ DEF_HELPER_4(glue(vpmaskmovd_st, SUFFIX), void, env, Reg, Reg, tl) DEF_HELPER_4(glue(vpmaskmovq_st, SUFFIX), void, env, Reg, Reg, tl) DEF_HELPER_4(glue(vpmaskmovd, SUFFIX), void, env, Reg, Reg, Reg) DEF_HELPER_4(glue(vpmaskmovq, SUFFIX), void, env, Reg, Reg, Reg) -DEF_HELPER_6(glue(vpgatherdd, SUFFIX), void, env, Reg, Reg, Reg, tl, i32) -DEF_HELPER_6(glue(vpgatherdq, SUFFIX), void, env, Reg, Reg, Reg, tl, i32) -DEF_HELPER_6(glue(vpgatherqd, SUFFIX), void, env, Reg, Reg, Reg, tl, i32) -DEF_HELPER_6(glue(vpgatherqq, SUFFIX), void, env, Reg, Reg, Reg, tl, i32) +DEF_HELPER_7(glue(vpgatherdd, SUFFIX), void, env, Reg, Reg, Reg, tl, i32, tl) +DEF_HELPER_7(glue(vpgatherdq, SUFFIX), void, env, Reg, Reg, Reg, tl, i32, tl) +DEF_HELPER_7(glue(vpgatherqd, SUFFIX), void, env, Reg, Reg, Reg, tl, i32, tl) +DEF_HELPER_7(glue(vpgatherqq, SUFFIX), void, env, Reg, Reg, Reg, tl, i32, tl) #if SHIFT == 2 DEF_HELPER_3(vpermd_ymm, void, Reg, Reg, Reg) DEF_HELPER_4(vpermdq_ymm, void, Reg, Reg, Reg, i32)
target/i386/tcg/emit.c.inc +9 -8
@@ -43,8 +43,8 @@ typedef void (*SSEFunc_0_pppi)(TCGv_ptr reg_a, TCGv_ptr reg_b, TCGv_ptr reg_c, TCGv_i32 val); typedef void (*SSEFunc_0_eppt)(TCGv_ptr env, TCGv_ptr reg_a, TCGv_ptr reg_b, TCGv val); -typedef void (*SSEFunc_0_epppti)(TCGv_ptr env, TCGv_ptr reg_a, TCGv_ptr reg_b, - TCGv_ptr reg_c, TCGv a0, TCGv_i32 scale); +typedef void (*SSEFunc_0_eppptit)(TCGv_ptr env, TCGv_ptr reg_a, TCGv_ptr reg_b, + TCGv_ptr reg_c, TCGv a0, TCGv_i32 scale, TCGv amask); typedef void (*SSEFunc_0_eppppi)(TCGv_ptr env, TCGv_ptr reg_a, TCGv_ptr reg_b, TCGv_ptr reg_c, TCGv_ptr reg_d, TCGv_i32 flags); typedef void (*SSEFunc_0_eppppii)(TCGv_ptr env, TCGv_ptr reg_a, TCGv_ptr reg_b,
@@ -1100,18 +1100,19 @@ VEXW_AVX(VPMASKMOV, vpmaskmov) /* Same as above, but with extra arguments to the helper. */ static inline void gen_vsib_avx(DisasContext *s, X86DecodedInsn *decode, - SSEFunc_0_epppti d_xmm, SSEFunc_0_epppti q_xmm, - SSEFunc_0_epppti d_ymm, SSEFunc_0_epppti q_ymm) + SSEFunc_0_eppptit d_xmm, SSEFunc_0_eppptit q_xmm, + SSEFunc_0_eppptit d_ymm, SSEFunc_0_eppptit q_ymm) { - SSEFunc_0_epppti d = s->vex_l ? d_ymm : d_xmm; - SSEFunc_0_epppti q = s->vex_l ? q_ymm : q_xmm; - SSEFunc_0_epppti fn = s->vex_w ? q : d; + SSEFunc_0_eppptit d = s->vex_l ? d_ymm : d_xmm; + SSEFunc_0_eppptit q = s->vex_l ? q_ymm : q_xmm; + SSEFunc_0_eppptit fn = s->vex_w ? q : d; TCGv_i32 scale = tcg_constant_i32(decode->mem.scale); TCGv_ptr index = tcg_temp_new_ptr(); + TCGv mask = tcg_constant_tl(MAKE_64BIT_MASK(0, 8 << s->aflag)); /* Pass third input as (index, base, scale) */ tcg_gen_addi_ptr(index, tcg_env, ZMM_OFFSET(decode->mem.index)); - fn(tcg_env, OP_PTR0, OP_PTR1, index, s->A0, scale); + fn(tcg_env, OP_PTR0, OP_PTR1, index, s->A0, scale, mask); /* * There are two output operands, so zero OP1's high 128 bits
Signature · 1 line
2.52.0
[PULL 7/7] rust: Update Cargo.lock
In reply to Paolo BonziniFrom: Zhao Liu <[email protected]>
cargo +nightly build updates Cargo.lock file.
--- rust/Cargo.lock | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
rust/Cargo.lock +3 -2
@@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "anyhow"
@@ -233,6 +233,8 @@ dependencies = [ [[package]] name = "probe" version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136558b6e1ebaecc92755d0ffaf9421f519531bed30cc2ad23b22cb00965cc5e" [[package]] name = "proc-macro-error"
@@ -392,7 +394,6 @@ dependencies = [ "migration", "qom", "system", - "trace", "util", ]
Signature · 1 line
2.52.0
[PULL 2/7] target/i386/tcg: remove dead code
In reply to Paolo BonziniRemove dead code; it arose when I noticed that, because 0x3? opcodes do have a pop, case 0x32 works just fine as fcomp (even though 0x?2 is fcom):
there is no need to hack the op to 0x03.
Reported by Coverity as CID 1643922.
--- target/i386/tcg/translate.c | 3 --- 1 file changed, 3 deletions(-)
target/i386/tcg/translate.c +0 -3
@@ -2543,9 +2543,6 @@ static void gen_x87(DisasContext *s, X86DecodedInsn *decode)break ; }break ; -/* map to fcomp; op & 7 == 2 would not pop */ - op =0x03 ; -/* fallthrough */ case 0x00 ... 0x07: /* fxxx st, sti */ case 0x22 ... 0x23: /* fcom2 and fcomp3, undocumented ops */case 0x32 :/* fcomp5, undocumented op */
Signature · 1 line
2.52.0
[PULL 5/7] target/i386/tcg: allow VEX in 16-bit protected mode
In reply to Paolo BonziniVEX is only forbidden in real and vm86 mode; 16-bit protected mode supports it for some unfathomable reason.
--- target/i386/tcg/decode-new.c.inc | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
target/i386/tcg/decode-new.c.inc +3 -7
@@ -2872,20 +2872,16 @@ static void disas_insn(DisasContext *s, CPUState *cpu) case 0xc5: /* 2-byte VEX */ case 0xc4: /* 3-byte VEX */ /* - * VEX prefixes cannot be used except in 32-bit mode. - * Otherwise the instruction is LES or LDS. + * Bits 6-7 of the first byte must be set except in 64-bit mode. + * Otherwise the instruction is LES or LDS. Not allowed in real mode. */ - if (CODE32(s) && !VM86(s)) { + if (PE(s) && !VM86(s)) { static const int pp_prefix[4] = { 0, PREFIX_DATA, PREFIX_REPZ, PREFIX_REPNZ }; int vex3, vex2 = x86_ldub_code(env, s); if (!CODE64(s) && (vex2 & 0xc0) != 0xc0) { - /* - * 4.1.4.6: In 32-bit mode, bits [7:6] must be 11b, - * otherwise the instruction is LES or LDS. - */ s->pc--; /* rewind the advance_pc() x86_ldub_code() did */ break; }
Signature · 1 line
2.52.0
[PULL 6/7] hw/i386/kvm: fix PIRQ bounds check in xen_physdev_map_pirq()
In reply to Paolo BonziniFrom: Vulnerability Report <[email protected]>
Reject pirq == s->nr_pirqs in xen_physdev_map_pirq().
--- hw/i386/kvm/xen_evtchn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/kvm/xen_evtchn.c +1 -1
@@ -1877,7 +1877,7 @@ int xen_physdev_map_pirq(struct physdev_map_pirq *map)return pirq; } map->pirq = pirq; - }else if (pirq > s->nr_pirqs) { + }else if (pirq >= s->nr_pirqs) {return -EINVAL ; }else {/*
Signature · 1 line
2.52.0
Richard Henderson
AppliedQuoted 8 lines · Paolo Bonzini
The following changes since commit
cf3e71d8fc8ba681266759bb6cb2e45a45983e3e:Merge tag 'single-binary-20260112' ofhttps://github.com/philmd/qemu into staging (2026-01-13 11:51:18 +1100)are available in the Git repository at:
https://gitlab.com/bonzini/qemu.git tags/for-upstream
Quoted 7 lines
for you to fetch changes up to
a24f045228271391b5c5064ebf049e1f50b6d712:rust: Update Cargo.lock (2026-01-13 10:54:28 +0100)----------------------------------------------------------------
* target/i386/tcg fixes
* hw/i386/kvm: fix PIRQ bounds check inxen_physdev_map_pirq()
Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/11.0 as appropriate.
r~