#include <asm/bug.h>
#include <asm/page.h>
#include <asm/unistd.h>
-#include <asm/vdso_datapage.h>
#ifndef CONFIG_AEABI
#error This code depends on AEABI system call conventions
#endif
-extern struct vdso_data *__get_datapage(void);
+#include "datapage.h"
-static notrace u32 vdso_read_begin(const struct vdso_data *vdata)
+static notrace u32 vdso_read_begin(const struct vdso_data *vd)
{
u32 seq;
do {
- seq = READ_ONCE(vdata->tb_seq_count);
+ seq = READ_ONCE(vd->tb_seq_count);
if ((seq & 1) == 0)
break;
return seq;
}
-static notrace int vdso_read_retry(const struct vdso_data *vdata, u32 start)
+static notrace int vdso_read_retry(const struct vdso_data *vd, u32 start)
{
u32 seq;
smp_rmb(); /* Pairs with first smp_wmb in update_vsyscall */
- seq = READ_ONCE(vdata->tb_seq_count);
+ seq = READ_ONCE(vd->tb_seq_count);
return seq != start;
}
return ret;
}
-static notrace int do_realtime_coarse(struct timespec *ts,
- struct vdso_data *vdata)
+static notrace int do_realtime_coarse(const struct vdso_data *vd,
+ struct timespec *ts)
{
u32 seq;
do {
- seq = vdso_read_begin(vdata);
+ seq = vdso_read_begin(vd);
- ts->tv_sec = vdata->xtime_coarse_sec;
- ts->tv_nsec = vdata->xtime_coarse_nsec;
+ ts->tv_sec = vd->xtime_coarse_sec;
+ ts->tv_nsec = vd->xtime_coarse_nsec;
- } while (vdso_read_retry(vdata, seq));
+ } while (vdso_read_retry(vd, seq));
return 0;
}
-static notrace int do_monotonic_coarse(struct timespec *ts,
- struct vdso_data *vdata)
+static notrace int do_monotonic_coarse(const struct vdso_data *vd,
+ struct timespec *ts)
{
struct timespec tomono;
u32 seq;
do {
- seq = vdso_read_begin(vdata);
+ seq = vdso_read_begin(vd);
- ts->tv_sec = vdata->xtime_coarse_sec;
- ts->tv_nsec = vdata->xtime_coarse_nsec;
+ ts->tv_sec = vd->xtime_coarse_sec;
+ ts->tv_nsec = vd->xtime_coarse_nsec;
- tomono.tv_sec = vdata->wtm_clock_sec;
- tomono.tv_nsec = vdata->wtm_clock_nsec;
+ tomono.tv_sec = vd->wtm_clock_sec;
+ tomono.tv_nsec = vd->wtm_clock_nsec;
- } while (vdso_read_retry(vdata, seq));
+ } while (vdso_read_retry(vd, seq));
ts->tv_sec += tomono.tv_sec;
timespec_add_ns(ts, tomono.tv_nsec);
#ifdef CONFIG_ARM_ARCH_TIMER
-static notrace u64 get_ns(struct vdso_data *vdata)
+static notrace u64 get_ns(const struct vdso_data *vd)
{
u64 cycle_delta;
u64 cycle_now;
cycle_now = arch_counter_get_cntvct();
- cycle_delta = (cycle_now - vdata->cs_cycle_last) & vdata->cs_mask;
+ cycle_delta = (cycle_now - vd->cs_cycle_last) & vd->cs_mask;
- nsec = (cycle_delta * vdata->cs_mono_mult) + vdata->xtime_clock_snsec;
- nsec >>= vdata->cs_shift;
+ nsec = (cycle_delta * vd->cs_mono_mult) + vd->xtime_clock_snsec;
+ nsec >>= vd->cs_shift;
return nsec;
}
-static notrace int do_realtime(struct timespec *ts, struct vdso_data *vdata)
+static notrace int do_realtime(const struct vdso_data *vd, struct timespec *ts)
{
u64 nsecs;
u32 seq;
do {
- seq = vdso_read_begin(vdata);
+ seq = vdso_read_begin(vd);
- if (vdata->use_syscall)
+ if (vd->use_syscall)
return -1;
- ts->tv_sec = vdata->xtime_clock_sec;
- nsecs = get_ns(vdata);
+ ts->tv_sec = vd->xtime_clock_sec;
+ nsecs = get_ns(vd);
- } while (vdso_read_retry(vdata, seq));
+ } while (vdso_read_retry(vd, seq));
ts->tv_nsec = 0;
timespec_add_ns(ts, nsecs);
return 0;
}
-static notrace int do_monotonic(struct timespec *ts, struct vdso_data *vdata)
+static notrace int do_monotonic(const struct vdso_data *vd, struct timespec *ts)
{
struct timespec tomono;
u64 nsecs;
u32 seq;
do {
- seq = vdso_read_begin(vdata);
+ seq = vdso_read_begin(vd);
- if (vdata->use_syscall)
+ if (vd->use_syscall)
return -1;
- ts->tv_sec = vdata->xtime_clock_sec;
- nsecs = get_ns(vdata);
+ ts->tv_sec = vd->xtime_clock_sec;
+ nsecs = get_ns(vd);
- tomono.tv_sec = vdata->wtm_clock_sec;
- tomono.tv_nsec = vdata->wtm_clock_nsec;
+ tomono.tv_sec = vd->wtm_clock_sec;
+ tomono.tv_nsec = vd->wtm_clock_nsec;
- } while (vdso_read_retry(vdata, seq));
+ } while (vdso_read_retry(vd, seq));
ts->tv_sec += tomono.tv_sec;
ts->tv_nsec = 0;
#else /* CONFIG_ARM_ARCH_TIMER */
-static notrace int do_realtime(struct timespec *ts, struct vdso_data *vdata)
+static notrace int do_realtime(const struct vdso_data *vd, struct timespec *ts)
{
return -1;
}
-static notrace int do_monotonic(struct timespec *ts, struct vdso_data *vdata)
+static notrace int do_monotonic(const struct vdso_data *vd, struct timespec *ts)
{
return -1;
}
notrace int __vdso_clock_gettime(clockid_t clkid, struct timespec *ts)
{
- struct vdso_data *vdata;
int ret = -1;
- vdata = __get_datapage();
+ const struct vdso_data *vd = __get_datapage();
switch (clkid) {
case CLOCK_REALTIME_COARSE:
- ret = do_realtime_coarse(ts, vdata);
+ ret = do_realtime_coarse(vd, ts);
break;
case CLOCK_MONOTONIC_COARSE:
- ret = do_monotonic_coarse(ts, vdata);
+ ret = do_monotonic_coarse(vd, ts);
break;
case CLOCK_REALTIME:
- ret = do_realtime(ts, vdata);
+ ret = do_realtime(vd, ts);
break;
case CLOCK_MONOTONIC:
- ret = do_monotonic(ts, vdata);
+ ret = do_monotonic(vd, ts);
break;
default:
break;
notrace int __vdso_gettimeofday(struct timeval *tv, struct timezone *tz)
{
struct timespec ts;
- struct vdso_data *vdata;
int ret;
- vdata = __get_datapage();
+ const struct vdso_data *vd = __get_datapage();
- ret = do_realtime(&ts, vdata);
+ ret = do_realtime(vd, &ts);
if (ret)
return gettimeofday_fallback(tv, tz);
tv->tv_usec = ts.tv_nsec / 1000;
}
if (tz) {
- tz->tz_minuteswest = vdata->tz_minuteswest;
- tz->tz_dsttime = vdata->tz_dsttime;
+ tz->tz_minuteswest = vd->tz_minuteswest;
+ tz->tz_dsttime = vd->tz_dsttime;
}
return ret;