Re: [PATCH v7 16/25] arm: Add support for generic vDSO (causing crash)

Philippe Mathieu-Daudé
2019-12-05T09:42:53Z

On Wed, Dec 4, 2019 at 6:23 PM Vincenzo Frascino
<vincenzo.frascino@arm.com> wrote:
> On 12/4/19 4:16 PM, Guenter Roeck wrote:
[...]
> --->8---
>
> Author: Vincenzo Frascino <vincenzo.frascino@arm.com>
> Date: Wed Dec 4 16:58:55 2019 +0000
>
> arm: Fix __arch_get_hw_counter() access to CNTVCT
>
> __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.
>
> Cc: Russell King <linux@armlinux.org.uk>
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> Investigated-by: Arnd Bergmann <arnd@arndb.de>

There are only 2 "Investigated-by" vs 7k+ "Suggested-by"... Is there a
real difference?

> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
>
> 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;
> +

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> isb();
> cycle_now = read_sysreg(CNTVCT);
>
>