Skip to content

Commit 9e01dc7

Browse files
christofferdall-armMarc Zyngier
authored andcommitted
KVM: arm/arm64: arch_timer: Assign the phys timer on VHE systems
VHE systems don't have to emulate the physical timer, we can simply assign the EL1 physical timer directly to the VM as the host always uses the EL2 timers. In order to minimize the amount of cruft, AArch32 gets definitions for the physical timer too, but is should be generally unused on this architecture. Co-written with Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Christoffer Dall <christoffer.dall@arm.com>
1 parent e604dd5 commit 9e01dc7

3 files changed

Lines changed: 180 additions & 49 deletions

File tree

‎arch/arm/include/asm/kvm_hyp.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#define TTBR1 __ACCESS_CP15_64(1, c2)
4141
#define VTTBR __ACCESS_CP15_64(6, c2)
4242
#define PAR __ACCESS_CP15_64(0, c7)
43+
#define CNTP_CVAL __ACCESS_CP15_64(2, c14)
4344
#define CNTV_CVAL __ACCESS_CP15_64(3, c14)
4445
#define CNTVOFF __ACCESS_CP15_64(4, c14)
4546

@@ -85,6 +86,7 @@
8586
#define TID_PRIV __ACCESS_CP15(c13, 0, c0, 4)
8687
#define HTPIDR __ACCESS_CP15(c13, 4, c0, 2)
8788
#define CNTKCTL __ACCESS_CP15(c14, 0, c1, 0)
89+
#define CNTP_CTL __ACCESS_CP15(c14, 0, c2, 1)
8890
#define CNTV_CTL __ACCESS_CP15(c14, 0, c3, 1)
8991
#define CNTHCTL __ACCESS_CP15(c14, 4, c1, 0)
9092

@@ -94,6 +96,8 @@
9496
#define read_sysreg_el0(r) read_sysreg(r##_el0)
9597
#define write_sysreg_el0(v, r) write_sysreg(v, r##_el0)
9698

99+
#define cntp_ctl_el0 CNTP_CTL
100+
#define cntp_cval_el0 CNTP_CVAL
97101
#define cntv_ctl_el0 CNTV_CTL
98102
#define cntv_cval_el0 CNTV_CVAL
99103
#define cntvoff_el2 CNTVOFF

‎include/kvm/arm_arch_timer.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ struct arch_timer_context {
5050

5151
/* Emulated Timer (may be unused) */
5252
struct hrtimer hrtimer;
53+
54+
/* Duplicated state from arch_timer.c for convenience */
55+
u32 host_timer_irq;
56+
u32 host_timer_irq_flags;
5357
};
5458

5559
struct arch_timer_cpu {
@@ -104,6 +108,8 @@ bool kvm_arch_timer_get_input_level(int vintid);
104108
#define vcpu_vtimer(v) (&(v)->arch.timer_cpu.timers[TIMER_VTIMER])
105109
#define vcpu_ptimer(v) (&(v)->arch.timer_cpu.timers[TIMER_PTIMER])
106110

111+
#define arch_timer_ctx_index(ctx) ((ctx) - vcpu_timer((ctx)->vcpu)->timers)
112+
107113
u64 kvm_arm_timer_read_sysreg(struct kvm_vcpu *vcpu,
108114
enum kvm_arch_timers tmr,
109115
enum kvm_arch_timer_regs treg);

0 commit comments

Comments
 (0)