handle snapshots over context_save context_restore

This commit is contained in:
Takacs, Philipp
2023-04-11 14:23:38 +02:00
parent e54cf7ee03
commit 716c8f1c4c
4 changed files with 75 additions and 25 deletions

View File

@@ -389,6 +389,7 @@ struct uc_struct {
uint64_t qemu_real_host_page_size;
int qemu_icache_linesize;
/* ARCH_REGS_STORAGE_SIZE */
uc_context_content context_content;
int cpu_context_size;
uint64_t next_pc; // save next PC for some special cases
bool hook_insert; // insert new hook at begin of the hook list (append by
@@ -419,6 +420,7 @@ struct uc_context {
size_t context_size; // size of the real internal context structure
uc_mode mode; // the mode of this context
uc_arch arch; // the arch of this context
int snapshot_level; // the memory snapshot level to restore
char data[0]; // context
};

View File

@@ -581,6 +581,9 @@ typedef enum uc_control_type {
// Write: @args = (uint32_t)
// Read: @args = (uint32_t*)
UC_CTL_TCG_BUFFER_SIZE,
// controle if context_save/restore should work with snapshots
// Write: @args = (int)
UC_CTL_CONTEXT_MODE,
} uc_control_type;
/*
@@ -662,6 +665,7 @@ See sample_ctl.c for a detailed example.
uc_ctl(uc, UC_CTL_READ(UC_CTL_TCG_BUFFER_SIZE, 1), (size))
#define uc_ctl_set_tcg_buffer_size(uc, size) \
uc_ctl(uc, UC_CTL_WRITE(UC_CTL_TCG_BUFFER_SIZE, 1), (size))
#define uc_ctl_context_mode(uc, mode) uc_ctl(uc, UC_CTL_WRITE(UC_CTL_CONTEXT_MODE, 1), (mode))
// Opaque storage for CPU context, used with uc_context_*()
struct uc_context;
@@ -1015,6 +1019,11 @@ struct uc_tlb_entry {
uc_prot perms;
};
typedef enum uc_context_content {
UC_CTL_CONTEXT_CPU = 1,
UC_CTL_CONTEXT_MEMORY = 2,
} uc_context_content;
/*
Map memory in for emulation.
This API adds a memory region that can be used by emulation.
@@ -1345,12 +1354,6 @@ size_t uc_context_size(uc_engine *uc);
UNICORN_EXPORT
uc_err uc_context_free(uc_context *context);
UNICORN_EXPORT
uc_err uc_snapshot(uc_engine *uc);
UNICORN_EXPORT
uc_err uc_restore_latest_snapshot(uc_engine *uc);
#ifdef __cplusplus
}
#endif