vsyscall.h 1.1 KB
Newer Older
H
H. Peter Anvin 已提交
1 2
#ifndef _ASM_X86_VSYSCALL_H
#define _ASM_X86_VSYSCALL_H
L
Linus Torvalds 已提交
3 4 5 6

enum vsyscall_num {
	__NR_vgettimeofday,
	__NR_vtime,
7
	__NR_vgetcpu,
L
Linus Torvalds 已提交
8 9 10 11 12
};

#define VSYSCALL_START (-10UL << 20)
#define VSYSCALL_SIZE 1024
#define VSYSCALL_END (-2UL << 20)
13
#define VSYSCALL_MAPPED_PAGES 1
L
Linus Torvalds 已提交
14 15 16
#define VSYSCALL_ADDR(vsyscall_nr) (VSYSCALL_START+VSYSCALL_SIZE*(vsyscall_nr))

#ifdef __KERNEL__
17
#include <linux/seqlock.h>
L
Linus Torvalds 已提交
18

19 20 21
#define VGETCPU_RDTSCP	1
#define VGETCPU_LSL	2

L
Linus Torvalds 已提交
22
/* kernel space (writeable) */
23
extern int vgetcpu_mode;
L
Linus Torvalds 已提交
24 25
extern struct timezone sys_tz;

26 27
#include <asm/vvar.h>

I
Ingo Molnar 已提交
28 29
extern void map_vsyscall(void);

30 31 32 33 34 35
/*
 * Called on instruction fetch fault in vsyscall page.
 * Returns true if handled.
 */
extern bool emulate_vsyscall(struct pt_regs *regs, unsigned long address);

36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
#ifdef CONFIG_X86_64

#define VGETCPU_CPU_MASK 0xfff

static inline unsigned int __getcpu(void)
{
	unsigned int p;

	if (VVAR(vgetcpu_mode) == VGETCPU_RDTSCP) {
		/* Load per CPU data from RDTSCP */
		native_read_tscp(&p);
	} else {
		/* Load per CPU data from GDT */
		asm("lsl %1,%0" : "=r" (p) : "r" (__PER_CPU_SEG));
	}

	return p;
}
#endif /* CONFIG_X86_64 */

L
Linus Torvalds 已提交
56 57
#endif /* __KERNEL__ */

H
H. Peter Anvin 已提交
58
#endif /* _ASM_X86_VSYSCALL_H */