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/brand/common/brand_solaris.s
+++ new/usr/src/uts/intel/brand/common/brand_solaris.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
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
↓ open down ↓ |
22 lines elided |
↑ open up ↑ |
23 23 * Copyright 2019 Joyent, Inc.
24 24 */
25 25
26 26 /*
27 27 * This is an assembly file that gets #include-ed into the brand-specific
28 28 * assembly files (e.g. sn1_brand_asm.s) for Solaris-derived brands.
29 29 * We can't make these into functions since in the trap context there's
30 30 * no easy place to save the extra parameters that would be required, so
31 31 * each brand module needs its own copy of this code. We #include this and
32 32 * use brand-specific #defines to replace the XXX_brand_... definitions.
33 - */
33 + */
34 34
35 35 #ifdef lint
36 36
37 37 #include <sys/systm.h>
38 38
39 39 #else /* !lint */
40 40
41 41 #include <sys/asm_linkage.h>
42 42 #include <sys/privregs.h>
43 43 #include <sys/segments.h>
44 44 #include "assym.h"
45 45 #include "brand_asm.h"
46 46
47 47 #endif /* !lint */
48 48
49 49 #ifdef lint
50 50
51 51 void
52 52 XXX_brand_sysenter_callback(void)
53 53 {
54 54 }
55 55
56 56 void
57 57 XXX_brand_syscall_callback(void)
58 58 {
59 59 }
60 60
61 61 #if defined(__amd64)
62 62 void
63 63 XXX_brand_syscall32_callback(void)
64 64 {
65 65 }
66 66 #endif /* amd64 */
67 67
68 68 void
69 69 XXX_brand_int91_callback(void)
70 70 {
71 71 }
72 72
73 73 #else /* !lint */
74 74
75 75 #ifdef _ASM /* The remainder of this file is only for assembly files */
76 76
77 77 #if defined(__amd64)
78 78
79 79 /*
80 80 * syscall handler for 32-bit user processes:
81 81 * See "64-BIT INTERPOSITION STACK" in brand_asm.h.
↓ open down ↓ |
38 lines elided |
↑ open up ↑ |
82 82 * To 'return' to our user-space handler, we just need to place its address
83 83 * into %rcx. The original return address is passed back in SYSCALL_REG.
84 84 */
85 85 ENTRY(XXX_brand_syscall32_callback)
86 86 CALLBACK_PROLOGUE(XXX_emulation_table, SPD_HANDLER, SYSCALL_REG,
87 87 SCR_REG, SCR_REGB);
88 88 CALC_TABLE_ADDR(SCR_REG, SPD_HANDLER);
89 89 mov %rcx, SYSCALL_REG; /* save orig return addr in syscall_reg */
90 90 mov SCR_REG, %rcx; /* place new return addr in %rcx */
91 91 mov %gs:CPU_RTMP_R15, SCR_REG; /* restore scratch register */
92 - call *x86_md_clear /* Flush micro-arch state */
92 + call x86_md_clear /* Flush micro-arch state */
93 93 mov V_SSP(SP_REG), SP_REG /* restore user stack pointer */
94 94 jmp nopop_sys_syscall32_swapgs_sysretl
95 95 9:
96 96 retq
97 97 SET_SIZE(XXX_brand_syscall32_callback)
98 98
99 99 /*
100 100 * syscall handler for 64-bit user processes:
101 101 * See "64-BIT INTERPOSITION STACK" in brand_asm.h.
102 102 * To 'return' to our user-space handler, we just need to place its address
103 103 * into %rcx. The original return address is passed back in SYSCALL_REG.
104 104 */
105 105 ENTRY(XXX_brand_syscall_callback)
106 106 CALLBACK_PROLOGUE(XXX_emulation_table, SPD_HANDLER, SYSCALL_REG,
107 107 SCR_REG, SCR_REGB);
108 108 CALC_TABLE_ADDR(SCR_REG, SPD_HANDLER);
109 109 mov %rcx, SYSCALL_REG; /* save orig return addr in syscall_reg */
110 110 mov SCR_REG, %rcx; /* place new return addr in %rcx */
111 111 mov %gs:CPU_RTMP_R15, SCR_REG; /* restore scratch register */
112 - call *x86_md_clear /* Flush micro-arch state */
112 + call x86_md_clear /* Flush micro-arch state */
113 113 mov V_SSP(SP_REG), SP_REG /* restore user stack pointer */
114 114 jmp nopop_sys_syscall_swapgs_sysretq
115 115 9:
116 116 retq
117 117 SET_SIZE(XXX_brand_syscall_callback)
118 118
119 119 /*
120 120 * See "64-BIT INTERPOSITION STACK" in brand_asm.h.
121 121 * To 'return' to our user-space handler, we just need to place its address
122 122 * into %rdx. The original return address is passed back in SYSCALL_REG.
123 123 */
124 124 ENTRY(XXX_brand_sysenter_callback)
125 125 CALLBACK_PROLOGUE(XXX_emulation_table, SPD_HANDLER, SYSCALL_REG,
126 126 SCR_REG, SCR_REGB);
127 127 CALC_TABLE_ADDR(SCR_REG, SPD_HANDLER);
128 128 mov %rdx, SYSCALL_REG; /* save orig return addr in syscall_reg */
129 129 mov SCR_REG, %rdx; /* place new return addr in %rdx */
130 130 mov %gs:CPU_RTMP_R15, SCR_REG; /* restore scratch register */
131 131 mov V_SSP(SP_REG), SP_REG /* restore user stack pointer */
132 132 jmp sys_sysenter_swapgs_sysexit
133 133 9:
134 134 ret
135 135 SET_SIZE(XXX_brand_sysenter_callback)
136 136
137 137 /*
138 138 * To 'return' to our user-space handler we need to update the user's %eip
139 139 * pointer in the saved interrupt state on the stack. The interrupt state was
140 140 * pushed onto our stack automatically when the interrupt occured; see the
141 141 * comments above. The original return address is passed back in SYSCALL_REG.
142 142 * See "64-BIT INTERPOSITION STACK" and "64-BIT INT STACK" in brand_asm.h.
143 143 */
144 144 ENTRY(XXX_brand_int91_callback)
145 145 CALLBACK_PROLOGUE(XXX_emulation_table, SPD_HANDLER, SYSCALL_REG,
146 146 SCR_REG, SCR_REGB);
147 147 CALC_TABLE_ADDR(SCR_REG, SPD_HANDLER); /* new ret addr is in scratch */
148 148 mov SCR_REG, SYSCALL_REG; /* place new ret addr in syscallreg */
149 149 mov %gs:CPU_RTMP_R15, SCR_REG; /* restore scratch register */
150 150 mov V_SSP(SP_REG), SP_REG; /* restore intr stack pointer */
151 151 /*CSTYLED*/
152 152 xchg (SP_REG), SYSCALL_REG /* swap new and orig. return addrs */
153 153 jmp sys_sysint_swapgs_iret
154 154 9:
155 155 retq
156 156 SET_SIZE(XXX_brand_int91_callback)
157 157
158 158 #else /* !__amd64 */
159 159
160 160 /*
161 161 * To 'return' to our user-space handler, we need to replace the iret target
162 162 * address. The original return address is passed back in %eax.
163 163 * See "32-BIT INTERPOSITION STACK" and "32-BIT INT STACK" in brand_asm.h.
164 164 */
165 165 ENTRY(XXX_brand_syscall_callback)
166 166 CALLBACK_PROLOGUE(XXX_emulation_table, SPD_HANDLER, SYSCALL_REG,
167 167 SCR_REG, SCR_REGB);
168 168 CALC_TABLE_ADDR(SCR_REG, SPD_HANDLER); /* new ret addr is in scratch */
169 169 mov SCR_REG, SYSCALL_REG; /* place new ret addr in syscallreg */
170 170 GET_V(SP_REG, 0, V_U_EBX, SCR_REG); /* restore scratch register */
171 171 add $V_END, SP_REG; /* restore intr stack pointer */
172 172 /*CSTYLED*/
173 173 xchg (SP_REG), SYSCALL_REG /* swap new and orig. return addrs */
174 174 jmp nopop_sys_rtt_syscall
175 175 9:
176 176 ret
177 177 SET_SIZE(XXX_brand_syscall_callback)
178 178
179 179 /*
180 180 * To 'return' to our user-space handler, we just need to place its address
181 181 * into %edx. The original return address is passed back in SYSCALL_REG.
182 182 * See "32-BIT INTERPOSITION STACK" in brand_asm.h.
183 183 */
184 184 ENTRY(XXX_brand_sysenter_callback)
185 185 CALLBACK_PROLOGUE(XXX_emulation_table, SPD_HANDLER, SYSCALL_REG,
186 186 SCR_REG, SCR_REGB);
187 187 mov %edx, SCR_REG; /* save orig return addr in scr reg */
188 188 CALC_TABLE_ADDR(%edx, SPD_HANDLER); /* new return addr is in %edx */
189 189 mov SCR_REG, SYSCALL_REG; /* save orig return addr in %eax */
190 190 GET_V(SP_REG, 0, V_U_EBX, SCR_REG) /* restore scratch register */
191 191 sysexit
192 192 9:
193 193 ret
194 194 SET_SIZE(XXX_brand_sysenter_callback)
195 195
196 196 #endif /* !__amd64 */
197 197 #endif /* _ASM */
198 198 #endif /* !lint */
↓ open down ↓ |
76 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX