aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorWill Deacon <will.deacon@arm.com>2012-11-29 17:48:31 -0500
committerCatalin Marinas <catalin.marinas@arm.com>2012-12-05 06:20:04 -0500
commit1f75ff0a3d63606c1345e316e88a903fd43ca8be (patch)
treed326cb2f58040c910390e80f5a5287b0074a0276 /arch
parent45a7905fc48f6079932e77d64237cf7f008db5f4 (diff)
arm64: generic timer: use virtual counter instead of physical at EL0
We want to use the virtual counter at EL0, as the physical counter may not track the current clocksource for guests running under a hypervisor. This patch updates the vdso and generic timer driver to use the virtual counter. The kernel EL2 entry code is also updated to ensure that the virtual offset is initialised to zero. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm64/include/asm/arm_generic.h8
-rw-r--r--arch/arm64/kernel/head.S1
-rw-r--r--arch/arm64/kernel/vdso/gettimeofday.S4
3 files changed, 7 insertions, 6 deletions
diff --git a/arch/arm64/include/asm/arm_generic.h b/arch/arm64/include/asm/arm_generic.h
index e4cec9d30f27..df2aeb82f74e 100644
--- a/arch/arm64/include/asm/arm_generic.h
+++ b/arch/arm64/include/asm/arm_generic.h
@@ -70,12 +70,12 @@ static inline void __cpuinit arch_counter_enable_user_access(void)
70{ 70{
71 u32 cntkctl; 71 u32 cntkctl;
72 72
73 /* Disable user access to the timers and the virtual counter. */ 73 /* Disable user access to the timers and the physical counter. */
74 asm volatile("mrs %0, cntkctl_el1" : "=r" (cntkctl)); 74 asm volatile("mrs %0, cntkctl_el1" : "=r" (cntkctl));
75 cntkctl &= ~((3 << 8) | (1 << 1)); 75 cntkctl &= ~((3 << 8) | (1 << 0));
76 76
77 /* Enable user access to the physical counter and frequency. */ 77 /* Enable user access to the virtual counter and frequency. */
78 cntkctl |= 1; 78 cntkctl |= (1 << 1);
79 asm volatile("msr cntkctl_el1, %0" : : "r" (cntkctl)); 79 asm volatile("msr cntkctl_el1, %0" : : "r" (cntkctl));
80} 80}
81 81
diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index a2f02b63eae9..90dec55b17a2 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -158,6 +158,7 @@ ENTRY(el2_setup)
158 mrs x0, cnthctl_el2 158 mrs x0, cnthctl_el2
159 orr x0, x0, #3 // Enable EL1 physical timers 159 orr x0, x0, #3 // Enable EL1 physical timers
160 msr cnthctl_el2, x0 160 msr cnthctl_el2, x0
161 msr cntvoff_el2, xzr // Clear virtual offset
161 162
162 /* Populate ID registers. */ 163 /* Populate ID registers. */
163 mrs x0, midr_el1 164 mrs x0, midr_el1
diff --git a/arch/arm64/kernel/vdso/gettimeofday.S b/arch/arm64/kernel/vdso/gettimeofday.S
index 6681f4032260..8bf658d974f9 100644
--- a/arch/arm64/kernel/vdso/gettimeofday.S
+++ b/arch/arm64/kernel/vdso/gettimeofday.S
@@ -220,9 +220,9 @@ ENTRY(__do_get_tspec)
220 ldp w11, w12, [vdso_data, #VDSO_CS_MULT] 220 ldp w11, w12, [vdso_data, #VDSO_CS_MULT]
221 seqcnt_read w9 221 seqcnt_read w9
222 222
223 /* Read the physical counter. */ 223 /* Read the virtual counter. */
224 isb 224 isb
225 mrs x15, cntpct_el0 225 mrs x15, cntvct_el0
226 226
227 /* Calculate cycle delta and convert to ns. */ 227 /* Calculate cycle delta and convert to ns. */
228 sub x10, x15, x10 228 sub x10, x15, x10