]> Pileus Git - ~andy/linux/commitdiff
arm64: generic timer: use virtual counter instead of physical at EL0
authorWill Deacon <will.deacon@arm.com>
Thu, 29 Nov 2012 22:48:31 +0000 (22:48 +0000)
committerCatalin Marinas <catalin.marinas@arm.com>
Wed, 5 Dec 2012 11:20:04 +0000 (11:20 +0000)
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>
arch/arm64/include/asm/arm_generic.h
arch/arm64/kernel/head.S
arch/arm64/kernel/vdso/gettimeofday.S
drivers/clocksource/arm_generic.c

index e4cec9d30f275b501af9fe73437c222340246489..df2aeb82f74e5b57cdb5dddf38b86d812b7415b1 100644 (file)
@@ -70,12 +70,12 @@ static inline void __cpuinit arch_counter_enable_user_access(void)
 {
        u32 cntkctl;
 
-       /* Disable user access to the timers and the virtual counter. */
+       /* Disable user access to the timers and the physical counter. */
        asm volatile("mrs       %0, cntkctl_el1" : "=r" (cntkctl));
-       cntkctl &= ~((3 << 8) | (1 << 1));
+       cntkctl &= ~((3 << 8) | (1 << 0));
 
-       /* Enable user access to the physical counter and frequency. */
-       cntkctl |= 1;
+       /* Enable user access to the virtual counter and frequency. */
+       cntkctl |= (1 << 1);
        asm volatile("msr       cntkctl_el1, %0" : : "r" (cntkctl));
 }
 
index a2f02b63eae9e2f5361aa0ee0200dd6fe71e87e4..90dec55b17a2bf32cc0ebd8db8f00e1230d26a8d 100644 (file)
@@ -158,6 +158,7 @@ ENTRY(el2_setup)
        mrs     x0, cnthctl_el2
        orr     x0, x0, #3                      // Enable EL1 physical timers
        msr     cnthctl_el2, x0
+       msr     cntvoff_el2, xzr                // Clear virtual offset
 
        /* Populate ID registers. */
        mrs     x0, midr_el1
index 6681f4032260cc0ab7aa3cf9ea204b85b96ff902..8bf658d974f947da714eb5e7a6812552173fe140 100644 (file)
@@ -220,9 +220,9 @@ ENTRY(__do_get_tspec)
        ldp     w11, w12, [vdso_data, #VDSO_CS_MULT]
        seqcnt_read w9
 
-       /* Read the physical counter. */
+       /* Read the virtual counter. */
        isb
-       mrs     x15, cntpct_el0
+       mrs     x15, cntvct_el0
 
        /* Calculate cycle delta and convert to ns. */
        sub     x10, x15, x10
index c4d9f9566c649ae3d8623493901e5b9302f59f66..df5d7e8e5b8472aef58e2946250e36a943c4d863 100644 (file)
@@ -109,7 +109,7 @@ static void __cpuinit arch_timer_setup(struct clock_event_device *clk)
 
        enable_percpu_irq(clk->irq, 0);
 
-       /* Ensure the physical counter is visible to userspace for the vDSO. */
+       /* Ensure the virtual counter is visible to userspace for the vDSO. */
        arch_counter_enable_user_access();
 }