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.


Implementation of resource control host os interface for Linux
[palacios.git] / gears / services / fsceu / syscall.S
1 /* Kyle C. Hale 2011 */
2
3 #include "syscall_decode.h"
4
5 .text 
6
7 /* Because SYSCALL doesn't put a kernel stack in place for us, we have to jump
8  * through some hoops. Linux uses the nifty swapgs instruction to pull
9  * a pointer to its data structures and replace it with the user gs (hence the
10  * name). The problem is that the kernel stack is at a fixed offset from the
11  * kernel gs, but in this module we don't have access to that offset (unless we
12  * can maybe find it through a symbol lookup, but I wanted to keep things
13  * compact). So, this module allocates 2 pages to use as a personal kernel stack.
14  * This should be enough because interrupts are off and since the code is small,
15  * I only expect a few page faults.
16  */
17
18 /* You might be wondering, "he said interrupts are off, but I don't see a cli!"
19  * Well, it's because Linux sets the SFMask MSR such that when SYSCALL
20  * is invoked (how we got here), the IF flag is cleared. The linux SYSCALL
21  * entry point later enables them. We won't bother. It's just asking for trouble.
22  */
23
24 ENTRY(syscall_stub)
25     pushq %rdi;  /* this is bad, shouldn't be using user-stack, any ideas? */
26     movq state_save_area, %rdi;
27     popq (%rdi);
28     pushq SYSCALL_ENTRY_OFFSET(%rdi);
29     SAVE_ALL 
30     leaq SYSCALL_ENTRY_OFFSET(%rdi), %rsp; /* create our own little kernel stack*/
31
32     movq syscall_map, %rsi;   
33     leaq (%rsi,%rax,1), %rsi;
34     cmpb $0x0, (%rsi);
35     je sysentry;
36     mov $SYSCALL_DISPATCH_HCALL, %eax;
37     vmmcall;
38
39 sysentry:
40     RESTORE_ALL
41     movq (%rdi), %rdi;
42     retq;