[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 4/6] target/i386: Assert MMX and XMM registers in range
|
From: |
Paolo Bonzini |
|
Subject: |
[PULL 4/6] target/i386: Assert MMX and XMM registers in range |
|
Date: |
Tue, 13 Aug 2024 19:05:53 +0200 |
From: Richard Henderson <richard.henderson@linaro.org>
The mmx assert would fire without the fix for #2495.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Link:
20240812025844.58956-4-richard.henderson@linaro.org">https://lore.kernel.org/r/20240812025844.58956-4-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
target/i386/tcg/emit.c.inc | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc
index 016dce81464..22a06897fb7 100644
--- a/target/i386/tcg/emit.c.inc
+++ b/target/i386/tcg/emit.c.inc
@@ -33,8 +33,13 @@
#define TCG_TARGET_extract_tl_valid TCG_TARGET_extract_i32_valid
#endif
+#define MMX_OFFSET(reg) \
+ ({ assert((reg) >= 0 && (reg) <= 7); \
+ offsetof(CPUX86State, fpregs[reg].mmx); })
-#define ZMM_OFFSET(reg) offsetof(CPUX86State, xmm_regs[reg])
+#define ZMM_OFFSET(reg) \
+ ({ assert((reg) >= 0 && (reg) <= 15); \
+ offsetof(CPUX86State, xmm_regs[reg]); })
typedef void (*SSEFunc_i_ep)(TCGv_i32 val, TCGv_ptr env, TCGv_ptr reg);
typedef void (*SSEFunc_l_ep)(TCGv_i64 val, TCGv_ptr env, TCGv_ptr reg);
@@ -168,7 +173,7 @@ static int vector_elem_offset(X86DecodedOp *op, MemOp ot,
int n)
static void compute_mmx_offset(X86DecodedOp *op)
{
if (!op->has_ea) {
- op->offset = offsetof(CPUX86State, fpregs[op->n].mmx) +
mmx_offset(op->ot);
+ op->offset = MMX_OFFSET(op->n) + mmx_offset(op->ot);
} else {
op->offset = offsetof(CPUX86State, mmx_t0) + mmx_offset(op->ot);
}
--
2.46.0
- [PULL for-9.1 0/6] Miscellaneous fixes for QEMU 9.1-rc, Paolo Bonzini, 2024/08/13
- [PULL 1/6] target/hexagon: don't look for static glib, Paolo Bonzini, 2024/08/13
- [PULL 2/6] target/i386: Do not apply REX to MMX operands, Paolo Bonzini, 2024/08/13
- [PULL 3/6] target/i386: Use unit not type in decode_modrm, Paolo Bonzini, 2024/08/13
- [PULL 5/6] module: Prevent crash by resetting local_err in module_load_qom_all(), Paolo Bonzini, 2024/08/13
- [PULL 6/6] po: update Italian translation, Paolo Bonzini, 2024/08/13
- [PULL 4/6] target/i386: Assert MMX and XMM registers in range,
Paolo Bonzini <=
- Re: [PULL for-9.1 0/6] Miscellaneous fixes for QEMU 9.1-rc, Richard Henderson, 2024/08/13