Skip to content

Commit 9e7462b

Browse files
Marc Zyngieroupton
authored andcommitted
arm64: Allow EL1 physical timer access when running VHE
To initialise the timer access from EL2 when HCR_EL2.E2H is set, we must make use the CNTHCTL_EL2 formap used is appropriate. This amounts to shifting the timer/counter enable bits by 10 to the left. Signed-off-by: Marc Zyngier <maz@kernel.org> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Link: https://lore.kernel.org/r/20230609162200.2024064-7-maz@kernel.org Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
1 parent 7a26e1f commit 9e7462b

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

arch/arm64/include/asm/el2_setup.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
*/
3535
.macro __init_el2_timers
3636
mov x0, #3 // Enable EL1 physical timers
37+
mrs x1, hcr_el2
38+
and x1, x1, #HCR_E2H
39+
cbz x1, .LnVHE_\@
40+
lsl x0, x0, #10
41+
.LnVHE_\@:
3742
msr cnthctl_el2, x0
3843
msr cntvoff_el2, xzr // Clear virtual offset
3944
.endm

arch/arm64/kvm/hyp/nvhe/hyp-init.S

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ SYM_CODE_START_LOCAL(___kvm_hyp_init)
9595
ldr x1, [x0, #NVHE_INIT_HCR_EL2]
9696
msr hcr_el2, x1
9797

98+
mov x2, #HCR_E2H
99+
and x2, x1, x2
100+
cbz x2, 1f
101+
102+
mrs x1, cnthctl_el2
103+
and x1, x1, #~(BIT(0) | BIT(1))
104+
orr x1, x1, #(BIT(10) | BIT(11))
105+
msr cnthctl_el2, x1
106+
1:
98107
ldr x1, [x0, #NVHE_INIT_VTTBR]
99108
msr vttbr_el2, x1
100109

0 commit comments

Comments
 (0)