mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
arm64: compat: Fix __arch_get_hw_counter() implementation
Provide the following fixes for the __arch_get_hw_counter() implementation on arm64: - Fallback on syscall when an unstable counter is detected. - Introduce isb()s before and after the counter read to avoid speculation of the counter value and of the seq lock respectively. The second isb() is a temporary solution that will be revisited in 5.3-rc1. These fixes restore the semantics that __arch_counter_get_cntvct() had on arm64. Signed-off-by: Vincenzo Frascino <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: Catalin Marinas <[email protected]> Cc: Will Deacon <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
This commit is contained in:
parent
27e11a9fe2
commit
6241c4dc6e
1 changed files with 18 additions and 0 deletions
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
#include <asm/vdso/compat_barrier.h>
|
||||
|
||||
#define __VDSO_USE_SYSCALL ULLONG_MAX
|
||||
|
||||
#define VDSO_HAS_CLOCK_GETRES 1
|
||||
|
||||
static __always_inline
|
||||
|
|
@ -74,8 +76,24 @@ static __always_inline u64 __arch_get_hw_counter(s32 clock_mode)
|
|||
{
|
||||
u64 res;
|
||||
|
||||
/*
|
||||
* clock_mode == 0 implies that vDSO are enabled otherwise
|
||||
* fallback on syscall.
|
||||
*/
|
||||
if (clock_mode)
|
||||
return __VDSO_USE_SYSCALL;
|
||||
|
||||
/*
|
||||
* This isb() is required to prevent that the counter value
|
||||
* is speculated.
|
||||
*/
|
||||
isb();
|
||||
asm volatile("mrrc p15, 1, %Q0, %R0, c14" : "=r" (res));
|
||||
/*
|
||||
* This isb() is required to prevent that the seq lock is
|
||||
* speculated.
|
||||
*/
|
||||
isb();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue