mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-18 14:47:17 +00:00
uc: Handle freeing of multiple address spaces
This commit is contained in:
parent
2210c7f486
commit
6d5f465449
|
@ -1645,9 +1645,9 @@ MemoryRegion *iotlb_to_region(CPUState *cpu, hwaddr index, MemTxAttrs attrs)
|
|||
return sections[index & ~TARGET_PAGE_MASK].mr;
|
||||
}
|
||||
|
||||
void phys_mem_clean(struct uc_struct* uc)
|
||||
void phys_mem_clean(AddressSpace *as)
|
||||
{
|
||||
AddressSpaceDispatch* d = uc->as.next_dispatch;
|
||||
AddressSpaceDispatch* d = as->next_dispatch;
|
||||
g_free(d->map.sections);
|
||||
}
|
||||
|
||||
|
|
|
@ -457,6 +457,7 @@ static inline bool cpu_can_do_io(CPUState *cpu)
|
|||
return true;
|
||||
}
|
||||
|
||||
void phys_mem_clean(struct uc_struct* uc);
|
||||
// Unicorn: Used for freeing
|
||||
void phys_mem_clean(AddressSpace *as);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -27,9 +27,7 @@ static void release_common(void *t)
|
|||
{
|
||||
TCGPool *po, *to;
|
||||
TCGContext *s = (TCGContext *)t;
|
||||
#if TCG_TARGET_REG_BITS == 32
|
||||
int i;
|
||||
#endif
|
||||
|
||||
// Clean TCG.
|
||||
TCGOpDef* def = &s->tcg_op_defs[0];
|
||||
|
@ -46,8 +44,11 @@ static void release_common(void *t)
|
|||
|
||||
// TODO(danghvu): these function is not available outside qemu
|
||||
// so we keep them here instead of outside uc_close.
|
||||
phys_mem_clean(s->uc);
|
||||
address_space_destroy(&(s->uc->as));
|
||||
for (i = 0; i < s->uc->cpu->num_ases; i++) {
|
||||
AddressSpace *as = s->uc->cpu->cpu_ases[i].as;
|
||||
phys_mem_clean(as);
|
||||
address_space_destroy(as);
|
||||
}
|
||||
memory_free(s->uc);
|
||||
tb_cleanup(s->uc);
|
||||
free_code_gen_buffer(s->uc);
|
||||
|
|
4
uc.c
4
uc.c
|
@ -429,7 +429,7 @@ uc_err uc_mem_read(uc_engine *uc, uint64_t address, void *_bytes, size_t size)
|
|||
MemoryRegion *mr = memory_mapping(uc, address);
|
||||
if (mr) {
|
||||
len = (size_t)MIN(size - count, mr->end - address);
|
||||
if (uc->read_mem(&uc->as, address, bytes, len) == false)
|
||||
if (uc->read_mem(uc->cpu->as, address, bytes, len) == false)
|
||||
break;
|
||||
count += len;
|
||||
address += len;
|
||||
|
@ -467,7 +467,7 @@ uc_err uc_mem_write(uc_engine *uc, uint64_t address, const void *_bytes, size_t
|
|||
uc->readonly_mem(mr, false);
|
||||
|
||||
len = (size_t)MIN(size - count, mr->end - address);
|
||||
if (uc->write_mem(&uc->as, address, bytes, len) == false)
|
||||
if (uc->write_mem(uc->cpu->as, address, bytes, len) == false)
|
||||
break;
|
||||
|
||||
if (!(operms & UC_PROT_WRITE)) // write protected
|
||||
|
|
Loading…
Reference in a new issue