parent
c9519ee8b6
commit
2edf778b1c
7
include/libafl/utils.h
Normal file
7
include/libafl/utils.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "qemu/osdep.h"
|
||||||
|
|
||||||
|
#ifndef CONFIG_USER_ONLY
|
||||||
|
uint8_t* libafl_paddr2host(CPUState* cpu, hwaddr addr, bool is_write);
|
||||||
|
#endif
|
@ -1,7 +1,8 @@
|
|||||||
specific_ss.add(files(
|
specific_ss.add(files(
|
||||||
'exit.c',
|
'exit.c',
|
||||||
'hook.c',
|
'hook.c',
|
||||||
'jit.c'
|
'jit.c',
|
||||||
|
'utils.c',
|
||||||
))
|
))
|
||||||
|
|
||||||
specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files(
|
specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files(
|
||||||
|
24
libafl/utils.c
Normal file
24
libafl/utils.c
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#include "qemu/osdep.h"
|
||||||
|
|
||||||
|
#ifndef CONFIG_USER_ONLY
|
||||||
|
#include "exec/memory.h"
|
||||||
|
#include "qemu/rcu.h"
|
||||||
|
#include "cpu.h"
|
||||||
|
|
||||||
|
#include "libafl/utils.h"
|
||||||
|
|
||||||
|
uint8_t* libafl_paddr2host(CPUState* cpu, hwaddr addr, bool is_write)
|
||||||
|
{
|
||||||
|
if (addr == -1) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
hwaddr xlat;
|
||||||
|
MemoryRegion* mr;
|
||||||
|
WITH_RCU_READ_LOCK_GUARD() {
|
||||||
|
mr = address_space_translate(cpu->as, addr, &xlat, NULL, is_write, MEMTXATTRS_UNSPECIFIED);
|
||||||
|
}
|
||||||
|
|
||||||
|
return qemu_map_ram_ptr(mr->ram_block, xlat);
|
||||||
|
}
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user