From 8e1f73a21d7d2105769794082be772e51abe2360 Mon Sep 17 00:00:00 2001 From: Alexander Potapenko Date: Tue, 24 Sep 2024 17:42:38 +0200 Subject: executor: arm64: store CPU ID in TPIDR_EL1 Let SYZOS distinguish CPUs inside VM by storing their ID in TPIDR_EL1. Make sure existing code uses that ID: - in guest_handle_msr(), to ensure concurrent calls do not write to the same cache line; - in gicv3_irq_enable(), to ensure proper CPU ID is being used for IRQ setup. --- executor/common_kvm_arm64.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'executor/common_kvm_arm64.h') diff --git a/executor/common_kvm_arm64.h b/executor/common_kvm_arm64.h index ea1305ed7..9bedf5478 100644 --- a/executor/common_kvm_arm64.h +++ b/executor/common_kvm_arm64.h @@ -23,6 +23,7 @@ #define KVM_ARM64_REGS_X1 0x6030000000100002UL #define KVM_ARM64_REGS_PC 0x6030000000100040UL #define KVM_ARM64_REGS_SP_EL1 0x6030000000100044UL +#define KVM_ARM64_REGS_TPIDR_EL1 0x603000000013c684 struct kvm_text { uintptr_t typ; @@ -120,6 +121,8 @@ 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_SP_EL1, ARM64_ADDR_EL1_STACK_BOTTOM + SYZ_KVM_PAGE_SIZE - 128); + // Store the CPU ID in TPIDR_EL1. + vcpu_set_reg(cpufd, KVM_ARM64_REGS_TPIDR_EL1, cpu_id); // Pass parameters to guest_main(). vcpu_set_reg(cpufd, KVM_ARM64_REGS_X0, text_size); vcpu_set_reg(cpufd, KVM_ARM64_REGS_X1, cpu_id); -- cgit mrf-deployment