* [PULL 01/22] tcg/riscv64: Factor encode_vi_raw() out of encode_vi()
2026-11-16 23:23 [PULL 00/22] Misc TCG & HW patches for 2026-11-17 Philippe Mathieu-Daudé
@ 2026-11-16 23:23 ` Philippe Mathieu-Daudé
2026-11-16 23:23 ` [PULL 02/22] tcg/riscv64: Use a uimm5 encoder for vector shift immediates Philippe Mathieu-Daudé
` (21 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-16 23:23 UTC (permalink / raw)
To: qemu-devel
Move the OPIVI field layout into encode_vi_raw(), keeping the
simm5 check in encode_vi(). The next commit adds a uimm5 variant
for the vector shift instructions. No functional change.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Message-ID: <20261028143330.6518-2-philmd@oss.qualcomm.com>
---
tcg/riscv64/tcg-target.c.inc | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/tcg/riscv64/tcg-target.c.inc b/tcg/riscv64/tcg-target.c.inc
index 6da52929a49b..319d5523fe7d 100644
--- a/tcg/riscv64/tcg-target.c.inc
+++ b/tcg/riscv64/tcg-target.c.inc
@@ -535,12 +535,18 @@ static tcg_insn_unit encode_j(RISCVInsn opc, TCGReg rd, tcg_target_long imm)
/* Type-OPIVI */
+static tcg_insn_unit encode_vi_raw(RISCVInsn opc, TCGReg rd, unsigned imm5,
+ TCGReg vs2, bool vm)
+{
+ return opc | (rd & 0x1f) << 7 | (imm5 & 0x1f) << 15 |
+ (vs2 & 0x1f) << 20 | (vm << 25);
+}
+
static tcg_insn_unit encode_vi(RISCVInsn opc, TCGReg rd, tcg_target_long imm,
TCGReg vs2, bool vm)
{
tcg_debug_assert(imm == sextract32(imm, 0, 5));
- return opc | (rd & 0x1f) << 7 | (imm & 0x1f) << 15 |
- (vs2 & 0x1f) << 20 | (vm << 25);
+ return encode_vi_raw(opc, rd, imm, vs2, vm);
}
/* Type-OPIVV/OPMVV/OPIVX/OPMVX, Vector load and store */
--
2.55.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PULL 02/22] tcg/riscv64: Use a uimm5 encoder for vector shift immediates
2026-11-16 23:23 [PULL 00/22] Misc TCG & HW patches for 2026-11-17 Philippe Mathieu-Daudé
2026-11-16 23:23 ` [PULL 01/22] tcg/riscv64: Factor encode_vi_raw() out of encode_vi() Philippe Mathieu-Daudé
@ 2026-11-16 23:23 ` Philippe Mathieu-Daudé
2026-11-16 23:23 ` [PULL 03/22] tcg/riscv64: Extract elements for vector arithmetic immediates Philippe Mathieu-Daudé
` (20 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-16 23:23 UTC (permalink / raw)
To: qemu-devel
RVV shift .vi forms take an unsigned 5-bit immediate, but
encode_vi() checks for simm5, so shift counts 16..31 trip
the debug assertion (and are undefined behaviour in release
builds).
Add encode_vi_u() and use it in tcg_out_vshifti().
Fixes: 006352d69f14 ("tcg/riscv64: Assert immediate in range ...")
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Message-ID: <20261028143330.6518-3-philmd@oss.qualcomm.com>
---
tcg/riscv64/tcg-target.c.inc | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/tcg/riscv64/tcg-target.c.inc b/tcg/riscv64/tcg-target.c.inc
index 319d5523fe7d..002b3b4b780d 100644
--- a/tcg/riscv64/tcg-target.c.inc
+++ b/tcg/riscv64/tcg-target.c.inc
@@ -542,6 +542,7 @@ static tcg_insn_unit encode_vi_raw(RISCVInsn opc, TCGReg rd, unsigned imm5,
(vs2 & 0x1f) << 20 | (vm << 25);
}
+/* OPIVI with a signed immediate (simm5). */
static tcg_insn_unit encode_vi(RISCVInsn opc, TCGReg rd, tcg_target_long imm,
TCGReg vs2, bool vm)
{
@@ -549,6 +550,14 @@ static tcg_insn_unit encode_vi(RISCVInsn opc, TCGReg rd, tcg_target_long imm,
return encode_vi_raw(opc, rd, imm, vs2, vm);
}
+/* OPIVI with an unsigned immediate (uimm5) */
+static tcg_insn_unit encode_vi_u(RISCVInsn opc, TCGReg rd, unsigned imm,
+ TCGReg vs2, bool vm)
+{
+ tcg_debug_assert(imm == extract32(imm, 0, 5));
+ return encode_vi_raw(opc, rd, imm, vs2, vm);
+}
+
/* Type-OPIVV/OPMVV/OPIVX/OPMVX, Vector load and store */
static tcg_insn_unit encode_v(RISCVInsn opc, TCGReg d, TCGReg s1,
@@ -721,6 +730,12 @@ static void tcg_out_opc_vi(TCGContext *s, RISCVInsn opc,
tcg_out32(s, encode_vi(opc, vd, imm, vs2, true));
}
+static void tcg_out_opc_vi_u(TCGContext *s, RISCVInsn opc,
+ TCGReg vd, TCGReg vs2, unsigned imm)
+{
+ tcg_out32(s, encode_vi_u(opc, vd, imm, vs2, true));
+}
+
static void tcg_out_opc_vv_vi(TCGContext *s, RISCVInsn o_vv, RISCVInsn o_vi,
TCGReg vd, TCGReg vs2, TCGArg vi1, int c_vi1)
{
@@ -1579,7 +1594,7 @@ static void tcg_out_vshifti(TCGContext *s, RISCVInsn opc_vi, RISCVInsn opc_vx,
TCGReg dst, TCGReg src, unsigned imm)
{
if (imm < 32) {
- tcg_out_opc_vi(s, opc_vi, dst, src, imm);
+ tcg_out_opc_vi_u(s, opc_vi, dst, src, imm);
} else {
tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_TMP0, imm);
tcg_out_opc_vx(s, opc_vx, dst, src, TCG_REG_TMP0);
--
2.55.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PULL 03/22] tcg/riscv64: Extract elements for vector arithmetic immediates
2026-11-16 23:23 [PULL 00/22] Misc TCG & HW patches for 2026-11-17 Philippe Mathieu-Daudé
2026-11-16 23:23 ` [PULL 01/22] tcg/riscv64: Factor encode_vi_raw() out of encode_vi() Philippe Mathieu-Daudé
2026-11-16 23:23 ` [PULL 02/22] tcg/riscv64: Use a uimm5 encoder for vector shift immediates Philippe Mathieu-Daudé
@ 2026-11-16 23:23 ` Philippe Mathieu-Daudé
2026-11-16 23:23 ` [PULL 04/22] tcg/riscv64: Fix constant handling in vector comparisons and selects Philippe Mathieu-Daudé
` (19 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-16 23:23 UTC (permalink / raw)
To: qemu-devel
The .vi emitters pass the whole replicated constant (e.g.
0x0505050505050505) instead of one element. The encoding is still
correct, because encode_vi() keeps the low 5 bits, but it trips the
range assert added in 006352d69f14 on common vectorized guest code
in debug builds. Extract the VECE element with vec_imm(), so the
assert keeps checking that the emitter agrees with the constraint
matcher.
Add vec_imm() to extract the VECE element, and use it.
Fixes: 006352d69f14 ("tcg/riscv64: Assert immediate in range ...")
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20261028143330.6518-4-philmd@oss.qualcomm.com>
---
tcg/riscv64/tcg-target.c.inc | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/tcg/riscv64/tcg-target.c.inc b/tcg/riscv64/tcg-target.c.inc
index 002b3b4b780d..55685db44f3a 100644
--- a/tcg/riscv64/tcg-target.c.inc
+++ b/tcg/riscv64/tcg-target.c.inc
@@ -736,6 +736,12 @@ static void tcg_out_opc_vi_u(TCGContext *s, RISCVInsn opc,
tcg_out32(s, encode_vi_u(opc, vd, imm, vs2, true));
}
+/* Constants are replicated by VECE; extract one element for .vi forms. */
+static int64_t vec_imm(TCGArg arg, unsigned vece)
+{
+ return sextract64(arg, 0, 8 << vece);
+}
+
static void tcg_out_opc_vv_vi(TCGContext *s, RISCVInsn o_vv, RISCVInsn o_vi,
TCGReg vd, TCGReg vs2, TCGArg vi1, int c_vi1)
{
@@ -2805,12 +2811,13 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc,
break;
case INDEX_op_add_vec:
set_vtype_len_sew(s, type, vece);
- tcg_out_opc_vv_vi(s, OPC_VADD_VV, OPC_VADD_VI, a0, a1, a2, c2);
+ tcg_out_opc_vv_vi(s, OPC_VADD_VV, OPC_VADD_VI, a0, a1,
+ c2 ? vec_imm(a2, vece) : a2, c2);
break;
case INDEX_op_sub_vec:
set_vtype_len_sew(s, type, vece);
if (const_args[1]) {
- tcg_out_opc_vi(s, OPC_VRSUB_VI, a0, a2, a1);
+ tcg_out_opc_vi(s, OPC_VRSUB_VI, a0, a2, vec_imm(a1, vece));
} else {
tcg_out_opc_vv(s, OPC_VSUB_VV, a0, a1, a2);
}
@@ -2841,19 +2848,23 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc,
break;
case INDEX_op_ssadd_vec:
set_vtype_len_sew(s, type, vece);
- tcg_out_opc_vv_vi(s, OPC_VSADD_VV, OPC_VSADD_VI, a0, a1, a2, c2);
+ tcg_out_opc_vv_vi(s, OPC_VSADD_VV, OPC_VSADD_VI, a0, a1,
+ c2 ? vec_imm(a2, vece) : a2, c2);
break;
case INDEX_op_sssub_vec:
set_vtype_len_sew(s, type, vece);
- tcg_out_opc_vv_vi(s, OPC_VSSUB_VV, OPC_VSSUB_VI, a0, a1, a2, c2);
+ tcg_out_opc_vv_vi(s, OPC_VSSUB_VV, OPC_VSSUB_VI, a0, a1,
+ c2 ? vec_imm(a2, vece) : a2, c2);
break;
case INDEX_op_usadd_vec:
set_vtype_len_sew(s, type, vece);
- tcg_out_opc_vv_vi(s, OPC_VSADDU_VV, OPC_VSADDU_VI, a0, a1, a2, c2);
+ tcg_out_opc_vv_vi(s, OPC_VSADDU_VV, OPC_VSADDU_VI, a0, a1,
+ c2 ? vec_imm(a2, vece) : a2, c2);
break;
case INDEX_op_ussub_vec:
set_vtype_len_sew(s, type, vece);
- tcg_out_opc_vv_vi(s, OPC_VSSUBU_VV, OPC_VSSUBU_VI, a0, a1, a2, c2);
+ tcg_out_opc_vv_vi(s, OPC_VSSUBU_VV, OPC_VSSUBU_VI, a0, a1,
+ c2 ? vec_imm(a2, vece) : a2, c2);
break;
case INDEX_op_smax_vec:
set_vtype_len_sew(s, type, vece);
--
2.55.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PULL 04/22] tcg/riscv64: Fix constant handling in vector comparisons and selects
2026-11-16 23:23 [PULL 00/22] Misc TCG & HW patches for 2026-11-17 Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2026-11-16 23:23 ` [PULL 03/22] tcg/riscv64: Extract elements for vector arithmetic immediates Philippe Mathieu-Daudé
@ 2026-11-16 23:23 ` Philippe Mathieu-Daudé
2026-11-16 23:23 ` [PULL 05/22] tcg/riscv64: Fix logical vector immediate matching and emission Philippe Mathieu-Daudé
` (18 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-16 23:23 UTC (permalink / raw)
To: qemu-devel
tcg_out_cmpsel() takes constants as TCGReg and passes the whole
replicated value to the .vi encoders instead of one element. The
encoding is still correct, because encode_vi() keeps the low 5 bits,
but it trips the range assert added in 006352d69f14 in debug builds.
E.g. "cmlt v0.8h, #0" computes 0 - 1 in unsigned TCGReg, giving
0xffffffff instead of -1.
Use TCGArg for these operands and extract the element with vec_imm()
before encoding, including before the LT/GE adjustment, so the assert
keeps checking that the emitter agrees with the constraint matcher.
Fixes: 006352d69f14 ("tcg/riscv64: Assert immediate in range ...")
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20261028143330.6518-5-philmd@oss.qualcomm.com>
---
tcg/riscv64/tcg-target.c.inc | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/tcg/riscv64/tcg-target.c.inc b/tcg/riscv64/tcg-target.c.inc
index 55685db44f3a..902e600a1f51 100644
--- a/tcg/riscv64/tcg-target.c.inc
+++ b/tcg/riscv64/tcg-target.c.inc
@@ -1556,9 +1556,9 @@ static void tcg_out_cltz(TCGContext *s, TCGType type, RISCVInsn insn,
static void tcg_out_cmpsel(TCGContext *s, TCGType type, unsigned vece,
TCGCond cond, TCGReg ret,
- TCGReg cmp1, TCGReg cmp2, bool c_cmp2,
- TCGReg val1, bool c_val1,
- TCGReg val2, bool c_val2)
+ TCGReg cmp1, TCGArg cmp2, bool c_cmp2,
+ TCGArg val1, bool c_val1,
+ TCGArg val2, bool c_val2)
{
set_vtype_len_sew(s, type, vece);
@@ -1575,7 +1575,7 @@ static void tcg_out_cmpsel(TCGContext *s, TCGType type, unsigned vece,
/* Perform the comparison into V0 mask. */
if (c_cmp2) {
tcg_out_opc_vi(s, tcg_cmpcond_to_rvv_vi[cond].op, TCG_REG_V0, cmp1,
- cmp2 - tcg_cmpcond_to_rvv_vi[cond].adjust);
+ vec_imm(cmp2, vece) - tcg_cmpcond_to_rvv_vi[cond].adjust);
} else if (tcg_cmpcond_to_rvv_vv[cond].swap) {
tcg_out_opc_vv(s, tcg_cmpcond_to_rvv_vv[cond].op,
TCG_REG_V0, cmp2, cmp1);
@@ -1585,11 +1585,12 @@ static void tcg_out_cmpsel(TCGContext *s, TCGType type, unsigned vece,
}
if (c_val1) {
if (c_val2) {
- tcg_out_opc_vi(s, OPC_VMV_V_I, ret, 0, val2);
+ tcg_out_opc_vi(s, OPC_VMV_V_I, ret, 0, vec_imm(val2, vece));
val2 = ret;
}
/* vd[i] == v0.mask[i] ? imm : vs2[i] */
- tcg_out_opc_vim_mask(s, OPC_VMERGE_VIM, ret, val2, val1);
+ tcg_out_opc_vim_mask(s, OPC_VMERGE_VIM, ret, val2,
+ vec_imm(val1, vece));
} else {
/* vd[i] == v0.mask[i] ? vs1[i] : vs2[i] */
tcg_out_opc_vvm_mask(s, OPC_VMERGE_VVM, ret, val2, val1);
--
2.55.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PULL 05/22] tcg/riscv64: Fix logical vector immediate matching and emission
2026-11-16 23:23 [PULL 00/22] Misc TCG & HW patches for 2026-11-17 Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2026-11-16 23:23 ` [PULL 04/22] tcg/riscv64: Fix constant handling in vector comparisons and selects Philippe Mathieu-Daudé
@ 2026-11-16 23:23 ` Philippe Mathieu-Daudé
2026-11-16 23:23 ` [PULL 06/22] tests/tcg/aarch64: Add vector immediate regression tests Philippe Mathieu-Daudé
` (17 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-16 23:23 UTC (permalink / raw)
To: qemu-devel
and/or/xor_vec are bitwise, so the generic layer doesn't track a
meaningful VECE for them (it is always 0). The backend nevertheless
matched the constant as a byte element, and emitted the .vi form at
whatever SEW the previous op left behind:
"bic v4.8h, #0xf0" became "vand.vi ..., 15".
Add the 'N' constraint: find the smallest element size at which the
constant replicates; the constant matches if that element fits simm5.
The emitter then sets SEW to that size. A wider element can't fit
when the smallest doesn't: its upper half repeats the smaller
element, which would then be 0 or -1.
Cc: qemu-stable@nongnu.org
Fixes: 5a63f5998791 ("tcg/riscv: Add support for basic vector opcodes")
Reported-by: Aurelien Jarno <aurelien@aurel32.net>
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Message-ID: <20261028143330.6518-6-philmd@oss.qualcomm.com>
---
tcg/riscv64/tcg-target-con-set.h | 1 +
tcg/riscv64/tcg-target-con-str.h | 1 +
tcg/riscv64/tcg-target.c.inc | 53 +++++++++++++++++++++++++++-----
3 files changed, 48 insertions(+), 7 deletions(-)
diff --git a/tcg/riscv64/tcg-target-con-set.h b/tcg/riscv64/tcg-target-con-set.h
index 0fc26d3f98b4..9b4e219fac16 100644
--- a/tcg/riscv64/tcg-target-con-set.h
+++ b/tcg/riscv64/tcg-target-con-set.h
@@ -26,4 +26,5 @@ C_O1_I2(v, v, v)
C_O1_I2(v, vK, v)
C_O1_I2(v, v, vK)
C_O1_I2(v, v, vL)
+C_O1_I2(v, v, vN)
C_O1_I4(v, v, vL, vK, vK)
diff --git a/tcg/riscv64/tcg-target-con-str.h b/tcg/riscv64/tcg-target-con-str.h
index c04e15ddfa3c..d7e8b2ce4f2f 100644
--- a/tcg/riscv64/tcg-target-con-str.h
+++ b/tcg/riscv64/tcg-target-con-str.h
@@ -19,3 +19,4 @@ CONST('I', TCG_CT_CONST_S12)
CONST('K', TCG_CT_CONST_S5)
CONST('L', TCG_CT_CONST_CMP_VI)
CONST('M', TCG_CT_CONST_M12)
+CONST('N', TCG_CT_CONST_LOGICAL_VI)
diff --git a/tcg/riscv64/tcg-target.c.inc b/tcg/riscv64/tcg-target.c.inc
index 902e600a1f51..4e1c68785d3b 100644
--- a/tcg/riscv64/tcg-target.c.inc
+++ b/tcg/riscv64/tcg-target.c.inc
@@ -116,6 +116,7 @@ static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot)
#define TCG_CT_CONST_M12 0x200
#define TCG_CT_CONST_S5 0x400
#define TCG_CT_CONST_CMP_VI 0x800
+#define TCG_CT_CONST_LOGICAL_VI 0x1000
#define ALL_GENERAL_REGS MAKE_64BIT_MASK(0, 32)
#define ALL_VECTOR_REGS MAKE_64BIT_MASK(32, 32)
@@ -385,6 +386,22 @@ static const struct {
[TCG_COND_GEU] = { OPC_VMSGTU_VI, 1, 16, true },
};
+/*
+ * Return the element size at which VAL is a replicated simm5,
+ * or -1 if there is none. Used for vector logical ops, whose
+ * VECE is not meaningful.
+ */
+static int vec_logical_immediate_vece(int64_t val)
+{
+ for (int e = MO_8; e <= MO_64; e++) {
+ if (val == dup_const(e, val)) {
+ int64_t x = sextract64(val, 0, 8 << e);
+ return x >= -0x10 && x <= 0x0f ? e : -1;
+ }
+ }
+ g_assert_not_reached();
+}
+
/* test if a constant matches the constraint */
static bool tcg_target_const_match(int64_t val, int ct,
TCGType type, TCGCond cond, int vece)
@@ -392,6 +409,10 @@ static bool tcg_target_const_match(int64_t val, int ct,
if (ct & TCG_CT_CONST) {
return 1;
}
+ if ((ct & TCG_CT_CONST_LOGICAL_VI) &&
+ vec_logical_immediate_vece(val) >= 0) {
+ return true;
+ }
if (type >= TCG_TYPE_V64) {
/* Val is replicated by VECE; extract the highest element. */
val >>= (-8 << vece) & 63;
@@ -2786,6 +2807,23 @@ static const TCGOutOpLea outop_lea = {
.out = tgen_lea,
};
+static void tcg_out_opc_vv_vi_logical(TCGContext *s, TCGType type,
+ RISCVInsn o_vv, RISCVInsn o_vi,
+ TCGReg vd, TCGReg vs2,
+ TCGArg vi1, int c_vi1)
+{
+ if (c_vi1) {
+ int vece = vec_logical_immediate_vece(vi1);
+
+ tcg_debug_assert(vece >= 0);
+ set_vtype_len_sew(s, type, vece);
+ tcg_out_opc_vi(s, o_vi, vd, vs2, vec_imm(vi1, vece));
+ } else {
+ set_vtype_len(s, type);
+ tcg_out_opc_vv(s, o_vv, vd, vs2, vi1);
+ }
+}
+
static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc,
unsigned vecl, unsigned vece,
const TCGArg args[TCG_MAX_OP_ARGS],
@@ -2824,16 +2862,16 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc,
}
break;
case INDEX_op_and_vec:
- set_vtype_len(s, type);
- tcg_out_opc_vv_vi(s, OPC_VAND_VV, OPC_VAND_VI, a0, a1, a2, c2);
+ tcg_out_opc_vv_vi_logical(s, type, OPC_VAND_VV, OPC_VAND_VI,
+ a0, a1, a2, c2);
break;
case INDEX_op_or_vec:
- set_vtype_len(s, type);
- tcg_out_opc_vv_vi(s, OPC_VOR_VV, OPC_VOR_VI, a0, a1, a2, c2);
+ tcg_out_opc_vv_vi_logical(s, type, OPC_VOR_VV, OPC_VOR_VI,
+ a0, a1, a2, c2);
break;
case INDEX_op_xor_vec:
- set_vtype_len(s, type);
- tcg_out_opc_vv_vi(s, OPC_VXOR_VV, OPC_VXOR_VI, a0, a1, a2, c2);
+ tcg_out_opc_vv_vi_logical(s, type, OPC_VXOR_VV, OPC_VXOR_VI,
+ a0, a1, a2, c2);
break;
case INDEX_op_not_vec:
set_vtype_len(s, type);
@@ -3025,10 +3063,11 @@ tcg_target_op_def(TCGOpcode op, TCGType type, unsigned flags)
case INDEX_op_sari_vec:
case INDEX_op_rotli_vec:
return C_O1_I1(v, v);
- case INDEX_op_add_vec:
case INDEX_op_and_vec:
case INDEX_op_or_vec:
case INDEX_op_xor_vec:
+ return C_O1_I2(v, v, vN);
+ case INDEX_op_add_vec:
case INDEX_op_ssadd_vec:
case INDEX_op_sssub_vec:
case INDEX_op_usadd_vec:
--
2.55.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PULL 06/22] tests/tcg/aarch64: Add vector immediate regression tests
2026-11-16 23:23 [PULL 00/22] Misc TCG & HW patches for 2026-11-17 Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2026-11-16 23:23 ` [PULL 05/22] tcg/riscv64: Fix logical vector immediate matching and emission Philippe Mathieu-Daudé
@ 2026-11-16 23:23 ` Philippe Mathieu-Daudé
2026-11-16 23:23 ` [PULL 07/22] meson.build: fix getifaddrs() detection on illumos Philippe Mathieu-Daudé
` (16 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-16 23:23 UTC (permalink / raw)
To: qemu-devel
Run SVE/AdvSIMD immediate operations after an operation
of another element size, at every SVE vector length,
against scalar references.
Catches backends encoding the replicated constant or
using a stale element size, as tcg/riscv64 did.
AI-used-for: Regression tests
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Acked-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20261028143330.6518-7-philmd@oss.qualcomm.com>
---
tests/tcg/aarch64/sve-vec-imm.c | 233 ++++++++++++++++++++++++++++++++
tests/tcg/aarch64/meson.build | 1 +
2 files changed, 234 insertions(+)
create mode 100644 tests/tcg/aarch64/sve-vec-imm.c
diff --git a/tests/tcg/aarch64/sve-vec-imm.c b/tests/tcg/aarch64/sve-vec-imm.c
new file mode 100644
index 000000000000..62391824946b
--- /dev/null
+++ b/tests/tcg/aarch64/sve-vec-imm.c
@@ -0,0 +1,233 @@
+/*
+ * Vector operations with immediates, at every SVE vector length.
+ *
+ * Each case first runs an operation with a given element size, then
+ * an operation with an immediate at another element size, within the
+ * same TB. This catches TCG backends that encode the immediate from
+ * the whole replicated constant, or apply it at a stale element size.
+ *
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/prctl.h>
+
+#define MAXVL 256
+
+static uint8_t in[MAXVL], out[MAXVL];
+
+typedef void test_fn(void);
+typedef uint64_t ref_fn(uint64_t x);
+
+#define TEST(NAME, SETUP, OP) \
+static void NAME(void) \
+{ \
+ asm volatile("ldr z0, [%0]\n\t" \
+ "ldr z1, [%0]\n\t" \
+ "mov z2.d, #0\n\t" \
+ SETUP "\n\t" \
+ OP "\n\t" \
+ "str z0, [%1]" \
+ : : "r"(in), "r"(out) : "z0", "z1", "z2", "memory"); \
+}
+
+#define SET_B "add z1.b, z1.b, z1.b"
+#define SET_D "add z1.d, z1.d, z1.d"
+
+static int64_t sext(uint64_t x, int bits)
+{
+ return (int64_t)(x << (64 - bits)) >> (64 - bits);
+}
+
+static uint64_t sat_s(int64_t x, int bits)
+{
+ int64_t max = (1ll << (bits - 1)) - 1;
+ return x > max ? max : x < -max - 1 ? -max - 1 : x;
+}
+
+static uint64_t sat_u(int64_t x, int bits)
+{
+ int64_t max = (1ll << bits) - 1;
+ return x > max ? max : x < 0 ? 0 : x;
+}
+
+static uint64_t ror(uint64_t x, int n, int bits)
+{
+ uint64_t m = bits == 64 ? -1ull : (1ull << bits) - 1;
+ return ((x >> n) | (x << (bits - n))) & m;
+}
+
+/* Arithmetic immediates (add_vec, sub_vec, saturating ops). */
+TEST(add_b5, SET_D, "add z0.b, z0.b, #5")
+static uint64_t r_add_b5(uint64_t x) { return x + 5; }
+TEST(add_h3, SET_B, "add z0.h, z0.h, #3")
+static uint64_t r_add_h3(uint64_t x) { return x + 3; }
+TEST(sub_s7, SET_B, "sub z0.s, z0.s, #7")
+static uint64_t r_sub_s7(uint64_t x) { return x - 7; }
+TEST(subr_h3, SET_B, "subr z0.h, z0.h, #3")
+static uint64_t r_subr_h3(uint64_t x) { return 3 - x; }
+TEST(sqadd_b3, SET_D, "sqadd z0.b, z0.b, #3")
+static uint64_t r_sqadd_b3(uint64_t x) { return sat_s(sext(x, 8) + 3, 8); }
+TEST(uqadd_h9, SET_B, "uqadd z0.h, z0.h, #9")
+static uint64_t r_uqadd_h9(uint64_t x) { return sat_u(x + 9, 16); }
+TEST(sqsub_s4, SET_B, "sqsub z0.s, z0.s, #4")
+static uint64_t r_sqsub_s4(uint64_t x) { return sat_s(sext(x, 32) - 4, 32); }
+TEST(uqsub_s2, SET_B, "uqsub z0.s, z0.s, #2")
+static uint64_t r_uqsub_s2(uint64_t x) { return sat_u((int64_t)x - 2, 32); }
+
+/* Logical immediates (and_vec, or_vec, xor_vec). */
+TEST(and_d_f, SET_B, "and z0.d, z0.d, #0xf")
+static uint64_t r_and_f(uint64_t x) { return x & 0xf; }
+TEST(and_b_f, SET_D, "and z0.b, z0.b, #0xf")
+TEST(orr_d_m16, SET_B, "orr z0.d, z0.d, #0xfffffffffffffff0")
+static uint64_t r_orr_m16(uint64_t x) { return x | -16ull; }
+TEST(eor_b_f, SET_D, "eor z0.b, z0.b, #0xf")
+static uint64_t r_eor_f(uint64_t x) { return x ^ 0xf; }
+TEST(orr_h_f, SET_D, "orr z0.h, z0.h, #0xf")
+static uint64_t r_orr_f(uint64_t x) { return x | 0xf; }
+TEST(eor_s_1, SET_B, "eor z0.s, z0.s, #0x1")
+static uint64_t r_eor_1(uint64_t x) { return x ^ 1; }
+
+/* Shift immediates, including counts above 15 and 31. */
+TEST(lsl_d40, SET_B, "lsl z0.d, z0.d, #40")
+static uint64_t r_lsl_d40(uint64_t x) { return x << 40; }
+TEST(asr_d63, SET_B, "asr z0.d, z0.d, #63")
+static uint64_t r_asr_d63(uint64_t x) { return sext(x, 64) >> 63; }
+TEST(lsr_s20, SET_D, "lsr z0.s, z0.s, #20")
+static uint64_t r_lsr_s20(uint64_t x) { return x >> 20; }
+TEST(lsl_s31, SET_D, "lsl z0.s, z0.s, #31")
+static uint64_t r_lsl_s31(uint64_t x) { return x << 31; }
+TEST(asr_h15, SET_D, "asr z0.h, z0.h, #15")
+static uint64_t r_asr_h15(uint64_t x) { return sext(x, 16) >> 15; }
+TEST(xar_d40, SET_B, "xar z0.d, z0.d, z2.d, #40")
+static uint64_t r_xar_d40(uint64_t x) { return ror(x, 40, 64); }
+TEST(xar_s20, SET_D, "xar z0.s, z0.s, z2.s, #20")
+static uint64_t r_xar_s20(uint64_t x) { return ror(x, 20, 32); }
+
+/* Compare with zero (cmp_vec), including the adjusted LT/GE forms. */
+TEST(cmeq_h0, SET_B, "cmeq v0.8h, v0.8h, #0")
+static uint64_t r_cmeq0(uint64_t x) { return x == 0 ? -1ull : 0; }
+TEST(cmgt_b0, SET_D, "cmgt v0.16b, v0.16b, #0")
+static uint64_t r_cmgt_b0(uint64_t x) { return sext(x, 8) > 0 ? -1ull : 0; }
+TEST(cmlt_b0, SET_D, "cmlt v0.16b, v0.16b, #0")
+static uint64_t r_cmlt_b0(uint64_t x) { return sext(x, 8) < 0 ? -1ull : 0; }
+TEST(cmlt_h0, SET_B, "cmlt v0.8h, v0.8h, #0")
+static uint64_t r_cmlt_h0(uint64_t x) { return sext(x, 16) < 0 ? -1ull : 0; }
+TEST(cmge_s0, SET_B, "cmge v0.4s, v0.4s, #0")
+static uint64_t r_cmge_s0(uint64_t x) { return sext(x, 32) >= 0 ? -1ull : 0; }
+TEST(cmle_d0, SET_B, "cmle v0.2d, v0.2d, #0")
+static uint64_t r_cmle_d0(uint64_t x) { return sext(x, 64) <= 0 ? -1ull : 0; }
+
+/* Vector constants (dupi_vec): vmv.v.i, 0/-1, and wide immediates. */
+TEST(movi_s5, SET_B, "movi v0.4s, #5")
+static uint64_t r_5(uint64_t x) { return 5; }
+TEST(movi_h99, SET_D, "movi v0.8h, #0x99")
+static uint64_t r_99(uint64_t x) { return 0x99; }
+TEST(movi_d_mask, SET_B, "movi v0.2d, #0xff00ff00ff00ff00")
+static uint64_t r_mask(uint64_t x) { return 0xff00ff00ff00ff00ull; }
+TEST(mvni_s0, SET_D, "mvni v0.4s, #0")
+static uint64_t r_m1(uint64_t x) { return -1ull; }
+
+static const struct {
+ const char *name;
+ test_fn *fn;
+ ref_fn *ref;
+ int esz; /* element size in bytes */
+ int neon; /* AdvSIMD op: only the low 16 bytes, rest zeroed */
+} tests[] = {
+ { "add .d; add .b, #5", add_b5, r_add_b5, 1 },
+ { "add .b; add .h, #3", add_h3, r_add_h3, 2 },
+ { "add .b; sub .s, #7", sub_s7, r_sub_s7, 4 },
+ { "add .b; subr .h, #3", subr_h3, r_subr_h3, 2 },
+ { "add .d; sqadd .b, #3", sqadd_b3, r_sqadd_b3, 1 },
+ { "add .b; uqadd .h, #9", uqadd_h9, r_uqadd_h9, 2 },
+ { "add .b; sqsub .s, #4", sqsub_s4, r_sqsub_s4, 4 },
+ { "add .b; uqsub .s, #2", uqsub_s2, r_uqsub_s2, 4 },
+
+ { "add .b; and .d, #0xf", and_d_f, r_and_f, 8 },
+ { "add .d; and .b, #0xf", and_b_f, r_and_f, 1 },
+ { "add .b; orr .d, #-16", orr_d_m16, r_orr_m16, 8 },
+ { "add .d; eor .b, #0xf", eor_b_f, r_eor_f, 1 },
+ { "add .d; orr .h, #0xf", orr_h_f, r_orr_f, 2 },
+ { "add .b; eor .s, #1", eor_s_1, r_eor_1, 4 },
+
+ { "add .b; lsl .d, #40", lsl_d40, r_lsl_d40, 8 },
+ { "add .b; asr .d, #63", asr_d63, r_asr_d63, 8 },
+ { "add .d; lsr .s, #20", lsr_s20, r_lsr_s20, 4 },
+ { "add .d; lsl .s, #31", lsl_s31, r_lsl_s31, 4 },
+ { "add .d; asr .h, #15", asr_h15, r_asr_h15, 2 },
+ { "add .b; xar .d, #40", xar_d40, r_xar_d40, 8 },
+ { "add .d; xar .s, #20", xar_s20, r_xar_s20, 4 },
+
+ { "add .b; cmeq .8h, #0", cmeq_h0, r_cmeq0, 2, 1 },
+ { "add .d; cmgt .16b, #0", cmgt_b0, r_cmgt_b0, 1, 1 },
+ { "add .d; cmlt .16b, #0", cmlt_b0, r_cmlt_b0, 1, 1 },
+ { "add .b; cmlt .8h, #0", cmlt_h0, r_cmlt_h0, 2, 1 },
+ { "add .b; cmge .4s, #0", cmge_s0, r_cmge_s0, 4, 1 },
+ { "add .b; cmle .2d, #0", cmle_d0, r_cmle_d0, 8, 1 },
+
+ { "add .b; movi .4s, #5", movi_s5, r_5, 4, 1 },
+ { "add .d; movi .8h, #0x99", movi_h99, r_99, 2, 1 },
+ { "add .b; movi .2d, #0xff00...", movi_d_mask, r_mask, 8, 1 },
+ { "add .d; mvni .4s, #0", mvni_s0, r_m1, 4, 1 },
+};
+
+static int check(int vl, int t)
+{
+ int esz = tests[t].esz;
+ int n = tests[t].neon ? 16 : vl;
+ uint64_t mask = esz == 8 ? -1ull : (1ull << (esz * 8)) - 1;
+
+ for (int i = 0; i < vl; i += esz) {
+ uint64_t x = 0, got = 0, exp = 0;
+
+ memcpy(&x, in + i, esz);
+ memcpy(&got, out + i, esz);
+ if (i < n) {
+ exp = tests[t].ref(x) & mask;
+ }
+ if (got != exp) {
+ fprintf(stderr, "vl %d: %s: byte %d: got 0x%llx, "
+ "expected 0x%llx\n", vl, tests[t].name, i,
+ (unsigned long long)got, (unsigned long long)exp);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int main(void)
+{
+ int err = 0, nvl = 0;
+
+ for (int i = 0; i < MAXVL; i++) {
+ in[i] = 0xa5 ^ (i * 0x37);
+ }
+ /* Zero, saturating and sign-boundary elements in the low 16 bytes. */
+ in[0] = 0x7e; /* sqadd .b overflow */
+ in[2] = in[3] = 0; /* cmeq .h, zero */
+ in[8] = 1; /* uqsub .s underflow */
+ in[9] = in[10] = in[11] = 0;
+ in[12] = 0xfa; in[13] = 0xff; /* uqadd .h overflow */
+
+ for (int vl = 16; vl <= MAXVL; vl *= 2) {
+ if (prctl(PR_SVE_SET_VL, vl, 0, 0, 0, 0) != vl) {
+ continue;
+ }
+ nvl++;
+ for (int t = 0; t < sizeof(tests) / sizeof(tests[0]); t++) {
+ memset(out, 0xee, sizeof(out));
+ tests[t].fn();
+ err |= check(vl, t);
+ }
+ }
+ if (nvl == 0) {
+ fprintf(stderr, "no SVE vector length available\n");
+ return 1;
+ }
+ return err;
+}
diff --git a/tests/tcg/aarch64/meson.build b/tests/tcg/aarch64/meson.build
index 52eb67ae6ace..2033356e3625 100644
--- a/tests/tcg/aarch64/meson.build
+++ b/tests/tcg/aarch64/meson.build
@@ -145,6 +145,7 @@ tests += {
tests += {
'test-826.c': {'cc_feat': 'sve2'},
'sve-while-ptr.c': {'cc_feat': 'sve2'},
+ 'sve-vec-imm.c': {'cc_feat': 'sve2'},
}
# FPRCVT test
--
2.55.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PULL 07/22] meson.build: fix getifaddrs() detection on illumos
2026-11-16 23:23 [PULL 00/22] Misc TCG & HW patches for 2026-11-17 Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2026-11-16 23:23 ` [PULL 06/22] tests/tcg/aarch64: Add vector immediate regression tests Philippe Mathieu-Daudé
@ 2026-11-16 23:23 ` Philippe Mathieu-Daudé
2026-11-16 23:23 ` [PULL 08/22] qga: fix build " Philippe Mathieu-Daudé
` (15 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-16 23:23 UTC (permalink / raw)
To: qemu-devel
From: Roman Bogorodskiy <bogorodskiy@gmail.com>
Currently, getifaddrs() fails to get detected on illumos
because it requires linking with libsocket which meson
is not doing.
Fix by adding socket to getifaddrs dependencies. This
unlocks 'guest-network-get-interfaces' implementation
for illumos.
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Message-ID: <20261015173250.65942-3-bogorodskiy@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
meson.build | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/meson.build b/meson.build
index d7bcb581c181..58286a3f8a71 100644
--- a/meson.build
+++ b/meson.build
@@ -2643,7 +2643,7 @@ config_host_data.set('CONFIG_TIMERFD', cc.has_function('timerfd_create'))
config_host_data.set('CONFIG_GETLOADAVG', cc.has_function('getloadavg'))
config_host_data.set('CONFIG_ARPA_INET_64', cc.has_function('htonll'))
config_host_data.set('HAVE_COPY_FILE_RANGE', cc.has_function('copy_file_range'))
-config_host_data.set('HAVE_GETIFADDRS', cc.has_function('getifaddrs'))
+config_host_data.set('HAVE_GETIFADDRS', cc.has_function('getifaddrs', dependencies: socket))
config_host_data.set('HAVE_GLIB_WITH_SLICE_ALLOCATOR', glib_has_gslice)
config_host_data.set('HAVE_OPENPTY', cc.has_function('openpty', dependencies: util))
config_host_data.set('HAVE_STRCHRNUL', cc.has_function('strchrnul', prefix: osdep_prefix))
--
2.55.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PULL 08/22] qga: fix build on illumos
2026-11-16 23:23 [PULL 00/22] Misc TCG & HW patches for 2026-11-17 Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2026-11-16 23:23 ` [PULL 07/22] meson.build: fix getifaddrs() detection on illumos Philippe Mathieu-Daudé
@ 2026-11-16 23:23 ` Philippe Mathieu-Daudé
2026-11-16 23:23 ` [PULL 09/22] qga: fix uname() return value check in guest-get-osinfo Philippe Mathieu-Daudé
` (14 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-16 23:23 UTC (permalink / raw)
To: qemu-devel
From: Roman Bogorodskiy <bogorodskiy@gmail.com>
Currently, build fails on illumos with:
../qga/commands-posix.c: In function 'qmp_guest_get_load':
../qga/commands-posix.c:1408:9: error: implicit declaration of function 'getloadavg' [-Wimplicit-function-declaration]
1408 | if (getloadavg(loadavg, G_N_ELEMENTS(loadavg)) < 0) {
| ^~~~~~~~~~
../qga/commands-posix.c:1408:9: warning: nested extern declaration of 'getloadavg' [-Wnested-externs]
This happens because including <sys/loadavg.h> which is needed
for getloadavg() on illumos is nested under the "#ifdef HAVE_GETIFADDRS"
block, and is not included when HAVE_GETIFADDRS is not defined.
As getloadavg() does not depend on HAVE_GETIFADDRS, include
<sys/loadavg.h> outside of the "#ifdef HAVE_GETIFADDRS".
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
Message-ID: <20261015173250.65942-2-bogorodskiy@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
qga/commands-posix.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index cfa5627a61d8..ae53eb356965 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -16,6 +16,9 @@
#include <sys/utsname.h>
#include <sys/wait.h>
#include <dirent.h>
+#if defined(CONFIG_SOLARIS) && defined(CONFIG_GETLOADAVG)
+#include <sys/loadavg.h>
+#endif
#include "qga-qapi-commands.h"
#include "qapi/error.h"
#include "qemu/host-utils.h"
@@ -43,9 +46,6 @@
#include <net/ethernet.h>
#endif
#ifdef CONFIG_SOLARIS
-#ifdef CONFIG_GETLOADAVG
-#include <sys/loadavg.h>
-#endif
#include <sys/sockio.h>
#endif
#endif
--
2.55.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PULL 09/22] qga: fix uname() return value check in guest-get-osinfo
2026-11-16 23:23 [PULL 00/22] Misc TCG & HW patches for 2026-11-17 Philippe Mathieu-Daudé
` (7 preceding siblings ...)
2026-11-16 23:23 ` [PULL 08/22] qga: fix build " Philippe Mathieu-Daudé
@ 2026-11-16 23:23 ` Philippe Mathieu-Daudé
2026-11-16 23:23 ` [PULL 10/22] build: remove vestigial CONFIG_SGA Philippe Mathieu-Daudé
` (13 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-16 23:23 UTC (permalink / raw)
To: qemu-devel
From: Brad Smith <brad@comstyle.com>
POSIX only specifies that uname() returns a non-negative value on
success. Solaris returns 1, so guest-get-osinfo treated every
successful call as a failure and reported a stale errno.
Check for a negative return value instead, as linux-user/uname.c
already does.
Signed-off-by: Brad Smith <brad@comstyle.com>
Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <auUjFweAHtj1YSFt@humpty.home.comstyle.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
qga/commands-posix.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index ae53eb356965..39e772b3ff32 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -1336,7 +1336,7 @@ GuestOSInfo *qmp_guest_get_osinfo(Error **errp)
info = g_new0(GuestOSInfo, 1);
- if (uname(&kinfo) != 0) {
+ if (uname(&kinfo) < 0) {
error_setg_errno(errp, errno, "uname failed");
} else {
info->kernel_version = g_strdup(kinfo.version);
--
2.55.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PULL 10/22] build: remove vestigial CONFIG_SGA
2026-11-16 23:23 [PULL 00/22] Misc TCG & HW patches for 2026-11-17 Philippe Mathieu-Daudé
` (8 preceding siblings ...)
2026-11-16 23:23 ` [PULL 09/22] qga: fix uname() return value check in guest-get-osinfo Philippe Mathieu-Daudé
@ 2026-11-16 23:23 ` Philippe Mathieu-Daudé
2026-11-16 23:23 ` [PULL 11/22] build: update CONFIG_PVPANIC Philippe Mathieu-Daudé
` (12 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-16 23:23 UTC (permalink / raw)
To: qemu-devel
From: John Snow <jsnow@redhat.com>
This configuration knob no longer exists as CONFIG_SGA was removed
quite some time ago. Remove it from our sample config files.
Signed-off-by: John Snow <jsnow@redhat.com>
Message-ID: <20261109183605.3210043-2-jsnow@redhat.com>
Fixes: b482fb43deb3 ("hw/misc/sga: Remove the deprecated "sga" device")
Message-ID: <avId9w77otpW6B1H@redhat.com>
[PMD: Unconditionally add the test (danpb)]
Message-ID: <20261109183605.3210043-2-jsnow@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
configs/devices/i386-softmmu/default.mak | 1 -
tests/qtest/meson.build | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/configs/devices/i386-softmmu/default.mak b/configs/devices/i386-softmmu/default.mak
index bc0479a7e0a3..b935ee613329 100644
--- a/configs/devices/i386-softmmu/default.mak
+++ b/configs/devices/i386-softmmu/default.mak
@@ -17,7 +17,6 @@
#CONFIG_PVPANIC=n
#CONFIG_QXL=n
#CONFIG_SEV=n
-#CONFIG_SGA=n
#CONFIG_TDX=n
#CONFIG_TEST_DEVICES=n
#CONFIG_TPM_CRB=n
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index 626791d1eb48..6e2938d913ef 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -74,7 +74,7 @@ qtests_i386 = \
(config_all_devices.has_key('CONFIG_I440FX') ? ['numa-test'] : []) + \
(config_all_devices.has_key('CONFIG_I440FX') ? ['test-x86-cpuid-compat'] : []) + \
(config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : []) + \
- (config_all_devices.has_key('CONFIG_SGA') ? ['boot-serial-test'] : []) + \
+ ['boot-serial-test'] + \
(config_all_devices.has_key('CONFIG_ISA_IPMI_KCS') ? ['ipmi-kcs-test'] : []) + \
(host_os == 'linux' and \
config_all_devices.has_key('CONFIG_ISA_IPMI_BT') and
--
2.55.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PULL 11/22] build: update CONFIG_PVPANIC
2026-11-16 23:23 [PULL 00/22] Misc TCG & HW patches for 2026-11-17 Philippe Mathieu-Daudé
` (9 preceding siblings ...)
2026-11-16 23:23 ` [PULL 10/22] build: remove vestigial CONFIG_SGA Philippe Mathieu-Daudé
@ 2026-11-16 23:23 ` Philippe Mathieu-Daudé
2026-11-16 23:23 ` [PULL 12/22] pvg: disable by default Philippe Mathieu-Daudé
` (11 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-16 23:23 UTC (permalink / raw)
To: qemu-devel
From: John Snow <jsnow@redhat.com>
The symbol for CONFIG_PVPANIC has been changed, update the dummy
config file to reference the new names.
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20261109183605.3210043-3-jsnow@redhat.com>
Fixes: 677726ef1ebc ("hw/misc/pvpanic: split-out generic and bus dependent code")
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
configs/devices/i386-softmmu/default.mak | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/configs/devices/i386-softmmu/default.mak b/configs/devices/i386-softmmu/default.mak
index b935ee613329..96716e30b9b0 100644
--- a/configs/devices/i386-softmmu/default.mak
+++ b/configs/devices/i386-softmmu/default.mak
@@ -14,7 +14,10 @@
#CONFIG_PCI_IPMI_BT=n
#CONFIG_IPMI_SSIF=n
#CONFIG_PCI_DEVICES=n
-#CONFIG_PVPANIC=n
+#CONFIG_PVPANIC_COMMON=n
+#CONFIG_PVPANIC_ISA=n
+#CONFIG_PVPANIC_PCI=n
+#CONFIG_PVPANIC_MMIO=n
#CONFIG_QXL=n
#CONFIG_SEV=n
#CONFIG_TDX=n
--
2.55.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PULL 12/22] pvg: disable by default
2026-11-16 23:23 [PULL 00/22] Misc TCG & HW patches for 2026-11-17 Philippe Mathieu-Daudé
` (10 preceding siblings ...)
2026-11-16 23:23 ` [PULL 11/22] build: update CONFIG_PVPANIC Philippe Mathieu-Daudé
@ 2026-11-16 23:23 ` Philippe Mathieu-Daudé
2026-11-16 23:23 ` [PULL 13/22] hw/i386: move bios functions into x86-bios.c Philippe Mathieu-Daudé
` (10 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-16 23:23 UTC (permalink / raw)
To: qemu-devel
From: Mohamed Mediouni <mohamed@unpredictable.fr>
macOS 27 removes support for x86 processors. As such, support
for ParavirtualizedGraphics as a public API has been removed.
Current QEMU does not compile with ParavirtualizedGraphics enabled
and the arm64 side of PVG is not documented or supported by Apple
for third-party use.
Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Message-ID: <20261116144951.71940-1-mohamed@unpredictable.fr>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
meson_options.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/meson_options.txt b/meson_options.txt
index 9ae8e44ab54e..ada233473eab 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -208,7 +208,7 @@ option('lzfse', type : 'feature', value : 'auto',
description: 'lzfse support for DMG images')
option('lzo', type : 'feature', value : 'auto',
description: 'lzo compression support')
-option('pvg', type: 'feature', value: 'auto',
+option('pvg', type: 'feature', value: 'disabled',
description: 'macOS paravirtualized graphics support')
option('rbd', type : 'feature', value : 'auto',
description: 'Ceph block device driver')
--
2.55.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PULL 13/22] hw/i386: move bios functions into x86-bios.c
2026-11-16 23:23 [PULL 00/22] Misc TCG & HW patches for 2026-11-17 Philippe Mathieu-Daudé
` (11 preceding siblings ...)
2026-11-16 23:23 ` [PULL 12/22] pvg: disable by default Philippe Mathieu-Daudé
@ 2026-11-16 23:23 ` Philippe Mathieu-Daudé
2026-11-16 23:23 ` [PULL 14/22] hw/usb/u2f: validate ring buffer indices on migration load Philippe Mathieu-Daudé
` (9 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-16 23:23 UTC (permalink / raw)
To: qemu-devel
From: John Snow <jsnow@redhat.com>
Currently, these functions are located in x86-common.c. However, when
configuring QEMU with `--without-default-devices`, we encounter a
linking error at final assembly time where these functions cannot be
located.
Split these functions out into a new x86-bios.c module to allow
defaultless compilations of x86_64 to succeed.
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
Message-ID: <20261106191356.1207295-1-jsnow@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
hw/i386/x86-bios.c | 143 +++++++++++++++++++++++++++++++++++++++++++
hw/i386/x86-common.c | 125 -------------------------------------
hw/i386/x86.c | 1 -
hw/i386/meson.build | 1 +
4 files changed, 144 insertions(+), 126 deletions(-)
create mode 100644 hw/i386/x86-bios.c
diff --git a/hw/i386/x86-bios.c b/hw/i386/x86-bios.c
new file mode 100644
index 000000000000..525e42e7252f
--- /dev/null
+++ b/hw/i386/x86-bios.c
@@ -0,0 +1,143 @@
+/*
+ * x86 bios loading functions
+ *
+ * Copyright (c) 2003-2004 Fabrice Bellard
+ * Copyright (c) 2019, 2024-2026 Red Hat, Inc.
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/datadir.h"
+#include "qapi/error.h"
+#include "qemu/units.h"
+
+#include "hw/core/loader.h"
+#include "hw/i386/x86.h"
+#include "kvm/tdx.h"
+#include "target/i386/sev.h"
+
+void x86_isa_bios_init(MemoryRegion *isa_bios, MemoryRegion *isa_memory,
+ MemoryRegion *bios, bool read_only)
+{
+ uint64_t bios_size = memory_region_size(bios);
+ uint64_t isa_bios_size = MIN(bios_size, 128 * KiB);
+
+ memory_region_init_alias(isa_bios, NULL, "isa-bios", bios,
+ bios_size - isa_bios_size, isa_bios_size);
+ memory_region_add_subregion_overlap(isa_memory, 1 * MiB - isa_bios_size,
+ isa_bios, 1);
+ memory_region_set_readonly(isa_bios, read_only);
+}
+
+static int get_bios_size(X86MachineState *x86ms,
+ const char *bios_name, char *filename)
+{
+ int bios_size;
+
+ if (filename) {
+ bios_size = get_image_size(filename, NULL);
+ } else {
+ bios_size = -1;
+ }
+ if (bios_size <= 0 ||
+ (bios_size % 65536) != 0) {
+ goto bios_error;
+ }
+
+ return bios_size;
+
+ bios_error:
+ fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name);
+ exit(1);
+}
+
+static void load_bios_from_file(X86MachineState *x86ms, const char *bios_name,
+ char *filename, int bios_size,
+ bool isapc_ram_fw)
+{
+ ssize_t ret;
+
+ /* BIOS load */
+ if (machine_require_guest_memfd_private(MACHINE(x86ms))) {
+ memory_region_init_ram_guest_memfd_private(
+ &x86ms->bios, NULL, "pc.bios", bios_size, &error_fatal);
+ if (is_tdx_vm()) {
+ tdx_set_tdvf_region(&x86ms->bios);
+ }
+ } else {
+ memory_region_init_ram(&x86ms->bios, NULL, "pc.bios",
+ bios_size, &error_fatal);
+ }
+ if (sev_enabled() || is_tdx_vm()) {
+ /*
+ * The concept of a "reset" simply doesn't exist for
+ * confidential computing guests, we have to destroy and
+ * re-launch them instead. So there is no need to register
+ * the firmware as rom to properly re-initialize on reset.
+ * Just go for a straight file load instead.
+ */
+ void *ptr = memory_region_get_ram_ptr(&x86ms->bios);
+ load_image_size(filename, ptr, bios_size);
+ x86_firmware_configure(0x100000000ULL - bios_size, ptr, bios_size);
+ } else {
+ memory_region_set_readonly(&x86ms->bios, !isapc_ram_fw);
+ ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1);
+ if (ret != 0) {
+ goto bios_error;
+ }
+ }
+
+ return;
+
+ bios_error:
+ fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name);
+ exit(1);
+}
+
+void x86_bios_rom_reload(X86MachineState *x86ms)
+{
+ int bios_size;
+ const char *bios_name;
+ char *filename;
+
+ if (memory_region_size(&x86ms->bios) == 0) {
+ /* if -bios is not used */
+ return;
+ }
+
+ bios_name = MACHINE(x86ms)->firmware ?: "bios.bin";
+ filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
+
+ bios_size = get_bios_size(x86ms, bios_name, filename);
+
+ void *ptr = memory_region_get_ram_ptr(&x86ms->bios);
+ load_image_size(filename, ptr, bios_size);
+ x86_firmware_configure(0x100000000ULL - bios_size, ptr, bios_size);
+}
+
+void x86_bios_rom_init(X86MachineState *x86ms, const char *default_firmware,
+ MemoryRegion *rom_memory, bool isapc_ram_fw)
+{
+ int bios_size;
+ const char *bios_name;
+ g_autofree char *filename;
+
+ bios_name = MACHINE(x86ms)->firmware ?: default_firmware;
+ filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
+
+ bios_size = get_bios_size(x86ms, bios_name, filename);
+ load_bios_from_file(x86ms, bios_name, filename, bios_size, isapc_ram_fw);
+
+ if (!machine_require_guest_memfd_private(MACHINE(x86ms))) {
+ /* map the last 128KB of the BIOS in ISA space */
+ x86_isa_bios_init(&x86ms->isa_bios, rom_memory, &x86ms->bios,
+ !isapc_ram_fw);
+ }
+
+ /* map all the bios at the top of memory */
+ memory_region_add_subregion(rom_memory,
+ (uint32_t)(-bios_size),
+ &x86ms->bios);
+ return;
+}
diff --git a/hw/i386/x86-common.c b/hw/i386/x86-common.c
index dcd4fa8eb798..350fcbc20e18 100644
--- a/hw/i386/x86-common.c
+++ b/hw/i386/x86-common.c
@@ -995,128 +995,3 @@ void x86_load_linux(X86MachineState *x86ms,
option_rom[nb_option_roms].name = "linuxboot_dma.bin";
nb_option_roms++;
}
-
-void x86_isa_bios_init(MemoryRegion *isa_bios, MemoryRegion *isa_memory,
- MemoryRegion *bios, bool read_only)
-{
- uint64_t bios_size = memory_region_size(bios);
- uint64_t isa_bios_size = MIN(bios_size, 128 * KiB);
-
- memory_region_init_alias(isa_bios, NULL, "isa-bios", bios,
- bios_size - isa_bios_size, isa_bios_size);
- memory_region_add_subregion_overlap(isa_memory, 1 * MiB - isa_bios_size,
- isa_bios, 1);
- memory_region_set_readonly(isa_bios, read_only);
-}
-
-static int get_bios_size(X86MachineState *x86ms,
- const char *bios_name, char *filename)
-{
- int bios_size;
-
- if (filename) {
- bios_size = get_image_size(filename, NULL);
- } else {
- bios_size = -1;
- }
- if (bios_size <= 0 ||
- (bios_size % 65536) != 0) {
- goto bios_error;
- }
-
- return bios_size;
-
- bios_error:
- fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name);
- exit(1);
-}
-
-static void load_bios_from_file(X86MachineState *x86ms, const char *bios_name,
- char *filename, int bios_size,
- bool isapc_ram_fw)
-{
- ssize_t ret;
-
- /* BIOS load */
- if (machine_require_guest_memfd_private(MACHINE(x86ms))) {
- memory_region_init_ram_guest_memfd_private(
- &x86ms->bios, NULL, "pc.bios", bios_size, &error_fatal);
- if (is_tdx_vm()) {
- tdx_set_tdvf_region(&x86ms->bios);
- }
- } else {
- memory_region_init_ram(&x86ms->bios, NULL, "pc.bios",
- bios_size, &error_fatal);
- }
- if (sev_enabled() || is_tdx_vm()) {
- /*
- * The concept of a "reset" simply doesn't exist for
- * confidential computing guests, we have to destroy and
- * re-launch them instead. So there is no need to register
- * the firmware as rom to properly re-initialize on reset.
- * Just go for a straight file load instead.
- */
- void *ptr = memory_region_get_ram_ptr(&x86ms->bios);
- load_image_size(filename, ptr, bios_size);
- x86_firmware_configure(0x100000000ULL - bios_size, ptr, bios_size);
- } else {
- memory_region_set_readonly(&x86ms->bios, !isapc_ram_fw);
- ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1);
- if (ret != 0) {
- goto bios_error;
- }
- }
-
- return;
-
- bios_error:
- fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name);
- exit(1);
-}
-
-void x86_bios_rom_reload(X86MachineState *x86ms)
-{
- int bios_size;
- const char *bios_name;
- char *filename;
-
- if (memory_region_size(&x86ms->bios) == 0) {
- /* if -bios is not used */
- return;
- }
-
- bios_name = MACHINE(x86ms)->firmware ?: "bios.bin";
- filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
-
- bios_size = get_bios_size(x86ms, bios_name, filename);
-
- void *ptr = memory_region_get_ram_ptr(&x86ms->bios);
- load_image_size(filename, ptr, bios_size);
- x86_firmware_configure(0x100000000ULL - bios_size, ptr, bios_size);
-}
-
-void x86_bios_rom_init(X86MachineState *x86ms, const char *default_firmware,
- MemoryRegion *rom_memory, bool isapc_ram_fw)
-{
- int bios_size;
- const char *bios_name;
- g_autofree char *filename;
-
- bios_name = MACHINE(x86ms)->firmware ?: default_firmware;
- filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
-
- bios_size = get_bios_size(x86ms, bios_name, filename);
- load_bios_from_file(x86ms, bios_name, filename, bios_size, isapc_ram_fw);
-
- if (!machine_require_guest_memfd_private(MACHINE(x86ms))) {
- /* map the last 128KB of the BIOS in ISA space */
- x86_isa_bios_init(&x86ms->isa_bios, rom_memory, &x86ms->bios,
- !isapc_ram_fw);
- }
-
- /* map all the bios at the top of memory */
- memory_region_add_subregion(rom_memory,
- (uint32_t)(-bios_size),
- &x86ms->bios);
- return;
-}
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index 4b75b7406a81..5f842351daff 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -35,7 +35,6 @@
#include "hw/acpi/aml-build.h"
#include "hw/i386/x86.h"
#include "hw/i386/topology.h"
-
#include "hw/core/nmi.h"
#include "kvm/kvm_i386.h"
diff --git a/hw/i386/meson.build b/hw/i386/meson.build
index e16930c43197..6bb73b8731cc 100644
--- a/hw/i386/meson.build
+++ b/hw/i386/meson.build
@@ -5,6 +5,7 @@ i386_ss.add(files(
'monitor.c',
'multiboot.c',
'x86.c',
+ 'x86-bios.c',
'x86-cpu.c',
))
--
2.55.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PULL 14/22] hw/usb/u2f: validate ring buffer indices on migration load
2026-11-16 23:23 [PULL 00/22] Misc TCG & HW patches for 2026-11-17 Philippe Mathieu-Daudé
` (12 preceding siblings ...)
2026-11-16 23:23 ` [PULL 13/22] hw/i386: move bios functions into x86-bios.c Philippe Mathieu-Daudé
@ 2026-11-16 23:23 ` Philippe Mathieu-Daudé
2026-11-16 23:23 ` [PULL 15/22] hw/usb/ccid-card-emulated: Use QemuSemaphore rather than QemuCond Philippe Mathieu-Daudé
` (8 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-16 23:23 UTC (permalink / raw)
To: qemu-devel
From: Bin Guo <guobin@linux.alibaba.com>
The U2F key pending_in ring buffer uses uint8_t start/end/num indices
over a 32-entry array, all serialized in the vmstate. A malicious
migration stream can inject values >= U2FHID_PENDING_IN_NUM (32),
causing an out-of-bounds heap read in u2f_pending_in_get() on the
first USB IN token after migration completes.
Add a post_load callback to validate the restored indices and reset
the ring buffer to empty on any out-of-range value. Pending packets
are non-critical (the device will regenerate them), so resetting the
ring is preferable to rejecting migration entirely.
As defense-in-depth, also add a bounds clamp in u2f_pending_in_get()
so that even if corrupted state somehow reaches the consumer path,
the index is folded into range before array access.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/4483
Signed-off-by: Bin Guo <guobin@linux.alibaba.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260916092342.2447-1-guobin@linux.alibaba.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
hw/usb/u2f.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/hw/usb/u2f.c b/hw/usb/u2f.c
index d6291852f631..9ca9879f3e0c 100644
--- a/hw/usb/u2f.c
+++ b/hw/usb/u2f.c
@@ -228,6 +228,11 @@ static uint8_t *u2f_pending_in_get(U2FKeyState *key)
return NULL;
}
+ /* Clamp to valid range in case of corrupted state (e.g. migration) */
+ if (key->pending_in_start >= U2FHID_PENDING_IN_NUM) {
+ key->pending_in_start %= U2FHID_PENDING_IN_NUM;
+ }
+
index = key->pending_in_start;
key->pending_in_start = (index + 1) % U2FHID_PENDING_IN_NUM;
--key->pending_in_num;
@@ -301,10 +306,36 @@ static void u2f_key_realize(USBDevice *dev, Error **errp)
key->ep = usb_ep_get(dev, USB_TOKEN_IN, 1);
}
+static int u2f_key_post_load(void *opaque, int version_id)
+{
+ U2FKeyState *key = opaque;
+
+ /*
+ * Validate pending_in ring buffer indices restored from the migration
+ * stream. An attacker-controlled stream could inject values >= 32
+ * (U2FHID_PENDING_IN_NUM), causing out-of-bounds heap access in
+ * u2f_pending_in_get() on the first IN token after migration.
+ *
+ * Reset the ring on any invalid value: pending packets are non-critical
+ * (they will be regenerated by the device), so rejecting migration
+ * entirely is not necessary.
+ */
+ if (key->pending_in_start >= U2FHID_PENDING_IN_NUM ||
+ key->pending_in_end >= U2FHID_PENDING_IN_NUM ||
+ key->pending_in_num > U2FHID_PENDING_IN_NUM) {
+ key->pending_in_start = 0;
+ key->pending_in_end = 0;
+ key->pending_in_num = 0;
+ }
+
+ return 0;
+}
+
const VMStateDescription vmstate_u2f_key = {
.name = "u2f-key",
.version_id = 1,
.minimum_version_id = 1,
+ .post_load = u2f_key_post_load,
.fields = (const VMStateField[]) {
VMSTATE_USB_DEVICE(dev, U2FKeyState),
VMSTATE_UINT8(idle, U2FKeyState),
--
2.55.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PULL 15/22] hw/usb/ccid-card-emulated: Use QemuSemaphore rather than QemuCond
2026-11-16 23:23 [PULL 00/22] Misc TCG & HW patches for 2026-11-17 Philippe Mathieu-Daudé
` (13 preceding siblings ...)
2026-11-16 23:23 ` [PULL 14/22] hw/usb/u2f: validate ring buffer indices on migration load Philippe Mathieu-Daudé
@ 2026-11-16 23:23 ` Philippe Mathieu-Daudé
2026-11-16 23:23 ` [PULL 16/22] hw/usb/u2f-emulated: " Philippe Mathieu-Daudé
` (7 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-16 23:23 UTC (permalink / raw)
To: qemu-devel
From: Peter Maydell <peter.maydell@linaro.org>
The emulated CCID card uses a QemuMutex and QemuCond to communicate
with its helper thread, but all it's trying to do here is "make the
helper thread loop wait until is signalled that it has more work to
do". The existing code functions correctly, but "wait until the
other thread signals you" is more simply implemented with a
QemuSemaphore.
This avoids a Coverity complaint that we're not using the condition
variable in the standard
lock mutex;
while (!some_predicate) {
cond_wait(condvar, mutex);
}
do stuff;
unlock mutex;
pattern.
Resolves: Coverity CID 1547639
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Marc-Andr=C3=A9 Lureau <marcandre.lureau@redhat.com>
Message-ID: <20261109203817.1683717-1-peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
hw/usb/ccid-card-emulated.c | 22 +++++++---------------
1 file changed, 7 insertions(+), 15 deletions(-)
diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c
index 6c8eec39faa9..c504c52a7cdc 100644
--- a/hw/usb/ccid-card-emulated.c
+++ b/hw/usb/ccid-card-emulated.c
@@ -129,8 +129,7 @@ struct EmulatedState {
VReader *reader;
QSIMPLEQ_HEAD(, EmulEvent) guest_apdu_list;
QemuMutex vreader_mutex; /* and guest_apdu_list mutex */
- QemuMutex handle_apdu_mutex;
- QemuCond handle_apdu_cond;
+ QemuSemaphore handle_apdu_sem;
EventNotifier notifier;
int quit_apdu_thread;
QemuThread apdu_thread_id;
@@ -149,9 +148,7 @@ static void emulated_apdu_from_guest(CCIDCardState *base,
qemu_mutex_lock(&card->vreader_mutex);
QSIMPLEQ_INSERT_TAIL(&card->guest_apdu_list, event, entry);
qemu_mutex_unlock(&card->vreader_mutex);
- qemu_mutex_lock(&card->handle_apdu_mutex);
- qemu_cond_signal(&card->handle_apdu_cond);
- qemu_mutex_unlock(&card->handle_apdu_mutex);
+ qemu_sem_post(&card->handle_apdu_sem);
}
static const uint8_t *emulated_get_atr(CCIDCardState *base, uint32_t *len)
@@ -238,9 +235,7 @@ static void *handle_apdu_thread(void* arg)
EmulEvent *event;
while (1) {
- qemu_mutex_lock(&card->handle_apdu_mutex);
- qemu_cond_wait(&card->handle_apdu_cond, &card->handle_apdu_mutex);
- qemu_mutex_unlock(&card->handle_apdu_mutex);
+ qemu_sem_wait(&card->handle_apdu_sem);
if (card->quit_apdu_thread) {
card->quit_apdu_thread = 0; /* debugging */
break;
@@ -496,8 +491,7 @@ static void emulated_realize(CCIDCardState *base, Error **errp)
QSIMPLEQ_INIT(&card->guest_apdu_list);
qemu_mutex_init(&card->event_list_mutex);
qemu_mutex_init(&card->vreader_mutex);
- qemu_mutex_init(&card->handle_apdu_mutex);
- qemu_cond_init(&card->handle_apdu_cond);
+ qemu_sem_init(&card->handle_apdu_sem, 0);
card->reader = NULL;
card->quit_apdu_thread = 0;
if (init_event_notifier(card, errp) < 0) {
@@ -556,8 +550,7 @@ static void emulated_realize(CCIDCardState *base, Error **errp)
out2:
clean_event_notifier(card);
out1:
- qemu_cond_destroy(&card->handle_apdu_cond);
- qemu_mutex_destroy(&card->handle_apdu_mutex);
+ qemu_sem_destroy(&card->handle_apdu_sem);
qemu_mutex_destroy(&card->vreader_mutex);
qemu_mutex_destroy(&card->event_list_mutex);
}
@@ -571,13 +564,12 @@ static void emulated_unrealize(CCIDCardState *base)
qemu_thread_join(&card->event_thread_id);
card->quit_apdu_thread = 1; /* stop handle_apdu thread */
- qemu_cond_signal(&card->handle_apdu_cond);
+ qemu_sem_post(&card->handle_apdu_sem);
qemu_thread_join(&card->apdu_thread_id);
clean_event_notifier(card);
/* threads exited, can destroy all condvars/mutexes */
- qemu_cond_destroy(&card->handle_apdu_cond);
- qemu_mutex_destroy(&card->handle_apdu_mutex);
+ qemu_sem_destroy(&card->handle_apdu_sem);
qemu_mutex_destroy(&card->vreader_mutex);
qemu_mutex_destroy(&card->event_list_mutex);
--
2.55.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PULL 16/22] hw/usb/u2f-emulated: Use QemuSemaphore rather than QemuCond
2026-11-16 23:23 [PULL 00/22] Misc TCG & HW patches for 2026-11-17 Philippe Mathieu-Daudé
` (14 preceding siblings ...)
2026-11-16 23:23 ` [PULL 15/22] hw/usb/ccid-card-emulated: Use QemuSemaphore rather than QemuCond Philippe Mathieu-Daudé
@ 2026-11-16 23:23 ` Philippe Mathieu-Daudé
2026-11-16 23:23 ` [PULL 17/22] hw/usb/dev-mtp: Fix recursive delete of directories Philippe Mathieu-Daudé
` (6 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-16 23:23 UTC (permalink / raw)
To: qemu-devel
The emulation thread only waits to be signalled that a packet
is pending, which a semaphore expresses directly. This also
avoids the Coverity complaint that the condition variable is
not used in the standard lock / while (!predicate) / cond_wait
pattern. Same change as ccid-card-emulated in previous commit
9590693b1d29 ("hw/usb/ccid-card-emulated: Use QemuSemaphore
rather than QemuCond").
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Message-Id: <20261116223625.24296-1-philmd@oss.qualcomm.com>
---
hw/usb/u2f-emulated.c | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/hw/usb/u2f-emulated.c b/hw/usb/u2f-emulated.c
index b82a31501934..0aabfc514b7b 100644
--- a/hw/usb/u2f-emulated.c
+++ b/hw/usb/u2f-emulated.c
@@ -90,8 +90,7 @@ struct U2FEmulatedState {
QemuMutex pending_out_mutex;
/* Emulation thread and sync */
- QemuCond key_cond;
- QemuMutex key_mutex;
+ QemuSemaphore key_sem;
QemuThread key_thread;
bool stop_thread;
EventNotifier notifier;
@@ -148,9 +147,7 @@ static void u2f_emulated_recv_from_guest(U2FKeyState *base,
u2f_pending_out_add(key, packet);
qemu_mutex_unlock(&key->pending_out_mutex);
- qemu_mutex_lock(&key->key_mutex);
- qemu_cond_signal(&key->key_cond);
- qemu_mutex_unlock(&key->key_mutex);
+ qemu_sem_post(&key->key_sem);
}
static void *u2f_emulated_thread(void* arg)
@@ -162,9 +159,7 @@ static void *u2f_emulated_thread(void* arg)
while (true) {
/* Wait signal */
- qemu_mutex_lock(&key->key_mutex);
- qemu_cond_wait(&key->key_cond, &key->key_mutex);
- qemu_mutex_unlock(&key->key_mutex);
+ qemu_sem_wait(&key->key_sem);
/* Exit thread check */
if (key->stop_thread) {
@@ -331,10 +326,9 @@ static void u2f_emulated_realize(U2FKeyState *base, Error **errp)
event_notifier_set_handler(&key->notifier, u2f_emulated_event_handler);
/* Synchronization */
- qemu_cond_init(&key->key_cond);
+ qemu_sem_init(&key->key_sem, 0);
qemu_mutex_init(&key->vdev_mutex);
qemu_mutex_init(&key->pending_out_mutex);
- qemu_mutex_init(&key->key_mutex);
u2f_emulated_reset(key);
/* Thread */
@@ -349,7 +343,7 @@ static void u2f_emulated_unrealize(U2FKeyState *base)
/* Thread */
key->stop_thread = true;
- qemu_cond_signal(&key->key_cond);
+ qemu_sem_post(&key->key_sem);
qemu_thread_join(&key->key_thread);
/* Notifier */
@@ -357,9 +351,8 @@ static void u2f_emulated_unrealize(U2FKeyState *base)
event_notifier_cleanup(&key->notifier);
/* Synchronization */
- qemu_cond_destroy(&key->key_cond);
+ qemu_sem_destroy(&key->key_sem);
qemu_mutex_destroy(&key->vdev_mutex);
- qemu_mutex_destroy(&key->key_mutex);
qemu_mutex_destroy(&key->pending_out_mutex);
/* Vdev */
--
2.55.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PULL 17/22] hw/usb/dev-mtp: Fix recursive delete of directories
2026-11-16 23:23 [PULL 00/22] Misc TCG & HW patches for 2026-11-17 Philippe Mathieu-Daudé
` (15 preceding siblings ...)
2026-11-16 23:23 ` [PULL 16/22] hw/usb/u2f-emulated: " Philippe Mathieu-Daudé
@ 2026-11-16 23:23 ` Philippe Mathieu-Daudé
2026-11-16 23:23 ` [PULL 18/22] hw/usb/dev-mtp: Check length of class control request Philippe Mathieu-Daudé
` (5 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-16 23:23 UTC (permalink / raw)
To: qemu-devel
From: Tommaso Califano <tcalifano@redhat.com>
usb_mtp_deletefn() only recursed into the grandchildren of the target,
never deleting the files directly inside it. The directory was left
non-empty, so rmdir() on the host always failed, and objects nested more
than two levels deep were silently kept.
Recurse into every child of the target instead. Since the root directory
can now actually become empty, skip the root object itself: rmdir()'ing
it and freeing it would leave s->objects empty.
Cc: qemu-stable@nongnu.org
Fixes: ec6206a68f70 ("usb-mtp: Support delete of mtp objects")
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4529
Suggested-by: Hui Peng <https://gitlab.com/benquike>
Signed-off-by: Tommaso Califano <tcalifano@redhat.com>
Reviewed-by: Junjie Cao <junjie.cao@linux.dev>
Tested-by: Junjie Cao <junjie.cao@linux.dev>
Message-ID: <20261112174907.158825-2-tcalifano@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
hw/usb/dev-mtp.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 8507e516ab1e..bc5a6f089178 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -1152,19 +1152,20 @@ enum {
static int usb_mtp_deletefn(MTPState *s, MTPObject *o, uint32_t trans)
{
- MTPObject *iter, *iter2, *iter2_next;
+ MTPObject *iter, *iter_next;
int ret = 0;
/*
* TODO: Add support for Protection Status
*/
- QLIST_FOREACH(iter, &o->children, list) {
- if (iter->format == FMT_ASSOCIATION) {
- QLIST_FOREACH_SAFE(iter2, &iter->children, list, iter2_next) {
- ret |= usb_mtp_deletefn(s, iter2, trans);
- }
- }
+ QLIST_FOREACH_SAFE(iter, &o->children, list, iter_next) {
+ ret |= usb_mtp_deletefn(s, iter, trans);
+ }
+
+ /* Avoid deleting the mtp root */
+ if (o->parent == NULL) {
+ return ret ? ret : DELETE_SUCCESS;
}
if (o->format == FMT_UNDEFINED_OBJECT) {
--
2.55.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PULL 18/22] hw/usb/dev-mtp: Check length of class control request
2026-11-16 23:23 [PULL 00/22] Misc TCG & HW patches for 2026-11-17 Philippe Mathieu-Daudé
` (16 preceding siblings ...)
2026-11-16 23:23 ` [PULL 17/22] hw/usb/dev-mtp: Fix recursive delete of directories Philippe Mathieu-Daudé
@ 2026-11-16 23:23 ` Philippe Mathieu-Daudé
2026-11-16 23:23 ` [PULL 19/22] hw/usb/dev-mtp: Stop processing SendObjectInfo after an error Philippe Mathieu-Daudé
` (4 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-16 23:23 UTC (permalink / raw)
To: qemu-devel
From: Tommaso Califano <tcalifano@redhat.com>
usb_mtp_handle_control() reads a 16-bit event code from the request
data without checking that the host actually sent it. A request with
wLength < 2 makes the device act on stale bytes left in the control
buffer.
STALL requests that are too short to hold the event code.
Cc: qemu-stable@nongnu.org
Fixes: 47bff13cea8d ("dev-mtp: add support for canceling transaction")
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4529
Suggested-by: Hui Peng <https://gitlab.com/benquike>
Signed-off-by: Tommaso Califano <tcalifano@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20261112174907.158825-4-tcalifano@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
hw/usb/dev-mtp.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index bc5a6f089178..92dc9a9e21d6 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -1516,6 +1516,10 @@ static void usb_mtp_handle_control(USBDevice *dev, USBPacket *p,
switch (request) {
case ClassInterfaceOutRequest | 0x64:
+ if (length < sizeof(*event)) {
+ p->status = USB_RET_STALL;
+ break;
+ }
if (*event == EVT_CANCEL_TRANSACTION) {
g_free(s->result);
s->result = NULL;
--
2.55.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PULL 19/22] hw/usb/dev-mtp: Stop processing SendObjectInfo after an error
2026-11-16 23:23 [PULL 00/22] Misc TCG & HW patches for 2026-11-17 Philippe Mathieu-Daudé
` (17 preceding siblings ...)
2026-11-16 23:23 ` [PULL 18/22] hw/usb/dev-mtp: Check length of class control request Philippe Mathieu-Daudé
@ 2026-11-16 23:23 ` Philippe Mathieu-Daudé
2026-11-16 23:23 ` [PULL 20/22] hw/block/m25p80: fix write enable latch after WRSR2 Philippe Mathieu-Daudé
` (3 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-16 23:23 UTC (permalink / raw)
To: qemu-devel
From: Tommaso Califano <tcalifano@redhat.com>
When SendObjectInfo fails its checks, usb_mtp_command() queues an error
response and then falls through. It still allocates s->data_out. The
data phase is then dropped because a result is pending, so s->data_out
is never released.
Return right after queueing the error response.
Cc: qemu-stable@nongnu.org
Fixes: 53735bef108c ("usb-mtp: Advertise SendObjectInfo for write support")
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4529
Suggested-by: Hui Peng <https://gitlab.com/benquike>
Signed-off-by: Tommaso Califano <tcalifano@redhat.com>
Reviewed-by: Junjie Cao <junjie.cao@linux.dev>
Tested-by: Junjie Cao <junjie.cao@linux.dev>
Message-ID: <20261112174907.158825-10-tcalifano@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
hw/usb/dev-mtp.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 92dc9a9e21d6..a8b89c938b79 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -1393,14 +1393,17 @@ static void usb_mtp_command(MTPState *s, MTPControl *c)
if (!FLAG_SET(s, MTP_FLAG_WRITABLE)) {
usb_mtp_queue_result(s, RES_STORE_READ_ONLY,
c->trans, 0, 0, 0, 0);
+ return;
} else if (c->argv[0] && (c->argv[0] != QEMU_STORAGE_ID)) {
/* First parameter points to storage id or is 0 */
usb_mtp_queue_result(s, RES_STORE_NOT_AVAILABLE, c->trans,
0, 0, 0, 0);
+ return;
} else if (c->argv[1] && !c->argv[0]) {
/* If second parameter is specified, first must also be specified */
usb_mtp_queue_result(s, RES_DESTINATION_UNSUPPORTED, c->trans,
0, 0, 0, 0);
+ return;
} else {
uint32_t handle = c->argv[1];
if (handle == 0xFFFFFFFF || handle == 0) {
@@ -1412,9 +1415,11 @@ static void usb_mtp_command(MTPState *s, MTPControl *c)
if (o == NULL) {
usb_mtp_queue_result(s, RES_INVALID_OBJECT_HANDLE, c->trans,
0, 0, 0, 0);
+ return;
} else if (o->format != FMT_ASSOCIATION) {
usb_mtp_queue_result(s, RES_INVALID_PARENT_OBJECT, c->trans,
0, 0, 0, 0);
+ return;
}
}
if (o) {
--
2.55.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PULL 20/22] hw/block/m25p80: fix write enable latch after WRSR2
2026-11-16 23:23 [PULL 00/22] Misc TCG & HW patches for 2026-11-17 Philippe Mathieu-Daudé
` (18 preceding siblings ...)
2026-11-16 23:23 ` [PULL 19/22] hw/usb/dev-mtp: Stop processing SendObjectInfo after an error Philippe Mathieu-Daudé
@ 2026-11-16 23:23 ` Philippe Mathieu-Daudé
2026-11-16 23:23 ` [PULL 21/22] hw/xen: Mark legacy Xen backends as hotpluggable Philippe Mathieu-Daudé
` (2 subsequent siblings)
22 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-16 23:23 UTC (permalink / raw)
To: qemu-devel
From: Chao Liu <chao.liu@processmission.com>
The flash clears the write enable latch when a WRSR2 command completes,
just like a WRSR write; otherwise a following program or erase could
proceed without a new WREN.
Fixes: 9785731ec4f7 ("hw/block:m25p80: Support write status register 2 command (0x31) for w25q01jvq")
Signed-off-by: Chao Liu <chao.liu@processmission.com>
Signed-off-by: Yifan Wang <w-yf22@mails.tsinghua.edu.cn>
Message-ID: <0c80a9c01452a8695b46a6d9fa920f9a14f4de47.1794558546.git.w-yf22@mails.tsinghua.edu.cn>
[PMD: Directly assign @write_enable]
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
hw/block/m25p80.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index baf798c6b5cc..92e67fdc5e04 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -840,6 +840,7 @@ static void complete_collecting_data(Flash *s)
default:
break;
}
+ s->write_enable = false;
break;
case BRWR:
case EXTEND_ADDR_WRITE:
--
2.55.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PULL 21/22] hw/xen: Mark legacy Xen backends as hotpluggable
2026-11-16 23:23 [PULL 00/22] Misc TCG & HW patches for 2026-11-17 Philippe Mathieu-Daudé
` (19 preceding siblings ...)
2026-11-16 23:23 ` [PULL 20/22] hw/block/m25p80: fix write enable latch after WRSR2 Philippe Mathieu-Daudé
@ 2026-11-16 23:23 ` Philippe Mathieu-Daudé
2026-11-16 23:23 ` [PULL 22/22] hw/virtio/virtio-iommu: Fix IOVA address lookup Philippe Mathieu-Daudé
2026-11-18 13:43 ` [PULL 00/22] Misc TCG & HW patches for 2026-11-17 Michael Tokarev
22 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-16 23:23 UTC (permalink / raw)
To: qemu-devel
From: Peng Fan <peng.fan@nxp.com>
Commit 250e797ceada ("hw/xen: Have legacy Xen backend inherit from
DYNAMIC_SYS_BUS_DEVICE") changed TYPE_XENBACKEND to inherit from
TYPE_DYNAMIC_SYS_BUS_DEVICE, whose class sets hotpluggable = false.
Legacy Xen backends are created from xenstore at runtime, after the
machine is ready, so device_initfn() marks them as hotplugged. The new
class setting makes device_set_realized() reject them with:
Device 'xen-backend' does not support hotplugging
Since xen_be_get_xendev() realizes the device with &error_fatal, QEMU
then exits. For example, "xl usbdev-attach" triggers this when the qusb
backend is created dynamically, killing the guest. The same flag also
causes qdev_unplug() to ignore these devices.
Override hotpluggable in xendev_class_init() to restore the behavior
before the offending commit.
Fixes: 250e797ceada ("hw/xen: Have legacy Xen backend inherit from DYNAMIC_SYS_BUS_DEVICE")
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Tested-by: Julian Vetter <julian.vetter@vates.tech>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Message-ID: <20261116-qemu-xen-usb-v1-1-bff36d5b646b@nxp.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
hw/xen/xen-legacy-backend.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/hw/xen/xen-legacy-backend.c b/hw/xen/xen-legacy-backend.c
index 7977b527127b..bf4396c9460d 100644
--- a/hw/xen/xen-legacy-backend.c
+++ b/hw/xen/xen-legacy-backend.c
@@ -640,6 +640,13 @@ static void xendev_class_init(ObjectClass *klass, const void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
+ /*
+ * Legacy Xen backends are created and destroyed dynamically from
+ * xenstore at runtime, after the machine has been initialized.
+ * TYPE_DYNAMIC_SYS_BUS_DEVICE marks devices as not hotpluggable,
+ * so override that here.
+ */
+ dc->hotpluggable = true;
dc->bus_type = TYPE_XENSYSBUS;
}
--
2.55.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PULL 22/22] hw/virtio/virtio-iommu: Fix IOVA address lookup
2026-11-16 23:23 [PULL 00/22] Misc TCG & HW patches for 2026-11-17 Philippe Mathieu-Daudé
` (20 preceding siblings ...)
2026-11-16 23:23 ` [PULL 21/22] hw/xen: Mark legacy Xen backends as hotpluggable Philippe Mathieu-Daudé
@ 2026-11-16 23:23 ` Philippe Mathieu-Daudé
2026-11-18 13:43 ` [PULL 00/22] Misc TCG & HW patches for 2026-11-17 Michael Tokarev
22 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-16 23:23 UTC (permalink / raw)
To: qemu-devel
From: Eric Auger <eric.auger@redhat.com>
The translation code checks the address to be translated
belongs to mapped segments by calling g_tree_lookup_extended().
This uses the interval_cmp() function. However the interval
is badly formed with the .low=addr and .high= addr + 1 instead
of both being set to addr.
As a result an attempt to translate an unmapped byte just before
a mapped segment will not fault as expected.
Example: only [0x2000, 0x2fff] IOVA range is mapped.
An attempt to translate 0x1fff will succeed
Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4754
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20261116173857.367638-1-eric.auger@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
hw/virtio/virtio-iommu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
index 208815096fc0..b9ecab01eee4 100644
--- a/hw/virtio/virtio-iommu.c
+++ b/hw/virtio/virtio-iommu.c
@@ -1185,7 +1185,7 @@ static IOMMUTLBEntry virtio_iommu_translate(IOMMUMemoryRegion *mr, hwaddr addr,
GList *l;
interval.low = addr;
- interval.high = addr + 1;
+ interval.high = addr;
granule = ctz64(s->config.page_size_mask);
IOMMUTLBEntry entry = {
--
2.55.0
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [PULL 00/22] Misc TCG & HW patches for 2026-11-17
2026-11-16 23:23 [PULL 00/22] Misc TCG & HW patches for 2026-11-17 Philippe Mathieu-Daudé
` (21 preceding siblings ...)
2026-11-16 23:23 ` [PULL 22/22] hw/virtio/virtio-iommu: Fix IOVA address lookup Philippe Mathieu-Daudé
@ 2026-11-18 13:43 ` Michael Tokarev
2026-11-18 14:45 ` Philippe Mathieu-Daudé
22 siblings, 1 reply; 26+ messages in thread
From: Michael Tokarev @ 2026-11-18 13:43 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Tommaso Califano
On 11/17/26 02:23, Philippe Mathieu-Daudé wrote:
> Tommaso Califano (3):
> hw/usb/dev-mtp: Fix recursive delete of directories
> hw/usb/dev-mtp: Check length of class control request
> hw/usb/dev-mtp: Stop processing SendObjectInfo after an error
Hi!
Philippe, there were a 7-patch series by Tommaso, grouped into a
single patch set because they touch the same file and all together
fix a single issue --
https://gitlab.com/qemu-project/qemu/-/work_items/4529
Did you omit the other 4 changes because of the review comments?
The original patchset cover letter is
https://lore.kernel.org/qemu-devel/20261112174907.158825-1-tcalifano@redhat.com/
Thanks,
/mjt
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [PULL 00/22] Misc TCG & HW patches for 2026-11-17
2026-11-18 13:43 ` [PULL 00/22] Misc TCG & HW patches for 2026-11-17 Michael Tokarev
@ 2026-11-18 14:45 ` Philippe Mathieu-Daudé
2026-11-18 16:36 ` Tommaso Califano
0 siblings, 1 reply; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-18 14:45 UTC (permalink / raw)
To: Michael Tokarev, qemu-devel; +Cc: Tommaso Califano
On 18/11/26 14:43, Michael Tokarev wrote:
> On 11/17/26 02:23, Philippe Mathieu-Daudé wrote:
>
>> Tommaso Califano (3):
>> hw/usb/dev-mtp: Fix recursive delete of directories
>> hw/usb/dev-mtp: Check length of class control request
>> hw/usb/dev-mtp: Stop processing SendObjectInfo after an error
>
> Hi!
>
> Philippe, there were a 7-patch series by Tommaso, grouped into a
> single patch set because they touch the same file and all together
> fix a single issue --
> https://gitlab.com/qemu-project/qemu/-/work_items/4529
I missed all are needed for the issue to be fixed :/
> Did you omit the other 4 changes because of the review comments?
Yeah, as individual fixes they seems worthwhile in the release,
unfortunately I couldn't merge all of them because the comments
were not addressed by the time we had to tag the RC.
>
> The original patchset cover letter is
> https://lore.kernel.org/qemu-devel/20261112174907.158825-1-
> tcalifano@redhat.com/
>
> Thanks,
>
> /mjt
>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PULL 00/22] Misc TCG & HW patches for 2026-11-17
2026-11-18 14:45 ` Philippe Mathieu-Daudé
@ 2026-11-18 16:36 ` Tommaso Califano
0 siblings, 0 replies; 26+ messages in thread
From: Tommaso Califano @ 2026-11-18 16:36 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, Michael Tokarev, qemu-devel; +Cc: Tommaso Califano
Hi,
On Wed Nov 18, 2026 at 3:45 PM CET, Philippe Mathieu-Daudé wrote:
> On 18/11/26 14:43, Michael Tokarev wrote:
>> On 11/17/26 02:23, Philippe Mathieu-Daudé wrote:
>>
>>> Tommaso Califano (3):
>>> hw/usb/dev-mtp: Fix recursive delete of directories
>>> hw/usb/dev-mtp: Check length of class control request
>>> hw/usb/dev-mtp: Stop processing SendObjectInfo after an error
>>
>> Hi!
>>
>> Philippe, there were a 7-patch series by Tommaso, grouped into a
>> single patch set because they touch the same file and all together
>> fix a single issue --
>> https://gitlab.com/qemu-project/qemu/-/work_items/4529
>
> I missed all are needed for the issue to be fixed :/
>
Since this issue covers multiple independent bugs, feel free to
cherry-pick only the commits you want. I’ll follow up with a new series
for the rest, and either open a new GitLab issue for the remaining bugs
or reopen the existing one once it auto-closes.
>> Did you omit the other 4 changes because of the review comments?
>
> Yeah, as individual fixes they seems worthwhile in the release,
> unfortunately I couldn't merge all of them because the comments
> were not addressed by the time we had to tag the RC.
>
Unfortunately, I just realized when (and what) the RC date is, and I had
been holding off a bit waiting for reviews :(
Regards,
Tommaso
^ permalink raw reply [flat|nested] 26+ messages in thread