QEMU host page size getter (#73)

* QEMU host page size getter
* Rename to sync_exit
This commit is contained in:
Romain Malmain 2024-05-06 18:07:38 +02:00 committed by GitHub
parent a14f8eae8e
commit 9f3e2399ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 10 deletions

View File

@ -22,7 +22,7 @@ void libafl_qemu_trigger_breakpoint(CPUState* cpu);
enum libafl_exit_reason_kind { enum libafl_exit_reason_kind {
INTERNAL = 0, INTERNAL = 0,
BREAKPOINT = 1, BREAKPOINT = 1,
SYNC_BACKDOOR = 2, SYNC_EXIT = 2,
}; };
// A breakpoint has been triggered. // A breakpoint has been triggered.
@ -31,7 +31,7 @@ struct libafl_exit_reason_breakpoint {
}; };
// A synchronous exit has been triggered. // 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. // QEMU exited on its own for some reason.
struct libafl_exit_reason_internal { struct libafl_exit_reason_internal {
@ -46,7 +46,7 @@ struct libafl_exit_reason {
union { union {
struct libafl_exit_reason_internal internal; struct libafl_exit_reason_internal internal;
struct libafl_exit_reason_breakpoint breakpoint; // kind == BREAKPOINT 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; } data;
}; };

View File

@ -2,6 +2,14 @@
#include "qemu/osdep.h" #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 #ifndef CONFIG_USER_ONLY
uint8_t* libafl_paddr2host(CPUState* cpu, hwaddr addr, bool is_write); uint8_t* libafl_paddr2host(CPUState* cpu, hwaddr addr, bool is_write);
#endif #endif

View File

@ -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) 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); prepare_qemu_exit(cpu, pc);
} }

View File

@ -1,12 +1,12 @@
#include "qemu/osdep.h" #include "qemu/osdep.h"
#ifndef CONFIG_USER_ONLY
#include "exec/memory.h"
#include "qemu/rcu.h"
#include "cpu.h"
#include "libafl/utils.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) uint8_t* libafl_paddr2host(CPUState* cpu, hwaddr addr, bool is_write)
{ {
if (addr == -1) { if (addr == -1) {