1
0
Fork 0
alistair23-linux/drivers/clocksource
Daniel Lezcano e0aeca3d8c clocksource/drivers/stm32: Fix kernel panic with multiple timers
The current code hides a couple of bugs:

 - The global variable 'clock_event_ddata' is overwritten each time the
   init function is invoked.

This is fixed with a kmemdup() instead of assigning the global variable. That
prevents a memory corruption when several timers are defined in the DT.

 - The clockevent's event_handler is NULL if the time framework does
   not select the clockevent when registering it, this is fine but the init
   code generates in any case an interrupt leading to dereference this
   NULL pointer.

The stm32 timer works with shadow registers, a mechanism to cache the
registers. When a change is done in one buffered register, we need to
artificially generate an event to force the timer to copy the content
of the register to the shadowed register.

The auto-reload register (ARR) is one of the shadowed register as well as
the prescaler register (PSC), so in order to force the copy, we issue an
event which in turn leads to an interrupt and the NULL dereference.

This is fixed by inverting two lines where we clear the status register
before enabling the update event interrupt.

As this kernel crash is resulting from the combination of these two bugs,
the fixes are grouped into a single patch.

Tested-by: Benjamin Gaignard <benjamin.gaignard@st.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Benjamin Gaignard <benjamin.gaignard@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/1515418139-23276-11-git-send-email-daniel.lezcano@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2018-01-08 17:57:25 +01:00
..
Kconfig clocksource/drivers/spreadtrum: Add timer driver for the Spreadtrum SC9860 platform 2018-01-08 17:57:24 +01:00
Makefile clocksource/drivers/spreadtrum: Add timer driver for the Spreadtrum SC9860 platform 2018-01-08 17:57:24 +01:00
acpi_pm.c clocksource: Use a plain u64 instead of cycle_t 2016-12-25 11:04:12 +01:00
arc_timer.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
arm_arch_timer.c First batch of KVM changes for 4.15 2017-11-16 13:00:24 -08:00
arm_global_timer.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
armv7m_systick.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
asm9260_timer.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
bcm2835_timer.c locking/atomics: COCCINELLE/treewide: Convert trivial ACCESS_ONCE() patterns to READ_ONCE()/WRITE_ONCE() 2017-10-25 11:01:08 +02:00
bcm_kona_timer.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
cadence_ttc_timer.c Merge branch 'timers/urgent' into timers/core 2017-06-21 09:07:52 +02:00
clksrc-dbx500-prcmu.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
clksrc_st_lpc.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
clps711x-timer.c clocksource/drivers: Rename CLKSRC_OF to TIMER_OF 2017-06-14 12:01:03 +02:00
cs5535-clockevt.c clockevents/drivers/cs5535: Improve resilience to spurious interrupts 2017-10-20 13:41:52 +02:00
dummy_timer.c cpu/hotplug: Cleanup state names 2016-12-25 10:47:44 +01:00
dw_apb_timer.c Merge branch 'clockevents/4.12' of https://git.linaro.org/people/daniel.lezcano/linux into timers/core 2017-04-17 10:55:14 +02:00
dw_apb_timer_of.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
em_sti.c clocksource/drivers/em_sti: Fix error return codes in em_sti_probe() 2017-08-10 14:48:18 +02:00
exynos_mct.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
fsl_ftm_timer.c clocksource/drivers/fsl_ftm_timer: Unmap region obtained by of_iomap 2017-06-27 11:25:39 +02:00
h8300_timer8.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
h8300_timer16.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
h8300_tpu.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
i8253.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
jcore-pit.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
meson6_timer.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
metag_generic.c clockevents/drivers/metag: Set ->min_delta_ticks and ->max_delta_ticks 2017-04-14 13:11:13 -07:00
mips-gic-timer.c clocksource/drivers/mips-gic-timer: Add fastpath for local timer updates 2017-10-19 23:51:31 +02:00
mmio.c clocksource: Use a plain u64 instead of cycle_t 2016-12-25 11:04:12 +01:00
mps2-timer.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
mtk_timer.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
mxs_timer.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
nomadik-mtu.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
numachip.c x86/numachip: Add const and __initconst to numachip2_clockevent 2017-09-25 09:36:15 +02:00
owl-timer.c clocksource/drivers/owl: Add the S700 timer 2018-01-08 17:57:23 +01:00
pxa_timer.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
qcom-timer.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
renesas-ostm.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
rockchip_timer.c clocksource/drivers/rockchip: pr_err() strings should end with newlines 2017-10-19 23:49:02 +02:00
samsung_pwm_timer.c clocksource/drivers: Rename CLKSRC_OF to TIMER_OF 2017-06-14 12:01:03 +02:00
scx200_hrt.c clocksource: Use a plain u64 instead of cycle_t 2016-12-25 11:04:12 +01:00
sh_cmt.c clocksource/drivers/sh_cmt: Use of_device_get_match_data() helper 2017-10-19 23:48:59 +02:00
sh_mtu2.c clocksource/drivers/sh_mtu2: Fix multiple shutdown call issue 2015-10-28 15:22:56 +01:00
sh_tmu.c clocksource: sh_tmu: Compute rate before registration again 2017-03-23 12:14:01 -07:00
sun4i_timer.c clocksource/drivers/sun4i: Switch to the timer-of common init 2017-06-26 18:32:04 +02:00
tango_xtal.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
tcb_clksrc.c clocksource/drivers/tcb_clksrc: Fix clock speed message 2018-01-08 17:57:23 +01:00
tegra20_timer.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
time-armada-370-xp.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
time-efm32.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
time-lpc32xx.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
time-orion.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
time-pistachio.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
timer-atlas7.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
timer-atmel-pit.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
timer-atmel-st.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
timer-digicolor.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
timer-fttmr010.c Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2017-11-13 17:56:58 -08:00
timer-imx-gpt.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
timer-imx-tpm.c clocksource/drivers/imx-tpm: Add imx tpm timer support 2017-08-29 11:07:56 +02:00
timer-integrator-ap.c clocksource/integrator: Fix section mismatch warning 2017-09-18 09:37:33 +02:00
timer-keystone.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
timer-nps.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
timer-of.c clocksource/drivers/timer-of: Don't request the resource by name 2018-01-08 17:57:24 +01:00
timer-of.h clocksource/drivers/timer-of: Store the device node pointer in 'struct timer_of' 2018-01-08 17:57:24 +01:00
timer-oxnas-rps.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
timer-prima2.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
timer-probe.c clocksource: Convert to using %pOF instead of full_name 2017-08-31 15:56:17 +02:00
timer-sp.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
timer-sp804.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
timer-sprd.c clocksource/drivers/spreadtrum: Add timer driver for the Spreadtrum SC9860 platform 2018-01-08 17:57:24 +01:00
timer-stm32.c clocksource/drivers/stm32: Fix kernel panic with multiple timers 2018-01-08 17:57:25 +01:00
timer-sun5i.c Merge branch 'timers/urgent' into timers/core 2017-06-21 09:07:52 +02:00
timer-ti-32k.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
timer-u300.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
versatile.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
vf_pit_timer.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
vt8500_timer.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00
zevio-timer.c clocksource/drivers: Rename CLOCKSOURCE_OF_DECLARE to TIMER_OF_DECLARE 2017-06-14 11:58:45 +02:00