-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add utils file * user only guard.
- Loading branch information
Showing
3 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |