]> git.baikalelectronics.ru Git - kernel.git/commit
arm64: arch_timer: Ensure counter register reads occur with seqlock held
authorWill Deacon <will.deacon@arm.com>
Mon, 29 Apr 2019 16:26:22 +0000 (17:26 +0100)
committerWill Deacon <will.deacon@arm.com>
Tue, 30 Apr 2019 10:04:23 +0000 (11:04 +0100)
commitadf35f1e3a4d954c6b292cdba545ae277cbdffef
tree7886de29f3a9a5e2b0b02e71b4bdaa93a3c6fffe
parent0a8be4b88a33ee354f0132c46f2fd6ead4c8cf58
arm64: arch_timer: Ensure counter register reads occur with seqlock held

When executing clock_gettime(), either in the vDSO or via a system call,
we need to ensure that the read of the counter register occurs within
the seqlock reader critical section. This ensures that updates to the
clocksource parameters (e.g. the multiplier) are consistent with the
counter value and therefore avoids the situation where time appears to
go backwards across multiple reads.

Extend the vDSO logic so that the seqlock critical section covers the
read of the counter register as well as accesses to the data page. Since
reads of the counter system registers are not ordered by memory barrier
instructions, introduce dependency ordering from the counter read to a
subsequent memory access so that the seqlock memory barriers apply to
the counter access in both the vDSO and the system call paths.

Cc: <stable@vger.kernel.org>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Link: https://lore.kernel.org/linux-arm-kernel/alpine.DEB.2.21.1902081950260.1662@nanos.tec.linutronix.de/
Reported-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Will Deacon <will.deacon@arm.com>
arch/arm64/include/asm/arch_timer.h
arch/arm64/kernel/vdso/gettimeofday.S