Skip to content

Commit 9aebdea

Browse files
David BrazdilMarc Zyngier
authored andcommitted
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 <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 13aeb9b commit 9aebdea

File tree

7 files changed

+19
-9
lines changed

7 files changed

+19
-9
lines changed

arch/arm64/include/asm/kvm_hyp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ void __vgic_v3_save_aprs(struct vgic_v3_cpu_if *cpu_if);
6363
void __vgic_v3_restore_aprs(struct vgic_v3_cpu_if *cpu_if);
6464
int __vgic_v3_perform_cpuif_access(struct kvm_vcpu *vcpu);
6565

66+
#ifdef __KVM_NVHE_HYPERVISOR__
6667
void __timer_enable_traps(struct kvm_vcpu *vcpu);
6768
void __timer_disable_traps(struct kvm_vcpu *vcpu);
69+
#endif
6870

6971
#ifdef __KVM_NVHE_HYPERVISOR__
7072
void __sysreg_save_state_nvhe(struct kvm_cpu_context *ctxt);

arch/arm64/kernel/image-vars.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@ KVM_NVHE_ALIAS(abort_guest_exit_start);
7676
KVM_NVHE_ALIAS(__fpsimd_restore_state);
7777
KVM_NVHE_ALIAS(__fpsimd_save_state);
7878

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-
8479
/* Symbols defined in vgic-v2-cpuif-proxy.c (not yet compiled with nVHE build rules). */
8580
KVM_NVHE_ALIAS(__vgic_v2_perform_cpuif_access);
8681

arch/arm64/kvm/hyp/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ subdir-ccflags-y := -I$(incdir) \
1313
obj-$(CONFIG_KVM) += hyp.o vhe/ nvhe/
1414
obj-$(CONFIG_KVM_INDIRECT_VECTORS) += smccc_wa.o
1515

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 \
1717
fpsimd.o
1818

1919
# KVM code is run at a different exception code with a different map, so

arch/arm64/kvm/hyp/nvhe/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
asflags-y := -D__KVM_NVHE_HYPERVISOR__
77
ccflags-y := -D__KVM_NVHE_HYPERVISOR__
88

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
1011

1112
obj-y := $(patsubst %.o,%.hyp.o,$(obj-y))
1213
extra-y := $(patsubst %.hyp.o,%.hyp.tmp.o,$(obj-y))

arch/arm64/kvm/hyp/timer-sr.c renamed to arch/arm64/kvm/hyp/nvhe/timer-sr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include <asm/kvm_hyp.h>
1212

13-
void __hyp_text __kvm_timer_set_cntvoff(u64 cntvoff)
13+
void __kvm_timer_set_cntvoff(u64 cntvoff)
1414
{
1515
write_sysreg(cntvoff, cntvoff_el2);
1616
}

arch/arm64/kvm/hyp/vhe/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
asflags-y := -D__KVM_VHE_HYPERVISOR__
77
ccflags-y := -D__KVM_VHE_HYPERVISOR__
88

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
1010

1111
# KVM code is run at a different exception code with a different map, so
1212
# compiler instrumentation that inserts callbacks or checks into the code may

arch/arm64/kvm/hyp/vhe/timer-sr.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/*
3+
* Copyright (C) 2012-2015 - ARM Ltd
4+
* Author: Marc Zyngier <[email protected]>
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+
}

0 commit comments

Comments
 (0)