1
2
3
4
5
6
7
8
9
10
11
12
13
14#include <asm/errno.h>
15#include <asm/percpu.h>
16#include <asm/processor-flags.h>
17#include <asm/segment.h>
18
19#include <xen/interface/xen.h>
20
21#include "xen-asm.h"
22
23ENTRY(xen_adjust_exception_frame)
24 mov 8+0(%rsp), %rcx
25 mov 8+8(%rsp), %r11
26 ret $16
27
28hypercall_iret = hypercall_page + __HYPERVISOR_iret * 32
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44ENTRY(xen_iret)
45 pushq $0
461: jmp hypercall_iret
47ENDPATCH(xen_iret)
48RELOC(xen_iret, 1b+1)
49
50
51
52
53
54ENTRY(xen_sysexit)
55 pushq $__USER32_DS
56 pushq %rcx
57 pushq $X86_EFLAGS_IF
58 pushq $__USER32_CS
59 pushq %rdx
60
61 pushq $0
621: jmp hypercall_iret
63ENDPATCH(xen_sysexit)
64RELOC(xen_sysexit, 1b+1)
65
66ENTRY(xen_sysret64)
67
68
69
70
71 movq %rsp, PER_CPU_VAR(old_rsp)
72 movq PER_CPU_VAR(kernel_stack), %rsp
73
74 pushq $__USER_DS
75 pushq PER_CPU_VAR(old_rsp)
76 pushq %r11
77 pushq $__USER_CS
78 pushq %rcx
79
80 pushq $VGCF_in_syscall
811: jmp hypercall_iret
82ENDPATCH(xen_sysret64)
83RELOC(xen_sysret64, 1b+1)
84
85ENTRY(xen_sysret32)
86
87
88
89
90 movq %rsp, PER_CPU_VAR(old_rsp)
91 movq PER_CPU_VAR(kernel_stack), %rsp
92
93 pushq $__USER32_DS
94 pushq PER_CPU_VAR(old_rsp)
95 pushq %r11
96 pushq $__USER32_CS
97 pushq %rcx
98
99 pushq $0
1001: jmp hypercall_iret
101ENDPATCH(xen_sysret32)
102RELOC(xen_sysret32, 1b+1)
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122.macro undo_xen_syscall
123 mov 0*8(%rsp), %rcx
124 mov 1*8(%rsp), %r11
125 mov 5*8(%rsp), %rsp
126.endm
127
128
129ENTRY(xen_syscall_target)
130 undo_xen_syscall
131 jmp system_call_after_swapgs
132ENDPROC(xen_syscall_target)
133
134#ifdef CONFIG_IA32_EMULATION
135
136
137ENTRY(xen_syscall32_target)
138 undo_xen_syscall
139 jmp ia32_cstar_target
140ENDPROC(xen_syscall32_target)
141
142
143ENTRY(xen_sysenter_target)
144 undo_xen_syscall
145 jmp ia32_sysenter_target
146ENDPROC(xen_sysenter_target)
147
148#else
149
150ENTRY(xen_syscall32_target)
151ENTRY(xen_sysenter_target)
152 lea 16(%rsp), %rsp
153 mov $-ENOSYS, %rax
154 pushq $0
155 jmp hypercall_iret
156ENDPROC(xen_syscall32_target)
157ENDPROC(xen_sysenter_target)
158
159#endif
160