Skip to content

Commit fdef407

Browse files
executor: unify ARM64_ADDR_EXECUTOR_CODE and X86_SYZOS_ADDR_EXECUTOR_CODE
Use SYZOS_ADDR_EXECUTOR_CODE instead of both. Also put platform-specific definitions under #if GOARCH_xxx.
1 parent 78f52e6 commit fdef407

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

executor/common_kvm_amd64.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ static const struct mem_region syzos_mem_regions[] = {
230230
// SYZOS user code (generated by the fuzzer).
231231
{X86_SYZOS_ADDR_USER_CODE, KVM_MAX_VCPU, MEM_REGION_FLAG_READONLY | MEM_REGION_FLAG_USER_CODE},
232232
// Executor guest code.
233-
{X86_SYZOS_ADDR_EXECUTOR_CODE, 4, MEM_REGION_FLAG_READONLY | MEM_REGION_FLAG_EXECUTOR_CODE},
233+
{SYZOS_ADDR_EXECUTOR_CODE, 4, MEM_REGION_FLAG_READONLY | MEM_REGION_FLAG_EXECUTOR_CODE},
234234
// Scratch memory for code generated at runtime.
235235
{X86_SYZOS_ADDR_SCRATCH_CODE, 1, 0},
236236
// CPU stack.

executor/common_kvm_arm64.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static void setup_vm(int vmfd, void* host_mem, void** text_slot)
108108

109109
struct addr_size host_text = alloc_guest_mem(&allocator, 4 * KVM_PAGE_SIZE);
110110
install_syzos_code(host_text.addr, host_text.size);
111-
vm_set_user_memory_region(vmfd, slot++, KVM_MEM_READONLY, ARM64_ADDR_EXECUTOR_CODE, host_text.size, (uintptr_t)host_text.addr);
111+
vm_set_user_memory_region(vmfd, slot++, KVM_MEM_READONLY, SYZOS_ADDR_EXECUTOR_CODE, host_text.size, (uintptr_t)host_text.addr);
112112

113113
struct addr_size next = alloc_guest_mem(&allocator, 2 * KVM_PAGE_SIZE);
114114
vm_set_user_memory_region(vmfd, slot++, KVM_MEM_LOG_DIRTY_PAGES, ARM64_ADDR_DIRTY_PAGES, next.size, (uintptr_t)next.addr);

executor/kvm.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright 2017 syzkaller project authors. All rights reserved.
22
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
33

4+
// x86-specific definitions.
5+
#if GOARCH_amd64
46
#define X86_ADDR_TEXT 0x0000
57
#define X86_ADDR_PD_IOAPIC 0x0000
68
#define X86_ADDR_GDT 0x1000
@@ -33,7 +35,6 @@
3335
#define X86_ADDR_VAR_USER_CODE 0x9100
3436
#define X86_ADDR_VAR_USER_CODE2 0x9120
3537

36-
// x86 SYZOS definitions.
3738
// Zero page (0x0 - 0xfff) is deliberately unused.
3839
#define X86_SYZOS_ADDR_ZERO 0x0
3940
#define X86_SYZOS_ADDR_GDT 0x1000
@@ -52,7 +53,8 @@
5253
#define X86_SYZOS_ADDR_UEXIT (X86_SYZOS_ADDR_EXIT + 256)
5354
#define X86_SYZOS_ADDR_DIRTY_PAGES 0x41000
5455
#define X86_SYZOS_ADDR_USER_CODE 0x50000
55-
#define X86_SYZOS_ADDR_EXECUTOR_CODE 0x54000
56+
// Location of the SYZOS guest code. Name shared with ARM64 SYZOS.
57+
#define SYZOS_ADDR_EXECUTOR_CODE 0x54000
5658
#define X86_SYZOS_ADDR_SCRATCH_CODE 0x58000
5759
#define X86_SYZOS_ADDR_STACK_BOTTOM 0x90000
5860
#define X86_SYZOS_ADDR_STACK0 0x90f80
@@ -163,6 +165,7 @@
163165

164166
#define X86_NEXT_INSN $0xbadc0de
165167
#define X86_PREFIX_SIZE 0xba1d
168+
#endif // x86-specific definitions.
166169

167170
#define KVM_MAX_VCPU 4
168171
#define KVM_PAGE_SIZE (1 << 12)
@@ -174,6 +177,8 @@
174177
(((~0ULL) - (1ULL << (l)) + 1ULL) & \
175178
(~0ULL >> (63 - (h))))
176179

180+
// ARM64 SYZOS definitions.
181+
#if GOARCH_arm64
177182
// GICv3 distributor address.
178183
#define ARM64_ADDR_GICD_BASE 0x08000000
179184
// GICv3 ITS address.
@@ -188,7 +193,8 @@
188193
// Two writable pages with KVM_MEM_LOG_DIRTY_PAGES explicitly set.
189194
#define ARM64_ADDR_DIRTY_PAGES 0xdddd1000
190195
#define ARM64_ADDR_USER_CODE 0xeeee0000
191-
#define ARM64_ADDR_EXECUTOR_CODE 0xeeee8000
196+
// Location of the SYZOS guest code. Name shared with x86 SYZOS.
197+
#define SYZOS_ADDR_EXECUTOR_CODE 0xeeee8000
192198
#define ARM64_ADDR_SCRATCH_CODE 0xeeef0000
193199
#define ARM64_ADDR_EL1_STACK_BOTTOM 0xffff1000
194200

@@ -201,3 +207,5 @@
201207
#define ARM64_ADDR_ITS_ITT_TABLES (ARM64_ADDR_ITS_CMDQ_BASE + SZ_64K)
202208
#define ARM64_ADDR_ITS_PROP_TABLE (ARM64_ADDR_ITS_ITT_TABLES + SZ_64K * ITS_MAX_DEVICES)
203209
#define ARM64_ADDR_ITS_PEND_TABLES (ARM64_ADDR_ITS_PROP_TABLE + SZ_64K)
210+
211+
#endif // ARM64 SYZOS definitions

0 commit comments

Comments
 (0)