4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #pragma ident "%Z%%M% %I% %E% SMI"
27
28 /*
29 * Companion to kdi_idt.c - the implementation of the trap and interrupt
30 * handlers. For the most part, these handlers do the same thing - they
31 * push a trap number onto the stack, followed by a jump to kdi_cmnint.
32 * Each trap and interrupt has its own handler because each one pushes a
33 * different number.
34 */
35
36 #include <sys/asm_linkage.h>
37 #include <sys/kdi_regs.h>
38
39 /* Nothing in this file is of interest to lint. */
40 #if !defined(__lint)
41
42 /*
43 * The default ASM_ENTRY_ALIGN (16) wastes far too much space. Pay no
44 * attention to the fleet of nop's we're adding to each handler.
45 */
46 #undef ASM_ENTRY_ALIGN
47 #define ASM_ENTRY_ALIGN 8
48
49 /*
50 * We need the .align in ENTRY_NP (defined to be ASM_ENTRY_ALIGN) to match our
51 * manual .align (KDI_MSR_PATCHOFF) in order to ensure that the space reserved
52 * at the beginning of the handler for code is exactly KDI_MSR_PATCHOFF bytes
53 * long. Note that the #error below isn't supported by the preprocessor invoked
54 * by as(1), and won't stop the build, but it'll emit a noticeable error message
55 * which won't escape the filters.
56 */
57 #if ASM_ENTRY_ALIGN != KDI_MSR_PATCHOFF
58 #error "ASM_ENTRY_ALIGN != KDI_MSR_PATCHOFF"
59 this won't assemble
60 #endif
61
62 /*
63 * kdi_idt_patch will, on certain processors, replace the patch points below
64 * with MSR-clearing code. kdi_id_patch has intimate knowledge of the size of
65 * the nop hole, as well as the structure of the handlers. Do not change
66 * anything here without also changing kdi_idt_patch.
67 */
68
69 /*
70 * Generic trap and interrupt handlers.
71 */
72
73 #if defined(__xpv) && defined(__amd64)
74
75 /*
76 * The hypervisor places r11 and rcx on the stack.
77 */
78
79 #define TRAP_NOERR(trapno) \
80 popq %rcx; \
81 popq %r11; \
82 pushq $trapno
83
84 #define TRAP_ERR(trapno) \
85 popq %rcx; \
86 popq %r11; \
87 pushq $0; \
88 pushq $trapno
89
90 #else
91
92 #define TRAP_NOERR(trapno) \
93 push $trapno
94
95 #define TRAP_ERR(trapno) \
96 push $0; \
97 push $trapno
98
99 #endif /* __xpv && __amd64 */
100
101
102 #define MKIVCT(n) \
103 ENTRY_NP(kdi_ivct/**/n/**/); \
104 TRAP_ERR(n); \
105 .align KDI_MSR_PATCHOFF; \
106 KDI_MSR_PATCH; \
107 jmp kdi_cmnint; \
108 SET_SIZE(kdi_ivct/**/n/**/)
109
110 #define MKTRAPHDLR(n) \
111 ENTRY_NP(kdi_trap/**/n); \
112 TRAP_ERR(n); \
113 .align KDI_MSR_PATCHOFF; \
114 KDI_MSR_PATCH; \
115 jmp kdi_cmnint; \
116 SET_SIZE(kdi_trap/**/n/**/)
117
118 #define MKTRAPERRHDLR(n) \
119 ENTRY_NP(kdi_traperr/**/n); \
120 TRAP_NOERR(n); \
121 .align KDI_MSR_PATCHOFF; \
122 KDI_MSR_PATCH; \
123 jmp kdi_cmnint; \
124 SET_SIZE(kdi_traperr/**/n)
125
126 #define MKNMIHDLR \
127 ENTRY_NP(kdi_int2); \
128 TRAP_NOERR(2); \
129 .align KDI_MSR_PATCHOFF; \
130 KDI_MSR_PATCH; \
131 jmp kdi_nmiint; \
132 SET_SIZE(kdi_int2)
133
134 #define MKINVALHDLR \
135 ENTRY_NP(kdi_invaltrap); \
136 TRAP_NOERR(255); \
137 .align KDI_MSR_PATCHOFF; \
138 KDI_MSR_PATCH; \
139 jmp kdi_cmnint; \
140 SET_SIZE(kdi_invaltrap)
141
142 /*
143 * The handlers themselves
144 */
145
146 MKINVALHDLR
147 MKTRAPHDLR(0)
148 MKTRAPHDLR(1)
149 MKNMIHDLR/*2*/
150 MKTRAPHDLR(3)
151 MKTRAPHDLR(4)
152 MKTRAPHDLR(5)
153 MKTRAPHDLR(6)
154 MKTRAPHDLR(7)
155 MKTRAPHDLR(9)
156 MKTRAPHDLR(15)
157 MKTRAPHDLR(16)
158 MKTRAPHDLR(17)
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 *
25 * Copyright 2018 Joyent, Inc.
26 */
27
28 /*
29 * Companion to kdi_idt.c - the implementation of the trap and interrupt
30 * handlers. For the most part, these handlers do the same thing - they
31 * push a trap number onto the stack, followed by a jump to kdi_cmnint.
32 * Each trap and interrupt has its own handler because each one pushes a
33 * different number.
34 */
35
36 #include <sys/asm_linkage.h>
37 #include <sys/kdi_regs.h>
38
39 /* Nothing in this file is of interest to lint. */
40 #if !defined(__lint)
41
42 /*
43 * The default ASM_ENTRY_ALIGN (16) wastes far too much space. Pay no
44 * attention to the fleet of nop's we're adding to each handler.
45 */
46 #undef ASM_ENTRY_ALIGN
47 #define ASM_ENTRY_ALIGN 8
48
49 /*
50 * Generic trap and interrupt handlers.
51 */
52
53 #if defined(__xpv) && defined(__amd64)
54
55 /*
56 * The hypervisor places r11 and rcx on the stack.
57 */
58
59 #define TRAP_NOERR(trapno) \
60 popq %rcx; \
61 popq %r11; \
62 pushq $trapno
63
64 #define TRAP_ERR(trapno) \
65 popq %rcx; \
66 popq %r11; \
67 pushq $0; \
68 pushq $trapno
69
70 #else
71
72 #define TRAP_NOERR(trapno) \
73 push $trapno
74
75 #define TRAP_ERR(trapno) \
76 push $0; \
77 push $trapno
78
79 #endif /* __xpv && __amd64 */
80
81
82 #define MKIVCT(n) \
83 ENTRY_NP(kdi_ivct/**/n/**/); \
84 TRAP_ERR(n); \
85 jmp kdi_cmnint; \
86 SET_SIZE(kdi_ivct/**/n/**/)
87
88 #define MKTRAPHDLR(n) \
89 ENTRY_NP(kdi_trap/**/n); \
90 TRAP_ERR(n); \
91 jmp kdi_cmnint; \
92 SET_SIZE(kdi_trap/**/n/**/)
93
94 #define MKTRAPERRHDLR(n) \
95 ENTRY_NP(kdi_traperr/**/n); \
96 TRAP_NOERR(n); \
97 jmp kdi_cmnint; \
98 SET_SIZE(kdi_traperr/**/n)
99
100 #define MKNMIHDLR \
101 ENTRY_NP(kdi_int2); \
102 TRAP_NOERR(2); \
103 jmp kdi_nmiint; \
104 SET_SIZE(kdi_int2)
105
106 #define MKINVALHDLR \
107 ENTRY_NP(kdi_invaltrap); \
108 TRAP_NOERR(255); \
109 jmp kdi_cmnint; \
110 SET_SIZE(kdi_invaltrap)
111
112 /*
113 * The handlers themselves
114 */
115
116 MKINVALHDLR
117 MKTRAPHDLR(0)
118 MKTRAPHDLR(1)
119 MKNMIHDLR/*2*/
120 MKTRAPHDLR(3)
121 MKTRAPHDLR(4)
122 MKTRAPHDLR(5)
123 MKTRAPHDLR(6)
124 MKTRAPHDLR(7)
125 MKTRAPHDLR(9)
126 MKTRAPHDLR(15)
127 MKTRAPHDLR(16)
128 MKTRAPHDLR(17)
|