Print this page
8956 Implement KPTI
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/i86pc/sys/machprivregs.h
+++ new/usr/src/uts/i86pc/sys/machprivregs.h
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.
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
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 /*
23 23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 + *
26 + * Copyright 2018 Joyent, Inc.
25 27 */
26 28
27 29 #ifndef _SYS_MACHPRIVREGS_H
28 30 #define _SYS_MACHPRIVREGS_H
29 31
30 -#pragma ident "%Z%%M% %I% %E% SMI"
31 -
32 32 /*
33 33 * Platform dependent instruction sequences for manipulating
34 34 * privileged state
35 35 */
36 36
37 37 #ifdef __cplusplus
38 38 extern "C" {
39 39 #endif
40 40
41 41 #define ASSERT_UPCALL_MASK_IS_SET /* empty */
42 42
43 43 /*
44 44 * CLI and STI
45 45 */
46 46
47 47 #define CLI(r) \
48 48 cli
49 49
50 50 #define STI \
51 51 sti
52 52
53 53 /*
54 54 * Used to re-enable interrupts in the body of exception handlers
55 55 */
56 56
57 57 #if defined(__amd64)
58 58
59 59 #define ENABLE_INTR_FLAGS \
60 60 pushq $F_ON; \
61 61 popfq
62 62
63 63 #elif defined(__i386)
64 64
65 65 #define ENABLE_INTR_FLAGS \
66 66 pushl $F_ON; \
67 67 popfl
68 68
69 69 #endif /* __i386 */
↓ open down ↓ |
28 lines elided |
↑ open up ↑ |
70 70
71 71 /*
72 72 * IRET and SWAPGS
73 73 */
74 74 #if defined(__amd64)
75 75
76 76 #define IRET iretq
77 77 #define SYSRETQ sysretq
78 78 #define SYSRETL sysretl
79 79 #define SWAPGS swapgs
80 -#define XPV_TRAP_POP /* empty */
81 -#define XPV_TRAP_PUSH /* empty */
82 80
83 81 #elif defined(__i386)
84 82
85 83 #define IRET iret
86 84
87 85 #endif /* __i386 */
88 86
87 +#define XPV_TRAP_POP /* empty */
88 +#define XPV_TRAP_PUSH /* empty */
89 89 #define CLEAN_CS /* empty */
90 90
91 91
92 92 /*
93 93 * Macros for saving the original segment registers and restoring them
94 94 * for fast traps.
95 95 */
96 96 #if defined(__amd64)
97 97
98 98 /*
99 99 * Smaller versions of INTR_PUSH and INTR_POP for fast traps.
100 100 * The following registers have been pushed onto the stack by
101 101 * hardware at this point:
102 102 *
103 103 * greg_t r_rip;
104 104 * greg_t r_cs;
105 105 * greg_t r_rfl;
106 106 * greg_t r_rsp;
107 107 * greg_t r_ss;
108 108 *
109 109 * This handler is executed both by 32-bit and 64-bit applications.
110 110 * 64-bit applications allow us to treat the set (%rdi, %rsi, %rdx,
111 111 * %rcx, %r8, %r9, %r10, %r11, %rax) as volatile across function calls.
112 112 * However, 32-bit applications only expect (%eax, %edx, %ecx) to be volatile
113 113 * across a function call -- in particular, %esi and %edi MUST be saved!
114 114 *
115 115 * We could do this differently by making a FAST_INTR_PUSH32 for 32-bit
116 116 * programs, and FAST_INTR_PUSH for 64-bit programs, but it doesn't seem
117 117 * particularly worth it.
118 118 */
119 119 #define FAST_INTR_PUSH \
120 120 INTGATE_INIT_KERNEL_FLAGS; \
121 121 subq $REGOFF_RIP, %rsp; \
↓ open down ↓ |
23 lines elided |
↑ open up ↑ |
122 122 movq %rsi, REGOFF_RSI(%rsp); \
123 123 movq %rdi, REGOFF_RDI(%rsp); \
124 124 swapgs
125 125
126 126 #define FAST_INTR_POP \
127 127 swapgs; \
128 128 movq REGOFF_RSI(%rsp), %rsi; \
129 129 movq REGOFF_RDI(%rsp), %rdi; \
130 130 addq $REGOFF_RIP, %rsp
131 131
132 -#define FAST_INTR_RETURN iretq
132 +#define FAST_INTR_RETURN jmp tr_iret_user
133 133
134 134 #elif defined(__i386)
135 135
136 136 #define FAST_INTR_PUSH \
137 137 cld; \
138 138 __SEGREGS_PUSH \
139 139 __SEGREGS_LOAD_KERNEL
140 140
141 141 #define FAST_INTR_POP \
142 142 __SEGREGS_POP
143 143
144 144 #define FAST_INTR_RETURN iret
145 145
146 146 #endif /* __i386 */
147 147
148 148 /*
149 149 * Handling the CR0.TS bit for floating point handling.
150 150 *
151 151 * When the TS bit is *set*, attempts to touch the floating
152 152 * point hardware will result in a #nm trap.
153 153 */
154 154 #if defined(__amd64)
155 155
156 156 #define STTS(rtmp) \
157 157 movq %cr0, rtmp; \
158 158 orq $CR0_TS, rtmp; \
159 159 movq rtmp, %cr0
160 160
161 161 #elif defined(__i386)
162 162
163 163 #define STTS(rtmp) \
164 164 movl %cr0, rtmp; \
165 165 orl $CR0_TS, rtmp; \
166 166 movl rtmp, %cr0
167 167
168 168 #endif /* __i386 */
169 169
170 170 #define CLTS \
171 171 clts
172 172
173 173 #ifdef __cplusplus
174 174 }
175 175 #endif
176 176
177 177 #endif /* _SYS_MACHPRIVREGS_H */
↓ open down ↓ |
35 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX