Hexagon (target/hexagon) probe the stores in a packet at start of commit
PATCH v2 1/1 Hexagon (target/hexagon) probe the stores in a packet at start of commit
When a packet has 2 stores, either both commit or neither commit. At the beginning of gen_commit_packet, we check for multiple stores. If there are multiple stores, call a helper that will probe each of them before proceeding with the commit.
Note that we don't call the probe helper for packets with only one store. Therefore, we call process_store_log before anything else involved in committing the packet.
Test case added in tests/tcg/hexagon/hex_sigsegv.c
*** Changes in v2 ***
Reduce the overhead of probe_pkt_stores - pass a bit mask instead of multiple booleans
Signed-off-by Taylor Simpson <[email protected]>
--- target/hexagon/helper.h | 2 + target/hexagon/op_helper.c | 33 ++++++++++++ target/hexagon/translate.c | 33 +++++++++++- tests/tcg/hexagon/hex_sigsegv.c | 106 ++++++++++++++++++++++++++++++++++++++ tests/tcg/hexagon/Makefile.target | 1 + 5 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/hexagon/hex_sigsegv.c
target/hexagon/helper.h +2 -0
@@ -89,3 +89,5 @@ DEF_HELPER_4(sffms_lib, f32, env, f32, f32, f32) DEF_HELPER_3(dfmpyfix, f64, env, f64, f64) DEF_HELPER_4(dfmpyhh, f64, env, f64, f64, f64) + +DEF_HELPER_3 (probe_pkt_stores, void, env, int, int)
target/hexagon/op_helper.c +33 -0
@@ -377,6 +377,39 @@ int32_t HELPER(vacsh_pred)(CPUHexagonState *env,return PeV; } +static void probe_store (CPUHexagonState *env,int slot,int mmu_idx) +{ +if (!(env->slot_cancelled & (1 << slot))) { +size1u_t width = env->mem_log_stores[slot].width; +target_ulong va = env->mem_log_stores[slot].va; +uintptr_t ra =GETPC (); +probe_write (env, va, width, mmu_idx, ra); + } +} + +void HELPER (probe_pkt_stores )(CPUHexagonState *env,int mask,int mmu_idx) +{ +bool has_st0 = (mask >>0 ) &1 ; +bool has_st1 = (mask >>1 ) &1 ; +bool has_dczeroa = (mask >>2 ) &1 ; + +if (has_st0 && !has_dczeroa) { +probe_store (env,0 , mmu_idx); + } +if (has_st1 && !has_dczeroa) { +probe_store (env,1 , mmu_idx); + } +if (has_dczeroa) { +/* Probe 32 bytes starting at (dczero_addr & ~0x1f) */ +target_ulong va = env->dczero_addr & ~0x1f ; +uintptr_t ra =GETPC (); +probe_write (env, va +0 ,8 , mmu_idx, ra); +probe_write (env, va +8 ,8 , mmu_idx, ra); +probe_write (env, va +16 ,8 , mmu_idx, ra); +probe_write (env, va +24 ,8 , mmu_idx, ra); + } +} +/* * mem_noshuf * Section 5.5 of the Hexagon V67 Programmer's Reference Manual
target/hexagon/translate.c +32 -1
@@ -471,9 +471,40 @@ static void update_exec_counters(DisasContext *ctx, Packet *pkt)static void gen_commit_packet (DisasContext *ctx,Packet *pkt) { +/* +* If there is more than one store in a packet, make sure they are all OK +* before proceeding with the rest of the packet commit. +* +* Note that we don't call the probe helper for packets with only one +* store. Therefore, we call process_store_log before anything else +* involved in committing the packet. +*/ +if ((pkt->pkt_has_store_s0 && + (pkt->pkt_has_store_s1 && !ctx->s1_store_processed)) || + pkt->pkt_has_dczeroa) { +TCGv mem_idx =tcg_const_tl (ctx->mem_idx); +int mask =0 ; +TCGv mask_tcgv; + +if (pkt->pkt_has_store_s0) { + mask |= (1 <<0 ); + } +if (pkt->pkt_has_store_s1 && !ctx->s1_store_processed) { + mask |= (1 <<1 ); + } +if (pkt->pkt_has_dczeroa) { + mask |= (1 <<2 ); + } + mask_tcgv =tcg_const_tl (mask); +gen_helper_probe_pkt_stores (cpu_env, mask_tcgv, mem_idx); +tcg_temp_free (mem_idx); +tcg_temp_free (mask_tcgv); + } + +process_store_log (ctx, pkt); +gen_reg_writes (ctx);gen_pred_writes (ctx, pkt); -process_store_log (ctx, pkt);process_dczeroa (ctx, pkt);update_exec_counters (ctx, pkt);if (HEX_DEBUG ) {
tests/tcg/hexagon/hex_sigsegv.c new file +106 -0
106 lines not on this page · raw message
tests/tcg/hexagon/Makefile.target +1 -0
@@ -28,6 +28,7 @@ first: $(HEX_SRC)/first.S $(CC) -static -mv67 -nostdlib $^ -o $@ HEX_TESTS = first +HEX_TESTS += hex_sigsegv HEX_TESTS += misc HEX_TESTS += preg_alias HEX_TESTS += dual_stores
Signature · 1 line
2.7.4