Skip to content

Commit 9f3e239

Browse files
authored
QEMU host page size getter (#73)
* QEMU host page size getter * Rename to sync_exit
1 parent a14f8ea commit 9f3e239

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

include/libafl/exit.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void libafl_qemu_trigger_breakpoint(CPUState* cpu);
2222
enum libafl_exit_reason_kind {
2323
INTERNAL = 0,
2424
BREAKPOINT = 1,
25-
SYNC_BACKDOOR = 2,
25+
SYNC_EXIT = 2,
2626
};
2727

2828
// A breakpoint has been triggered.
@@ -31,7 +31,7 @@ struct libafl_exit_reason_breakpoint {
3131
};
3232

3333
// A synchronous exit has been triggered.
34-
struct libafl_exit_reason_sync_backdoor { };
34+
struct libafl_exit_reason_sync_exit { };
3535

3636
// QEMU exited on its own for some reason.
3737
struct libafl_exit_reason_internal {
@@ -46,7 +46,7 @@ struct libafl_exit_reason {
4646
union {
4747
struct libafl_exit_reason_internal internal;
4848
struct libafl_exit_reason_breakpoint breakpoint; // kind == BREAKPOINT
49-
struct libafl_exit_reason_sync_backdoor backdoor; // kind == SYNC_BACKDOOR
49+
struct libafl_exit_reason_sync_exit sync_exit; // kind == SYNC_EXIT
5050
} data;
5151
};
5252

include/libafl/utils.h

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
#include "qemu/osdep.h"
44

5+
#ifndef CONFIG_USER_ONLY
6+
#include "exec/memory.h"
7+
#include "qemu/rcu.h"
8+
#include "cpu.h"
9+
#endif
10+
11+
uintptr_t libafl_qemu_host_page_size(void);
12+
513
#ifndef CONFIG_USER_ONLY
614
uint8_t* libafl_paddr2host(CPUState* cpu, hwaddr addr, bool is_write);
715
#endif

libafl/exit.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void libafl_exit_request_internal(CPUState* cpu, uint64_t pc, ShutdownCause caus
110110

111111
void libafl_exit_request_sync_backdoor(CPUState* cpu, target_ulong pc)
112112
{
113-
last_exit_reason.kind = SYNC_BACKDOOR;
113+
last_exit_reason.kind = SYNC_EXIT;
114114

115115
prepare_qemu_exit(cpu, pc);
116116
}

libafl/utils.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#include "qemu/osdep.h"
2-
3-
#ifndef CONFIG_USER_ONLY
4-
#include "exec/memory.h"
5-
#include "qemu/rcu.h"
6-
#include "cpu.h"
7-
82
#include "libafl/utils.h"
93

4+
uintptr_t libafl_qemu_host_page_size(void)
5+
{
6+
return qemu_real_host_page_size();
7+
}
8+
9+
#ifndef CONFIG_USER_ONLY
1010
uint8_t* libafl_paddr2host(CPUState* cpu, hwaddr addr, bool is_write)
1111
{
1212
if (addr == -1) {

0 commit comments

Comments
 (0)