Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add qemu runtime defs for aarch64 #2151

Merged
merged 1 commit into from
May 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion libafl_qemu/runtime/libafl_qemu.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ typedef UINT64 libafl_word;
#else
#include <stdint.h>

#ifdef __x86_64__
#if defined(__x86_64__) || defined(__aarch64__)
typedef uint64_t libafl_word;
#define LIBAFL_CALLING_CONVENTION __attribute__(())
#endif
Expand Down Expand Up @@ -176,6 +176,54 @@ typedef enum LibaflQemuEndStatus {
}
#endif

#ifdef __aarch64__
#define LIBAFL_DEFINE_FUNCTIONS(name, opcode) \
libafl_word LIBAFL_CALLING_CONVENTION _libafl_##name##_call0( \
libafl_word action) { \
libafl_word ret; \
__asm__ volatile ( \
"mov x0, %1\n" \
".word " XSTRINGIFY(opcode) "\n" \
"mov %0, x0\n" \
: "=r"(ret) \
: "r"(action) \
: "x0" \
); \
return ret; \
} \
\
libafl_word LIBAFL_CALLING_CONVENTION _libafl_##name##_call1( \
libafl_word action, libafl_word arg1) { \
libafl_word ret; \
__asm__ volatile ( \
"mov x0, %1\n" \
"mov x1, %2\n" \
".word " XSTRINGIFY(opcode) "\n" \
"mov %0, x0\n" \
: "=r"(ret) \
: "r"(action), "r"(arg1) \
: "x0", "x1" \
); \
return ret; \
} \
\
libafl_word LIBAFL_CALLING_CONVENTION _libafl_##name##_call2( \
libafl_word action, libafl_word arg1, libafl_word arg2) { \
libafl_word ret; \
__asm__ volatile ( \
"mov x0, %1\n" \
"mov x1, %2\n" \
"mov x2, %3\n" \
".word " XSTRINGIFY(opcode) "\n" \
"mov %0, x0\n" \
: "=r"(ret) \
: "r"(action), "r"(arg1), "r"(arg2) \
: "x0", "x1", "x2" \
); \
return ret; \
}
#endif

#endif

// Generates sync exit functions
Expand Down
Loading