blob: 2a46ca720afca5fd6f5e5010698e8eea56748837 [file] [log] [blame]
H. Peter Anvin1965aae2008-10-22 22:26:29 -07001#ifndef _ASM_X86_VSYSCALL_H
2#define _ASM_X86_VSYSCALL_H
Linus Torvalds1da177e2005-04-16 15:20:36 -07003
David Woodhouse75da7362006-09-16 12:15:48 -07004#include <linux/seqlock.h>
David Howellsaf170c52012-12-14 22:37:13 +00005#include <uapi/asm/vsyscall.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006
Vojtech Pavlikc08c8202006-09-26 10:52:28 +02007#define VGETCPU_RDTSCP 1
8#define VGETCPU_LSL 2
9
Linus Torvalds1da177e2005-04-16 15:20:36 -070010/* kernel space (writeable) */
Vojtech Pavlikc08c8202006-09-26 10:52:28 +020011extern int vgetcpu_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -070012extern struct timezone sys_tz;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
Andy Lutomirski8c49d9a2011-05-23 09:31:24 -040014#include <asm/vvar.h>
15
Ingo Molnare4026442008-01-30 13:32:39 +010016extern void map_vsyscall(void);
17
Andy Lutomirski3ae36652011-08-10 11:15:32 -040018/*
19 * Called on instruction fetch fault in vsyscall page.
20 * Returns true if handled.
21 */
22extern bool emulate_vsyscall(struct pt_regs *regs, unsigned long address);
23
Marcelo Tosatti51c19b42012-11-27 23:28:57 -020024#ifdef CONFIG_X86_64
25
26#define VGETCPU_CPU_MASK 0xfff
27
28static inline unsigned int __getcpu(void)
29{
30 unsigned int p;
31
32 if (VVAR(vgetcpu_mode) == VGETCPU_RDTSCP) {
33 /* Load per CPU data from RDTSCP */
34 native_read_tscp(&p);
35 } else {
36 /* Load per CPU data from GDT */
37 asm("lsl %1,%0" : "=r" (p) : "r" (__PER_CPU_SEG));
38 }
39
40 return p;
41}
42#endif /* CONFIG_X86_64 */
43
H. Peter Anvin1965aae2008-10-22 22:26:29 -070044#endif /* _ASM_X86_VSYSCALL_H */