Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clocksource: arm_arch_timer: Enable counter access for 32-bit ARM

The only difference between arm and arm64's implementations of
arch_counter_set_user_access is that 32-bit ARM does not enable user
access to the virtual counter. We want to enable this access for the
32-bit ARM VDSO, so copy the arm64 version to the driver itself, and
remove the arch-specific implementations.

Signed-off-by: Nathan Lynch <nathan_lynch@mentor.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Will Deacon <will.deacon@arm.com>

authored by

Nathan Lynch and committed by
Daniel Lezcano
8b8dde00 423bd69e

+17 -31
-14
arch/arm/include/asm/arch_timer.h
··· 99 99 asm volatile("mcr p15, 0, %0, c14, c1, 0" : : "r" (cntkctl)); 100 100 } 101 101 102 - static inline void arch_counter_set_user_access(void) 103 - { 104 - u32 cntkctl = arch_timer_get_cntkctl(); 105 - 106 - /* Disable user access to both physical/virtual counters/timers */ 107 - /* Also disable virtual event stream */ 108 - cntkctl &= ~(ARCH_TIMER_USR_PT_ACCESS_EN 109 - | ARCH_TIMER_USR_VT_ACCESS_EN 110 - | ARCH_TIMER_VIRT_EVT_EN 111 - | ARCH_TIMER_USR_VCT_ACCESS_EN 112 - | ARCH_TIMER_USR_PCT_ACCESS_EN); 113 - arch_timer_set_cntkctl(cntkctl); 114 - } 115 - 116 102 static inline void arch_timer_evtstrm_enable(int divider) 117 103 { 118 104 u32 cntkctl = arch_timer_get_cntkctl();
-17
arch/arm64/include/asm/arch_timer.h
··· 104 104 asm volatile("msr cntkctl_el1, %0" : : "r" (cntkctl)); 105 105 } 106 106 107 - static inline void arch_counter_set_user_access(void) 108 - { 109 - u32 cntkctl = arch_timer_get_cntkctl(); 110 - 111 - /* Disable user access to the timers and the physical counter */ 112 - /* Also disable virtual event stream */ 113 - cntkctl &= ~(ARCH_TIMER_USR_PT_ACCESS_EN 114 - | ARCH_TIMER_USR_VT_ACCESS_EN 115 - | ARCH_TIMER_VIRT_EVT_EN 116 - | ARCH_TIMER_USR_PCT_ACCESS_EN); 117 - 118 - /* Enable user access to the virtual counter */ 119 - cntkctl |= ARCH_TIMER_USR_VCT_ACCESS_EN; 120 - 121 - arch_timer_set_cntkctl(cntkctl); 122 - } 123 - 124 107 static inline void arch_timer_evtstrm_enable(int divider) 125 108 { 126 109 u32 cntkctl = arch_timer_get_cntkctl();
+17
drivers/clocksource/arm_arch_timer.c
··· 312 312 arch_timer_evtstrm_enable(min(pos, 15)); 313 313 } 314 314 315 + static void arch_counter_set_user_access(void) 316 + { 317 + u32 cntkctl = arch_timer_get_cntkctl(); 318 + 319 + /* Disable user access to the timers and the physical counter */ 320 + /* Also disable virtual event stream */ 321 + cntkctl &= ~(ARCH_TIMER_USR_PT_ACCESS_EN 322 + | ARCH_TIMER_USR_VT_ACCESS_EN 323 + | ARCH_TIMER_VIRT_EVT_EN 324 + | ARCH_TIMER_USR_PCT_ACCESS_EN); 325 + 326 + /* Enable user access to the virtual counter */ 327 + cntkctl |= ARCH_TIMER_USR_VCT_ACCESS_EN; 328 + 329 + arch_timer_set_cntkctl(cntkctl); 330 + } 331 + 315 332 static int arch_timer_setup(struct clock_event_device *clk) 316 333 { 317 334 __arch_timer_setup(ARCH_CP15_TIMER, clk);