Fix regression: We should triage MIPS internal exceptions to Unicorn exceptions

This commit is contained in:
2024-12-07 17:09:59 +08:00
parent c22651c9fe
commit 3b2f54fc61
3 changed files with 24 additions and 1 deletions

View File

@@ -408,7 +408,9 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret)
// Unicorn: If un-catched interrupt, stop executions.
if (!catched) {
// printf("AAAAAAAAAAAA\n"); qq
uc->invalid_error = UC_ERR_EXCEPTION;
if (uc->invalid_error == UC_ERR_OK) {
uc->invalid_error = UC_ERR_EXCEPTION;
}
cpu->halted = 1;
*ret = EXCP_HLT;
return true;

View File

@@ -535,6 +535,18 @@ static void raise_mmu_exception(CPUMIPSState *env, target_ulong address,
#endif
cs->exception_index = exception;
env->error_code = error_code;
// Dispatch internal exceptions to Unicorn Exceptions
switch (exception) {
case EXCP_TLBL:
env->uc->invalid_error = UC_ERR_READ_UNMAPPED;
env->uc->invalid_addr = address;
break;
case EXCP_TLBS:
env->uc->invalid_error = UC_ERR_WRITE_UNMAPPED;
env->uc->invalid_addr = address;
break;
}
}
hwaddr mips_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)

View File

@@ -1098,6 +1098,15 @@ void mips_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
}
}
switch (excp) {
case EXCP_AdEL:
env->uc->invalid_error = UC_ERR_READ_UNALIGNED;
break;
case EXCP_AdES:
env->uc->invalid_error = UC_ERR_WRITE_UNALIGNED;
break;
}
do_raise_exception_err(env, excp, error_code, retaddr);
}