![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0 */ 0002 #ifndef __VDSO_DATAPAGE_H 0003 #define __VDSO_DATAPAGE_H 0004 0005 #ifndef __ASSEMBLY__ 0006 0007 #include <linux/compiler.h> 0008 #include <uapi/linux/time.h> 0009 #include <uapi/linux/types.h> 0010 #include <uapi/asm-generic/errno-base.h> 0011 0012 #include <vdso/bits.h> 0013 #include <vdso/clocksource.h> 0014 #include <vdso/ktime.h> 0015 #include <vdso/limits.h> 0016 #include <vdso/math64.h> 0017 #include <vdso/processor.h> 0018 #include <vdso/time.h> 0019 #include <vdso/time32.h> 0020 #include <vdso/time64.h> 0021 0022 #ifdef CONFIG_ARCH_HAS_VDSO_DATA 0023 #include <asm/vdso/data.h> 0024 #else 0025 struct arch_vdso_data {}; 0026 #endif 0027 0028 #define VDSO_BASES (CLOCK_TAI + 1) 0029 #define VDSO_HRES (BIT(CLOCK_REALTIME) | \ 0030 BIT(CLOCK_MONOTONIC) | \ 0031 BIT(CLOCK_BOOTTIME) | \ 0032 BIT(CLOCK_TAI)) 0033 #define VDSO_COARSE (BIT(CLOCK_REALTIME_COARSE) | \ 0034 BIT(CLOCK_MONOTONIC_COARSE)) 0035 #define VDSO_RAW (BIT(CLOCK_MONOTONIC_RAW)) 0036 0037 #define CS_HRES_COARSE 0 0038 #define CS_RAW 1 0039 #define CS_BASES (CS_RAW + 1) 0040 0041 /** 0042 * struct vdso_timestamp - basetime per clock_id 0043 * @sec: seconds 0044 * @nsec: nanoseconds 0045 * 0046 * There is one vdso_timestamp object in vvar for each vDSO-accelerated 0047 * clock_id. For high-resolution clocks, this encodes the time 0048 * corresponding to vdso_data.cycle_last. For coarse clocks this encodes 0049 * the actual time. 0050 * 0051 * To be noticed that for highres clocks nsec is left-shifted by 0052 * vdso_data.cs[x].shift. 0053 */ 0054 struct vdso_timestamp { 0055 u64 sec; 0056 u64 nsec; 0057 }; 0058 0059 /** 0060 * struct vdso_data - vdso datapage representation 0061 * @seq: timebase sequence counter 0062 * @clock_mode: clock mode 0063 * @cycle_last: timebase at clocksource init 0064 * @mask: clocksource mask 0065 * @mult: clocksource multiplier 0066 * @shift: clocksource shift 0067 * @basetime[clock_id]: basetime per clock_id 0068 * @offset[clock_id]: time namespace offset per clock_id 0069 * @tz_minuteswest: minutes west of Greenwich 0070 * @tz_dsttime: type of DST correction 0071 * @hrtimer_res: hrtimer resolution 0072 * @__unused: unused 0073 * @arch_data: architecture specific data (optional, defaults 0074 * to an empty struct) 0075 * 0076 * vdso_data will be accessed by 64 bit and compat code at the same time 0077 * so we should be careful before modifying this structure. 0078 * 0079 * @basetime is used to store the base time for the system wide time getter 0080 * VVAR page. 0081 * 0082 * @offset is used by the special time namespace VVAR pages which are 0083 * installed instead of the real VVAR page. These namespace pages must set 0084 * @seq to 1 and @clock_mode to VDSO_CLOCKMODE_TIMENS to force the code into 0085 * the time namespace slow path. The namespace aware functions retrieve the 0086 * real system wide VVAR page, read host time and add the per clock offset. 0087 * For clocks which are not affected by time namespace adjustment the 0088 * offset must be zero. 0089 */ 0090 struct vdso_data { 0091 u32 seq; 0092 0093 s32 clock_mode; 0094 u64 cycle_last; 0095 u64 mask; 0096 u32 mult; 0097 u32 shift; 0098 0099 union { 0100 struct vdso_timestamp basetime[VDSO_BASES]; 0101 struct timens_offset offset[VDSO_BASES]; 0102 }; 0103 0104 s32 tz_minuteswest; 0105 s32 tz_dsttime; 0106 u32 hrtimer_res; 0107 u32 __unused; 0108 0109 struct arch_vdso_data arch_data; 0110 }; 0111 0112 /* 0113 * We use the hidden visibility to prevent the compiler from generating a GOT 0114 * relocation. Not only is going through a GOT useless (the entry couldn't and 0115 * must not be overridden by another library), it does not even work: the linker 0116 * cannot generate an absolute address to the data page. 0117 * 0118 * With the hidden visibility, the compiler simply generates a PC-relative 0119 * relocation, and this is what we need. 0120 */ 0121 extern struct vdso_data _vdso_data[CS_BASES] __attribute__((visibility("hidden"))); 0122 extern struct vdso_data _timens_data[CS_BASES] __attribute__((visibility("hidden"))); 0123 0124 /* 0125 * The generic vDSO implementation requires that gettimeofday.h 0126 * provides: 0127 * - __arch_get_vdso_data(): to get the vdso datapage. 0128 * - __arch_get_hw_counter(): to get the hw counter based on the 0129 * clock_mode. 0130 * - gettimeofday_fallback(): fallback for gettimeofday. 0131 * - clock_gettime_fallback(): fallback for clock_gettime. 0132 * - clock_getres_fallback(): fallback for clock_getres. 0133 */ 0134 #ifdef ENABLE_COMPAT_VDSO 0135 #include <asm/vdso/compat_gettimeofday.h> 0136 #else 0137 #include <asm/vdso/gettimeofday.h> 0138 #endif /* ENABLE_COMPAT_VDSO */ 0139 0140 #endif /* !__ASSEMBLY__ */ 0141 0142 #endif /* __VDSO_DATAPAGE_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |