1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __ASM_VDSO_VSYSCALL_H 3 #define __ASM_VDSO_VSYSCALL_H 4 5 #ifndef __ASSEMBLY__ 6 7 #include <linux/timekeeper_internal.h> 8 #include <vdso/datapage.h> 9 #include <asm/cacheflush.h> 10 11 extern struct vdso_data *vdso_data; 12 extern bool cntvct_ok; 13 14 static __always_inline 15 bool tk_is_cntvct(const struct timekeeper *tk) 16 { 17 if (!IS_ENABLED(CONFIG_ARM_ARCH_TIMER)) 18 return false; 19 20 if (!tk->tkr_mono.clock->archdata.vdso_direct) 21 return false; 22 23 return true; 24 } 25 26 /* 27 * Update the vDSO data page to keep in sync with kernel timekeeping. 28 */ 29 static __always_inline 30 struct vdso_data *__arm_get_k_vdso_data(void) 31 { 32 return vdso_data; 33 } 34 #define __arch_get_k_vdso_data __arm_get_k_vdso_data 35 36 static __always_inline 37 bool __arm_update_vdso_data(void) 38 { 39 return cntvct_ok; 40 } 41 #define __arch_update_vdso_data __arm_update_vdso_data 42 43 static __always_inline 44 int __arm_get_clock_mode(struct timekeeper *tk) 45 { 46 u32 __tk_is_cntvct = tk_is_cntvct(tk); 47 48 return __tk_is_cntvct; 49 } 50 #define __arch_get_clock_mode __arm_get_clock_mode 51 52 static __always_inline 53 int __arm_use_vsyscall(struct vdso_data *vdata) 54 { 55 return vdata[CS_HRES_COARSE].clock_mode; 56 } 57 #define __arch_use_vsyscall __arm_use_vsyscall 58 59 static __always_inline 60 void __arm_sync_vdso_data(struct vdso_data *vdata) 61 { 62 flush_dcache_page(virt_to_page(vdata)); 63 } 64 #define __arch_sync_vdso_data __arm_sync_vdso_data 65 66 /* The asm-generic header needs to be included after the definitions above */ 67 #include <asm-generic/vdso/vsyscall.h> 68 69 #endif /* !__ASSEMBLY__ */ 70 71 #endif /* __ASM_VDSO_VSYSCALL_H */ 72