diff options
| author | Alexander Potapenko <glider@google.com> | 2025-09-30 11:02:37 +0200 |
|---|---|---|
| committer | Alexander Potapenko <glider@google.com> | 2025-10-17 06:51:20 +0000 |
| commit | 6ca4530067ac25a78291b176b6d3dbe6ba592d15 (patch) | |
| tree | 731490cefa5b43b5ccf48f83f77979a829da72c0 /executor/common_kvm_arm64.h | |
| parent | 554d3ef1c24ae1bc3c8c439e8c8f3a9006434244 (diff) | |
executor: introduce DEFINE_GUEST_FN_TO_GPA_FN()
DEFINE_GUEST_FN_TO_GPA_FN() allows to define helper functions to
calculate guest addresses in the host/guest code.
Diffstat (limited to 'executor/common_kvm_arm64.h')
| -rw-r--r-- | executor/common_kvm_arm64.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/executor/common_kvm_arm64.h b/executor/common_kvm_arm64.h index 4428a3484..badfcf417 100644 --- a/executor/common_kvm_arm64.h +++ b/executor/common_kvm_arm64.h @@ -144,11 +144,20 @@ static void vcpu_set_reg(int vcpu_fd, uint64 id, uint64 val) ioctl(vcpu_fd, KVM_SET_ONE_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, ARM64_ADDR_EXECUTOR_CODE + ((uint64)guest_main - (uint64)&__start_guest)); + vcpu_set_reg(cpufd, KVM_ARM64_REGS_PC, executor_fn_guest_addr((uintptr_t)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); |
