xref: /openbmc/linux/arch/x86/include/asm/vdso/vsyscall.h (revision 9e3bd0f6)
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/hrtimer.h>
8 #include <linux/timekeeper_internal.h>
9 #include <vdso/datapage.h>
10 #include <asm/vgtod.h>
11 #include <asm/vvar.h>
12 
13 int vclocks_used __read_mostly;
14 
15 DEFINE_VVAR(struct vdso_data, _vdso_data);
16 /*
17  * Update the vDSO data page to keep in sync with kernel timekeeping.
18  */
19 static __always_inline
20 struct vdso_data *__x86_get_k_vdso_data(void)
21 {
22 	return _vdso_data;
23 }
24 #define __arch_get_k_vdso_data __x86_get_k_vdso_data
25 
26 static __always_inline
27 int __x86_get_clock_mode(struct timekeeper *tk)
28 {
29 	int vclock_mode = tk->tkr_mono.clock->archdata.vclock_mode;
30 
31 	/* Mark the new vclock used. */
32 	BUILD_BUG_ON(VCLOCK_MAX >= 32);
33 	WRITE_ONCE(vclocks_used, READ_ONCE(vclocks_used) | (1 << vclock_mode));
34 
35 	return vclock_mode;
36 }
37 #define __arch_get_clock_mode __x86_get_clock_mode
38 
39 /* The asm-generic header needs to be included after the definitions above */
40 #include <asm-generic/vdso/vsyscall.h>
41 
42 #endif /* !__ASSEMBLY__ */
43 
44 #endif /* __ASM_VDSO_VSYSCALL_H */
45