Skip to content

Commit 3b2f54f

Browse files
committed
Fix regression: We should triage MIPS internal exceptions to Unicorn exceptions
1 parent c22651c commit 3b2f54f

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

qemu/accel/tcg/cpu-exec.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,9 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret)
408408
// Unicorn: If un-catched interrupt, stop executions.
409409
if (!catched) {
410410
// printf("AAAAAAAAAAAA\n"); qq
411-
uc->invalid_error = UC_ERR_EXCEPTION;
411+
if (uc->invalid_error == UC_ERR_OK) {
412+
uc->invalid_error = UC_ERR_EXCEPTION;
413+
}
412414
cpu->halted = 1;
413415
*ret = EXCP_HLT;
414416
return true;

qemu/target/mips/helper.c

+12
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,18 @@ static void raise_mmu_exception(CPUMIPSState *env, target_ulong address,
535535
#endif
536536
cs->exception_index = exception;
537537
env->error_code = error_code;
538+
539+
// Dispatch internal exceptions to Unicorn Exceptions
540+
switch (exception) {
541+
case EXCP_TLBL:
542+
env->uc->invalid_error = UC_ERR_READ_UNMAPPED;
543+
env->uc->invalid_addr = address;
544+
break;
545+
case EXCP_TLBS:
546+
env->uc->invalid_error = UC_ERR_WRITE_UNMAPPED;
547+
env->uc->invalid_addr = address;
548+
break;
549+
}
538550
}
539551

540552
hwaddr mips_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)

qemu/target/mips/op_helper.c

+9
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,15 @@ void mips_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
10981098
}
10991099
}
11001100

1101+
switch (excp) {
1102+
case EXCP_AdEL:
1103+
env->uc->invalid_error = UC_ERR_READ_UNALIGNED;
1104+
break;
1105+
case EXCP_AdES:
1106+
env->uc->invalid_error = UC_ERR_WRITE_UNALIGNED;
1107+
break;
1108+
}
1109+
11011110
do_raise_exception_err(env, excp, error_code, retaddr);
11021111
}
11031112

0 commit comments

Comments
 (0)