Print this page
10924 Need mitigation of L1TF (CVE-2018-3646)
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Peter Tribble <peter.tribble@gmail.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/disp.h
+++ new/usr/src/uts/common/sys/disp.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.
15 15 * If applicable, add the following below this CDDL HEADER, with the
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
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 2013 Nexenta Systems, Inc. All rights reserved.
26 + *
27 + * Copyright 2018 Joyent, Inc.
26 28 */
27 29
28 30 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
29 31 /* All Rights Reserved */
30 32
31 33
32 34 #ifndef _SYS_DISP_H
33 35 #define _SYS_DISP_H
34 36
35 37 #include <sys/priocntl.h>
36 38 #include <sys/thread.h>
37 39 #include <sys/class.h>
38 40
39 41 #ifdef __cplusplus
40 42 extern "C" {
41 43 #endif
42 44
43 45 /*
44 46 * The following is the format of a dispatcher queue entry.
45 47 */
46 48 typedef struct dispq {
47 49 kthread_t *dq_first; /* first thread on queue or NULL */
48 50 kthread_t *dq_last; /* last thread on queue or NULL */
49 51 int dq_sruncnt; /* number of loaded, runnable */
50 52 /* threads on queue */
51 53 } dispq_t;
52 54
53 55 /*
54 56 * Dispatch queue structure.
55 57 */
↓ open down ↓ |
20 lines elided |
↑ open up ↑ |
56 58 typedef struct _disp {
57 59 disp_lock_t disp_lock; /* protects dispatching fields */
58 60 pri_t disp_npri; /* # of priority levels in queue */
59 61 dispq_t *disp_q; /* the dispatch queue */
60 62 dispq_t *disp_q_limit; /* ptr past end of dispatch queue */
61 63 ulong_t *disp_qactmap; /* bitmap of active dispatch queues */
62 64
63 65 /*
64 66 * Priorities:
65 67 * disp_maxrunpri is the maximum run priority of runnable threads
66 - * on this queue. It is -1 if nothing is runnable.
68 + * on this queue. It is -1 if nothing is runnable.
67 69 *
68 70 * disp_max_unbound_pri is the maximum run priority of threads on
69 71 * this dispatch queue but runnable by any CPU. This may be left
70 - * artificially high, then corrected when some CPU tries to take
72 + * artificially high, then corrected when some CPU tries to take
71 73 * an unbound thread. It is -1 if nothing is runnable.
72 74 */
73 75 pri_t disp_maxrunpri; /* maximum run priority */
74 76 pri_t disp_max_unbound_pri; /* max pri of unbound threads */
75 77
76 78 volatile int disp_nrunnable; /* runnable threads in cpu dispq */
77 79
78 80 struct cpu *disp_cpu; /* cpu owning this queue or NULL */
79 81 hrtime_t disp_steal; /* time when threads become stealable */
80 82 } disp_t;
81 83
82 84 #if defined(_KERNEL) || defined(_FAKE_KERNEL)
83 85
84 86 #define MAXCLSYSPRI 99
85 87 #define MINCLSYSPRI 60
86 88
87 89
88 90 /*
89 91 * Global scheduling variables.
90 92 * - See sys/cpuvar.h for CPU-local variables.
91 93 */
92 94 extern int nswapped; /* number of swapped threads */
93 95 /* nswapped protected by swap_lock */
94 96
95 97 extern pri_t minclsyspri; /* minimum level of any system class */
96 98 extern pri_t maxclsyspri; /* maximum level of any system class */
97 99 extern pri_t intr_pri; /* interrupt thread priority base level */
98 100
99 101 #endif /* _KERNEL || _FAKE_KERNEL */
100 102 #if defined(_KERNEL)
101 103
102 104 /*
103 105 * Minimum amount of time that a thread can remain runnable before it can
104 106 * be stolen by another CPU (in nanoseconds).
105 107 */
106 108 extern hrtime_t nosteal_nsec;
107 109
108 110 /*
109 111 * Kernel preemption occurs if a higher-priority thread is runnable with
110 112 * a priority at or above kpreemptpri.
111 113 *
112 114 * So that other processors can watch for such threads, a separate
113 115 * dispatch queue with unbound work above kpreemptpri is maintained.
114 116 * This is part of the CPU partition structure (cpupart_t).
115 117 */
116 118 extern pri_t kpreemptpri; /* level above which preemption takes place */
117 119
118 120 extern void disp_kp_alloc(disp_t *, pri_t); /* allocate kp queue */
119 121 extern void disp_kp_free(disp_t *); /* free kp queue */
120 122
121 123 /*
122 124 * Macro for use by scheduling classes to decide whether the thread is about
123 125 * to be scheduled or not. This returns the maximum run priority.
124 126 */
125 127 #define DISP_MAXRUNPRI(t) ((t)->t_disp_queue->disp_maxrunpri)
126 128
127 129 /*
128 130 * Platform callbacks for various dispatcher operations
129 131 *
130 132 * idle_cpu() is invoked when a cpu goes idle, and has nothing to do.
131 133 * disp_enq_thread() is invoked when a thread is placed on a run queue.
132 134 */
133 135 extern void (*idle_cpu)();
134 136 extern void (*disp_enq_thread)(struct cpu *, int);
135 137
136 138
137 139 extern int dispdeq(kthread_t *);
138 140 extern void dispinit(void);
139 141 extern void disp_add(sclass_t *);
140 142 extern int intr_active(struct cpu *, int);
141 143 extern int servicing_interrupt(void);
142 144 extern void preempt(void);
143 145 extern void setbackdq(kthread_t *);
↓ open down ↓ |
63 lines elided |
↑ open up ↑ |
144 146 extern void setfrontdq(kthread_t *);
145 147 extern void swtch(void);
146 148 extern void swtch_to(kthread_t *);
147 149 extern void swtch_from_zombie(void)
148 150 __NORETURN;
149 151 extern void dq_sruninc(kthread_t *);
150 152 extern void dq_srundec(kthread_t *);
151 153 extern void cpu_rechoose(kthread_t *);
152 154 extern void cpu_surrender(kthread_t *);
153 155 extern void kpreempt(int);
154 -extern struct cpu *disp_lowpri_cpu(struct cpu *, struct lgrp_ld *, pri_t,
155 - struct cpu *);
156 +extern struct cpu *disp_lowpri_cpu(struct cpu *, kthread_t *, pri_t);
156 157 extern int disp_bound_threads(struct cpu *, int);
157 158 extern int disp_bound_anythreads(struct cpu *, int);
158 159 extern int disp_bound_partition(struct cpu *, int);
159 160 extern void disp_cpu_init(struct cpu *);
160 161 extern void disp_cpu_fini(struct cpu *);
161 162 extern void disp_cpu_inactive(struct cpu *);
162 163 extern void disp_adjust_unbound_pri(kthread_t *);
163 164 extern void resume(kthread_t *);
164 165 extern void resume_from_intr(kthread_t *);
165 166 extern void resume_from_zombie(kthread_t *)
166 167 __NORETURN;
167 168 extern void disp_swapped_enq(kthread_t *);
168 169 extern int disp_anywork(void);
169 170
171 +extern struct cpu *disp_choose_best_cpu(void);
172 +
170 173 #define KPREEMPT_SYNC (-1)
171 174 #define kpreempt_disable() \
172 175 { \
173 176 curthread->t_preempt++; \
174 177 ASSERT(curthread->t_preempt >= 1); \
175 178 }
176 179 #define kpreempt_enable() \
177 180 { \
178 181 ASSERT(curthread->t_preempt >= 1); \
179 182 if (--curthread->t_preempt == 0 && \
180 183 CPU->cpu_kprunrun) \
181 184 kpreempt(KPREEMPT_SYNC); \
182 185 }
183 186
184 187 #endif /* _KERNEL */
185 188
189 +#define CPU_IDLE_PRI (-1)
190 +
186 191 #ifdef __cplusplus
187 192 }
188 193 #endif
189 194
190 195 #endif /* _SYS_DISP_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX