x86/vdso: Introduce and use vgtod_ts
[linux-block.git] / arch / x86 / include / asm / vgtod.h
index fb856c9f04494b6633d9ea8fd3ebb9204cc2c620..10e534a1a51afc0fba1ac2f2a75478d797730dc6 100644 (file)
@@ -5,33 +5,37 @@
 #include <linux/compiler.h>
 #include <linux/clocksource.h>
 
+#include <uapi/linux/time.h>
+
 #ifdef BUILD_VDSO32_64
 typedef u64 gtod_long_t;
 #else
 typedef unsigned long gtod_long_t;
 #endif
+
+struct vgtod_ts {
+       u64             sec;
+       u64             nsec;
+};
+
+#define VGTOD_BASES    (CLOCK_MONOTONIC_COARSE + 1)
+#define VGTOD_HRES     (BIT(CLOCK_REALTIME) | BIT(CLOCK_MONOTONIC))
+#define VGTOD_COARSE   (BIT(CLOCK_REALTIME_COARSE) | BIT(CLOCK_MONOTONIC_COARSE))
+
 /*
  * vsyscall_gtod_data will be accessed by 32 and 64 bit code at the same time
  * so be carefull by modifying this structure.
  */
 struct vsyscall_gtod_data {
-       unsigned seq;
-
-       int vclock_mode;
-       u64     cycle_last;
-       u64     mask;
-       u32     mult;
-       u32     shift;
-
-       /* open coded 'struct timespec' */
-       u64             wall_time_snsec;
-       gtod_long_t     wall_time_sec;
-       gtod_long_t     monotonic_time_sec;
-       u64             monotonic_time_snsec;
-       gtod_long_t     wall_time_coarse_sec;
-       gtod_long_t     wall_time_coarse_nsec;
-       gtod_long_t     monotonic_time_coarse_sec;
-       gtod_long_t     monotonic_time_coarse_nsec;
+       unsigned int    seq;
+
+       int             vclock_mode;
+       u64             cycle_last;
+       u64             mask;
+       u32             mult;
+       u32             shift;
+
+       struct vgtod_ts basetime[VGTOD_BASES];
 
        int             tz_minuteswest;
        int             tz_dsttime;
@@ -44,9 +48,9 @@ static inline bool vclock_was_used(int vclock)
        return READ_ONCE(vclocks_used) & (1 << vclock);
 }
 
-static inline unsigned gtod_read_begin(const struct vsyscall_gtod_data *s)
+static inline unsigned int gtod_read_begin(const struct vsyscall_gtod_data *s)
 {
-       unsigned ret;
+       unsigned int ret;
 
 repeat:
        ret = READ_ONCE(s->seq);
@@ -59,7 +63,7 @@ repeat:
 }
 
 static inline int gtod_read_retry(const struct vsyscall_gtod_data *s,
-                                       unsigned start)
+                                 unsigned int start)
 {
        smp_rmb();
        return unlikely(s->seq != start);
@@ -93,7 +97,7 @@ static inline unsigned int __getcpu(void)
         *
         * If RDPID is available, use it.
         */
-       alternative_io ("lsl %[p],%[seg]",
+       alternative_io ("lsl %[seg],%[p]",
                        ".byte 0xf3,0x0f,0xc7,0xf8", /* RDPID %eax/rax */
                        X86_FEATURE_RDPID,
                        [p] "=a" (p), [seg] "r" (__PER_CPU_SEG));