x86/vdso: Switch to generic vDSO implementation
The x86 vDSO library requires some adaptations to take advantage of the newly introduced generic vDSO library. Introduce the following changes: - Modification of vdso.c to be compliant with the common vdso datapage - Use of lib/vdso for gettimeofday [ tglx: Massaged changelog and cleaned up the function signature formatting ] Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: linux-arch@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-mips@vger.kernel.org Cc: linux-kselftest@vger.kernel.org Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will.deacon@arm.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Russell King <linux@armlinux.org.uk> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Paul Burton <paul.burton@mips.com> Cc: Daniel Lezcano <daniel.lezcano@linaro.org> Cc: Mark Salyzyn <salyzyn@android.com> Cc: Peter Collingbourne <pcc@google.com> Cc: Shuah Khan <shuah@kernel.org> Cc: Dmitry Safonov <0x7f454c46@gmail.com> Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk> Cc: Huw Davies <huw@codeweavers.com> Cc: Shijith Thotton <sthotton@marvell.com> Cc: Andre Przywara <andre.przywara@arm.com> Link: https://lkml.kernel.org/r/20190621095252.32307-23-vincenzo.frascino@arm.com
This commit is contained in:

committed by
Thomas Gleixner

parent
bfe801ebe8
commit
7ac8707479
@@ -3,7 +3,9 @@
|
||||
#define _ASM_X86_VGTOD_H
|
||||
|
||||
#include <linux/compiler.h>
|
||||
#include <linux/clocksource.h>
|
||||
#include <asm/clocksource.h>
|
||||
#include <vdso/datapage.h>
|
||||
#include <vdso/helpers.h>
|
||||
|
||||
#include <uapi/linux/time.h>
|
||||
|
||||
@@ -13,81 +15,10 @@ typedef u64 gtod_long_t;
|
||||
typedef unsigned long gtod_long_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* There is one of these objects in the vvar page for each
|
||||
* vDSO-accelerated clockid. For high-resolution clocks, this encodes
|
||||
* the time corresponding to vsyscall_gtod_data.cycle_last. For coarse
|
||||
* clocks, this encodes the actual time.
|
||||
*
|
||||
* To confuse the reader, for high-resolution clocks, nsec is left-shifted
|
||||
* by vsyscall_gtod_data.shift.
|
||||
*/
|
||||
struct vgtod_ts {
|
||||
u64 sec;
|
||||
u64 nsec;
|
||||
};
|
||||
|
||||
#define VGTOD_BASES (CLOCK_TAI + 1)
|
||||
#define VGTOD_HRES (BIT(CLOCK_REALTIME) | BIT(CLOCK_MONOTONIC) | BIT(CLOCK_TAI))
|
||||
#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 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;
|
||||
};
|
||||
extern struct vsyscall_gtod_data vsyscall_gtod_data;
|
||||
|
||||
extern int vclocks_used;
|
||||
static inline bool vclock_was_used(int vclock)
|
||||
{
|
||||
return READ_ONCE(vclocks_used) & (1 << vclock);
|
||||
}
|
||||
|
||||
static inline unsigned int gtod_read_begin(const struct vsyscall_gtod_data *s)
|
||||
{
|
||||
unsigned int ret;
|
||||
|
||||
repeat:
|
||||
ret = READ_ONCE(s->seq);
|
||||
if (unlikely(ret & 1)) {
|
||||
cpu_relax();
|
||||
goto repeat;
|
||||
}
|
||||
smp_rmb();
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline int gtod_read_retry(const struct vsyscall_gtod_data *s,
|
||||
unsigned int start)
|
||||
{
|
||||
smp_rmb();
|
||||
return unlikely(s->seq != start);
|
||||
}
|
||||
|
||||
static inline void gtod_write_begin(struct vsyscall_gtod_data *s)
|
||||
{
|
||||
++s->seq;
|
||||
smp_wmb();
|
||||
}
|
||||
|
||||
static inline void gtod_write_end(struct vsyscall_gtod_data *s)
|
||||
{
|
||||
smp_wmb();
|
||||
++s->seq;
|
||||
}
|
||||
|
||||
#endif /* _ASM_X86_VGTOD_H */
|
||||
|
Reference in New Issue
Block a user