Several bugfixes (#2049)

* Remove global variable from aarch64 tcg target

This obviously breaks trying to run two unicorn instances at once on
aarch64. It appears a similar variable had already been moved to the
state struct for i386 tcg target.

* Reenable writing to jit region while calling tb_add_jump

On arm macs, every place that writes to jit code needs to have
tb_exec_unlock called first. This is already in most necessary places,
but not this one.

* Don't forget to call restore_jit_state in uc_context_restore

Every time UC_INIT is used, restore_jit_state must be used on the return
path, or occasional assertion failures will pop up on arm macs.

* Restore pc before calling into tlb fill hook

In my application it is important to have correct pc values available
from this hook.
This commit is contained in:
tbodt
2024-11-03 20:53:26 -08:00
committed by GitHub
parent ab23d4ceb0
commit f71bc1a115
5 changed files with 12 additions and 5 deletions

6
uc.c
View File

@@ -2429,6 +2429,7 @@ uc_err uc_context_restore(uc_engine *uc, uc_context *context)
uc->snapshot_level = context->snapshot_level;
ret = uc_restore_latest_snapshot(uc);
if (ret != UC_ERR_OK) {
restore_jit_state(uc);
return ret;
}
uc_snapshot(uc);
@@ -2443,9 +2444,12 @@ uc_err uc_context_restore(uc_engine *uc, uc_context *context)
if (uc->context_content & UC_CTL_CONTEXT_CPU) {
if (!uc->context_restore) {
memcpy(uc->cpu->env_ptr, context->data, context->context_size);
restore_jit_state(uc);
return UC_ERR_OK;
} else {
return uc->context_restore(uc, context);
ret = uc->context_restore(uc, context);
restore_jit_state(uc);
return ret;
}
}
return UC_ERR_OK;