Merge pull request #1558 from bet4it/sc

Fix pc after ppc sc inst
This commit is contained in:
lazymio 2022-02-20 15:42:23 +01:00 committed by GitHub
commit 051ae39f08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 0 deletions

View File

@ -386,6 +386,10 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret)
#if defined(TARGET_RISCV)
CPURISCVState *env = &(RISCV_CPU(uc->cpu)->env);
env->pc += 4;
#endif
#if defined(TARGET_PPC)
CPUPPCState *env = &(POWERPC_CPU(uc->cpu)->env);
env->nip += 4;
#endif
// Unicorn: call registered interrupt callbacks
catched = false;

View File

@ -63,6 +63,33 @@ static void test_ppc32_fadd()
OK(uc_close(uc));
}
static void test_ppc32_sc_cb(uc_engine *uc, uint32_t intno, void *data)
{
uc_emu_stop(uc);
return;
}
static void test_ppc32_sc()
{
uc_engine *uc;
char code[] = "\x44\x00\x00\x02"; // sc
uint32_t r_pc;
uc_hook h;
uc_common_setup(&uc, UC_ARCH_PPC, UC_MODE_32 | UC_MODE_BIG_ENDIAN, code,
sizeof(code) - 1);
OK(uc_hook_add(uc, &h, UC_HOOK_INTR, test_ppc32_sc_cb, NULL, 1, 0));
OK(uc_emu_start(uc, code_start, code_start + sizeof(code) - 1, 0, 0));
OK(uc_reg_read(uc, UC_PPC_REG_PC, &r_pc));
TEST_CHECK(r_pc == code_start + 4);
OK(uc_close(uc));
}
TEST_LIST = {{"test_ppc32_add", test_ppc32_add},
{"test_ppc32_fadd", test_ppc32_fadd},
{"test_ppc32_sc", test_ppc32_sc},
{NULL, NULL}};