Rewrite cprng_fast in terms of new ChaCha API.diff -r1.15 -r1.16 src/sys/crypto/cprng_fast/cprng_fast.c
(riastradh)
--- src/sys/crypto/cprng_fast/cprng_fast.c 2020/04/30 03:29:45 1.15
+++ src/sys/crypto/cprng_fast/cprng_fast.c 2020/07/28 20:15:07 1.16
@@ -1,509 +1,258 @@ | @@ -1,509 +1,258 @@ | |||
1 | /* $NetBSD: cprng_fast.c,v 1.15 2020/04/30 03:29:45 riastradh Exp $ */ | 1 | /* $NetBSD: cprng_fast.c,v 1.16 2020/07/28 20:15:07 riastradh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2014 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2014 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Taylor R. Campbell. | 8 | * by Taylor R. Campbell. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright | |
16 | * notice, this list of conditions and the following disclaimer in the | 16 | * notice, this list of conditions and the following disclaimer in the | |
17 | * documentation and/or other materials provided with the distribution. | 17 | * documentation and/or other materials provided with the distribution. | |
18 | * | 18 | * | |
19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | __KERNEL_RCSID(0, "$NetBSD: cprng_fast.c,v 1.15 2020/04/30 03:29:45 riastradh Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: cprng_fast.c,v 1.16 2020/07/28 20:15:07 riastradh Exp $"); | |
34 | 34 | |||
35 | #include <sys/types.h> | 35 | #include <sys/types.h> | |
36 | #include <sys/param.h> | 36 | #include <sys/param.h> | |
37 | #include <sys/bitops.h> | 37 | #include <sys/bitops.h> | |
38 | #include <sys/cprng.h> | 38 | #include <sys/cprng.h> | |
39 | #include <sys/cpu.h> | 39 | #include <sys/cpu.h> | |
40 | #include <sys/entropy.h> | 40 | #include <sys/entropy.h> | |
41 | #include <sys/evcnt.h> | 41 | #include <sys/evcnt.h> | |
42 | #include <sys/intr.h> | 42 | #include <sys/intr.h> | |
43 | #include <sys/kmem.h> | 43 | #include <sys/kmem.h> | |
44 | #include <sys/percpu.h> | 44 | #include <sys/percpu.h> | |
45 | ||||
46 | /* ChaCha core */ | |||
47 | ||||
48 | #define crypto_core_OUTPUTWORDS 16 | |||
49 | #define crypto_core_INPUTWORDS 4 | |||
50 | #define crypto_core_KEYWORDS 8 | |||
51 | #define crypto_core_CONSTWORDS 4 | |||
52 | ||||
53 | #define crypto_core_ROUNDS 8 | |||
54 | ||||
55 | static uint32_t | |||
56 | rotate(uint32_t u, unsigned c) | |||
57 | { | |||
58 | ||||
59 | return (u << c) | (u >> (32 - c)); | |||
60 | } | |||
61 | ||||
62 | #define QUARTERROUND(a, b, c, d) do { \ | |||
63 | (a) += (b); (d) ^= (a); (d) = rotate((d), 16); \ | |||
64 | (c) += (d); (b) ^= (c); (b) = rotate((b), 12); \ | |||
65 | (a) += (b); (d) ^= (a); (d) = rotate((d), 8); \ | |||
66 | (c) += (d); (b) ^= (c); (b) = rotate((b), 7); \ | |||
67 | } while (0) | |||
68 | ||||
69 | static void | |||
70 | crypto_core(uint32_t *out, const uint32_t *in, const uint32_t *k, | |||
71 | const uint32_t *c) | |||
72 | { | |||
73 | uint32_t x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15; | |||
74 | int i; | |||
75 | ||||
76 | x0 = c[0]; | |||
77 | x1 = c[1]; | |||
78 | x2 = c[2]; | |||
79 | x3 = c[3]; | |||
80 | x4 = k[0]; | |||
81 | x5 = k[1]; | |||
82 | x6 = k[2]; | |||
83 | x7 = k[3]; | |||
84 | x8 = k[4]; | |||
85 | x9 = k[5]; | |||
86 | x10 = k[6]; | |||
87 | x11 = k[7]; | |||
88 | x12 = in[0]; | |||
89 | x13 = in[1]; | |||
90 | x14 = in[2]; | |||
91 | x15 = in[3]; | |||
92 | ||||
93 | for (i = crypto_core_ROUNDS; i > 0; i -= 2) { | |||
94 | QUARTERROUND( x0, x4, x8,x12); | |||
95 | QUARTERROUND( x1, x5, x9,x13); | |||
96 | QUARTERROUND( x2, x6,x10,x14); | |||
97 | QUARTERROUND( x3, x7,x11,x15); | |||
98 | QUARTERROUND( x0, x5,x10,x15); | |||
99 | QUARTERROUND( x1, x6,x11,x12); | |||
100 | QUARTERROUND( x2, x7, x8,x13); | |||
101 | QUARTERROUND( x3, x4, x9,x14); | |||
102 | } | |||
103 | ||||
104 | out[0] = x0 + c[0]; | |||
105 | out[1] = x1 + c[1]; | |||
106 | out[2] = x2 + c[2]; | |||
107 | out[3] = x3 + c[3]; | |||
108 | out[4] = x4 + k[0]; | |||
109 | out[5] = x5 + k[1]; | |||
110 | out[6] = x6 + k[2]; | |||
111 | out[7] = x7 + k[3]; | |||
112 | out[8] = x8 + k[4]; | |||
113 | out[9] = x9 + k[5]; | |||
114 | out[10] = x10 + k[6]; | |||
115 | out[11] = x11 + k[7]; | |||
116 | out[12] = x12 + in[0]; | |||
117 | out[13] = x13 + in[1]; | |||
118 | out[14] = x14 + in[2]; | |||
119 | out[15] = x15 + in[3]; | |||
120 | } | |||
121 | ||||
122 | /* `expand 32-byte k' */ | |||
123 | static const uint32_t crypto_core_constant32[4] = { | |||
124 | 0x61707865U, 0x3320646eU, 0x79622d32U, 0x6b206574U, | |||
125 | }; | |||
126 | ||||
127 | /* | |||
128 | * Test vector for ChaCha20 from | |||
129 | * <http://tools.ietf.org/html/draft-strombergson-chacha-test-vectors-00>, | |||
130 | * test vectors for ChaCha12 and ChaCha8 generated by the same | |||
131 | * crypto_core code with crypto_core_ROUNDS varied. | |||
132 | */ | |||
133 | ||||
134 | #define check(E) do \ | |||
135 | { \ | |||
136 | if (!(E)) \ | |||
137 | panic("crypto self-test failed: %s", #E); \ | |||
138 | } while (0) | |||
139 | ||||
140 | static void | |||
141 | crypto_core_selftest(void) | |||
142 | { | |||
143 | const uint32_t zero32[8] = {0}; | |||
144 | const uint8_t sigma[] = "expand 32-byte k"; | |||
145 | uint32_t block[16]; | |||
146 | unsigned i; | |||
147 | ||||
148 | #if crypto_core_ROUNDS == 8 | |||
149 | static const uint8_t out[64] = { | |||
150 | 0x3e,0x00,0xef,0x2f,0x89,0x5f,0x40,0xd6, | |||
151 | 0x7f,0x5b,0xb8,0xe8,0x1f,0x09,0xa5,0xa1, | |||
152 | 0x2c,0x84,0x0e,0xc3,0xce,0x9a,0x7f,0x3b, | |||
153 | 0x18,0x1b,0xe1,0x88,0xef,0x71,0x1a,0x1e, | |||
154 | 0x98,0x4c,0xe1,0x72,0xb9,0x21,0x6f,0x41, | |||
155 | 0x9f,0x44,0x53,0x67,0x45,0x6d,0x56,0x19, | |||
156 | 0x31,0x4a,0x42,0xa3,0xda,0x86,0xb0,0x01, | |||
157 | 0x38,0x7b,0xfd,0xb8,0x0e,0x0c,0xfe,0x42, | |||
158 | }; | |||
159 | #elif crypto_core_ROUNDS == 12 | |||
160 | static const uint8_t out[64] = { | |||
161 | 0x9b,0xf4,0x9a,0x6a,0x07,0x55,0xf9,0x53, | |||
162 | 0x81,0x1f,0xce,0x12,0x5f,0x26,0x83,0xd5, | |||
163 | 0x04,0x29,0xc3,0xbb,0x49,0xe0,0x74,0x14, | |||
164 | 0x7e,0x00,0x89,0xa5,0x2e,0xae,0x15,0x5f, | |||
165 | 0x05,0x64,0xf8,0x79,0xd2,0x7a,0xe3,0xc0, | |||
166 | 0x2c,0xe8,0x28,0x34,0xac,0xfa,0x8c,0x79, | |||
167 | 0x3a,0x62,0x9f,0x2c,0xa0,0xde,0x69,0x19, | |||
168 | 0x61,0x0b,0xe8,0x2f,0x41,0x13,0x26,0xbe, | |||
169 | }; | |||
170 | #elif crypto_core_ROUNDS == 20 | |||
171 | static const uint8_t out[64] = { | |||
172 | 0x76,0xb8,0xe0,0xad,0xa0,0xf1,0x3d,0x90, | |||
173 | 0x40,0x5d,0x6a,0xe5,0x53,0x86,0xbd,0x28, | |||
174 | 0xbd,0xd2,0x19,0xb8,0xa0,0x8d,0xed,0x1a, | |||
175 | 0xa8,0x36,0xef,0xcc,0x8b,0x77,0x0d,0xc7, | |||
176 | 0xda,0x41,0x59,0x7c,0x51,0x57,0x48,0x8d, | |||
177 | 0x77,0x24,0xe0,0x3f,0xb8,0xd8,0x4a,0x37, | |||
178 | 0x6a,0x43,0xb8,0xf4,0x15,0x18,0xa1,0x1c, | |||
179 | 0xc3,0x87,0xb6,0x69,0xb2,0xee,0x65,0x86, | |||
180 | }; | |||
181 | #else | |||
182 | #error crypto_core_ROUNDS must be 8, 12, or 20. | |||
183 | #endif | |||
184 | 45 | |||
185 | check(crypto_core_constant32[0] == le32dec(&sigma[0])); | 46 | #include <crypto/chacha/chacha.h> | |
186 | check(crypto_core_constant32[1] == le32dec(&sigma[4])); | |||
187 | check(crypto_core_constant32[2] == le32dec(&sigma[8])); | |||
188 | check(crypto_core_constant32[3] == le32dec(&sigma[12])); | |||
189 | ||||
190 | crypto_core(block, zero32, zero32, crypto_core_constant32); | |||
191 | for (i = 0; i < 16; i++) | |||
192 | check(block[i] == le32dec(&out[i*4])); | |||
193 | } | |||
194 | ||||
195 | #undef check | |||
196 | 47 | |||
197 | #define CPRNG_FAST_SEED_BYTES (crypto_core_KEYWORDS * sizeof(uint32_t)) | 48 | #define CPRNG_FAST_SEED_BYTES CHACHA_STREAM_KEYBYTES | |
198 | 49 | |||
199 | struct cprng_fast { | 50 | struct cprng_fast { | |
200 | uint32_t buffer[crypto_core_OUTPUTWORDS]; | 51 | /* 128-bit vector unit generates 256 bytes at once */ | |
201 | uint32_t key[crypto_core_KEYWORDS]; | 52 | uint8_t buf[256]; | |
202 | uint32_t nonce[crypto_core_INPUTWORDS]; | 53 | uint8_t key[CPRNG_FAST_SEED_BYTES]; | |
54 | uint8_t nonce[CHACHA_STREAM_NONCEBYTES]; | |||
55 | unsigned i; | |||
203 | struct evcnt *reseed_evcnt; | 56 | struct evcnt *reseed_evcnt; | |
204 | unsigned epoch; | 57 | unsigned epoch; | |
205 | }; | 58 | }; | |
206 | 59 | |||
207 | __CTASSERT(sizeof ((struct cprng_fast *)0)->key == CPRNG_FAST_SEED_BYTES); | |||
208 | ||||
209 | static void cprng_fast_init_cpu(void *, void *, struct cpu_info *); | 60 | static void cprng_fast_init_cpu(void *, void *, struct cpu_info *); | |
210 | static void cprng_fast_schedule_reseed(struct cprng_fast *); | 61 | static void cprng_fast_schedule_reseed(struct cprng_fast *); | |
211 | static void cprng_fast_intr(void *); | 62 | static void cprng_fast_intr(void *); | |
212 | 63 | |||
213 | static void cprng_fast_seed(struct cprng_fast *, const void *); | 64 | static void cprng_fast_seed(struct cprng_fast *, const void *); | |
214 | static void cprng_fast_buf(struct cprng_fast *, void *, unsigned); | 65 | static void cprng_fast_buf(struct cprng_fast *, void *, unsigned); | |
215 | 66 | |||
216 | static void cprng_fast_buf_short(void *, size_t); | 67 | static void cprng_fast_buf_short(void *, size_t); | |
217 | static void cprng_fast_buf_long(void *, size_t); | 68 | static void cprng_fast_buf_long(void *, size_t); | |
218 | 69 | |||
219 | static percpu_t *cprng_fast_percpu __read_mostly; | 70 | static percpu_t *cprng_fast_percpu __read_mostly; | |
220 | static void *cprng_fast_softint __read_mostly; | 71 | static void *cprng_fast_softint __read_mostly; | |
221 | 72 | |||
222 | void | 73 | void | |
223 | cprng_fast_init(void) | 74 | cprng_fast_init(void) | |
224 | { | 75 | { | |
225 | 76 | |||
226 | crypto_core_selftest(); | |||
227 | cprng_fast_percpu = percpu_create(sizeof(struct cprng_fast), | 77 | cprng_fast_percpu = percpu_create(sizeof(struct cprng_fast), | |
228 | cprng_fast_init_cpu, NULL, NULL); | 78 | cprng_fast_init_cpu, NULL, NULL); | |
229 | cprng_fast_softint = softint_establish(SOFTINT_SERIAL|SOFTINT_MPSAFE, | 79 | cprng_fast_softint = softint_establish(SOFTINT_SERIAL|SOFTINT_MPSAFE, | |
230 | &cprng_fast_intr, NULL); | 80 | &cprng_fast_intr, NULL); | |
231 | } | 81 | } | |
232 | 82 | |||
233 | static void | 83 | static void | |
234 | cprng_fast_init_cpu(void *p, void *arg __unused, struct cpu_info *ci) | 84 | cprng_fast_init_cpu(void *p, void *arg __unused, struct cpu_info *ci) | |
235 | { | 85 | { | |
236 | struct cprng_fast *const cprng = p; | 86 | struct cprng_fast *const cprng = p; | |
237 | uint8_t seed[CPRNG_FAST_SEED_BYTES]; | 87 | uint8_t seed[CPRNG_FAST_SEED_BYTES]; | |
238 | 88 | |||
239 | cprng->epoch = entropy_epoch(); | 89 | cprng->epoch = entropy_epoch(); | |
240 | cprng_strong(kern_cprng, seed, sizeof seed, 0); | 90 | cprng_strong(kern_cprng, seed, sizeof seed, 0); | |
241 | cprng_fast_seed(cprng, seed); | 91 | cprng_fast_seed(cprng, seed); | |
242 | (void)explicit_memset(seed, 0, sizeof seed); | 92 | (void)explicit_memset(seed, 0, sizeof seed); | |
243 | 93 | |||
244 | cprng->reseed_evcnt = kmem_alloc(sizeof(*cprng->reseed_evcnt), | 94 | cprng->reseed_evcnt = kmem_alloc(sizeof(*cprng->reseed_evcnt), | |
245 | KM_SLEEP); | 95 | KM_SLEEP); | |
246 | evcnt_attach_dynamic(cprng->reseed_evcnt, EVCNT_TYPE_MISC, NULL, | 96 | evcnt_attach_dynamic(cprng->reseed_evcnt, EVCNT_TYPE_MISC, NULL, | |
247 | ci->ci_cpuname, "cprng_fast reseed"); | 97 | ci->ci_cpuname, "cprng_fast reseed"); | |
248 | } | 98 | } | |
249 | 99 | |||
250 | static inline int | 100 | static int | |
251 | cprng_fast_get(struct cprng_fast **cprngp) | 101 | cprng_fast_get(struct cprng_fast **cprngp) | |
252 | { | 102 | { | |
253 | struct cprng_fast *cprng; | 103 | struct cprng_fast *cprng; | |
254 | int s; | 104 | int s; | |
255 | 105 | |||
256 | *cprngp = cprng = percpu_getref(cprng_fast_percpu); | 106 | *cprngp = cprng = percpu_getref(cprng_fast_percpu); | |
257 | s = splvm(); | 107 | s = splvm(); | |
258 | 108 | |||
259 | if (__predict_false(cprng->epoch != entropy_epoch())) | 109 | if (__predict_false(cprng->epoch != entropy_epoch())) | |
260 | cprng_fast_schedule_reseed(cprng); | 110 | cprng_fast_schedule_reseed(cprng); | |
261 | 111 | |||
262 | return s; | 112 | return s; | |
263 | } | 113 | } | |
264 | 114 | |||
265 | static inline void | 115 | static void | |
266 | cprng_fast_put(struct cprng_fast *cprng, int s) | 116 | cprng_fast_put(struct cprng_fast *cprng, int s) | |
267 | { | 117 | { | |
268 | 118 | |||
269 | KASSERT((cprng == percpu_getref(cprng_fast_percpu)) && | 119 | KASSERT((cprng == percpu_getref(cprng_fast_percpu)) && | |
270 | (percpu_putref(cprng_fast_percpu), true)); | 120 | (percpu_putref(cprng_fast_percpu), true)); | |
271 | splx(s); | 121 | splx(s); | |
272 | percpu_putref(cprng_fast_percpu); | 122 | percpu_putref(cprng_fast_percpu); | |
273 | } | 123 | } | |
274 | 124 | |||
275 | static void | 125 | static void | |
276 | cprng_fast_schedule_reseed(struct cprng_fast *cprng __unused) | 126 | cprng_fast_schedule_reseed(struct cprng_fast *cprng __unused) | |
277 | { | 127 | { | |
278 | 128 | |||
279 | softint_schedule(cprng_fast_softint); | 129 | softint_schedule(cprng_fast_softint); | |
280 | } | 130 | } | |
281 | 131 | |||
282 | static void | 132 | static void | |
283 | cprng_fast_intr(void *cookie __unused) | 133 | cprng_fast_intr(void *cookie __unused) | |
284 | { | 134 | { | |
285 | unsigned epoch = entropy_epoch(); | 135 | unsigned epoch = entropy_epoch(); | |
286 | struct cprng_fast *cprng; | 136 | struct cprng_fast *cprng; | |
287 | uint8_t seed[CPRNG_FAST_SEED_BYTES]; | 137 | uint8_t seed[CPRNG_FAST_SEED_BYTES]; | |
288 | int s; | 138 | int s; | |
289 | 139 | |||
290 | cprng_strong(kern_cprng, seed, sizeof(seed), 0); | 140 | cprng_strong(kern_cprng, seed, sizeof(seed), 0); | |
291 | 141 | |||
292 | cprng = percpu_getref(cprng_fast_percpu); | 142 | cprng = percpu_getref(cprng_fast_percpu); | |
293 | s = splvm(); | 143 | s = splvm(); | |
294 | cprng_fast_seed(cprng, seed); | 144 | cprng_fast_seed(cprng, seed); | |
295 | cprng->epoch = epoch; | 145 | cprng->epoch = epoch; | |
296 | cprng->reseed_evcnt->ev_count++; | 146 | cprng->reseed_evcnt->ev_count++; | |
297 | splx(s); | 147 | splx(s); | |
298 | percpu_putref(cprng_fast_percpu); | 148 | percpu_putref(cprng_fast_percpu); | |
299 | 149 | |||
300 | explicit_memset(seed, 0, sizeof(seed)); | 150 | explicit_memset(seed, 0, sizeof(seed)); | |
301 | } | 151 | } | |
302 | 152 | |||
303 | /* CPRNG algorithm */ | 153 | /* CPRNG algorithm */ | |
304 | 154 | |||
305 | /* | |||
306 | * The state consists of a key, the current nonce, and a 64-byte buffer | |||
307 | * of output. Since we fill the buffer only when we need output, and | |||
308 | * eat a 32-bit word at a time, one 32-bit word of the buffer would be | |||
309 | * wasted. Instead, we repurpose it to count the number of entries in | |||
310 | * the buffer remaining, counting from high to low in order to allow | |||
311 | * comparison to zero to detect when we need to refill it. | |||
312 | */ | |||
313 | #define CPRNG_FAST_BUFIDX (crypto_core_OUTPUTWORDS - 1) | |||
314 | ||||
315 | static void | 155 | static void | |
316 | cprng_fast_seed(struct cprng_fast *cprng, const void *seed) | 156 | cprng_fast_seed(struct cprng_fast *cprng, const void *seed) | |
317 | { | 157 | { | |
318 | 158 | |||
319 | (void)memset(cprng->buffer, 0, sizeof cprng->buffer); | 159 | (void)memset(cprng->buf, 0, sizeof cprng->buf); | |
320 | (void)memcpy(cprng->key, seed, sizeof cprng->key); | 160 | (void)memcpy(cprng->key, seed, sizeof cprng->key); | |
321 | (void)memset(cprng->nonce, 0, sizeof cprng->nonce); | 161 | (void)memset(cprng->nonce, 0, sizeof cprng->nonce); | |
162 | cprng->i = sizeof cprng->buf; | |||
322 | } | 163 | } | |
323 | 164 | |||
324 | static inline uint32_t | 165 | static void | |
325 | cprng_fast_word(struct cprng_fast *cprng) | 166 | cprng_fast_buf(struct cprng_fast *cprng, void *buf, unsigned len) | |
326 | { | 167 | { | |
327 | uint32_t v; | 168 | uint8_t *p = buf; | |
169 | unsigned n = len, n0; | |||
328 | 170 | |||
329 | if (__predict_true(0 < cprng->buffer[CPRNG_FAST_BUFIDX])) { | 171 | KASSERT(cprng->i <= sizeof(cprng->buf)); | |
330 | v = cprng->buffer[--cprng->buffer[CPRNG_FAST_BUFIDX]]; | 172 | KASSERT(len <= sizeof(cprng->buf)); | |
331 | } else { | |||
332 | /* If we don't have enough words, refill the buffer. */ | |||
333 | crypto_core(cprng->buffer, cprng->nonce, cprng->key, | |||
334 | crypto_core_constant32); | |||
335 | if (__predict_false(++cprng->nonce[0] == 0)) { | |||
336 | cprng->nonce[1]++; | |||
337 | cprng_fast_schedule_reseed(cprng); | |||
338 | } | |||
339 | v = cprng->buffer[CPRNG_FAST_BUFIDX]; | |||
340 | cprng->buffer[CPRNG_FAST_BUFIDX] = CPRNG_FAST_BUFIDX; | |||
341 | } | |||
342 | 173 | |||
343 | return v; | 174 | n0 = MIN(n, sizeof(cprng->buf) - cprng->i); | |
175 | memcpy(p, &cprng->buf[cprng->i], n0); | |||
176 | if ((n -= n0) == 0) { | |||
177 | cprng->i += n0; | |||
178 | KASSERT(cprng->i <= sizeof(cprng->buf)); | |||
179 | return; | |||
180 | } | |||
181 | p += n0; | |||
182 | le64enc(cprng->nonce, 1 + le64dec(cprng->nonce)); | |||
183 | chacha_stream(cprng->buf, sizeof(cprng->buf), 0, cprng->nonce, | |||
184 | cprng->key, 8); | |||
185 | memcpy(p, cprng->buf, n); | |||
186 | cprng->i = n; | |||
344 | } | 187 | } | |
188 | ||||
189 | /* Public API */ | |||
345 | 190 | |||
346 | static inline void | 191 | static void | |
347 | cprng_fast_buf(struct cprng_fast *cprng, void *buf, unsigned n) | 192 | cprng_fast_buf_short(void *buf, size_t len) | |
348 | { | 193 | { | |
349 | uint8_t *p = buf; | 194 | struct cprng_fast *cprng; | |
350 | uint32_t v; | 195 | int s; | |
351 | unsigned w, r; | |||
352 | 196 | |||
353 | w = n / sizeof(uint32_t); | 197 | KASSERT(len <= sizeof(cprng->buf)); | |
354 | while (w--) { | |||
355 | v = cprng_fast_word(cprng); | |||
356 | (void)memcpy(p, &v, 4); | |||
357 | p += 4; | |||
358 | } | |||
359 | 198 | |||
360 | r = n % sizeof(uint32_t); | 199 | s = cprng_fast_get(&cprng); | |
361 | if (r) { | 200 | cprng_fast_buf(cprng, buf, len); | |
362 | v = cprng_fast_word(cprng); | 201 | cprng_fast_put(cprng, s); | |
363 | while (r--) { | |||
364 | *p++ = (v & 0xff); | |||
365 | v >>= 8; | |||
366 | } | |||
367 | } | |||
368 | } | 202 | } | |
369 | 203 | |||
370 | /* | |||
371 | * crypto_onetimestream: Expand a short unpredictable one-time seed | |||
372 | * into a long unpredictable output. | |||
373 | */ | |||
374 | static void | 204 | static void | |
375 | crypto_onetimestream(const uint32_t seed[crypto_core_KEYWORDS], void *buf, | 205 | cprng_fast_buf_long(void *buf, size_t len) | |
376 | size_t n) | |||
377 | { | 206 | { | |
378 | uint32_t block[crypto_core_OUTPUTWORDS]; | 207 | uint8_t seed[CHACHA_STREAM_KEYBYTES]; | |
379 | uint32_t nonce[crypto_core_INPUTWORDS] = {0}; | 208 | uint8_t nonce[CHACHA_STREAM_NONCEBYTES] = {0}; | |
380 | uint8_t *p8; | |||
381 | uint32_t *p32; | |||
382 | size_t ni, nb, nf; | |||
383 | 209 | |||
384 | /* | 210 | CTASSERT(sizeof(seed) <= sizeof(((struct cprng_fast *)0)->buf)); | |
385 | * Guarantee we can generate up to n bytes. We have | |||
386 | * 2^(32*INPUTWORDS) possible inputs yielding output of | |||
387 | * 4*OUTPUTWORDS*2^(32*INPUTWORDS) bytes. It suffices to | |||
388 | * require that sizeof n > (1/CHAR_BIT) log_2 n be less than | |||
389 | * (1/CHAR_BIT) log_2 of the total output stream length. We | |||
390 | * have | |||
391 | * | |||
392 | * log_2 (4 o 2^(32 i)) = log_2 (4 o) + log_2 2^(32 i) | |||
393 | * = 2 + log_2 o + 32 i. | |||
394 | */ | |||
395 | __CTASSERT(CHAR_BIT*sizeof n <= | |||
396 | (2 + ilog2(crypto_core_OUTPUTWORDS) + 32*crypto_core_INPUTWORDS)); | |||
397 | 211 | |||
398 | p8 = buf; | 212 | #if SIZE_MAX >= 0x3fffffffff | |
399 | p32 = (uint32_t *)roundup2((uintptr_t)p8, sizeof(uint32_t)); | 213 | /* >=256 GB is not reasonable */ | |
400 | ni = (uint8_t *)p32 - p8; | 214 | KASSERT(len <= 0x3fffffffff); | |
401 | if (n < ni) | 215 | #endif | |
402 | ni = n; | |||
403 | nb = (n - ni) / sizeof block; | |||
404 | nf = (n - ni) % sizeof block; | |||
405 | ||||
406 | KASSERT(((uintptr_t)p32 & 3) == 0); | |||
407 | KASSERT(ni <= n); | |||
408 | KASSERT(nb <= (n / sizeof block)); | |||
409 | KASSERT(nf <= n); | |||
410 | KASSERT(n == (ni + (nb * sizeof block) + nf)); | |||
411 | KASSERT(ni < sizeof(uint32_t)); | |||
412 | KASSERT(nf < sizeof block); | |||
413 | ||||
414 | if (ni) { | |||
415 | crypto_core(block, nonce, seed, crypto_core_constant32); | |||
416 | nonce[0]++; | |||
417 | (void)memcpy(p8, block, ni); | |||
418 | } | |||
419 | while (nb--) { | |||
420 | crypto_core(p32, nonce, seed, crypto_core_constant32); | |||
421 | if (++nonce[0] == 0) | |||
422 | nonce[1]++; | |||
423 | p32 += crypto_core_OUTPUTWORDS; | |||
424 | } | |||
425 | if (nf) { | |||
426 | crypto_core(block, nonce, seed, crypto_core_constant32); | |||
427 | if (++nonce[0] == 0) | |||
428 | nonce[1]++; | |||
429 | (void)memcpy(p32, block, nf); | |||
430 | } | |||
431 | 216 | |||
432 | if (ni | nf) | 217 | cprng_fast_buf_short(seed, sizeof seed); | |
433 | (void)explicit_memset(block, 0, sizeof block); | 218 | chacha_stream(buf, len, 0, nonce, seed, 8); | |
219 | ||||
220 | (void)explicit_memset(seed, 0, sizeof seed); | |||
434 | } | 221 | } | |
435 | ||||
436 | /* Public API */ | |||
437 | 222 | |||
438 | uint32_t | 223 | uint32_t | |
439 | cprng_fast32(void) | 224 | cprng_fast32(void) | |
440 | { | 225 | { | |
441 | struct cprng_fast *cprng; | |||
442 | uint32_t v; | 226 | uint32_t v; | |
443 | int s; | |||
444 | 227 | |||
445 | s = cprng_fast_get(&cprng); | 228 | cprng_fast_buf_short(&v, sizeof v); | |
446 | v = cprng_fast_word(cprng); | |||
447 | cprng_fast_put(cprng, s); | |||
448 | 229 | |||
449 | return v; | 230 | return v; | |
450 | } | 231 | } | |
451 | 232 | |||
452 | uint64_t | 233 | uint64_t | |
453 | cprng_fast64(void) | 234 | cprng_fast64(void) | |
454 | { | 235 | { | |
455 | struct cprng_fast *cprng; | 236 | uint64_t v; | |
456 | uint32_t hi, lo; | |||
457 | int s; | |||
458 | ||||
459 | s = cprng_fast_get(&cprng); | |||
460 | hi = cprng_fast_word(cprng); | |||
461 | lo = cprng_fast_word(cprng); | |||
462 | cprng_fast_put(cprng, s); | |||
463 | ||||
464 | return ((uint64_t)hi << 32) | lo; | |||
465 | } | |||
466 | ||||
467 | static void | |||
468 | cprng_fast_buf_short(void *buf, size_t len) | |||
469 | { | |||
470 | struct cprng_fast *cprng; | |||
471 | int s; | |||
472 | ||||
473 | s = cprng_fast_get(&cprng); | |||
474 | cprng_fast_buf(cprng, buf, len); | |||
475 | cprng_fast_put(cprng, s); | |||
476 | } | |||
477 | ||||
478 | static __noinline void | |||
479 | cprng_fast_buf_long(void *buf, size_t len) | |||
480 | { | |||
481 | uint32_t seed[crypto_core_KEYWORDS]; | |||
482 | struct cprng_fast *cprng; | |||
483 | int s; | |||
484 | ||||
485 | s = cprng_fast_get(&cprng); | |||
486 | cprng_fast_buf(cprng, seed, sizeof seed); | |||
487 | cprng_fast_put(cprng, s); | |||
488 | 237 | |||
489 | crypto_onetimestream(seed, buf, len); | 238 | cprng_fast_buf_short(&v, sizeof v); | |
490 | 239 | |||
491 | (void)explicit_memset(seed, 0, sizeof seed); | 240 | return v; | |
492 | } | 241 | } | |
493 | 242 | |||
494 | size_t | 243 | size_t | |
495 | cprng_fast(void *buf, size_t len) | 244 | cprng_fast(void *buf, size_t len) | |
496 | { | 245 | { | |
497 | 246 | |||
498 | /* | 247 | /* | |
499 | * We don't want to hog the CPU, so we use the short version, | 248 | * We don't want to hog the CPU, so we use the short version, | |
500 | * to generate output without preemption, only if we can do it | 249 | * to generate output without preemption, only if we can do it | |
501 | * with at most one crypto_core. | 250 | * with at most one ChaCha call. | |
502 | */ | 251 | */ | |
503 | if (len <= (sizeof(uint32_t) * crypto_core_OUTPUTWORDS)) | 252 | if (len <= sizeof(((struct cprng_fast *)0)->buf)) | |
504 | cprng_fast_buf_short(buf, len); | 253 | cprng_fast_buf_short(buf, len); | |
505 | else | 254 | else | |
506 | cprng_fast_buf_long(buf, len); | 255 | cprng_fast_buf_long(buf, len); | |
507 | 256 | |||
508 | return len; | 257 | return len; /* hysterical raisins */ | |
509 | } | 258 | } |
--- src/sys/crypto/cprng_fast/files.cprng_fast 2014/08/10 16:44:35 1.2
+++ src/sys/crypto/cprng_fast/files.cprng_fast 2020/07/28 20:15:07 1.3
@@ -1,3 +1,5 @@ | @@ -1,3 +1,5 @@ | |||
1 | # $NetBSD: files.cprng_fast,v 1.2 2014/08/10 16:44:35 tls Exp $ | 1 | # $NetBSD: files.cprng_fast,v 1.3 2020/07/28 20:15:07 riastradh Exp $ | |
2 | 2 | |||
3 | file crypto/cprng_fast/cprng_fast.c | 3 | define cprng_fast: chacha | |
4 | ||||
5 | file crypto/cprng_fast/cprng_fast.c cprng_fast |
--- src/sys/kern/files.kern 2020/06/07 09:45:19 1.49
+++ src/sys/kern/files.kern 2020/07/28 20:15:07 1.50
@@ -1,238 +1,238 @@ | @@ -1,238 +1,238 @@ | |||
1 | # $NetBSD: files.kern,v 1.49 2020/06/07 09:45:19 maxv Exp $ | 1 | # $NetBSD: files.kern,v 1.50 2020/07/28 20:15:07 riastradh Exp $ | |
2 | 2 | |||
3 | # | 3 | # | |
4 | # kernel sources | 4 | # kernel sources | |
5 | # | 5 | # | |
6 | define kern: machdep, uvm | 6 | define kern: cprng_fast, machdep, uvm | |
7 | defflag opt_kern.h KERN | 7 | defflag opt_kern.h KERN | |
8 | defflag opt_script.h SETUIDSCRIPTS FDSCRIPTS | 8 | defflag opt_script.h SETUIDSCRIPTS FDSCRIPTS | |
9 | defflag KASLR | 9 | defflag KASLR | |
10 | file conf/debugsyms.c kern | 10 | file conf/debugsyms.c kern | |
11 | file conf/param.c kern | 11 | file conf/param.c kern | |
12 | file kern/bufq_disksort.c bufq_disksort | 12 | file kern/bufq_disksort.c bufq_disksort | |
13 | file kern/bufq_fcfs.c bufq_fcfs | 13 | file kern/bufq_fcfs.c bufq_fcfs | |
14 | file kern/bufq_priocscan.c bufq_priocscan | 14 | file kern/bufq_priocscan.c bufq_priocscan | |
15 | file kern/bufq_readprio.c bufq_readprio | new_bufq_strategy | 15 | file kern/bufq_readprio.c bufq_readprio | new_bufq_strategy | |
16 | file kern/compat_stub.c kern | 16 | file kern/compat_stub.c kern | |
17 | file kern/core_elf32.c exec_elf32 | 17 | file kern/core_elf32.c exec_elf32 | |
18 | file kern/core_elf64.c exec_elf64 | 18 | file kern/core_elf64.c exec_elf64 | |
19 | file kern/core_netbsd.c coredump | 19 | file kern/core_netbsd.c coredump | |
20 | file kern/cnmagic.c kern | 20 | file kern/cnmagic.c kern | |
21 | file kern/exec_aout.c exec_aout | 21 | file kern/exec_aout.c exec_aout | |
22 | file kern/exec_ecoff.c exec_ecoff | 22 | file kern/exec_ecoff.c exec_ecoff | |
23 | file kern/exec_elf32.c exec_elf32 | 23 | file kern/exec_elf32.c exec_elf32 | |
24 | file kern/exec_elf64.c exec_elf64 | 24 | file kern/exec_elf64.c exec_elf64 | |
25 | file kern/exec_script.c exec_script | 25 | file kern/exec_script.c exec_script | |
26 | file kern/exec_subr.c kern | 26 | file kern/exec_subr.c kern | |
27 | file kern/init_main.c kern | 27 | file kern/init_main.c kern | |
28 | file kern/init_sysctl.c kern | 28 | file kern/init_sysctl.c kern | |
29 | file kern/init_sysctl_base.c kern | 29 | file kern/init_sysctl_base.c kern | |
30 | file kern/init_sysent.c kern | 30 | file kern/init_sysent.c kern | |
31 | file kern/kern_acct.c kern | 31 | file kern/kern_acct.c kern | |
32 | file kern/kern_auth.c kern | 32 | file kern/kern_auth.c kern | |
33 | file kern/kern_cfglock.c kern | 33 | file kern/kern_cfglock.c kern | |
34 | file kern/kern_clock.c kern | 34 | file kern/kern_clock.c kern | |
35 | file kern/kern_condvar.c kern | 35 | file kern/kern_condvar.c kern | |
36 | file kern/kern_core.c coredump | 36 | file kern/kern_core.c coredump | |
37 | file kern/kern_cpu.c kern | 37 | file kern/kern_cpu.c kern | |
38 | 38 | |||
39 | #kern/kern_ctf.c is only needed as part of dtrace_fbt module | 39 | #kern/kern_ctf.c is only needed as part of dtrace_fbt module | |
40 | #file kern/kern_ctf.c kdtrace_hooks | 40 | #file kern/kern_ctf.c kdtrace_hooks | |
41 | 41 | |||
42 | file kern/kern_descrip.c kern | 42 | file kern/kern_descrip.c kern | |
43 | file kern/kern_entropy.c kern | 43 | file kern/kern_entropy.c kern | |
44 | file kern/kern_event.c kern | 44 | file kern/kern_event.c kern | |
45 | file kern/kern_exec.c kern | 45 | file kern/kern_exec.c kern | |
46 | file kern/kern_exit.c kern | 46 | file kern/kern_exit.c kern | |
47 | file kern/kern_fork.c kern | 47 | file kern/kern_fork.c kern | |
48 | file kern/kern_idle.c kern | 48 | file kern/kern_idle.c kern | |
49 | file kern/kern_hook.c kern | 49 | file kern/kern_hook.c kern | |
50 | file kern/kern_kthread.c kern | 50 | file kern/kern_kthread.c kern | |
51 | file kern/kern_ktrace.c ktrace | 51 | file kern/kern_ktrace.c ktrace | |
52 | file kern/kern_ktrace_vfs.c ktrace | 52 | file kern/kern_ktrace_vfs.c ktrace | |
53 | file kern/kern_ksyms.c ksyms | ddb | modular needs-flag | 53 | file kern/kern_ksyms.c ksyms | ddb | modular needs-flag | |
54 | file kern/kern_lock.c kern | 54 | file kern/kern_lock.c kern | |
55 | file kern/kern_lwp.c kern | 55 | file kern/kern_lwp.c kern | |
56 | file kern/kern_malloc.c kern | 56 | file kern/kern_malloc.c kern | |
57 | file kern/kern_module.c kern | 57 | file kern/kern_module.c kern | |
58 | file kern/kern_module_hook.c kern | 58 | file kern/kern_module_hook.c kern | |
59 | file kern/kern_module_vfs.c kern | 59 | file kern/kern_module_vfs.c kern | |
60 | file kern/kern_mutex.c kern | 60 | file kern/kern_mutex.c kern | |
61 | file kern/kern_mutex_obj.c kern | 61 | file kern/kern_mutex_obj.c kern | |
62 | file kern/kern_fileassoc.c fileassoc | 62 | file kern/kern_fileassoc.c fileassoc | |
63 | file kern/kern_ntptime.c kern | 63 | file kern/kern_ntptime.c kern | |
64 | file kern/kern_pax.c pax_mprotect | pax_segvguard | pax_aslr | 64 | file kern/kern_pax.c pax_mprotect | pax_segvguard | pax_aslr | |
65 | file kern/kern_physio.c kern | 65 | file kern/kern_physio.c kern | |
66 | file kern/kern_pmf.c kern | 66 | file kern/kern_pmf.c kern | |
67 | file kern/kern_proc.c kern | 67 | file kern/kern_proc.c kern | |
68 | file kern/kern_prot.c kern | 68 | file kern/kern_prot.c kern | |
69 | file kern/kern_ras.c kern | 69 | file kern/kern_ras.c kern | |
70 | file kern/kern_rate.c kern | 70 | file kern/kern_rate.c kern | |
71 | file kern/kern_reboot.c kern | 71 | file kern/kern_reboot.c kern | |
72 | file kern/kern_resource.c kern | 72 | file kern/kern_resource.c kern | |
73 | file kern/kern_runq.c kern | 73 | file kern/kern_runq.c kern | |
74 | file kern/kern_rwlock.c kern | 74 | file kern/kern_rwlock.c kern | |
75 | file kern/kern_rwlock_obj.c kern | 75 | file kern/kern_rwlock_obj.c kern | |
76 | file kern/kern_scdebug.c kern | 76 | file kern/kern_scdebug.c kern | |
77 | file kern/kern_sdt.c kdtrace_hooks | 77 | file kern/kern_sdt.c kdtrace_hooks | |
78 | file kern/kern_crashme.c kern | 78 | file kern/kern_crashme.c kern | |
79 | file kern/kern_sig.c kern | 79 | file kern/kern_sig.c kern | |
80 | file kern/kern_sleepq.c kern | 80 | file kern/kern_sleepq.c kern | |
81 | file kern/kern_softint.c kern | 81 | file kern/kern_softint.c kern | |
82 | file kern/kern_ssp.c kern | 82 | file kern/kern_ssp.c kern | |
83 | file kern/kern_stub.c kern | 83 | file kern/kern_stub.c kern | |
84 | file kern/kern_subr.c kern | 84 | file kern/kern_subr.c kern | |
85 | file kern/kern_synch.c kern | 85 | file kern/kern_synch.c kern | |
86 | file kern/kern_syscall.c kern | 86 | file kern/kern_syscall.c kern | |
87 | file kern/kern_sysctl.c kern | 87 | file kern/kern_sysctl.c kern | |
88 | file kern/kern_tc.c kern | 88 | file kern/kern_tc.c kern | |
89 | file kern/kern_threadpool.c kern | 89 | file kern/kern_threadpool.c kern | |
90 | file kern/kern_time.c kern | 90 | file kern/kern_time.c kern | |
91 | file kern/kern_timeout.c kern | 91 | file kern/kern_timeout.c kern | |
92 | file kern/kern_turnstile.c kern | 92 | file kern/kern_turnstile.c kern | |
93 | file kern/kern_todr.c kern | 93 | file kern/kern_todr.c kern | |
94 | file kern/kern_uidinfo.c kern | 94 | file kern/kern_uidinfo.c kern | |
95 | file kern/kern_uuid.c kern | 95 | file kern/kern_uuid.c kern | |
96 | file kern/kgdb_stub.c kgdb | 96 | file kern/kgdb_stub.c kgdb | |
97 | file kern/sched_4bsd.c sched_4bsd | 97 | file kern/sched_4bsd.c sched_4bsd | |
98 | file kern/sched_m2.c sched_m2 | 98 | file kern/sched_m2.c sched_m2 | |
99 | file kern/subr_acl_posix1e.c kern | 99 | file kern/subr_acl_posix1e.c kern | |
100 | file kern/subr_acl_nfs4.c kern | 100 | file kern/subr_acl_nfs4.c kern | |
101 | file kern/subr_asan.c kasan | 101 | file kern/subr_asan.c kasan | |
102 | file kern/subr_autoconf.c kern | 102 | file kern/subr_autoconf.c kern | |
103 | file kern/subr_blist.c vmswap | 103 | file kern/subr_blist.c vmswap | |
104 | file kern/subr_bufq.c kern | 104 | file kern/subr_bufq.c kern | |
105 | file kern/subr_callback.c kern | 105 | file kern/subr_callback.c kern | |
106 | file kern/subr_cprng.c kern | 106 | file kern/subr_cprng.c kern | |
107 | file kern/subr_cpu.c kern | 107 | file kern/subr_cpu.c kern | |
108 | file kern/subr_cpufreq.c kern | 108 | file kern/subr_cpufreq.c kern | |
109 | file kern/subr_copy.c kern | 109 | file kern/subr_copy.c kern | |
110 | file kern/subr_csan.c kcsan | 110 | file kern/subr_csan.c kcsan | |
111 | file kern/subr_debug.c debug | 111 | file kern/subr_debug.c debug | |
112 | file kern/subr_device.c kern | 112 | file kern/subr_device.c kern | |
113 | file kern/subr_devsw.c kern | 113 | file kern/subr_devsw.c kern | |
114 | file kern/subr_disk.c kern | 114 | file kern/subr_disk.c kern | |
115 | file kern/subr_disklabel.c kern | 115 | file kern/subr_disklabel.c kern | |
116 | file kern/subr_disk_open.c kern | 116 | file kern/subr_disk_open.c kern | |
117 | file kern/subr_emul.c kern | 117 | file kern/subr_emul.c kern | |
118 | file kern/subr_evcnt.c kern | 118 | file kern/subr_evcnt.c kern | |
119 | file kern/subr_exec_fd.c kern | 119 | file kern/subr_exec_fd.c kern | |
120 | file kern/subr_extent.c kern | 120 | file kern/subr_extent.c kern | |
121 | file kern/subr_fault.c fault | 121 | file kern/subr_fault.c fault | |
122 | file kern/subr_hash.c kern | 122 | file kern/subr_hash.c kern | |
123 | file kern/subr_humanize.c kern | 123 | file kern/subr_humanize.c kern | |
124 | file kern/subr_interrupt.c kern | 124 | file kern/subr_interrupt.c kern | |
125 | file kern/subr_iostat.c kern | 125 | file kern/subr_iostat.c kern | |
126 | file kern/subr_ipi.c kern | 126 | file kern/subr_ipi.c kern | |
127 | file kern/subr_kcpuset.c kern | 127 | file kern/subr_kcpuset.c kern | |
128 | file kern/subr_kcov.c kcov | 128 | file kern/subr_kcov.c kcov | |
129 | defflag opt_kmem.h KMEM_SIZE | 129 | defflag opt_kmem.h KMEM_SIZE | |
130 | file kern/subr_kmem.c kern | 130 | file kern/subr_kmem.c kern | |
131 | file kern/subr_kobj.c kern | 131 | file kern/subr_kobj.c kern | |
132 | file kern/subr_kobj_vfs.c kern | 132 | file kern/subr_kobj_vfs.c kern | |
133 | file kern/subr_localcount.c kern | 133 | file kern/subr_localcount.c kern | |
134 | file kern/subr_lockdebug.c kern | 134 | file kern/subr_lockdebug.c kern | |
135 | file kern/subr_log.c kern | 135 | file kern/subr_log.c kern | |
136 | file kern/subr_lwp_specificdata.c kern | 136 | file kern/subr_lwp_specificdata.c kern | |
137 | file kern/subr_msan.c kmsan | 137 | file kern/subr_msan.c kmsan | |
138 | file kern/subr_once.c kern | 138 | file kern/subr_once.c kern | |
139 | file kern/subr_optstr.c kern | 139 | file kern/subr_optstr.c kern | |
140 | file kern/subr_pcq.c kern | 140 | file kern/subr_pcq.c kern | |
141 | file kern/subr_pcu.c kern | 141 | file kern/subr_pcu.c kern | |
142 | file kern/subr_percpu.c kern | 142 | file kern/subr_percpu.c kern | |
143 | file kern/subr_pool.c kern | 143 | file kern/subr_pool.c kern | |
144 | file kern/subr_prf.c kern | 144 | file kern/subr_prf.c kern | |
145 | file kern/subr_prof.c kern | 145 | file kern/subr_prof.c kern | |
146 | file kern/subr_pserialize.c kern | 146 | file kern/subr_pserialize.c kern | |
147 | file kern/subr_psref.c kern | 147 | file kern/subr_psref.c kern | |
148 | file kern/subr_specificdata.c kern | 148 | file kern/subr_specificdata.c kern | |
149 | file kern/subr_tftproot.c tftproot | 149 | file kern/subr_tftproot.c tftproot | |
150 | file kern/subr_time.c kern | 150 | file kern/subr_time.c kern | |
151 | file kern/subr_thmap.c kern | 151 | file kern/subr_thmap.c kern | |
152 | file kern/subr_userconf.c userconf | 152 | file kern/subr_userconf.c userconf | |
153 | file kern/subr_vmem.c kern | 153 | file kern/subr_vmem.c kern | |
154 | file kern/subr_workqueue.c kern | 154 | file kern/subr_workqueue.c kern | |
155 | file kern/subr_xcall.c kern | 155 | file kern/subr_xcall.c kern | |
156 | file kern/sys_aio.c aio | 156 | file kern/sys_aio.c aio | |
157 | file kern/sys_descrip.c kern | 157 | file kern/sys_descrip.c kern | |
158 | file kern/sys_futex.c kern | 158 | file kern/sys_futex.c kern | |
159 | file kern/sys_generic.c kern | 159 | file kern/sys_generic.c kern | |
160 | file kern/sys_module.c kern | 160 | file kern/sys_module.c kern | |
161 | file kern/sys_mqueue.c mqueue | 161 | file kern/sys_mqueue.c mqueue | |
162 | file kern/sys_lwp.c kern | 162 | file kern/sys_lwp.c kern | |
163 | file kern/sys_pipe.c !pipe_socketpair | 163 | file kern/sys_pipe.c !pipe_socketpair | |
164 | file kern/sys_process.c ptrace_hooks | ktrace | 164 | file kern/sys_process.c ptrace_hooks | ktrace | |
165 | file kern/sys_process_lwpstatus.c kern | 165 | file kern/sys_process_lwpstatus.c kern | |
166 | file kern/sys_ptrace.c ptrace | 166 | file kern/sys_ptrace.c ptrace | |
167 | file kern/sys_ptrace_common.c ptrace | 167 | file kern/sys_ptrace_common.c ptrace | |
168 | file kern/sys_pset.c kern | 168 | file kern/sys_pset.c kern | |
169 | file kern/sys_select.c kern | 169 | file kern/sys_select.c kern | |
170 | file kern/sys_sig.c kern | 170 | file kern/sys_sig.c kern | |
171 | file kern/sys_sched.c kern | 171 | file kern/sys_sched.c kern | |
172 | file kern/sys_socket.c kern | 172 | file kern/sys_socket.c kern | |
173 | file kern/syscalls.c syscall_debug | kdtrace_hooks | 173 | file kern/syscalls.c syscall_debug | kdtrace_hooks | |
174 | file kern/sysv_ipc.c sysvshm | sysvsem | sysvmsg | 174 | file kern/sysv_ipc.c sysvshm | sysvsem | sysvmsg | |
175 | file kern/sysv_msg.c sysvmsg | 175 | file kern/sysv_msg.c sysvmsg | |
176 | file kern/sysv_sem.c sysvsem | 176 | file kern/sysv_sem.c sysvsem | |
177 | file kern/sysv_shm.c sysvshm | 177 | file kern/sysv_shm.c sysvshm | |
178 | file kern/tty.c kern | 178 | file kern/tty.c kern | |
179 | file kern/tty_conf.c kern | 179 | file kern/tty_conf.c kern | |
180 | file kern/tty_bsdpty.c compat_bsdpty | 180 | file kern/tty_bsdpty.c compat_bsdpty | |
181 | file kern/tty_pty.c pty needs-flag | 181 | file kern/tty_pty.c pty needs-flag | |
182 | file kern/tty_ptm.c pty | 182 | file kern/tty_ptm.c pty | |
183 | file kern/tty_subr.c kern | 183 | file kern/tty_subr.c kern | |
184 | file kern/tty_tty.c kern | 184 | file kern/tty_tty.c kern | |
185 | file kern/uipc_accf.c kern | 185 | file kern/uipc_accf.c kern | |
186 | file kern/uipc_domain.c kern | 186 | file kern/uipc_domain.c kern | |
187 | file kern/uipc_mbuf.c kern | 187 | file kern/uipc_mbuf.c kern | |
188 | file kern/uipc_mbufdebug.c kern & ether & ddb | 188 | file kern/uipc_mbufdebug.c kern & ether & ddb | |
189 | file net/link_proto.c kern # XXX | 189 | file net/link_proto.c kern # XXX | |
190 | file kern/uipc_proto.c kern | 190 | file kern/uipc_proto.c kern | |
191 | file kern/uipc_sem.c kern | 191 | file kern/uipc_sem.c kern | |
192 | file kern/uipc_socket.c kern | 192 | file kern/uipc_socket.c kern | |
193 | file kern/uipc_socket2.c kern | 193 | file kern/uipc_socket2.c kern | |
194 | file kern/uipc_syscalls.c kern | 194 | file kern/uipc_syscalls.c kern | |
195 | file kern/uipc_usrreq.c kern | 195 | file kern/uipc_usrreq.c kern | |
196 | 196 | |||
197 | define vfs: kern | 197 | define vfs: kern | |
198 | file kern/vfs_acl.c vfs | 198 | file kern/vfs_acl.c vfs | |
199 | file kern/vfs_bio.c vfs | 199 | file kern/vfs_bio.c vfs | |
200 | file kern/vfs_cache.c vfs | 200 | file kern/vfs_cache.c vfs | |
201 | file kern/vfs_cwd.c vfs | 201 | file kern/vfs_cwd.c vfs | |
202 | file kern/vfs_dirhash.c vfs | 202 | file kern/vfs_dirhash.c vfs | |
203 | file kern/vfs_getcwd.c vfs | 203 | file kern/vfs_getcwd.c vfs | |
204 | file kern/vfs_hooks.c vfs | 204 | file kern/vfs_hooks.c vfs | |
205 | file kern/vfs_init.c vfs | 205 | file kern/vfs_init.c vfs | |
206 | file kern/vfs_lockf.c vfs | 206 | file kern/vfs_lockf.c vfs | |
207 | file kern/vfs_lookup.c vfs | 207 | file kern/vfs_lookup.c vfs | |
208 | file kern/vfs_mount.c vfs | 208 | file kern/vfs_mount.c vfs | |
209 | file kern/vfs_quotactl.c vfs | 209 | file kern/vfs_quotactl.c vfs | |
210 | file kern/vfs_subr.c vfs | 210 | file kern/vfs_subr.c vfs | |
211 | file kern/vfs_syscalls.c vfs | 211 | file kern/vfs_syscalls.c vfs | |
212 | file kern/vfs_trans.c vfs | 212 | file kern/vfs_trans.c vfs | |
213 | file kern/vfs_vnode.c vfs | 213 | file kern/vfs_vnode.c vfs | |
214 | file kern/vfs_vnops.c vfs | 214 | file kern/vfs_vnops.c vfs | |
215 | file kern/vfs_wapbl.c wapbl | 215 | file kern/vfs_wapbl.c wapbl | |
216 | file kern/vfs_xattr.c vfs | 216 | file kern/vfs_xattr.c vfs | |
217 | file kern/vnode_if.c vfs | 217 | file kern/vnode_if.c vfs | |
218 | file miscfs/deadfs/dead_vfsops.c vfs | 218 | file miscfs/deadfs/dead_vfsops.c vfs | |
219 | file miscfs/deadfs/dead_vnops.c vfs | 219 | file miscfs/deadfs/dead_vnops.c vfs | |
220 | file miscfs/fifofs/fifo_vnops.c vfs | 220 | file miscfs/fifofs/fifo_vnops.c vfs | |
221 | file miscfs/genfs/genfs_io.c vfs | 221 | file miscfs/genfs/genfs_io.c vfs | |
222 | file miscfs/genfs/genfs_rename.c vfs | 222 | file miscfs/genfs/genfs_rename.c vfs | |
223 | file miscfs/genfs/genfs_vfsops.c vfs | 223 | file miscfs/genfs/genfs_vfsops.c vfs | |
224 | file miscfs/genfs/genfs_vnops.c vfs | 224 | file miscfs/genfs/genfs_vnops.c vfs | |
225 | 225 | |||
226 | define layerfs | 226 | define layerfs | |
227 | file miscfs/genfs/layer_subr.c layerfs | 227 | file miscfs/genfs/layer_subr.c layerfs | |
228 | file miscfs/genfs/layer_vfsops.c layerfs | 228 | file miscfs/genfs/layer_vfsops.c layerfs | |
229 | file miscfs/genfs/layer_vnops.c layerfs | 229 | file miscfs/genfs/layer_vnops.c layerfs | |
230 | 230 | |||
231 | file miscfs/specfs/spec_vnops.c vfs | 231 | file miscfs/specfs/spec_vnops.c vfs | |
232 | 232 | |||
233 | defflag KUBSAN | 233 | defflag KUBSAN | |
234 | prefix ../common/lib/libc/misc | 234 | prefix ../common/lib/libc/misc | |
235 | file ubsan.c kubsan | 235 | file ubsan.c kubsan | |
236 | prefix | 236 | prefix | |
237 | makeoptions kubsan CFLAGS+="-fsanitize=undefined" | 237 | makeoptions kubsan CFLAGS+="-fsanitize=undefined" | |
238 | makeoptions kubsan CPPFLAGS+="-DACPI_MISALIGNMENT_NOT_SUPPORTED" | 238 | makeoptions kubsan CPPFLAGS+="-DACPI_MISALIGNMENT_NOT_SUPPORTED" |
--- src/sys/rump/kern/lib/libcrypto/Makefile 2020/07/26 04:25:49 1.12
+++ src/sys/rump/kern/lib/libcrypto/Makefile 2020/07/28 20:15:07 1.13
@@ -1,51 +1,45 @@ | @@ -1,51 +1,45 @@ | |||
1 | # $NetBSD: Makefile,v 1.12 2020/07/26 04:25:49 riastradh Exp $ | 1 | # $NetBSD: Makefile,v 1.13 2020/07/28 20:15:07 riastradh Exp $ | |
2 | # | 2 | # | |
3 | 3 | |||
4 | .PATH: ${.CURDIR}/../../../../crypto/adiantum \ | 4 | .PATH: ${.CURDIR}/../../../../crypto/adiantum \ | |
5 | ${.CURDIR}/../../../../crypto/aes \ | 5 | ${.CURDIR}/../../../../crypto/aes \ | |
6 | ${.CURDIR}/../../../../crypto/blowfish \ | 6 | ${.CURDIR}/../../../../crypto/blowfish \ | |
7 | ${.CURDIR}/../../../../crypto/camellia \ | 7 | ${.CURDIR}/../../../../crypto/camellia \ | |
8 | ${.CURDIR}/../../../../crypto/cast128 \ | 8 | ${.CURDIR}/../../../../crypto/cast128 \ | |
9 | ${.CURDIR}/../../../../crypto/chacha \ | |||
10 | ${.CURDIR}/../../../../crypto/des \ | 9 | ${.CURDIR}/../../../../crypto/des \ | |
11 | ${.CURDIR}/../../../../crypto/skipjack | 10 | ${.CURDIR}/../../../../crypto/skipjack | |
12 | 11 | |||
13 | LIB= rumpkern_crypto | 12 | LIB= rumpkern_crypto | |
14 | COMMENT=Cryptographic routines | 13 | COMMENT=Cryptographic routines | |
15 | 14 | |||
16 | # Adiantum | 15 | # Adiantum | |
17 | SRCS+= adiantum.c | 16 | SRCS+= adiantum.c | |
18 | SRCS+= adiantum_selftest.c | 17 | SRCS+= adiantum_selftest.c | |
19 | 18 | |||
20 | # AES | 19 | # AES | |
21 | SRCS+= aes_bear.c | 20 | SRCS+= aes_bear.c | |
22 | SRCS+= aes_ccm.c | 21 | SRCS+= aes_ccm.c | |
23 | SRCS+= aes_ccm_mbuf.c | 22 | SRCS+= aes_ccm_mbuf.c | |
24 | SRCS+= aes_ct.c | 23 | SRCS+= aes_ct.c | |
25 | SRCS+= aes_ct_dec.c | 24 | SRCS+= aes_ct_dec.c | |
26 | SRCS+= aes_ct_enc.c | 25 | SRCS+= aes_ct_enc.c | |
27 | SRCS+= aes_impl.c | 26 | SRCS+= aes_impl.c | |
28 | SRCS+= aes_selftest.c | 27 | SRCS+= aes_selftest.c | |
29 | 28 | |||
30 | # blowfish | 29 | # blowfish | |
31 | SRCS+= bf_ecb.c bf_enc.c bf_cbc.c bf_skey.c bf_module.c | 30 | SRCS+= bf_ecb.c bf_enc.c bf_cbc.c bf_skey.c bf_module.c | |
32 | 31 | |||
33 | # camellia | 32 | # camellia | |
34 | SRCS+= camellia.c camellia-api.c | 33 | SRCS+= camellia.c camellia-api.c | |
35 | 34 | |||
36 | # cast128 | 35 | # cast128 | |
37 | SRCS+= cast128.c | 36 | SRCS+= cast128.c | |
38 | 37 | |||
39 | # ChaCha | |||
40 | SRCS+= chacha_impl.c | |||
41 | SRCS+= chacha_ref.c | |||
42 | SRCS+= chacha_selftest.c | |||
43 | ||||
44 | # DES | 38 | # DES | |
45 | SRCS+= des_ecb.c des_setkey.c des_enc.c des_cbc.c des_module.c | 39 | SRCS+= des_ecb.c des_setkey.c des_enc.c des_cbc.c des_module.c | |
46 | 40 | |||
47 | # skipjack | 41 | # skipjack | |
48 | SRCS+= skipjack.c | 42 | SRCS+= skipjack.c | |
49 | 43 | |||
50 | .include <bsd.lib.mk> | 44 | .include <bsd.lib.mk> | |
51 | .include <bsd.klinks.mk> | 45 | .include <bsd.klinks.mk> |
--- src/sys/rump/librump/rumpkern/Makefile.rumpkern 2020/04/30 03:28:19 1.183
+++ src/sys/rump/librump/rumpkern/Makefile.rumpkern 2020/07/28 20:15:07 1.184
@@ -1,245 +1,249 @@ | @@ -1,245 +1,249 @@ | |||
1 | # $NetBSD: Makefile.rumpkern,v 1.183 2020/04/30 03:28:19 riastradh Exp $ | 1 | # $NetBSD: Makefile.rumpkern,v 1.184 2020/07/28 20:15:07 riastradh Exp $ | |
2 | # | 2 | # | |
3 | 3 | |||
4 | IOCONFDIR:= ${.PARSEDIR} | 4 | IOCONFDIR:= ${.PARSEDIR} | |
5 | IOCONF= MAINBUS.ioconf | 5 | IOCONF= MAINBUS.ioconf | |
6 | 6 | |||
7 | LIB= rump | 7 | LIB= rump | |
8 | COMMENT= Rump kernel base | 8 | COMMENT= Rump kernel base | |
9 | 9 | |||
10 | MAN= rump.3 rump_lwproc.3 | 10 | MAN= rump.3 rump_lwproc.3 | |
11 | 11 | |||
12 | .PATH: ${RUMPTOP}/librump/rumpkern \ | 12 | .PATH: ${RUMPTOP}/librump/rumpkern \ | |
13 | ${RUMPTOP}/librump/rumpkern/arch/generic \ | 13 | ${RUMPTOP}/librump/rumpkern/arch/generic \ | |
14 | ${RUMPTOP}/../kern \ | 14 | ${RUMPTOP}/../kern \ | |
15 | ${RUMPTOP}/../uvm \ | 15 | ${RUMPTOP}/../uvm \ | |
16 | ${RUMPTOP}/../conf \ | 16 | ${RUMPTOP}/../conf \ | |
17 | ${RUMPTOP}/../dev \ | 17 | ${RUMPTOP}/../dev \ | |
18 | ${RUMPTOP}/../crypto/nist_hash_drbg \ | 18 | ${RUMPTOP}/../crypto/nist_hash_drbg \ | |
19 | ${RUMPTOP}/../crypto/cprng_fast \ | 19 | ${RUMPTOP}/../crypto/cprng_fast \ | |
20 | ${RUMPTOP}/../crypto/chacha \ | |||
20 | ${RUMPTOP}/../secmodel \ | 21 | ${RUMPTOP}/../secmodel \ | |
21 | ${RUMPTOP}/../secmodel/suser \ | 22 | ${RUMPTOP}/../secmodel/suser \ | |
22 | ${RUMPTOP}/../compat/common | 23 | ${RUMPTOP}/../compat/common | |
23 | 24 | |||
24 | # | 25 | # | |
25 | # Source modules, first the ones specifically implemented for librump. | 26 | # Source modules, first the ones specifically implemented for librump. | |
26 | # | 27 | # | |
27 | SRCS+= rump.c rumpcopy.c cons.c emul.c etfs_wrap.c intr.c \ | 28 | SRCS+= rump.c rumpcopy.c cons.c emul.c etfs_wrap.c intr.c \ | |
28 | lwproc.c klock.c kobj_rename.c ltsleep.c scheduler.c \ | 29 | lwproc.c klock.c kobj_rename.c ltsleep.c scheduler.c \ | |
29 | signals.c sleepq.c threads.c vm.c hyperentropy.c \ | 30 | signals.c sleepq.c threads.c vm.c hyperentropy.c \ | |
30 | accessors.c | 31 | accessors.c | |
31 | 32 | |||
32 | SRCS+= rump_autoconf.c rumpkern_syscalls.c | 33 | SRCS+= rump_autoconf.c rumpkern_syscalls.c | |
33 | 34 | |||
34 | # autogenerated into the correct namespace | 35 | # autogenerated into the correct namespace | |
35 | RUMPOBJ_NORENAME= rump_syscalls.o rump_syscalls.pico rump_syscalls.po | 36 | RUMPOBJ_NORENAME= rump_syscalls.o rump_syscalls.pico rump_syscalls.po | |
36 | 37 | |||
37 | .ifdef RUMP_KERNEL_IS_LIBC | 38 | .ifdef RUMP_KERNEL_IS_LIBC | |
38 | CPPFLAGS+= -DRUMP_KERNEL_IS_LIBC | 39 | CPPFLAGS+= -DRUMP_KERNEL_IS_LIBC | |
39 | .endif | 40 | .endif | |
40 | 41 | |||
41 | # Multiprocessor or uniprocessor locking. TODO: select right | 42 | # Multiprocessor or uniprocessor locking. TODO: select right | |
42 | # locking at runtime. | 43 | # locking at runtime. | |
43 | .if ${RUMP_LOCKS_UP:Uno} == "yes" | 44 | .if ${RUMP_LOCKS_UP:Uno} == "yes" | |
44 | SRCS+= locks_up.c | 45 | SRCS+= locks_up.c | |
45 | .else | 46 | .else | |
46 | SRCS+= locks.c | 47 | SRCS+= locks.c | |
47 | .endif | 48 | .endif | |
48 | 49 | |||
49 | vers.c: ${RUMPTOP}/../conf/newvers.sh ${RUMPTOP}/../conf/osrelease.sh \ | 50 | vers.c: ${RUMPTOP}/../conf/newvers.sh ${RUMPTOP}/../conf/osrelease.sh \ | |
50 | ${RUMPTOP}/../sys/param.h ${_NETBSD_VERSION_DEPENDS} | 51 | ${RUMPTOP}/../sys/param.h ${_NETBSD_VERSION_DEPENDS} | |
51 | ${_MKMSG_CREATE} vers.c | 52 | ${_MKMSG_CREATE} vers.c | |
52 | ${HOST_SH} ${RUMPTOP}/../conf/newvers.sh -i RUMP-ROAST -n -R | 53 | ${HOST_SH} ${RUMPTOP}/../conf/newvers.sh -i RUMP-ROAST -n -R | |
53 | SRCS+= vers.c | 54 | SRCS+= vers.c | |
54 | CLEANFILES+= vers.c version | 55 | CLEANFILES+= vers.c version | |
55 | 56 | |||
56 | # autogenerated | 57 | # autogenerated | |
57 | # | 58 | # | |
58 | SRCS+= rump_syscalls.c rumpkern_if_wrappers.c | 59 | SRCS+= rump_syscalls.c rumpkern_if_wrappers.c | |
59 | 60 | |||
60 | # "auto"generated | 61 | # "auto"generated | |
61 | SRCS+= devsw.c | 62 | SRCS+= devsw.c | |
62 | 63 | |||
63 | # | 64 | # | |
64 | # std kernel sources | 65 | # std kernel sources | |
65 | # | 66 | # | |
66 | # sys/kern | 67 | # sys/kern | |
67 | SRCS+= init_sysctl_base.c \ | 68 | SRCS+= init_sysctl_base.c \ | |
68 | compat_stub.c \ | 69 | compat_stub.c \ | |
69 | kern_auth.c \ | 70 | kern_auth.c \ | |
70 | kern_cfglock.c \ | 71 | kern_cfglock.c \ | |
71 | kern_clock.c \ | 72 | kern_clock.c \ | |
72 | kern_descrip.c \ | 73 | kern_descrip.c \ | |
73 | kern_entropy.c \ | 74 | kern_entropy.c \ | |
74 | kern_event.c \ | 75 | kern_event.c \ | |
75 | kern_hook.c \ | 76 | kern_hook.c \ | |
76 | kern_ksyms.c \ | 77 | kern_ksyms.c \ | |
77 | kern_malloc.c \ | 78 | kern_malloc.c \ | |
78 | kern_module.c \ | 79 | kern_module.c \ | |
79 | kern_module_hook.c \ | 80 | kern_module_hook.c \ | |
80 | kern_mutex_obj.c \ | 81 | kern_mutex_obj.c \ | |
81 | kern_ntptime.c \ | 82 | kern_ntptime.c \ | |
82 | kern_proc.c \ | 83 | kern_proc.c \ | |
83 | kern_prot.c \ | 84 | kern_prot.c \ | |
84 | kern_rate.c \ | 85 | kern_rate.c \ | |
85 | kern_reboot.c \ | 86 | kern_reboot.c \ | |
86 | kern_resource.c \ | 87 | kern_resource.c \ | |
87 | kern_rwlock_obj.c \ | 88 | kern_rwlock_obj.c \ | |
88 | kern_scdebug.c \ | 89 | kern_scdebug.c \ | |
89 | kern_stub.c \ | 90 | kern_stub.c \ | |
90 | kern_ssp.c \ | 91 | kern_ssp.c \ | |
91 | kern_syscall.c \ | 92 | kern_syscall.c \ | |
92 | kern_sysctl.c \ | 93 | kern_sysctl.c \ | |
93 | kern_tc.c \ | 94 | kern_tc.c \ | |
94 | kern_threadpool.c \ | 95 | kern_threadpool.c \ | |
95 | kern_time.c \ | 96 | kern_time.c \ | |
96 | kern_timeout.c \ | 97 | kern_timeout.c \ | |
97 | kern_uidinfo.c \ | 98 | kern_uidinfo.c \ | |
98 | param.c \ | 99 | param.c \ | |
99 | subr_autoconf.c \ | 100 | subr_autoconf.c \ | |
100 | subr_callback.c \ | 101 | subr_callback.c \ | |
101 | subr_copy.c \ | 102 | subr_copy.c \ | |
102 | subr_cprng.c \ | 103 | subr_cprng.c \ | |
103 | subr_cpu.c \ | 104 | subr_cpu.c \ | |
104 | subr_device.c \ | 105 | subr_device.c \ | |
105 | subr_devsw.c \ | 106 | subr_devsw.c \ | |
106 | subr_evcnt.c \ | 107 | subr_evcnt.c \ | |
107 | subr_extent.c \ | 108 | subr_extent.c \ | |
108 | subr_hash.c \ | 109 | subr_hash.c \ | |
109 | subr_humanize.c \ | 110 | subr_humanize.c \ | |
110 | subr_iostat.c \ | 111 | subr_iostat.c \ | |
111 | subr_kcpuset.c \ | 112 | subr_kcpuset.c \ | |
112 | subr_kmem.c \ | 113 | subr_kmem.c \ | |
113 | subr_kobj.c \ | 114 | subr_kobj.c \ | |
114 | subr_localcount.c \ | 115 | subr_localcount.c \ | |
115 | subr_log.c \ | 116 | subr_log.c \ | |
116 | subr_lwp_specificdata.c \ | 117 | subr_lwp_specificdata.c \ | |
117 | subr_once.c \ | 118 | subr_once.c \ | |
118 | subr_pcq.c \ | 119 | subr_pcq.c \ | |
119 | subr_percpu.c \ | 120 | subr_percpu.c \ | |
120 | subr_pool.c \ | 121 | subr_pool.c \ | |
121 | subr_prf.c \ | 122 | subr_prf.c \ | |
122 | subr_pserialize.c \ | 123 | subr_pserialize.c \ | |
123 | subr_psref.c \ | 124 | subr_psref.c \ | |
124 | subr_specificdata.c \ | 125 | subr_specificdata.c \ | |
125 | subr_time.c \ | 126 | subr_time.c \ | |
126 | subr_thmap.c \ | 127 | subr_thmap.c \ | |
127 | subr_vmem.c \ | 128 | subr_vmem.c \ | |
128 | subr_workqueue.c \ | 129 | subr_workqueue.c \ | |
129 | subr_xcall.c \ | 130 | subr_xcall.c \ | |
130 | sys_descrip.c \ | 131 | sys_descrip.c \ | |
131 | sys_generic.c \ | 132 | sys_generic.c \ | |
132 | sys_module.c \ | 133 | sys_module.c \ | |
133 | sys_pipe.c \ | 134 | sys_pipe.c \ | |
134 | sys_select.c \ | 135 | sys_select.c \ | |
135 | syscalls.c \ | 136 | syscalls.c \ | |
136 | uipc_sem.c | 137 | uipc_sem.c | |
137 | 138 | |||
138 | # sys/uvm | 139 | # sys/uvm | |
139 | SRCS+= uvm_aobj.c uvm_readahead.c uvm_object.c uvm_swapstub.c | 140 | SRCS+= uvm_aobj.c uvm_readahead.c uvm_object.c uvm_swapstub.c | |
140 | SRCS+= uvm_page_array.c uvm_page_status.c | 141 | SRCS+= uvm_page_array.c uvm_page_status.c | |
141 | 142 | |||
142 | # 4.4BSD secmodel. selection is hardcoded for now | 143 | # 4.4BSD secmodel. selection is hardcoded for now | |
143 | SRCS+= secmodel.c | 144 | SRCS+= secmodel.c | |
144 | SRCS+= secmodel_suser.c | 145 | SRCS+= secmodel_suser.c | |
145 | 146 | |||
146 | # the funny bit. this doesn't really belong here, but helps with the | 147 | # the funny bit. this doesn't really belong here, but helps with the | |
147 | # needs of kern_descrip.c. And since it's a fully dynamic interface, | 148 | # needs of kern_descrip.c. And since it's a fully dynamic interface, | |
148 | # it doesn't pull in other gunk. | 149 | # it doesn't pull in other gunk. | |
149 | SRCS+= vnode_if.c | 150 | SRCS+= vnode_if.c | |
150 | 151 | |||
151 | # sys/dev | 152 | # sys/dev | |
152 | SRCS+= clock_subr.c | 153 | SRCS+= clock_subr.c | |
153 | 154 | |||
154 | # sys/dev/crypto | 155 | # sys/dev/crypto | |
155 | # Note: these are here only for cprng. More crypto algos for drivers | 156 | # Note: these are here only for cprng. More crypto algos for drivers | |
156 | # are available from the rumpkern_crypto component | 157 | # are available from the rumpkern_crypto component | |
157 | SRCS+= nist_hash_drbg.c | 158 | SRCS+= nist_hash_drbg.c | |
158 | SRCS+= cprng_fast.c | 159 | SRCS+= cprng_fast.c | |
160 | SRCS+= chacha_impl.c | |||
161 | SRCS+= chacha_ref.c | |||
162 | SRCS+= chacha_selftest.c | |||
159 | 163 | |||
160 | .include "${RUMPTOP}/Makefile.rump" | 164 | .include "${RUMPTOP}/Makefile.rump" | |
161 | .include <bsd.own.mk> | 165 | .include <bsd.own.mk> | |
162 | 166 | |||
163 | # compat | 167 | # compat | |
164 | .if !empty(RUMP_NBCOMPAT:M50) | 168 | .if !empty(RUMP_NBCOMPAT:M50) | |
165 | SRCS+= kern_select_50.c | 169 | SRCS+= kern_select_50.c | |
166 | SRCS+= kern_time_50.c | 170 | SRCS+= kern_time_50.c | |
167 | SRCS+= rndpseudo_50.c | 171 | SRCS+= rndpseudo_50.c | |
168 | .endif | 172 | .endif | |
169 | 173 | |||
170 | 174 | |||
171 | .ifdef RUMP_LOCKDEBUG | 175 | .ifdef RUMP_LOCKDEBUG | |
172 | SRCS+= subr_lockdebug.c | 176 | SRCS+= subr_lockdebug.c | |
173 | .endif | 177 | .endif | |
174 | 178 | |||
175 | .if ${RUMP_KTRACE} == "yes" | 179 | .if ${RUMP_KTRACE} == "yes" | |
176 | SRCS+= kern_ktrace.c | 180 | SRCS+= kern_ktrace.c | |
177 | .endif | 181 | .endif | |
178 | 182 | |||
179 | CPPFLAGS+= -I${RUMPTOP}/librump/rumpkern | 183 | CPPFLAGS+= -I${RUMPTOP}/librump/rumpkern | |
180 | AFLAGS+= -D_LOCORE -Wa,--fatal-warnings | 184 | AFLAGS+= -D_LOCORE -Wa,--fatal-warnings | |
181 | 185 | |||
182 | # | 186 | # | |
183 | # If archdir exists, it is required to provide: | 187 | # If archdir exists, it is required to provide: | |
184 | # 1) kobj_reloc() and kobj_machdep() | 188 | # 1) kobj_reloc() and kobj_machdep() | |
185 | # 2) rump_cpu_bootstrap() | 189 | # 2) rump_cpu_bootstrap() | |
186 | # 3) ...? | 190 | # 3) ...? | |
187 | # 4) PROFIT! | 191 | # 4) PROFIT! | |
188 | # | 192 | # | |
189 | 193 | |||
190 | # | 194 | # | |
191 | # Check if we are building compat. In compat mode we need to provide | 195 | # Check if we are building compat. In compat mode we need to provide | |
192 | # the kernel of our compat target (amd64->i386 & sparc64->sparc), so | 196 | # the kernel of our compat target (amd64->i386 & sparc64->sparc), so | |
193 | # take MD stuff from the right arch. | 197 | # take MD stuff from the right arch. | |
194 | # | 198 | # | |
195 | .if defined(COMPAT_MACHINE_CPU) \ | 199 | .if defined(COMPAT_MACHINE_CPU) \ | |
196 | && exists(${RUMPTOP}/librump/rumpkern/arch/${COMPAT_MACHINE_CPU}) | 200 | && exists(${RUMPTOP}/librump/rumpkern/arch/${COMPAT_MACHINE_CPU}) | |
197 | ARCHDIR= ${RUMPTOP}/librump/rumpkern/arch/${COMPAT_MACHINE_CPU} | 201 | ARCHDIR= ${RUMPTOP}/librump/rumpkern/arch/${COMPAT_MACHINE_CPU} | |
198 | LIBKERN_ARCH= ${COMPAT_MACHINE_CPU} | 202 | LIBKERN_ARCH= ${COMPAT_MACHINE_CPU} | |
199 | .elif defined(MLIBDIR) | 203 | .elif defined(MLIBDIR) | |
200 | ARCHDIR= ${RUMPTOP}/librump/rumpkern/arch/${MLIBDIR} | 204 | ARCHDIR= ${RUMPTOP}/librump/rumpkern/arch/${MLIBDIR} | |
201 | LIBKERN_ARCH= ${MLIBDIR} | 205 | LIBKERN_ARCH= ${MLIBDIR} | |
202 | .elif exists(${RUMPTOP}/librump/rumpkern/arch/${MACHINE_CPU}) | 206 | .elif exists(${RUMPTOP}/librump/rumpkern/arch/${MACHINE_CPU}) | |
203 | ARCHDIR= ${RUMPTOP}/librump/rumpkern/arch/${MACHINE_CPU} | 207 | ARCHDIR= ${RUMPTOP}/librump/rumpkern/arch/${MACHINE_CPU} | |
204 | .else | 208 | .else | |
205 | ARCHDIR= ${RUMPTOP}/librump/rumpkern/arch/${MACHINE_ARCH} | 209 | ARCHDIR= ${RUMPTOP}/librump/rumpkern/arch/${MACHINE_ARCH} | |
206 | .endif | 210 | .endif | |
207 | .if !exists(${ARCHDIR}) | 211 | .if !exists(${ARCHDIR}) | |
208 | ARCHDIR= ${RUMPTOP}/librump/rumpkern/arch/generic | 212 | ARCHDIR= ${RUMPTOP}/librump/rumpkern/arch/generic | |
209 | .endif | 213 | .endif | |
210 | 214 | |||
211 | .include "${ARCHDIR}/Makefile.inc" | 215 | .include "${ARCHDIR}/Makefile.inc" | |
212 | .PATH: ${ARCHDIR} | 216 | .PATH: ${ARCHDIR} | |
213 | 217 | |||
214 | .if ${MACHINE} == "sun3" | 218 | .if ${MACHINE} == "sun3" | |
215 | CPPFLAGS+= -Dsun3 | 219 | CPPFLAGS+= -Dsun3 | |
216 | .endif | 220 | .endif | |
217 | 221 | |||
218 | # include libkern source files | 222 | # include libkern source files | |
219 | KERNDIR=${RUMPTOP}/../lib/libkern | 223 | KERNDIR=${RUMPTOP}/../lib/libkern | |
220 | .if "${_RUMP_NATIVEABI}" == "yes" | 224 | .if "${_RUMP_NATIVEABI}" == "yes" | |
221 | KERNMISCCPPFLAGS+= -D_RUMPKERNEL | 225 | KERNMISCCPPFLAGS+= -D_RUMPKERNEL | |
222 | .endif | 226 | .endif | |
223 | .include "${RUMPTOP}/../lib/libkern/Makefile.libkern" | 227 | .include "${RUMPTOP}/../lib/libkern/Makefile.libkern" | |
224 | 228 | |||
225 | # Some architectures require a little special massage with atomic | 229 | # Some architectures require a little special massage with atomic | |
226 | # compare-and-swap. This is because the kernel version is using | 230 | # compare-and-swap. This is because the kernel version is using | |
227 | # instructions or routines unavailable to us in userspace. | 231 | # instructions or routines unavailable to us in userspace. | |
228 | # | 232 | # | |
229 | .if (${MACHINE_CPU} == "arm" && "${FEAT_LDREX}" != "yes") \ | 233 | .if (${MACHINE_CPU} == "arm" && "${FEAT_LDREX}" != "yes") \ | |
230 | || ${MACHINE_ARCH} == "coldfire" || ${MACHINE_CPU} == "hppa" \ | 234 | || ${MACHINE_ARCH} == "coldfire" || ${MACHINE_CPU} == "hppa" \ | |
231 | || ${MACHINE_CPU} == "mips" || ${MACHINE_CPU} == "sh3" \ | 235 | || ${MACHINE_CPU} == "mips" || ${MACHINE_CPU} == "sh3" \ | |
232 | || ${MACHINE_ARCH} == "vax" || ${MACHINE_ARCH} == "m68000" | 236 | || ${MACHINE_ARCH} == "vax" || ${MACHINE_ARCH} == "m68000" | |
233 | CPPFLAGS+= -I${RUMPTOP}/../../common/lib/libc/atomic | 237 | CPPFLAGS+= -I${RUMPTOP}/../../common/lib/libc/atomic | |
234 | SRCS+= atomic_cas_generic.c | 238 | SRCS+= atomic_cas_generic.c | |
235 | #SRCS+= rump_atomic_cas_up.c | 239 | #SRCS+= rump_atomic_cas_up.c | |
236 | .endif | 240 | .endif | |
237 | 241 | |||
238 | COPTS.if_ethersubr.c+= ${GCC_NO_CAST_FUNCTION_TYPE} | 242 | COPTS.if_ethersubr.c+= ${GCC_NO_CAST_FUNCTION_TYPE} | |
239 | COPTS.kern_hook.c+= ${GCC_NO_CAST_FUNCTION_TYPE} | 243 | COPTS.kern_hook.c+= ${GCC_NO_CAST_FUNCTION_TYPE} | |
240 | COPTS.subr_vmem.c+= ${GCC_NO_CAST_FUNCTION_TYPE} | 244 | COPTS.subr_vmem.c+= ${GCC_NO_CAST_FUNCTION_TYPE} | |
241 | COPTS.subr_pool.c+= ${GCC_NO_CAST_FUNCTION_TYPE} | 245 | COPTS.subr_pool.c+= ${GCC_NO_CAST_FUNCTION_TYPE} | |
242 | COPTS.rump.c+= ${GCC_NO_CAST_FUNCTION_TYPE} | 246 | COPTS.rump.c+= ${GCC_NO_CAST_FUNCTION_TYPE} | |
243 | 247 | |||
244 | .include <bsd.lib.mk> | 248 | .include <bsd.lib.mk> | |
245 | .include <bsd.klinks.mk> | 249 | .include <bsd.klinks.mk> |