Optimize Notdirty write (#2031)

* enable notdirty_write for snapshots when possible

Snapshots only happens when the priority of the memory region is smaller
then the snapshot_level. After a snapshot notdirty can be set.

* disable notdirty_write for self modifying code

When SMC access the memory region more then once the
tb must be rebuild multible times.

fixes #2029

* notdirty_write better hook check

Check all relevant memory hooks before enabling notdirty write.
This also checks if the memory hook is registered for the affected
region. So it is possible to use notdirty write and have some hooks
on different addresses.

* notdirty_write check for addr_write in snapshot case

* self modifying code clear recursive mem access

when self modifying code does unaligned memory accese sometimes
uc->size_recur_mem is changed but for notdirty write not changed back.
This causes mem_hooks to be missed. To fix this uc->size_recur_mem is
set to 0 before each cpu_exec() call.
This commit is contained in:
PhilippTakacs
2024-10-31 17:02:11 +01:00
committed by GitHub
parent 957df0ec3a
commit ab23d4ceb0
6 changed files with 102 additions and 12 deletions

2
uc.c
View File

@@ -2160,6 +2160,7 @@ uc_err uc_context_save(uc_engine *uc, uc_context *context)
}
context->ramblock_freed = uc->ram_list.freed;
context->last_block = uc->ram_list.last_block;
uc->tcg_flush_tlb(uc);
}
context->snapshot_level = uc->snapshot_level;
@@ -2436,6 +2437,7 @@ uc_err uc_context_restore(uc_engine *uc, uc_context *context)
if (!uc->flatview_copy(uc, uc->address_space_memory.current_map, context->fv, true)) {
return UC_ERR_NOMEM;
}
uc->tcg_flush_tlb(uc);
}
if (uc->context_content & UC_CTL_CONTEXT_CPU) {