Cleaner implementation for uc_mem_prot on mmio regions
This commit is contained in:
parent
2a6529348c
commit
289034538d
|
@ -1657,13 +1657,6 @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi,
|
|||
res = load_memop(haddr, op);
|
||||
|
||||
_out:
|
||||
// mmio error check
|
||||
if (uc->invalid_error != UC_ERR_OK) {
|
||||
uc->invalid_addr = addr;
|
||||
cpu_exit(uc->cpu);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Unicorn: callback on successful data read
|
||||
if (!code_read) {
|
||||
if (!uc->size_recur_mem) { // disabling read callback if in recursive call
|
||||
|
|
|
@ -88,7 +88,6 @@ static uint64_t mmio_read_wrapper(struct uc_struct *uc, void *opaque, hwaddr add
|
|||
if (cbs->read) {
|
||||
return cbs->read(uc, addr, size, cbs->user_data_read);
|
||||
} else {
|
||||
uc->invalid_error = UC_ERR_READ_PROT;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -101,8 +100,6 @@ static void mmio_write_wrapper(struct uc_struct *uc, void *opaque, hwaddr addr,
|
|||
addr = addr & ( (target_ulong)(-1) );
|
||||
if (cbs->write) {
|
||||
cbs->write(uc, addr, size, data, cbs->user_data_write);
|
||||
} else {
|
||||
uc->invalid_error = UC_ERR_WRITE_PROT;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
14
uc.c
14
uc.c
|
@ -1366,7 +1366,7 @@ uc_err uc_mem_protect(struct uc_struct *uc, uint64_t address, size_t size,
|
|||
uint64_t addr = address;
|
||||
uint64_t pc;
|
||||
size_t count, len;
|
||||
mmio_cbs* new_cb;
|
||||
mmio_cbs *mmio;
|
||||
bool remove_exec = false;
|
||||
|
||||
UC_INIT(uc);
|
||||
|
@ -1422,20 +1422,12 @@ uc_err uc_mem_protect(struct uc_struct *uc, uint64_t address, size_t size,
|
|||
uc->readonly_mem(mr, (perms & UC_PROT_WRITE) == 0);
|
||||
|
||||
} else {
|
||||
if(!split_mmio_region(uc, mr, addr, len, false)) {
|
||||
if (!split_mmio_region(uc, mr, addr, len, false)) {
|
||||
return UC_ERR_NOMEM;
|
||||
}
|
||||
|
||||
mr = memory_mapping(uc, addr);
|
||||
new_cb = (mmio_cbs*)mr->opaque;
|
||||
|
||||
if (!(perms & UC_PROT_READ)) {
|
||||
new_cb->read = NULL;
|
||||
}
|
||||
|
||||
if (!(perms & UC_PROT_WRITE)) {
|
||||
new_cb->write = NULL;
|
||||
}
|
||||
mr->perms = perms;
|
||||
}
|
||||
|
||||
count += len;
|
||||
|
|
Loading…
Reference in New Issue