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.


HVM capability enhancement: asynchronous upcalls to ROS userspace
[palacios.git] / guest / linux / hvm-ros / v3_hvm_ros_user_low_level.S
1 .section .text
2         
3 .extern __v3_hvm_ros_signal_handler  
4
5 /* 
6    This is the entry point for signal dispatch
7    from the VMM.
8         
9    VMM invokes this stub when a user signal is
10    raised and:  the relevant address space
11    is active, and we are at user-level.
12    It will be invoked  on exactly one core,  
13    although there are  no guarantees on which one.
14    
15 */
16
17
18 #define GPR_SAVE()                                               \
19         pushq %rbp              ;                                \
20         pushq %rax              ;                                \
21         pushq %rbx              ;                                \
22         pushq %rcx              ;                                \
23         pushq %rdx              ;                                \
24         pushq %rsi              ;                                \
25         pushq %rdi              ;                                \
26         pushq %r8               ;                                \
27         pushq %r9               ;                                \
28         pushq %r10              ;                                \
29         pushq %r11              ;                                \
30         pushq %r12              ;                                \
31         pushq %r13              ;                                \
32         pushq %r14              ;                                \
33         pushq %r15              ;                                \
34
35 #define GPR_LOAD()                       \
36         popq %r15               ;                                \
37         popq %r14               ;                                \
38         popq %r13               ;                                \
39         popq %r12               ;                                \
40         popq %r11               ;                                \
41         popq %r10               ;                                \
42         popq %r9                ;                                \
43         popq %r8                ;                                \
44         popq %rdi               ;                                \
45         popq %rsi               ;                                \
46         popq %rdx               ;                                \
47         popq %rcx               ;                                \
48         popq %rbx               ;                                \
49         popq %rax               ;                                \
50         popq %rbp               ;          
51
52         
53 /*
54    The VMM puts us here with what looks like a long mode 
55    interrupt dispatch, but it's from CPL 3 to CPL 3 and
56    it's not done as an interrupt injection per se, so
57    we can be interrupted, and deliverable interrupts
58    automatically prioritize over us.
59
60         48bitsblank | return SS (16 bits)
61         Return RSP
62         Return RFLAGS
63         48bitsblank | return CS (16 bits)
64         Return RIP
65         ERROR CODE (HVM-specific non-zero number here)  <- RSP on entry
66         
67         We then need simply to do this:
68
69         save regs
70         call the handler (if installed)
71         restore regs
72         iret
73         
74 */
75
76 .global __v3_hvm_ros_signal_handler_stub
77 __v3_hvm_ros_signal_handler_stub:
78         GPR_SAVE()
79         movabs __v3_hvm_ros_signal_handler, %rax
80         testq %rax, %rax
81         jz skip_handler
82         movq 120(%rsp), %rdi /* error code becomes argument */
83         callq *%rax     
84 skip_handler:   
85         GPR_LOAD()
86         addq $8, %rsp /* nuke the error code */
87         iretq
88