Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Merge branch 'devel'
[palacios.git] / kitten / arch / x86_64 / kernel / vsyscall.c
1 /*
2  * Derived from Linux 2.6.25 linux-2.6.25/arch/x86/kernel/vsyscall.c
3  * Original header:
4  *  Copyright (C) 2001 Andrea Arcangeli <andrea@suse.de> SuSE
5  *  Copyright 2003 Andi Kleen, SuSE Labs.
6  *
7  *  Thanks to hpa@transmeta.com for some useful hint.
8  *  Special thanks to Ingo Molnar for his early experience with
9  *  a different vsyscall implementation for Linux/IA32 and for the name.
10  *
11  *  vsyscall 1 is located at -10Mbyte, vsyscall 2 is located
12  *  at virtual address -10Mbyte+1024bytes etc... There are at max 4
13  *  vsyscalls. One vsyscall can reserve more than 1 slot to avoid
14  *  jumping out of line if necessary. We cannot add more with this
15  *  mechanism because older kernels won't return -ENOSYS.
16  *  If we want more than four we need a vDSO.
17  *
18  *  Note: the concept clashes with user mode linux. If you use UML and
19  *  want per guest time just set the kernel.vsyscall64 sysctl to 0.
20  */
21
22 #include <lwk/kernel.h>
23 #include <lwk/init.h>
24 #include <lwk/time.h>
25 #include <lwk/unistd.h>
26 #include <arch/vsyscall.h>
27 #include <arch/pgtable.h>
28 #include <arch/fixmap.h>
29
30 #define __vsyscall(nr) __attribute__ ((unused,__section__(".vsyscall_" #nr)))
31 #define __syscall_clobber "r11","cx","memory"
32
33 int __vsyscall(0)
34 vgettimeofday(struct timeval *tv, struct timezone *tz)
35 {
36         int ret;
37         asm volatile("syscall"
38                 : "=a" (ret)
39                 : "0" (__NR_gettimeofday),"D" (tv),"S" (tz)
40                 : __syscall_clobber );
41         return ret;
42 }
43
44 time_t __vsyscall(1)
45 vtime(time_t *t)
46 {
47         int ret;
48         asm volatile("syscall"
49                 : "=a" (ret)
50                 : "0" (__NR_time),"D" (t)
51                 : __syscall_clobber );
52         return ret;
53 }
54
55 void __init
56 vsyscall_map(void)
57 {
58         extern char __vsyscall_0;
59         unsigned long physaddr_page0 = __pa_symbol(&__vsyscall_0);
60
61         /* Setup the virtual syscall fixmap entry */
62         __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_page0, PAGE_KERNEL_VSYSCALL);
63
64         BUG_ON((VSYSCALL_ADDR(0) != __fix_to_virt(VSYSCALL_FIRST_PAGE)));
65
66         BUG_ON((unsigned long) &vgettimeofday !=
67                         VSYSCALL_ADDR(__NR_vgettimeofday));
68         BUG_ON((unsigned long) &vtime !=
69                         VSYSCALL_ADDR(__NR_vtime));
70 }
71