From 04bb96427d4ee33fbdf15648ddf578c6ba1aef54 Mon Sep 17 00:00:00 2001 From: Vincenzo Frascino Date: Thu, 5 Dec 2019 11:04:51 +0100 Subject: ARM: 8947/1: Fix __arch_get_hw_counter() access to CNTVCT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit __arch_get_hw_counter() should check clock_mode to see if it can access CNTVCT. With the conversion to unified vDSO this check has been left out. This causes on imx v6 and v7 (imx_v6_v7_defconfig) and other platforms to hang at boot during the execution of the init process as per below: [ 19.976852] Run /sbin/init as init process [ 20.044931] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000004 Fix the problem verifying that clock_mode is set coherently before accessing CNTVCT. Investigated-by: Arnd Bergmann Reported-by: Guenter Roeck Tested-by: Guenter Roeck Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Vincenzo Frascino Signed-off-by: Russell King --- arch/arm/include/asm/vdso/gettimeofday.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/include/asm/vdso/gettimeofday.h b/arch/arm/include/asm/vdso/gettimeofday.h index 5b879ae7afc1..0ad2429c324f 100644 --- a/arch/arm/include/asm/vdso/gettimeofday.h +++ b/arch/arm/include/asm/vdso/gettimeofday.h @@ -75,6 +75,9 @@ static __always_inline u64 __arch_get_hw_counter(int clock_mode) #ifdef CONFIG_ARM_ARCH_TIMER u64 cycle_now; + if (!clock_mode) + return -EINVAL; + isb(); cycle_now = read_sysreg(CNTVCT); -- cgit