Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions qemu/target/mips/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -30951,6 +30951,7 @@ static void mips_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
dyn_is_slot = tcg_const_i32(tcg_ctx, 0);
slot_op = tcg_last_op(tcg_ctx);
tcg_gen_mov_i32(tcg_ctx, tcg_ctx->delay_slot_flag, dyn_is_slot);
tcg_temp_free_i32(tcg_ctx, dyn_is_slot);

// Unicorn: trace this instruction on request
if (HOOK_EXISTS_BOUNDED(uc, UC_HOOK_CODE, ctx->base.pc_next)) {
Expand Down
22 changes: 18 additions & 4 deletions tests/unit/test_mips.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,20 @@ static void test_mips_simple_coredump_2137(void)
OK(uc_close(uc));
}

static void test_mips_ctx_temps_overflow(void)
{
uc_engine *uc = NULL;
uint64_t base = 0x1000;
uc_tb tb;

OK(uc_open(UC_ARCH_MIPS, UC_MODE_MIPS64, &uc));
// Map a page of NOPs (0x00); exercises a potential for a bug when a TB contains
// more instructions than temp slots (if temp tcg vars are not freed)
uc_mem_map(uc, base, 0x1000, UC_PROT_READ | UC_PROT_EXEC | UC_PROT_WRITE);
uc_ctl_request_cache(uc, base, &tb);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also use OK() for the other two uc calls and add a OK(uc_close(uc))

}


TEST_LIST = {
{"test_mips_stop_at_branch", test_mips_stop_at_branch},
{"test_mips_stop_at_delay_slot", test_mips_stop_at_delay_slot},
Expand All @@ -230,8 +244,8 @@ TEST_LIST = {
{"test_mips_lwx_exception_issue_1314", test_mips_lwx_exception_issue_1314},
{"test_mips_mips16", test_mips_mips16},
{"test_mips_mips_fpr", test_mips_mips_fpr},
{"test_mips_stop_delay_slot_from_qiling",
test_mips_stop_delay_slot_from_qiling},
{"test_mips_simple_coredump_2134", test_mips_simple_coredump_2134},
{"test_mips_simple_coredump_2137", test_mips_simple_coredump_2137},
{"test_mips_stop_delay_slot_from_qiling", test_mips_stop_delay_slot_from_qiling},
{"test_mips_simple_coredump_2134", test_mips_simple_coredump_2134},
{"test_mips_simple_coredump_2137", test_mips_simple_coredump_2137},
{"test_mips_ctx_temps_overflow", test_mips_ctx_temps_overflow},
{NULL, NULL}};