aboutsummaryrefslogtreecommitdiffstats
path: root/executor/common_kvm_arm64.h
diff options
context:
space:
mode:
authorAlexander Potapenko <glider@google.com>2025-10-14 13:20:39 +0200
committerAlexander Potapenko <glider@google.com>2025-10-17 06:51:20 +0000
commite18aa5057febfc3f9f61c8755234e361528def0e (patch)
tree49bb7b0dd0b2841fca59d6eb23f49818332cdf81 /executor/common_kvm_arm64.h
parentbc0cbe5709e294d9755f481e7f41be68413e14f9 (diff)
executor: introduce __addrspace_guest
Apply __addrspace_guest to every guest function and use a C++ template to statically validate that host functions are not passed to executor_fn_guest_addr(). This only works in Clang builds of syz-executor, because GCC does not support address spaces, and C reproducers cannot use templates. The static check allows us to drop the dynamic checks in DEFINE_GUEST_FN_TO_GPA_FN(). While at it, replace DEFINE_GUEST_FN_TO_GPA_FN() with explicit declarations of host_fn_guest_addr() and guest_fn_guest_addr().
Diffstat (limited to 'executor/common_kvm_arm64.h')
-rw-r--r--executor/common_kvm_arm64.h11
1 files changed, 1 insertions, 10 deletions
diff --git a/executor/common_kvm_arm64.h b/executor/common_kvm_arm64.h
index 0837017ef..8c02b0745 100644
--- a/executor/common_kvm_arm64.h
+++ b/executor/common_kvm_arm64.h
@@ -144,20 +144,11 @@ static void vcpu_set_reg(int vcpu_fd, uint64 id, uint64 val)
ioctl(vcpu_fd, KVM_SET_ONE_REG, &reg);
}
-// 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, ARM64_ADDR_EXECUTOR_CODE, error_in_executor_fn_guest_addr());
-
// Set up CPU registers.
static void reset_cpu_regs(int cpufd, int cpu_id, size_t text_size)
{
// PC points to the relative offset of guest_main() within the guest code.
- vcpu_set_reg(cpufd, KVM_ARM64_REGS_PC, executor_fn_guest_addr((uintptr_t)guest_main));
+ vcpu_set_reg(cpufd, KVM_ARM64_REGS_PC, executor_fn_guest_addr(guest_main));
vcpu_set_reg(cpufd, KVM_ARM64_REGS_SP_EL1, ARM64_ADDR_EL1_STACK_BOTTOM + KVM_PAGE_SIZE - 128);
// Store the CPU ID in TPIDR_EL1.
vcpu_set_reg(cpufd, KVM_ARM64_REGS_TPIDR_EL1, cpu_id);