Print this page
11787 Kernel needs to be built with retpolines
11788 Kernel needs to generally use RSB stuffing
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: John Levon <john.levon@joyent.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/ia32/ml/hypersubr.s
+++ new/usr/src/uts/intel/ia32/ml/hypersubr.s
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 +/*
28 + * Copyright 2019 Joyent, Inc.
29 + */
30 +
27 31 #include <sys/asm_linkage.h>
28 32 #ifndef __xpv
29 33 #include <sys/xpv_support.h>
30 34 #endif
31 35 #include <sys/hypervisor.h>
32 36
33 37 /*
34 38 * Hypervisor "system calls"
35 39 *
36 40 * i386
37 - * %eax == call number
38 - * args in registers (%ebx, %ecx, %edx, %esi, %edi)
41 + * %eax == call number
42 + * args in registers (%ebx, %ecx, %edx, %esi, %edi)
39 43 *
40 44 * amd64
41 - * %rax == call number
42 - * args in registers (%rdi, %rsi, %rdx, %r10, %r8, %r9)
45 + * %rax == call number
46 + * args in registers (%rdi, %rsi, %rdx, %r10, %r8, %r9)
43 47 *
44 48 * Note that for amd64 we use %r10 instead of %rcx for passing 4th argument
45 49 * as in C calling convention since the "syscall" instruction clobbers %rcx.
46 50 *
47 51 * (These calls can be done more efficiently as gcc-style inlines, but
48 52 * for simplicity and help with initial debugging, we use these primitives
49 53 * to build the hypervisor calls up from C wrappers.)
50 54 */
51 55
52 56 #if defined(__lint)
53 57
54 58 /*ARGSUSED*/
55 59 long
56 60 __hypercall0(int callnum)
57 61 { return (0); }
58 62
59 63 /*ARGSUSED*/
60 64 long
61 65 __hypercall1(int callnum, ulong_t a1)
62 66 { return (0); }
63 67
64 68 /*ARGSUSED*/
65 69 long
66 70 __hypercall2(int callnum, ulong_t a1, ulong_t a2)
67 71 { return (0); }
68 72
69 73 /*ARGSUSED*/
70 74 long
71 75 __hypercall3(int callnum, ulong_t a1, ulong_t a2, ulong_t a3)
72 76 { return (0); }
73 77
74 78 /*ARGSUSED*/
75 79 long
76 80 __hypercall4(int callnum, ulong_t a1, ulong_t a2, ulong_t a3, ulong_t a4)
77 81 { return (0); }
78 82
79 83 /*ARGSUSED*/
80 84 long
81 85 __hypercall5(int callnum,
82 86 ulong_t a1, ulong_t a2, ulong_t a3, ulong_t a4, ulong_t a5)
83 87 { return (0); }
84 88
85 89 /*ARGSUSED*/
86 90 int
87 91 __hypercall0_int(int callnum)
88 92 { return (0); }
89 93
90 94 /*ARGSUSED*/
91 95 int
92 96 __hypercall1_int(int callnum, ulong_t a1)
93 97 { return (0); }
94 98
95 99 /*ARGSUSED*/
96 100 int
97 101 __hypercall2_int(int callnum, ulong_t a1, ulong_t a2)
98 102 { return (0); }
99 103
100 104 /*ARGSUSED*/
101 105 int
102 106 __hypercall3_int(int callnum, ulong_t a1, ulong_t a2, ulong_t a3)
103 107 { return (0); }
104 108
105 109 /*ARGSUSED*/
106 110 int
107 111 __hypercall4_int(int callnum, ulong_t a1, ulong_t a2, ulong_t a3, ulong_t a4)
108 112 { return (0); }
109 113
110 114 /*ARGSUSED*/
111 115 int
112 116 __hypercall5_int(int callnum,
113 117 ulong_t a1, ulong_t a2, ulong_t a3, ulong_t a4, ulong_t a5)
114 118 { return (0); }
115 119
116 120 #else /* __lint */
117 121
118 122 /*
119 123 * XXPV grr - assembler can't deal with an instruction in a quoted string
120 124 */
121 125 #undef TRAP_INSTR /* cause it's currently "int $0x82" */
122 126
123 127 /*
124 128 * The method for issuing a hypercall (i.e. a system call to the
125 129 * hypervisor) varies from platform to platform. In 32-bit PV domains, an
126 130 * 'int 82' triggers the call. In 64-bit PV domains, a 'syscall' does the
127 131 * trick.
128 132 *
129 133 * HVM domains are more complicated. In all cases, we want to issue a
130 134 * VMEXIT instruction, but AMD and Intel use different opcodes to represent
131 135 * that instruction. Rather than build CPU-specific modules with the
132 136 * different opcodes, we use the 'hypercall page' provided by Xen. This
133 137 * page contains a collection of code stubs that do nothing except issue
134 138 * hypercalls using the proper instructions for this machine. To keep the
135 139 * wrapper code as simple and efficient as possible, we preallocate that
136 140 * page below. When the module is loaded, we ask Xen to remap the
137 141 * underlying PFN to that of the hypercall page.
138 142 *
139 143 * Note: this same mechanism could be used in PV domains, but using
140 144 * hypercall page requires a call and several more instructions than simply
141 145 * issuing the proper trap.
142 146 */
143 147 #if !defined(__xpv)
144 148
145 149 #define HYPERCALL_PAGESIZE 0x1000
146 150 #define HYPERCALL_SHINFO_PAGESIZE 0x1000
147 151
148 152 .data
149 153 .align HYPERCALL_SHINFO_PAGESIZE
150 154 .globl hypercall_shared_info_page
151 155 .type hypercall_shared_info_page, @object
152 156 .size hypercall_shared_info_page, HYPERCALL_SHINFO_PAGESIZE
153 157 hypercall_shared_info_page:
154 158 .skip HYPERCALL_SHINFO_PAGESIZE
155 159
156 160 .text
↓ open down ↓ |
104 lines elided |
↑ open up ↑ |
157 161 .align HYPERCALL_PAGESIZE
158 162 .globl hypercall_page
159 163 .type hypercall_page, @function
160 164 hypercall_page:
161 165 .skip HYPERCALL_PAGESIZE
162 166 .size hypercall_page, HYPERCALL_PAGESIZE
163 167 #if defined(__amd64)
164 168 #define TRAP_INSTR \
165 169 shll $5, %eax; \
166 170 addq $hypercall_page, %rax; \
167 - jmp *%rax
171 + INDIRECT_JMP_REG(rax);
168 172 #else
169 173 #define TRAP_INSTR \
170 174 shll $5, %eax; \
171 175 addl $hypercall_page, %eax; \
172 176 call *%eax
173 177 #endif
174 178
175 179 #else /* !_xpv */
176 180
177 181 #if defined(__amd64)
178 182 #define TRAP_INSTR syscall
179 183 #elif defined(__i386)
180 184 #define TRAP_INSTR int $0x82
181 185 #endif
182 186 #endif /* !__xpv */
183 187
184 188
185 -#if defined(__amd64)
189 +#if defined(__amd64)
186 190
187 191 ENTRY_NP(__hypercall0)
188 192 ALTENTRY(__hypercall0_int)
189 193 movl %edi, %eax
190 194 TRAP_INSTR
191 195 ret
192 196 SET_SIZE(__hypercall0)
193 197
194 198 ENTRY_NP(__hypercall1)
195 199 ALTENTRY(__hypercall1_int)
196 200 movl %edi, %eax
197 201 movq %rsi, %rdi /* arg 1 */
198 202 TRAP_INSTR
199 203 ret
200 204 SET_SIZE(__hypercall1)
201 205
202 206 ENTRY_NP(__hypercall2)
203 207 ALTENTRY(__hypercall2_int)
204 208 movl %edi, %eax
205 209 movq %rsi, %rdi /* arg 1 */
206 210 movq %rdx, %rsi /* arg 2 */
207 211 TRAP_INSTR
208 212 ret
209 213 SET_SIZE(__hypercall2)
210 214
211 215 ENTRY_NP(__hypercall3)
212 216 ALTENTRY(__hypercall3_int)
213 217 movl %edi, %eax
214 218 movq %rsi, %rdi /* arg 1 */
215 219 movq %rdx, %rsi /* arg 2 */
216 220 movq %rcx, %rdx /* arg 3 */
217 221 TRAP_INSTR
218 222 ret
219 223 SET_SIZE(__hypercall3)
220 224
221 225 ENTRY_NP(__hypercall4)
222 226 ALTENTRY(__hypercall4_int)
223 227 movl %edi, %eax
224 228 movq %rsi, %rdi /* arg 1 */
225 229 movq %rdx, %rsi /* arg 2 */
226 230 movq %rcx, %rdx /* arg 3 */
227 231 movq %r8, %r10 /* r10 = 4th arg */
228 232 TRAP_INSTR
229 233 ret
230 234 SET_SIZE(__hypercall4)
231 235
232 236 ENTRY_NP(__hypercall5)
233 237 ALTENTRY(__hypercall5_int)
234 238 movl %edi, %eax
235 239 movq %rsi, %rdi /* arg 1 */
236 240 movq %rdx, %rsi /* arg 2 */
237 241 movq %rcx, %rdx /* arg 3 */
238 242 movq %r8, %r10 /* r10 = 4th arg */
239 243 movq %r9, %r8 /* arg 5 */
240 244 TRAP_INSTR
241 245 ret
242 246 SET_SIZE(__hypercall5)
243 247
244 248 #elif defined(__i386)
245 249
246 250 ENTRY_NP(__hypercall0)
247 251 ALTENTRY(__hypercall0_int)
248 252 movl 4(%esp), %eax
249 253 TRAP_INSTR
250 254 ret
251 255 SET_SIZE(__hypercall0)
252 256
253 257 ENTRY_NP(__hypercall1)
254 258 ALTENTRY(__hypercall1_int)
255 259 pushl %ebx
256 260 movl 8(%esp), %eax
257 261 movl 12(%esp), %ebx
258 262 TRAP_INSTR
259 263 popl %ebx
260 264 ret
261 265 SET_SIZE(__hypercall1)
262 266
263 267 ENTRY_NP(__hypercall2)
264 268 ALTENTRY(__hypercall2_int)
265 269 pushl %ebx
266 270 movl 8(%esp), %eax
267 271 movl 12(%esp), %ebx
268 272 movl 16(%esp), %ecx
269 273 TRAP_INSTR
270 274 popl %ebx
271 275 ret
272 276 SET_SIZE(__hypercall2)
273 277
274 278 ENTRY_NP(__hypercall3)
275 279 ALTENTRY(__hypercall3_int)
276 280 pushl %ebx
277 281 movl 8(%esp), %eax
278 282 movl 12(%esp), %ebx
279 283 movl 16(%esp), %ecx
280 284 movl 20(%esp), %edx
281 285 TRAP_INSTR
282 286 popl %ebx
283 287 ret
284 288 SET_SIZE(__hypercall3)
285 289
286 290 ENTRY_NP(__hypercall4)
287 291 ALTENTRY(__hypercall4_int)
288 292 pushl %ebx
289 293 pushl %esi
290 294 movl 12(%esp), %eax
291 295 movl 16(%esp), %ebx
292 296 movl 20(%esp), %ecx
293 297 movl 24(%esp), %edx
294 298 movl 28(%esp), %esi
295 299 TRAP_INSTR
296 300 popl %esi
297 301 popl %ebx
298 302 ret
299 303 SET_SIZE(__hypercall4)
300 304
301 305 ENTRY_NP(__hypercall5)
302 306 ALTENTRY(__hypercall5_int)
303 307 pushl %ebx
304 308 pushl %esi
305 309 pushl %edi
306 310 movl 16(%esp), %eax
307 311 movl 20(%esp), %ebx
308 312 movl 24(%esp), %ecx
309 313 movl 28(%esp), %edx
310 314 movl 32(%esp), %esi
311 315 movl 36(%esp), %edi
312 316 TRAP_INSTR
313 317 popl %edi
314 318 popl %esi
315 319 popl %ebx
316 320 ret
317 321 SET_SIZE(__hypercall5)
318 322
319 323 #endif /* __i386 */
320 324
321 325 #endif /* lint */
↓ open down ↓ |
126 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX