Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: arm64: Duplicate hyp/timer-sr.c for VHE/nVHE

timer-sr.c contains a HVC handler for setting CNTVOFF_EL2 and two helper
functions for controlling access to physical counter. The former is used by
both VHE/nVHE and is duplicated, the latter are used only by nVHE and moved
to nvhe/timer-sr.c.

Signed-off-by: David Brazdil <dbrazdil@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20200625131420.71444-13-dbrazdil@google.com

authored by

David Brazdil and committed by
Marc Zyngier
9aebdea4 13aeb9b4

+19 -9
+2
arch/arm64/include/asm/kvm_hyp.h
··· 63 63 void __vgic_v3_restore_aprs(struct vgic_v3_cpu_if *cpu_if); 64 64 int __vgic_v3_perform_cpuif_access(struct kvm_vcpu *vcpu); 65 65 66 + #ifdef __KVM_NVHE_HYPERVISOR__ 66 67 void __timer_enable_traps(struct kvm_vcpu *vcpu); 67 68 void __timer_disable_traps(struct kvm_vcpu *vcpu); 69 + #endif 68 70 69 71 #ifdef __KVM_NVHE_HYPERVISOR__ 70 72 void __sysreg_save_state_nvhe(struct kvm_cpu_context *ctxt);
-5
arch/arm64/kernel/image-vars.h
··· 76 76 KVM_NVHE_ALIAS(__fpsimd_restore_state); 77 77 KVM_NVHE_ALIAS(__fpsimd_save_state); 78 78 79 - /* Symbols defined in timer-sr.c (not yet compiled with nVHE build rules). */ 80 - KVM_NVHE_ALIAS(__kvm_timer_set_cntvoff); 81 - KVM_NVHE_ALIAS(__timer_disable_traps); 82 - KVM_NVHE_ALIAS(__timer_enable_traps); 83 - 84 79 /* Symbols defined in vgic-v2-cpuif-proxy.c (not yet compiled with nVHE build rules). */ 85 80 KVM_NVHE_ALIAS(__vgic_v2_perform_cpuif_access); 86 81
+1 -1
arch/arm64/kvm/hyp/Makefile
··· 13 13 obj-$(CONFIG_KVM) += hyp.o vhe/ nvhe/ 14 14 obj-$(CONFIG_KVM_INDIRECT_VECTORS) += smccc_wa.o 15 15 16 - hyp-y := vgic-v3-sr.o timer-sr.o aarch32.o vgic-v2-cpuif-proxy.o entry.o \ 16 + hyp-y := vgic-v3-sr.o aarch32.o vgic-v2-cpuif-proxy.o entry.o \ 17 17 fpsimd.o 18 18 19 19 # KVM code is run at a different exception code with a different map, so
+2 -1
arch/arm64/kvm/hyp/nvhe/Makefile
··· 6 6 asflags-y := -D__KVM_NVHE_HYPERVISOR__ 7 7 ccflags-y := -D__KVM_NVHE_HYPERVISOR__ 8 8 9 - obj-y := sysreg-sr.o debug-sr.o switch.o tlb.o hyp-init.o ../hyp-entry.o 9 + obj-y := timer-sr.o sysreg-sr.o debug-sr.o switch.o tlb.o hyp-init.o \ 10 + ../hyp-entry.o 10 11 11 12 obj-y := $(patsubst %.o,%.hyp.o,$(obj-y)) 12 13 extra-y := $(patsubst %.hyp.o,%.hyp.tmp.o,$(obj-y))
+1 -1
arch/arm64/kvm/hyp/timer-sr.c arch/arm64/kvm/hyp/nvhe/timer-sr.c
··· 10 10 11 11 #include <asm/kvm_hyp.h> 12 12 13 - void __hyp_text __kvm_timer_set_cntvoff(u64 cntvoff) 13 + void __kvm_timer_set_cntvoff(u64 cntvoff) 14 14 { 15 15 write_sysreg(cntvoff, cntvoff_el2); 16 16 }
+1 -1
arch/arm64/kvm/hyp/vhe/Makefile
··· 6 6 asflags-y := -D__KVM_VHE_HYPERVISOR__ 7 7 ccflags-y := -D__KVM_VHE_HYPERVISOR__ 8 8 9 - obj-y := sysreg-sr.o debug-sr.o switch.o tlb.o ../hyp-entry.o 9 + obj-y := timer-sr.o sysreg-sr.o debug-sr.o switch.o tlb.o ../hyp-entry.o 10 10 11 11 # KVM code is run at a different exception code with a different map, so 12 12 # compiler instrumentation that inserts callbacks or checks into the code may
+12
arch/arm64/kvm/hyp/vhe/timer-sr.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (C) 2012-2015 - ARM Ltd 4 + * Author: Marc Zyngier <marc.zyngier@arm.com> 5 + */ 6 + 7 + #include <asm/kvm_hyp.h> 8 + 9 + void __kvm_timer_set_cntvoff(u64 cntvoff) 10 + { 11 + write_sysreg(cntvoff, cntvoff_el2); 12 + }