Skip to content

Commit

Permalink
QEMU host page size getter (AFLplusplus#73)
Browse files Browse the repository at this point in the history
* QEMU host page size getter
* Rename to sync_exit
  • Loading branch information
rmalmain authored May 6, 2024
1 parent a14f8ea commit 9f3e239
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
6 changes: 3 additions & 3 deletions include/libafl/exit.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void libafl_qemu_trigger_breakpoint(CPUState* cpu);
enum libafl_exit_reason_kind {
INTERNAL = 0,
BREAKPOINT = 1,
SYNC_BACKDOOR = 2,
SYNC_EXIT = 2,
};

// A breakpoint has been triggered.
Expand All @@ -31,7 +31,7 @@ struct libafl_exit_reason_breakpoint {
};

// A synchronous exit has been triggered.
struct libafl_exit_reason_sync_backdoor { };
struct libafl_exit_reason_sync_exit { };

// QEMU exited on its own for some reason.
struct libafl_exit_reason_internal {
Expand All @@ -46,7 +46,7 @@ struct libafl_exit_reason {
union {
struct libafl_exit_reason_internal internal;
struct libafl_exit_reason_breakpoint breakpoint; // kind == BREAKPOINT
struct libafl_exit_reason_sync_backdoor backdoor; // kind == SYNC_BACKDOOR
struct libafl_exit_reason_sync_exit sync_exit; // kind == SYNC_EXIT
} data;
};

Expand Down
8 changes: 8 additions & 0 deletions include/libafl/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

#include "qemu/osdep.h"

#ifndef CONFIG_USER_ONLY
#include "exec/memory.h"
#include "qemu/rcu.h"
#include "cpu.h"
#endif

uintptr_t libafl_qemu_host_page_size(void);

#ifndef CONFIG_USER_ONLY
uint8_t* libafl_paddr2host(CPUState* cpu, hwaddr addr, bool is_write);
#endif
2 changes: 1 addition & 1 deletion libafl/exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void libafl_exit_request_internal(CPUState* cpu, uint64_t pc, ShutdownCause caus

void libafl_exit_request_sync_backdoor(CPUState* cpu, target_ulong pc)
{
last_exit_reason.kind = SYNC_BACKDOOR;
last_exit_reason.kind = SYNC_EXIT;

prepare_qemu_exit(cpu, pc);
}
Expand Down
12 changes: 6 additions & 6 deletions libafl/utils.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "qemu/osdep.h"

#ifndef CONFIG_USER_ONLY
#include "exec/memory.h"
#include "qemu/rcu.h"
#include "cpu.h"

#include "libafl/utils.h"

uintptr_t libafl_qemu_host_page_size(void)
{
return qemu_real_host_page_size();
}

#ifndef CONFIG_USER_ONLY
uint8_t* libafl_paddr2host(CPUState* cpu, hwaddr addr, bool is_write)
{
if (addr == -1) {
Expand Down

0 comments on commit 9f3e239

Please sign in to comment.