H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 1 | #ifndef _ASM_X86_VSYSCALL_H |
| 2 | #define _ASM_X86_VSYSCALL_H |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | |
David Woodhouse | 75da736 | 2006-09-16 12:15:48 -0700 | [diff] [blame] | 4 | #include <linux/seqlock.h> |
David Howells | af170c5 | 2012-12-14 22:37:13 +0000 | [diff] [blame] | 5 | #include <uapi/asm/vsyscall.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | |
Vojtech Pavlik | c08c820 | 2006-09-26 10:52:28 +0200 | [diff] [blame] | 7 | #define VGETCPU_RDTSCP 1 |
| 8 | #define VGETCPU_LSL 2 |
| 9 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | /* kernel space (writeable) */ |
Vojtech Pavlik | c08c820 | 2006-09-26 10:52:28 +0200 | [diff] [blame] | 11 | extern int vgetcpu_mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | extern struct timezone sys_tz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
Andy Lutomirski | 8c49d9a | 2011-05-23 09:31:24 -0400 | [diff] [blame] | 14 | #include <asm/vvar.h> |
| 15 | |
Ingo Molnar | e402644 | 2008-01-30 13:32:39 +0100 | [diff] [blame] | 16 | extern void map_vsyscall(void); |
| 17 | |
Andy Lutomirski | 3ae3665 | 2011-08-10 11:15:32 -0400 | [diff] [blame] | 18 | /* |
| 19 | * Called on instruction fetch fault in vsyscall page. |
| 20 | * Returns true if handled. |
| 21 | */ |
| 22 | extern bool emulate_vsyscall(struct pt_regs *regs, unsigned long address); |
| 23 | |
Marcelo Tosatti | 51c19b4 | 2012-11-27 23:28:57 -0200 | [diff] [blame] | 24 | #ifdef CONFIG_X86_64 |
| 25 | |
| 26 | #define VGETCPU_CPU_MASK 0xfff |
| 27 | |
| 28 | static 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 Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 44 | #endif /* _ASM_X86_VSYSCALL_H */ |