summaryrefslogtreecommitdiffstats
path: root/lib/vdso
diff options
context:
space:
mode:
Diffstat (limited to 'lib/vdso')
-rw-r--r--lib/vdso/Kconfig3
-rw-r--r--lib/vdso/gettimeofday.c13
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/vdso/Kconfig b/lib/vdso/Kconfig
index d883ac299508..d9f43c84fcc6 100644
--- a/lib/vdso/Kconfig
+++ b/lib/vdso/Kconfig
@@ -30,4 +30,7 @@ config GENERIC_VDSO_TIME_NS
Selected by architectures which support time namespaces in the
VDSO
+config GENERIC_VDSO_CLOCK_MODE
+ bool
+
endif
diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c
index 5804e4e168e7..3f2d8b859130 100644
--- a/lib/vdso/gettimeofday.c
+++ b/lib/vdso/gettimeofday.c
@@ -7,6 +7,7 @@
#include <linux/time.h>
#include <linux/kernel.h>
#include <linux/hrtimer_defs.h>
+#include <linux/clocksource.h>
#include <vdso/datapage.h>
#include <vdso/helpers.h>
@@ -64,10 +65,14 @@ static int do_hres_timens(const struct vdso_data *vdns, clockid_t clk,
do {
seq = vdso_read_begin(vd);
+ if (IS_ENABLED(CONFIG_GENERIC_VDSO_CLOCK_MODE) &&
+ vd->clock_mode == VDSO_CLOCKMODE_NONE)
+ return -1;
cycles = __arch_get_hw_counter(vd->clock_mode);
ns = vdso_ts->nsec;
last = vd->cycle_last;
- if (unlikely((s64)cycles < 0))
+ if (!IS_ENABLED(CONFIG_GENERIC_VDSO_CLOCK_MODE) &&
+ unlikely((s64)cycles < 0))
return -1;
ns += vdso_calc_delta(cycles, last, vd->mask, vd->mult);
@@ -132,10 +137,14 @@ static __always_inline int do_hres(const struct vdso_data *vd, clockid_t clk,
}
smp_rmb();
+ if (IS_ENABLED(CONFIG_GENERIC_VDSO_CLOCK_MODE) &&
+ vd->clock_mode == VDSO_CLOCKMODE_NONE)
+ return -1;
cycles = __arch_get_hw_counter(vd->clock_mode);
ns = vdso_ts->nsec;
last = vd->cycle_last;
- if (unlikely((s64)cycles < 0))
+ if (!IS_ENABLED(CONFIG_GENERIC_VDSO_CLOCK_MODE) &&
+ unlikely((s64)cycles < 0))
return -1;
ns += vdso_calc_delta(cycles, last, vd->mask, vd->mult);