aboutsummaryrefslogtreecommitdiffstats
path: root/executor/common_kvm_arm64_syzos.h
diff options
context:
space:
mode:
authorAlexander Potapenko <glider@google.com>2024-07-23 11:32:12 +0200
committerAlexander Potapenko <glider@google.com>2024-07-29 15:29:47 +0000
commitd44a00853f501db00c2c9e47b8c770b892d57721 (patch)
treec23f3b508c544d0591bf876c0b5ab90498f94bbc /executor/common_kvm_arm64_syzos.h
parent3fac346ac6e2c0adadc6a268582fc50fc07f16f2 (diff)
executor: arm64: add syzos header
For KVM fuzzing we are going to need some library code that will be running inside KVM to perform common tasks (e.g. register accesses, device setup etc.) This code will reside in a special ".guest" section that the executor will map at address 0xeeee8000. For now it contains just the main function, but will be extended in further patches.
Diffstat (limited to 'executor/common_kvm_arm64_syzos.h')
-rw-r--r--executor/common_kvm_arm64_syzos.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/executor/common_kvm_arm64_syzos.h b/executor/common_kvm_arm64_syzos.h
new file mode 100644
index 000000000..b9edf0069
--- /dev/null
+++ b/executor/common_kvm_arm64_syzos.h
@@ -0,0 +1,20 @@
+// Copyright 2024 syzkaller project authors. All rights reserved.
+// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
+
+// This file provides guest code running inside the ARM64 KVM.
+
+#include "kvm.h"
+
+// Host will map the code in this section into the guest address space.
+#define GUEST_CODE __attribute__((section("guest")))
+
+// Start/end of the guest section.
+extern char *__start_guest, *__stop_guest;
+
+// Main guest function that performs necessary setup and passes the control to the user-provided
+// payload.
+GUEST_CODE static void guest_main()
+{
+ void (*guest_payload)() = (void (*)())ARM64_ADDR_USER_CODE;
+ guest_payload();
+}