mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
Hexagon (target/hexagon) fix bug in mem_noshuf load exception
The semantics of a mem_noshuf packet are that the store effectively happens before the load. However, in cases where the load raises an exception, we cannot simply execute the store first. This change adds a probe to check that the load will not raise an exception before executing the store. If the load is predicated, this requires special handling. We check the condition before performing the probe. Since, we need the EA to perform the check, we move the GET_EA portion inside CHECK_NOSHUF_PRED. Test case added in tests/tcg/hexagon/mem_noshuf_exception.c Suggested-by: Alessandro Di Federico <ale@rev.ng> Suggested-by: Anton Johansson <anjo@rev.ng> Signed-off-by: Taylor Simpson <tsimpson@quicinc.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220707210546.15985-3-tsimpson@quicinc.com>
This commit is contained in:
parent
cab86dea1d
commit
15fc6badbd
7 changed files with 206 additions and 21 deletions
|
@ -87,11 +87,28 @@
|
|||
*
|
||||
*
|
||||
* For qemu, we look for a load in slot 0 when there is a store in slot 1
|
||||
* in the same packet. When we see this, we call a helper that merges the
|
||||
* bytes from the store buffer with the value loaded from memory.
|
||||
* in the same packet. When we see this, we call a helper that probes the
|
||||
* load to make sure it doesn't fault. Then, we process the store ahead of
|
||||
* the actual load.
|
||||
|
||||
*/
|
||||
#define CHECK_NOSHUF \
|
||||
#define CHECK_NOSHUF(VA, SIZE) \
|
||||
do { \
|
||||
if (insn->slot == 0 && pkt->pkt_has_store_s1) { \
|
||||
probe_noshuf_load(VA, SIZE, ctx->mem_idx); \
|
||||
process_store(ctx, pkt, 1); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define CHECK_NOSHUF_PRED(GET_EA, SIZE, PRED) \
|
||||
do { \
|
||||
TCGLabel *label = gen_new_label(); \
|
||||
tcg_gen_brcondi_tl(TCG_COND_EQ, PRED, 0, label); \
|
||||
GET_EA; \
|
||||
if (insn->slot == 0 && pkt->pkt_has_store_s1) { \
|
||||
probe_noshuf_load(EA, SIZE, ctx->mem_idx); \
|
||||
} \
|
||||
gen_set_label(label); \
|
||||
if (insn->slot == 0 && pkt->pkt_has_store_s1) { \
|
||||
process_store(ctx, pkt, 1); \
|
||||
} \
|
||||
|
@ -99,37 +116,37 @@
|
|||
|
||||
#define MEM_LOAD1s(DST, VA) \
|
||||
do { \
|
||||
CHECK_NOSHUF; \
|
||||
CHECK_NOSHUF(VA, 1); \
|
||||
tcg_gen_qemu_ld8s(DST, VA, ctx->mem_idx); \
|
||||
} while (0)
|
||||
#define MEM_LOAD1u(DST, VA) \
|
||||
do { \
|
||||
CHECK_NOSHUF; \
|
||||
CHECK_NOSHUF(VA, 1); \
|
||||
tcg_gen_qemu_ld8u(DST, VA, ctx->mem_idx); \
|
||||
} while (0)
|
||||
#define MEM_LOAD2s(DST, VA) \
|
||||
do { \
|
||||
CHECK_NOSHUF; \
|
||||
CHECK_NOSHUF(VA, 2); \
|
||||
tcg_gen_qemu_ld16s(DST, VA, ctx->mem_idx); \
|
||||
} while (0)
|
||||
#define MEM_LOAD2u(DST, VA) \
|
||||
do { \
|
||||
CHECK_NOSHUF; \
|
||||
CHECK_NOSHUF(VA, 2); \
|
||||
tcg_gen_qemu_ld16u(DST, VA, ctx->mem_idx); \
|
||||
} while (0)
|
||||
#define MEM_LOAD4s(DST, VA) \
|
||||
do { \
|
||||
CHECK_NOSHUF; \
|
||||
CHECK_NOSHUF(VA, 4); \
|
||||
tcg_gen_qemu_ld32s(DST, VA, ctx->mem_idx); \
|
||||
} while (0)
|
||||
#define MEM_LOAD4u(DST, VA) \
|
||||
do { \
|
||||
CHECK_NOSHUF; \
|
||||
CHECK_NOSHUF(VA, 4); \
|
||||
tcg_gen_qemu_ld32s(DST, VA, ctx->mem_idx); \
|
||||
} while (0)
|
||||
#define MEM_LOAD8u(DST, VA) \
|
||||
do { \
|
||||
CHECK_NOSHUF; \
|
||||
CHECK_NOSHUF(VA, 8); \
|
||||
tcg_gen_qemu_ld64(DST, VA, ctx->mem_idx); \
|
||||
} while (0)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue