Skip to content

Commit

Permalink
fix overwritten ld
Browse files Browse the repository at this point in the history
  • Loading branch information
rmalmain committed May 7, 2024
1 parent 6a16adc commit 20b43b4
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions tcg/tcg-op-ldst.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,30 @@ static void tcg_gen_req_mo(TCGBar type)
}
}

static TCGv_i64 maybe_preserve_addr(TCGTemp *addr)\
{
/* Save a copy of the vaddr for use after a load. */
TCGv_i64 temp = tcg_temp_ebb_new_i64();
if (tcg_ctx->addr_type == TCG_TYPE_I32) {
tcg_gen_extu_i32_i64(temp, temp_tcgv_i32(addr));
} else {
tcg_gen_mov_i64(temp, temp_tcgv_i64(addr));
}
return temp;
}

/* Only required for loads, where value might overlap addr. */
/*
static TCGv_i64 plugin_maybe_preserve_addr(TCGTemp *addr)
{
#ifdef CONFIG_PLUGIN
if (tcg_ctx->plugin_insn != NULL) {
/* Save a copy of the vaddr for use after a load. */
TCGv_i64 temp = tcg_temp_ebb_new_i64();
if (tcg_ctx->addr_type == TCG_TYPE_I32) {
tcg_gen_extu_i32_i64(temp, temp_tcgv_i32(addr));
} else {
tcg_gen_mov_i64(temp, temp_tcgv_i64(addr));
}
return temp;
return maybe_preserve_addr(addr);
}
#endif
return NULL;
}
*/

static void
plugin_gen_mem_callbacks(TCGv_i64 copy_addr, TCGTemp *orig_addr, MemOpIdx oi,
Expand Down Expand Up @@ -204,7 +211,7 @@ static void tcg_gen_qemu_ld_i32_int(TCGv_i32 val, TCGTemp *addr,
oi = make_memop_idx(memop, idx);
}

copy_addr = plugin_maybe_preserve_addr(addr);
copy_addr = maybe_preserve_addr(addr);
if (tcg_ctx->addr_type == TCG_TYPE_I32) {
opc = INDEX_op_qemu_ld_a32_i32;
} else {
Expand Down Expand Up @@ -344,7 +351,7 @@ static void tcg_gen_qemu_ld_i64_int(TCGv_i64 val, TCGTemp *addr,
oi = make_memop_idx(memop, idx);
}

copy_addr = plugin_maybe_preserve_addr(addr);
copy_addr = maybe_preserve_addr(addr);
if (tcg_ctx->addr_type == TCG_TYPE_I32) {
opc = INDEX_op_qemu_ld_a32_i64;
} else {
Expand All @@ -358,7 +365,7 @@ static void tcg_gen_qemu_ld_i64_int(TCGv_i64 val, TCGTemp *addr,
mmu_idx = tcg_constant_i64(idx);
load_size = tcg_constant_i64(1 << (memop & MO_SIZE));
gen_helper_sym_load_guest_i64(tcgv_i64_expr(val), tcg_env,
temp_tcgv_i64(addr), tcgv_i64_expr(temp_tcgv_i64(addr)),
copy_addr, tcgv_i64_expr(copy_addr),
load_size, mmu_idx);

if ((orig_memop ^ memop) & MO_BSWAP) {
Expand Down

0 comments on commit 20b43b4

Please sign in to comment.