save cpu->jmp_env in saving context, so uc_emu_start() can be reentrant. also improved Python binding on handling context

This commit is contained in:
Nguyen Anh Quynh
2020-06-05 20:12:44 +08:00
parent a4784cc96c
commit 2e0f753e6f
5 changed files with 34 additions and 31 deletions

View File

@ -39,13 +39,9 @@ void cpu_loop_exit(CPUState *cpu)
/* exit the current TB from a signal handler. The host registers are
restored in a state compatible with the CPU emulator
*/
#if defined(CONFIG_SOFTMMU)
void cpu_resume_from_signal(CPUState *cpu, void *puc)
{
#endif
/* XXX: restore cpu registers saved in host registers */
cpu->exception_index = -1;
siglongjmp(cpu->jmp_env, 1);
}
@ -66,7 +62,6 @@ int cpu_exec(struct uc_struct *uc, CPUArchState *env) // qq
uintptr_t next_tb;
struct hook *hook;
if (cpu->halted) {
if (!cpu_has_work(cpu)) {
return EXCP_HALTED;
@ -306,7 +301,8 @@ int cpu_exec(struct uc_struct *uc, CPUArchState *env) // qq
tb_flush(env);
/* fail safe : never use current_cpu outside cpu_exec() */
uc->current_cpu = NULL;
// uc->current_cpu = NULL;
return ret;
}

View File

@ -71,6 +71,8 @@ int resume_all_vcpus(struct uc_struct *uc)
return -1;
}
cpu->exit_request = 0;
//qemu_clock_enable(QEMU_CLOCK_VIRTUAL, true);
cpu_resume(cpu);
qemu_tcg_cpu_loop(uc);