Print this page
de-linting of .s files
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/kdi/kdi_idthdl.s
+++ new/usr/src/uts/intel/kdi/kdi_idthdl.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 2007 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 *
25 25 * Copyright 2018 Joyent, Inc.
↓ open down ↓ |
25 lines elided |
↑ open up ↑ |
26 26 */
27 27
28 28 /*
29 29 * Companion to kdi_asm.s - the implementation of the trap and interrupt
30 30 * handlers. For the most part, these handlers do the same thing - they
31 31 * push a trap number onto the stack, followed by a jump to kdi_cmnint.
32 32 * Each trap and interrupt has its own handler because each one pushes a
33 33 * different number.
34 34 */
35 35
36 -#if defined(__lint)
37 -#include <sys/types.h>
38 -#else
39 -
40 36 #include <sys/asm_linkage.h>
41 37 #include <sys/asm_misc.h>
42 38 #include <sys/machprivregs.h>
43 39 #include <sys/privregs.h>
44 40 #include <sys/kdi_regs.h>
45 41 #include <sys/trap.h>
46 42 #include <sys/param.h>
47 43
48 44 #include <kdi_assym.h>
49 45 #include <assym.h>
50 46
51 47 /*
52 48 * The default ASM_ENTRY_ALIGN (16) wastes far too much space.
53 49 */
54 50 #undef ASM_ENTRY_ALIGN
55 51 #define ASM_ENTRY_ALIGN 8
56 52
57 53 /*
58 54 * Generic trap and interrupt handlers.
59 55 */
60 56
61 57 #if defined(__xpv)
62 58
63 59 #define INTERRUPT_TRAMPOLINE
64 60
65 61 #else
66 62
67 63 /*
68 64 * If we're !xpv, then we will need to support KPTI (kernel page table
69 65 * isolation), where we have separate page tables for user and kernel modes.
70 66 * There's more detail about this in kpti_trampolines.s and hat_i86.c
71 67 */
72 68
73 69 #define INTERRUPT_TRAMPOLINE \
74 70 pushq %r13; \
75 71 pushq %r14; \
76 72 subq $KPTI_R14, %rsp; \
77 73 /* Check for clobbering */ \
78 74 cmp $0, KPTI_FLAG(%rsp); \
79 75 je 1f; \
80 76 /* Don't worry, this totally works */ \
81 77 int $8; \
82 78 1: \
83 79 movq $1, KPTI_FLAG(%rsp); \
84 80 /* Save current %cr3. */ \
85 81 mov %cr3, %r14; \
86 82 mov %r14, KPTI_TR_CR3(%rsp); \
87 83 /* Switch to paranoid %cr3. */ \
88 84 mov kpti_safe_cr3, %r14; \
89 85 mov %r14, %cr3; \
90 86 \
91 87 cmpw $KCS_SEL, KPTI_CS(%rsp); \
92 88 je 3f; \
93 89 2: \
94 90 /* Get our cpu_t in %r13 */ \
95 91 mov %rsp, %r13; \
96 92 and $(~(MMU_PAGESIZE - 1)), %r13; \
97 93 subq $CPU_KPTI_START, %r13; \
98 94 /* Use top of the kthread stk */ \
99 95 mov CPU_THREAD(%r13), %r14; \
100 96 mov T_STACK(%r14), %r14; \
101 97 addq $REGSIZE+MINFRAME, %r14; \
102 98 jmp 5f; \
103 99 3: \
104 100 /* Check the %rsp in the frame. */ \
105 101 /* Is it above kernel base? */ \
106 102 mov kpti_kbase, %r14; \
107 103 cmp %r14, KPTI_RSP(%rsp); \
108 104 jb 2b; \
109 105 /* Is it within the kpti_frame page? */ \
110 106 mov %rsp, %r13; \
111 107 and $(~(MMU_PAGESIZE - 1)), %r13; \
112 108 mov KPTI_RSP(%rsp), %r14; \
113 109 and $(~(MMU_PAGESIZE - 1)), %r14; \
114 110 cmp %r13, %r14; \
115 111 je 2b; \
116 112 /* Use the %rsp from the trap frame. */ \
117 113 /* We already did %cr3. */ \
118 114 mov KPTI_RSP(%rsp), %r14; \
119 115 and $(~0xf), %r14; \
120 116 5: \
121 117 mov %rsp, %r13; \
122 118 /* %r14 contains our destination stk */ \
123 119 mov %r14, %rsp; \
124 120 pushq KPTI_SS(%r13); \
125 121 pushq KPTI_RSP(%r13); \
126 122 pushq KPTI_RFLAGS(%r13); \
127 123 pushq KPTI_CS(%r13); \
128 124 pushq KPTI_RIP(%r13); \
129 125 pushq KPTI_ERR(%r13); \
130 126 mov KPTI_R14(%r13), %r14; \
131 127 movq $0, KPTI_FLAG(%r13); \
132 128 mov KPTI_R13(%r13), %r13
133 129
134 130 #endif /* !__xpv */
135 131
136 132
137 133 #define MKIVCT(n) \
138 134 ENTRY_NP(kdi_ivct/**/n/**/); \
139 135 XPV_TRAP_POP; \
140 136 push $0; /* err */ \
141 137 INTERRUPT_TRAMPOLINE; \
142 138 push $n; \
143 139 jmp kdi_cmnint; \
144 140 SET_SIZE(kdi_ivct/**/n/**/)
145 141
146 142 #define MKTRAPHDLR(n) \
147 143 ENTRY_NP(kdi_trap/**/n); \
148 144 XPV_TRAP_POP; \
149 145 push $0; /* err */ \
150 146 INTERRUPT_TRAMPOLINE; \
151 147 push $n; \
152 148 jmp kdi_cmnint; \
153 149 SET_SIZE(kdi_trap/**/n/**/)
154 150
155 151 #define MKTRAPERRHDLR(n) \
156 152 ENTRY_NP(kdi_traperr/**/n); \
157 153 XPV_TRAP_POP; \
158 154 INTERRUPT_TRAMPOLINE; \
159 155 push $n; \
160 156 jmp kdi_cmnint; \
161 157 SET_SIZE(kdi_traperr/**/n)
162 158
163 159 #if !defined(__xpv)
164 160 #define MKNMIHDLR \
165 161 ENTRY_NP(kdi_int2); \
166 162 push $0; \
167 163 push $2; \
168 164 pushq %r13; \
169 165 mov kpti_safe_cr3, %r13; \
170 166 mov %r13, %cr3; \
171 167 popq %r13; \
172 168 jmp kdi_nmiint; \
173 169 SET_SIZE(kdi_int2)
174 170
175 171 #define MKMCEHDLR \
176 172 ENTRY_NP(kdi_trap18); \
177 173 push $0; \
178 174 push $18; \
179 175 pushq %r13; \
180 176 mov kpti_safe_cr3, %r13; \
181 177 mov %r13, %cr3; \
182 178 popq %r13; \
183 179 jmp kdi_cmnint; \
184 180 SET_SIZE(kdi_trap18)
185 181 #else
186 182 #define MKNMIHDLR \
187 183 ENTRY_NP(kdi_int2); \
188 184 push $0; \
189 185 push $2; \
190 186 jmp kdi_nmiint; \
191 187 SET_SIZE(kdi_int2)
192 188
193 189 #define MKMCEHDLR \
194 190 ENTRY_NP(kdi_trap18); \
195 191 push $0; \
196 192 push $18; \
197 193 jmp kdi_cmnint; \
198 194 SET_SIZE(kdi_trap18)
199 195 #endif
200 196
201 197 /*
202 198 * The only way we should reach here is by an explicit "int 0x.." which is
203 199 * defined not to push an error code.
204 200 */
205 201 #define MKINVALHDLR \
206 202 ENTRY_NP(kdi_invaltrap); \
207 203 XPV_TRAP_POP; \
208 204 push $0; /* err */ \
209 205 INTERRUPT_TRAMPOLINE; \
210 206 push $255; \
211 207 jmp kdi_cmnint; \
212 208 SET_SIZE(kdi_invaltrap)
213 209
214 210 .data
215 211 DGDEF3(kdi_idt, 16 * NIDT, MMU_PAGESIZE)
216 212 .fill MMU_PAGESIZE, 1, 0
217 213
218 214 #if !defined(__xpv)
219 215 .section ".text"
220 216 .align MMU_PAGESIZE
221 217 .global kdi_isr_start
222 218 kdi_isr_start:
223 219 nop
224 220
225 221 .global kpti_safe_cr3
226 222 .global kpti_kbase
227 223 #endif
228 224
229 225 /*
230 226 * The handlers themselves
231 227 */
232 228
233 229 MKINVALHDLR
234 230 MKTRAPHDLR(0)
235 231 MKTRAPHDLR(1)
236 232 MKNMIHDLR/*2*/
237 233 MKTRAPHDLR(3)
238 234 MKTRAPHDLR(4)
239 235 MKTRAPHDLR(5)
240 236 MKTRAPHDLR(6)
241 237 MKTRAPHDLR(7)
242 238 MKTRAPHDLR(9)
243 239 MKTRAPHDLR(15)
244 240 MKTRAPHDLR(16)
245 241 MKMCEHDLR/*18*/
246 242 MKTRAPHDLR(19)
247 243 MKTRAPHDLR(20)
248 244
249 245 MKTRAPERRHDLR(8)
250 246 MKTRAPERRHDLR(10)
251 247 MKTRAPERRHDLR(11)
252 248 MKTRAPERRHDLR(12)
253 249 MKTRAPERRHDLR(13)
254 250 MKTRAPERRHDLR(14)
255 251 MKTRAPERRHDLR(17)
256 252
257 253 .globl kdi_ivct_size
258 254 kdi_ivct_size:
259 255 .NWORD [kdi_ivct33-kdi_ivct32]
260 256
261 257 /* 10 billion and one interrupt handlers */
262 258 kdi_ivct_base:
263 259 MKIVCT(32); MKIVCT(33); MKIVCT(34); MKIVCT(35);
264 260 MKIVCT(36); MKIVCT(37); MKIVCT(38); MKIVCT(39);
265 261 MKIVCT(40); MKIVCT(41); MKIVCT(42); MKIVCT(43);
266 262 MKIVCT(44); MKIVCT(45); MKIVCT(46); MKIVCT(47);
267 263 MKIVCT(48); MKIVCT(49); MKIVCT(50); MKIVCT(51);
268 264 MKIVCT(52); MKIVCT(53); MKIVCT(54); MKIVCT(55);
269 265 MKIVCT(56); MKIVCT(57); MKIVCT(58); MKIVCT(59);
270 266 MKIVCT(60); MKIVCT(61); MKIVCT(62); MKIVCT(63);
271 267 MKIVCT(64); MKIVCT(65); MKIVCT(66); MKIVCT(67);
272 268 MKIVCT(68); MKIVCT(69); MKIVCT(70); MKIVCT(71);
273 269 MKIVCT(72); MKIVCT(73); MKIVCT(74); MKIVCT(75);
274 270 MKIVCT(76); MKIVCT(77); MKIVCT(78); MKIVCT(79);
275 271 MKIVCT(80); MKIVCT(81); MKIVCT(82); MKIVCT(83);
276 272 MKIVCT(84); MKIVCT(85); MKIVCT(86); MKIVCT(87);
277 273 MKIVCT(88); MKIVCT(89); MKIVCT(90); MKIVCT(91);
278 274 MKIVCT(92); MKIVCT(93); MKIVCT(94); MKIVCT(95);
279 275 MKIVCT(96); MKIVCT(97); MKIVCT(98); MKIVCT(99);
280 276 MKIVCT(100); MKIVCT(101); MKIVCT(102); MKIVCT(103);
281 277 MKIVCT(104); MKIVCT(105); MKIVCT(106); MKIVCT(107);
282 278 MKIVCT(108); MKIVCT(109); MKIVCT(110); MKIVCT(111);
283 279 MKIVCT(112); MKIVCT(113); MKIVCT(114); MKIVCT(115);
284 280 MKIVCT(116); MKIVCT(117); MKIVCT(118); MKIVCT(119);
285 281 MKIVCT(120); MKIVCT(121); MKIVCT(122); MKIVCT(123);
286 282 MKIVCT(124); MKIVCT(125); MKIVCT(126); MKIVCT(127);
287 283 MKIVCT(128); MKIVCT(129); MKIVCT(130); MKIVCT(131);
288 284 MKIVCT(132); MKIVCT(133); MKIVCT(134); MKIVCT(135);
289 285 MKIVCT(136); MKIVCT(137); MKIVCT(138); MKIVCT(139);
290 286 MKIVCT(140); MKIVCT(141); MKIVCT(142); MKIVCT(143);
291 287 MKIVCT(144); MKIVCT(145); MKIVCT(146); MKIVCT(147);
292 288 MKIVCT(148); MKIVCT(149); MKIVCT(150); MKIVCT(151);
293 289 MKIVCT(152); MKIVCT(153); MKIVCT(154); MKIVCT(155);
294 290 MKIVCT(156); MKIVCT(157); MKIVCT(158); MKIVCT(159);
295 291 MKIVCT(160); MKIVCT(161); MKIVCT(162); MKIVCT(163);
296 292 MKIVCT(164); MKIVCT(165); MKIVCT(166); MKIVCT(167);
297 293 MKIVCT(168); MKIVCT(169); MKIVCT(170); MKIVCT(171);
298 294 MKIVCT(172); MKIVCT(173); MKIVCT(174); MKIVCT(175);
299 295 MKIVCT(176); MKIVCT(177); MKIVCT(178); MKIVCT(179);
300 296 MKIVCT(180); MKIVCT(181); MKIVCT(182); MKIVCT(183);
301 297 MKIVCT(184); MKIVCT(185); MKIVCT(186); MKIVCT(187);
302 298 MKIVCT(188); MKIVCT(189); MKIVCT(190); MKIVCT(191);
303 299 MKIVCT(192); MKIVCT(193); MKIVCT(194); MKIVCT(195);
304 300 MKIVCT(196); MKIVCT(197); MKIVCT(198); MKIVCT(199);
305 301 MKIVCT(200); MKIVCT(201); MKIVCT(202); MKIVCT(203);
306 302 MKIVCT(204); MKIVCT(205); MKIVCT(206); MKIVCT(207);
307 303 MKIVCT(208); MKIVCT(209); MKIVCT(210); MKIVCT(211);
308 304 MKIVCT(212); MKIVCT(213); MKIVCT(214); MKIVCT(215);
309 305 MKIVCT(216); MKIVCT(217); MKIVCT(218); MKIVCT(219);
310 306 MKIVCT(220); MKIVCT(221); MKIVCT(222); MKIVCT(223);
311 307 MKIVCT(224); MKIVCT(225); MKIVCT(226); MKIVCT(227);
312 308 MKIVCT(228); MKIVCT(229); MKIVCT(230); MKIVCT(231);
313 309 MKIVCT(232); MKIVCT(233); MKIVCT(234); MKIVCT(235);
314 310 MKIVCT(236); MKIVCT(237); MKIVCT(238); MKIVCT(239);
315 311 MKIVCT(240); MKIVCT(241); MKIVCT(242); MKIVCT(243);
316 312 MKIVCT(244); MKIVCT(245); MKIVCT(246); MKIVCT(247);
317 313 MKIVCT(248); MKIVCT(249); MKIVCT(250); MKIVCT(251);
↓ open down ↓ |
268 lines elided |
↑ open up ↑ |
318 314 MKIVCT(252); MKIVCT(253); MKIVCT(254); MKIVCT(255);
319 315
320 316 #if !defined(__xpv)
321 317 .section ".text"
322 318 .align MMU_PAGESIZE
323 319 .global kdi_isr_end
324 320 kdi_isr_end:
325 321 nop
326 322 #endif
327 323
328 -#endif /* !__lint */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX