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/i86pc/ml/fast_trap_asm.s
+++ new/usr/src/uts/i86pc/ml/fast_trap_asm.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
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
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 2007 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 + * Copyright 2019 Joyent, Inc.
24 25 */
25 26
26 -#pragma ident "%Z%%M% %I% %E% SMI"
27 -
28 27 #include <sys/asm_linkage.h>
29 28 #include <sys/asm_misc.h>
30 29 #include <sys/regset.h>
31 30 #include <sys/psw.h>
32 31
33 32 #if defined(__lint)
34 33
35 34 #include <sys/types.h>
36 35 #include <sys/thread.h>
37 36 #include <sys/systm.h>
38 37 #include <sys/lgrp.h>
39 38
40 39 #else /* __lint */
41 40
42 41 #include <sys/pcb.h>
43 42 #include <sys/trap.h>
44 43 #include <sys/ftrace.h>
45 44 #include <sys/traptrace.h>
46 45 #include <sys/clock.h>
47 46 #include <sys/panic.h>
48 47 #include <sys/privregs.h>
49 48
50 49 #include "assym.h"
51 50
52 51 #endif /* __lint */
53 52
54 53
55 54 #if defined(__lint)
56 55
57 56 hrtime_t
58 57 get_hrtime(void)
59 58 { return (0); }
60 59
61 60 hrtime_t
62 61 get_hrestime(void)
63 62 {
64 63 hrtime_t ts;
65 64
66 65 gethrestime((timespec_t *)&ts);
67 66 return (ts);
68 67 }
69 68
70 69 hrtime_t
71 70 gethrvtime(void)
72 71 {
73 72 klwp_t *lwp = ttolwp(curthread);
74 73 struct mstate *ms = &lwp->lwp_mstate;
75 74
76 75 return (gethrtime() - ms->ms_state_start + ms->ms_acct[LMS_USER]);
77 76 }
78 77
79 78 uint64_t
80 79 getlgrp(void)
81 80 {
82 81 return (((uint64_t)(curthread->t_lpl->lpl_lgrpid) << 32) |
83 82 curthread->t_cpu->cpu_id);
84 83 }
85 84
86 85 #else /* __lint */
87 86
88 87 /*
89 88 * XX64: We are assuming that libc continues to expect the 64-bit value being
90 89 * returned in %edx:%eax. We further assume that it is safe to leave
91 90 * the top 32-bit intact in %rax as they will be ignored by libc. In
92 91 * other words, if the 64-bit value is already in %rax, while we manually
93 92 * manufacture a 64-bit value in %edx:%eax by setting %edx to be the high
↓ open down ↓ |
56 lines elided |
↑ open up ↑ |
94 93 * 32 bits of %rax, we don't zero them out in %rax.
95 94 * The following amd64 versions will need to be changed if the above
96 95 * assumptions are not true.
97 96 */
98 97
99 98 #if defined(__amd64)
100 99
101 100 .globl gethrtimef
102 101 ENTRY_NP(get_hrtime)
103 102 FAST_INTR_PUSH
104 - call *gethrtimef(%rip)
103 + movq gethrtimef(%rip), %rax
104 + INDIRECT_CALL_REG(rax)
105 105 movq %rax, %rdx
106 106 shrq $32, %rdx /* high 32-bit in %edx */
107 107 FAST_INTR_POP
108 108 FAST_INTR_RETURN
109 109 SET_SIZE(get_hrtime)
110 110
111 111 #elif defined(__i386)
112 112
113 113 .globl gethrtimef
114 114 ENTRY_NP(get_hrtime)
115 115 FAST_INTR_PUSH
116 116 call *gethrtimef
117 117 FAST_INTR_POP
118 118 FAST_INTR_RETURN
119 119 SET_SIZE(get_hrtime)
↓ open down ↓ |
5 lines elided |
↑ open up ↑ |
120 120
121 121 #endif /* __i386 */
122 122
123 123 #if defined(__amd64)
124 124
125 125 .globl gethrestimef
126 126 ENTRY_NP(get_hrestime)
127 127 FAST_INTR_PUSH
128 128 subq $TIMESPEC_SIZE, %rsp
129 129 movq %rsp, %rdi
130 - call *gethrestimef(%rip)
130 + movq gethrestimef(%rip), %rax
131 + INDIRECT_CALL_REG(rax)
131 132 movl (%rsp), %eax
132 133 movl CLONGSIZE(%rsp), %edx
133 134 addq $TIMESPEC_SIZE, %rsp
134 135 FAST_INTR_POP
135 136 FAST_INTR_RETURN
136 137 SET_SIZE(get_hrestime)
137 138
138 139 #elif defined(__i386)
139 140
140 141 .globl gethrestimef
141 142 ENTRY_NP(get_hrestime)
142 143 FAST_INTR_PUSH
143 144 subl $TIMESPEC_SIZE, %esp
144 145 pushl %esp
145 146 call *gethrestimef
146 147 movl _CONST(4 + 0)(%esp), %eax
147 148 movl _CONST(4 + CLONGSIZE)(%esp), %edx
148 149 addl $_CONST(4 + TIMESPEC_SIZE), %esp
149 150 FAST_INTR_POP
150 151 FAST_INTR_RETURN
151 152 SET_SIZE(get_hrestime)
152 153
153 154 #endif /* __i386 */
154 155
155 156 #if defined(__amd64)
156 157
157 158 ENTRY_NP(gethrvtime)
158 159 FAST_INTR_PUSH
159 160 call gethrtime_unscaled /* get time since boot */
160 161 movq %gs:CPU_LWP, %rcx /* current lwp */
161 162 subq LWP_MS_STATE_START(%rcx), %rax /* - ms->ms_state_start */
162 163 addq LWP_ACCT_USER(%rcx), %rax /* add ms->ms_acct[LMS_USER] */
163 164 subq $16, %rsp
164 165 movq %rax, (%rsp)
165 166 movq %rsp, %rdi
166 167 call scalehrtime
167 168 movq (%rsp), %rax
168 169 addq $16, %rsp
169 170 movq %rax, %rdx
170 171 shrq $32, %rdx /* high 32-bit in %rdx */
171 172 FAST_INTR_POP
172 173 FAST_INTR_RETURN
173 174 SET_SIZE(gethrvtime)
174 175
175 176 #elif defined(__i386)
176 177
177 178 ENTRY_NP(gethrvtime)
178 179 FAST_INTR_PUSH
179 180 call gethrtime_unscaled /* get time since boot */
180 181 movl %gs:CPU_LWP, %ecx /* current lwp */
181 182 subl LWP_MS_STATE_START(%ecx), %eax /* - ms->ms_state_start */
182 183 sbbl LWP_MS_STATE_START+4(%ecx), %edx
183 184 addl LWP_ACCT_USER(%ecx), %eax /* add ms->ms_acct[LMS_USER] */
184 185 adcl LWP_ACCT_USER+4(%ecx), %edx
185 186 subl $0x8, %esp
186 187 leal (%esp), %ecx
187 188 movl %eax, (%ecx)
188 189 movl %edx, 4(%ecx)
189 190 pushl %ecx
190 191 call scalehrtime
191 192 popl %ecx
192 193 movl (%ecx), %eax
193 194 movl 4(%ecx), %edx
194 195 addl $0x8, %esp
195 196 FAST_INTR_POP
196 197 FAST_INTR_RETURN
197 198 SET_SIZE(gethrvtime)
198 199
199 200 #endif /* __i386 */
200 201
201 202 #if defined(__amd64)
202 203
203 204 ENTRY_NP(getlgrp)
204 205 FAST_INTR_PUSH
205 206 movq %gs:CPU_THREAD, %rcx
206 207 movq T_LPL(%rcx), %rcx
207 208 movl LPL_LGRPID(%rcx), %edx
208 209 movl %gs:CPU_ID, %eax
209 210 FAST_INTR_POP
210 211 FAST_INTR_RETURN
211 212 SET_SIZE(getlgrp)
212 213
213 214 #elif defined(__i386)
214 215
215 216 ENTRY_NP(getlgrp)
216 217 FAST_INTR_PUSH
217 218 movl %gs:CPU_THREAD, %ecx
218 219 movl T_LPL(%ecx), %ecx
219 220 movl LPL_LGRPID(%ecx), %edx
220 221 movl %gs:CPU_ID, %eax
221 222 FAST_INTR_POP
222 223 FAST_INTR_RETURN
223 224 SET_SIZE(getlgrp)
224 225
225 226 #endif /* __i386 */
226 227
227 228 #endif /* __lint */
↓ open down ↓ |
87 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX