aboutsummaryrefslogtreecommitdiffstats
path: root/executor/common_kvm_amd64.h
diff options
context:
space:
mode:
Diffstat (limited to 'executor/common_kvm_amd64.h')
-rw-r--r--executor/common_kvm_amd64.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/executor/common_kvm_amd64.h b/executor/common_kvm_amd64.h
index 718d63243..39804b4b8 100644
--- a/executor/common_kvm_amd64.h
+++ b/executor/common_kvm_amd64.h
@@ -883,6 +883,16 @@ static volatile long syz_kvm_setup_cpu(volatile long a0, volatile long a1, volat
#endif
#if SYZ_EXECUTOR || __NR_syz_kvm_add_vcpu
+
+// Post-processing code in pkg/csource/csource.go is very picky and won't let us directly pass
+// fail() to DEFINE_GUEST_FN_TO_GPA_FN.
+static inline void error_in_executor_fn_guest_addr()
+{
+ fail("SYZOS: executor_fn_guest_addr: invalid guest address");
+}
+
+DEFINE_GUEST_FN_TO_GPA_FN(executor_fn_guest_addr, X86_SYZOS_ADDR_EXECUTOR_CODE, error_in_executor_fn_guest_addr());
+
static void reset_cpu_regs(int cpufd, int cpu_id, size_t text_size)
{
struct kvm_regs regs;
@@ -890,7 +900,7 @@ static void reset_cpu_regs(int cpufd, int cpu_id, size_t text_size)
regs.rflags |= 2; // bit 1 is always set
// PC points to the relative offset of guest_main() within the guest code.
- regs.rip = X86_SYZOS_ADDR_EXECUTOR_CODE + ((uint64)guest_main - (uint64)&__start_guest);
+ regs.rip = executor_fn_guest_addr((uintptr_t)guest_main);
regs.rsp = X86_SYZOS_ADDR_STACK0;
// Pass parameters to guest_main().
regs.rdi = text_size;