| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: systm.h,v 1.286 2019/07/23 17:39:36 rin Exp $ */ | | 1 | /* $NetBSD: systm.h,v 1.287 2019/10/10 13:45:14 maxv Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1982, 1988, 1991, 1993 | | 4 | * Copyright (c) 1982, 1988, 1991, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * (c) UNIX System Laboratories, Inc. | | 6 | * (c) UNIX System Laboratories, Inc. |
7 | * All or some portions of this file are derived from material licensed | | 7 | * All or some portions of this file are derived from material licensed |
8 | * to the University of California by American Telephone and Telegraph | | 8 | * to the University of California by American Telephone and Telegraph |
9 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with | | 9 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with |
10 | * the permission of UNIX System Laboratories, Inc. | | 10 | * the permission of UNIX System Laboratories, Inc. |
11 | * | | 11 | * |
12 | * Redistribution and use in source and binary forms, with or without | | 12 | * Redistribution and use in source and binary forms, with or without |
13 | * modification, are permitted provided that the following conditions | | 13 | * modification, are permitted provided that the following conditions |
14 | * are met: | | 14 | * are met: |
| @@ -33,26 +33,27 @@ | | | @@ -33,26 +33,27 @@ |
33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
34 | * SUCH DAMAGE. | | 34 | * SUCH DAMAGE. |
35 | * | | 35 | * |
36 | * @(#)systm.h 8.7 (Berkeley) 3/29/95 | | 36 | * @(#)systm.h 8.7 (Berkeley) 3/29/95 |
37 | */ | | 37 | */ |
38 | | | 38 | |
39 | #ifndef _SYS_SYSTM_H_ | | 39 | #ifndef _SYS_SYSTM_H_ |
40 | #define _SYS_SYSTM_H_ | | 40 | #define _SYS_SYSTM_H_ |
41 | | | 41 | |
42 | #if defined(_KERNEL_OPT) | | 42 | #if defined(_KERNEL_OPT) |
43 | #include "opt_ddb.h" | | 43 | #include "opt_ddb.h" |
44 | #include "opt_multiprocessor.h" | | 44 | #include "opt_multiprocessor.h" |
45 | #include "opt_gprof.h" | | 45 | #include "opt_gprof.h" |
| | | 46 | #include "opt_kasan.h" |
46 | #include "opt_kleak.h" | | 47 | #include "opt_kleak.h" |
47 | #include "opt_wsdisplay_compat.h" | | 48 | #include "opt_wsdisplay_compat.h" |
48 | #endif | | 49 | #endif |
49 | #if !defined(_KERNEL) && !defined(_STANDALONE) | | 50 | #if !defined(_KERNEL) && !defined(_STANDALONE) |
50 | #include <stdbool.h> | | 51 | #include <stdbool.h> |
51 | #endif | | 52 | #endif |
52 | | | 53 | |
53 | #include <machine/endian.h> | | 54 | #include <machine/endian.h> |
54 | | | 55 | |
55 | #include <sys/types.h> | | 56 | #include <sys/types.h> |
56 | #include <sys/stdarg.h> | | 57 | #include <sys/stdarg.h> |
57 | | | 58 | |
58 | #include <sys/device_if.h> | | 59 | #include <sys/device_if.h> |
| @@ -309,94 +310,122 @@ void kleak_fill_stack(void); | | | @@ -309,94 +310,122 @@ void kleak_fill_stack(void); |
309 | typedef int (*copyin_t)(const void *, void *, size_t); | | 310 | typedef int (*copyin_t)(const void *, void *, size_t); |
310 | typedef int (*copyout_t)(const void *, void *, size_t); | | 311 | typedef int (*copyout_t)(const void *, void *, size_t); |
311 | #endif | | 312 | #endif |
312 | | | 313 | |
313 | int copyin_proc(struct proc *, const void *, void *, size_t); | | 314 | int copyin_proc(struct proc *, const void *, void *, size_t); |
314 | int copyout_proc(struct proc *, const void *, void *, size_t); | | 315 | int copyout_proc(struct proc *, const void *, void *, size_t); |
315 | int copyin_pid(pid_t, const void *, void *, size_t); | | 316 | int copyin_pid(pid_t, const void *, void *, size_t); |
316 | int copyin_vmspace(struct vmspace *, const void *, void *, size_t); | | 317 | int copyin_vmspace(struct vmspace *, const void *, void *, size_t); |
317 | int copyout_vmspace(struct vmspace *, const void *, void *, size_t); | | 318 | int copyout_vmspace(struct vmspace *, const void *, void *, size_t); |
318 | | | 319 | |
319 | int ioctl_copyin(int ioctlflags, const void *src, void *dst, size_t len); | | 320 | int ioctl_copyin(int ioctlflags, const void *src, void *dst, size_t len); |
320 | int ioctl_copyout(int ioctlflags, const void *src, void *dst, size_t len); | | 321 | int ioctl_copyout(int ioctlflags, const void *src, void *dst, size_t len); |
321 | | | 322 | |
322 | int ucas_32(volatile uint32_t *uaddr, uint32_t old, uint32_t new, | | 323 | int ucas_32(volatile uint32_t *, uint32_t, uint32_t, uint32_t *); |
323 | uint32_t *ret); | | | |
324 | #ifdef _LP64 | | 324 | #ifdef _LP64 |
325 | int ucas_64(volatile uint64_t *uaddr, uint64_t old, uint64_t new, | | 325 | int ucas_64(volatile uint64_t *, uint64_t, uint64_t, uint64_t *); |
326 | uint64_t *ret); | | 326 | #endif |
327 | #endif /* _LP64 */ | | | |
328 | | | | |
329 | int ucas_ptr(volatile void *, void *, void *, void *); | | 327 | int ucas_ptr(volatile void *, void *, void *, void *); |
330 | int ucas_int(volatile unsigned int *, unsigned int, unsigned int, | | 328 | int ucas_int(volatile unsigned int *, unsigned int, unsigned int, |
331 | unsigned int *); | | 329 | unsigned int *); |
| | | 330 | int ufetch_8(const uint8_t *, uint8_t *); |
| | | 331 | int ufetch_16(const uint16_t *, uint16_t *); |
| | | 332 | int ufetch_32(const uint32_t *, uint32_t *); |
| | | 333 | #ifdef _LP64 |
| | | 334 | int ufetch_64(const uint64_t *, uint64_t *); |
| | | 335 | #endif |
| | | 336 | int ufetch_char(const unsigned char *, unsigned char *); |
| | | 337 | int ufetch_short(const unsigned short *, unsigned short *); |
| | | 338 | int ufetch_int(const unsigned int *, unsigned int *); |
| | | 339 | int ufetch_long(const unsigned long *, unsigned long *); |
| | | 340 | int ufetch_ptr(const void **, void **); |
| | | 341 | int ustore_8(uint8_t *, uint8_t); |
| | | 342 | int ustore_16(uint16_t *, uint16_t); |
| | | 343 | int ustore_32(uint32_t *, uint32_t); |
| | | 344 | #ifdef _LP64 |
| | | 345 | int ustore_64(uint64_t *, uint64_t); |
| | | 346 | #endif |
| | | 347 | int ustore_char(unsigned char *, unsigned char); |
| | | 348 | int ustore_short(unsigned short *, unsigned short); |
| | | 349 | int ustore_int(unsigned int *, unsigned int); |
| | | 350 | int ustore_long(unsigned long *, unsigned long); |
| | | 351 | int ustore_ptr(void **, void *); |
332 | | | 352 | |
333 | #ifdef __UCAS_PRIVATE | | 353 | #ifdef __UCAS_PRIVATE |
334 | int _ucas_32(volatile uint32_t *uaddr, uint32_t old, uint32_t new, | | 354 | |
335 | uint32_t *ret); | | 355 | #if defined(KASAN) |
| | | 356 | int kasan__ucas_32(volatile uint32_t *, uint32_t, uint32_t, uint32_t *); |
336 | #ifdef __HAVE_UCAS_MP | | 357 | #ifdef __HAVE_UCAS_MP |
337 | int _ucas_32_mp(volatile uint32_t *uaddr, uint32_t old, uint32_t new, | | 358 | int kasan__ucas_32_mp(volatile uint32_t *, uint32_t, uint32_t, uint32_t *); |
338 | uint32_t *ret); | | | |
339 | #endif /* __HAVE_UCAS_MP */ | | 359 | #endif /* __HAVE_UCAS_MP */ |
340 | #ifdef _LP64 | | 360 | #ifdef _LP64 |
341 | int _ucas_64(volatile uint64_t *uaddr, uint64_t old, uint64_t new, | | 361 | int kasan__ucas_64(volatile uint64_t *, uint64_t, uint64_t, uint64_t *); |
342 | uint64_t *ret); | | | |
343 | #ifdef __HAVE_UCAS_MP | | 362 | #ifdef __HAVE_UCAS_MP |
344 | int _ucas_64_mp(volatile uint64_t *uaddr, uint64_t old, uint64_t new, | | 363 | int kasan__ucas_64_mp(volatile uint64_t *, uint64_t, uint64_t, uint64_t *); |
345 | uint64_t *ret); | | | |
346 | #endif /* __HAVE_UCAS_MP */ | | 364 | #endif /* __HAVE_UCAS_MP */ |
347 | #endif /* _LP64 */ | | 365 | #endif /* _LP64 */ |
| | | 366 | #define _ucas_32 kasan__ucas_32 |
| | | 367 | #define _ucas_32_mp kasan__ucas_32_mp |
| | | 368 | #define _ucas_64 kasan__ucas_64 |
| | | 369 | #define _ucas_64_mp kasan__ucas_64_mp |
| | | 370 | #else |
| | | 371 | int _ucas_32(volatile uint32_t *, uint32_t, uint32_t, uint32_t *); |
| | | 372 | #ifdef __HAVE_UCAS_MP |
| | | 373 | int _ucas_32_mp(volatile uint32_t *, uint32_t, uint32_t, uint32_t *); |
| | | 374 | #endif /* __HAVE_UCAS_MP */ |
| | | 375 | #ifdef _LP64 |
| | | 376 | int _ucas_64(volatile uint64_t *, uint64_t, uint64_t, uint64_t *); |
| | | 377 | #ifdef __HAVE_UCAS_MP |
| | | 378 | int _ucas_64_mp(volatile uint64_t *, uint64_t, uint64_t, uint64_t *); |
| | | 379 | #endif /* __HAVE_UCAS_MP */ |
| | | 380 | #endif /* _LP64 */ |
| | | 381 | #endif |
| | | 382 | |
348 | #endif /* __UCAS_PRIVATE */ | | 383 | #endif /* __UCAS_PRIVATE */ |
349 | | | 384 | |
350 | int ufetch_8(const uint8_t *uaddr, uint8_t *valp); | | 385 | #ifdef __UFETCHSTORE_PRIVATE |
351 | int ufetch_16(const uint16_t *uaddr, uint16_t *valp); | | 386 | |
352 | int ufetch_32(const uint32_t *uaddr, uint32_t *valp); | | 387 | #if defined(KASAN) |
| | | 388 | int kasan__ufetch_8(const uint8_t *, uint8_t *); |
| | | 389 | int kasan__ufetch_16(const uint16_t *, uint16_t *); |
| | | 390 | int kasan__ufetch_32(const uint32_t *, uint32_t *); |
353 | #ifdef _LP64 | | 391 | #ifdef _LP64 |
354 | int ufetch_64(const uint64_t *uaddr, uint64_t *valp); | | 392 | int kasan__ufetch_64(const uint64_t *, uint64_t *); |
355 | #endif | | 393 | #endif |
356 | | | 394 | int _ustore_8(uint8_t *, uint8_t); |
357 | int ufetch_char(const unsigned char *uaddr, unsigned char *valp); | | 395 | int _ustore_16(uint16_t *, uint16_t); |
358 | int ufetch_short(const unsigned short *uaddr, unsigned short *valp); | | 396 | int _ustore_32(uint32_t *, uint32_t); |
359 | int ufetch_int(const unsigned int *uaddr, unsigned int *valp); | | | |
360 | int ufetch_long(const unsigned long *uaddr, unsigned long *valp); | | | |
361 | int ufetch_ptr(const void **uaddr, void **valp); | | | |
362 | | | | |
363 | int ustore_8(uint8_t *uaddr, uint8_t val); | | | |
364 | int ustore_16(uint16_t *uaddr, uint16_t val); | | | |
365 | int ustore_32(uint32_t *uaddr, uint32_t val); | | | |
366 | #ifdef _LP64 | | 397 | #ifdef _LP64 |
367 | int ustore_64(uint64_t *uaddr, uint64_t val); | | 398 | int _ustore_64(uint64_t *, uint64_t); |
368 | #endif | | 399 | #endif |
369 | | | 400 | #define _ufetch_8 kasan__ufetch_8 |
370 | int ustore_char(unsigned char *uaddr, unsigned char val); | | 401 | #define _ufetch_16 kasan__ufetch_16 |
371 | int ustore_short(unsigned short *uaddr, unsigned short val); | | 402 | #define _ufetch_32 kasan__ufetch_32 |
372 | int ustore_int(unsigned int *uaddr, unsigned int val); | | 403 | #define _ufetch_64 kasan__ufetch_64 |
373 | int ustore_long(unsigned long *uaddr, unsigned long val); | | 404 | #else |
374 | int ustore_ptr(void **uaddr, void *val); | | 405 | int _ufetch_8(const uint8_t *, uint8_t *); |
375 | | | 406 | int _ufetch_16(const uint16_t *, uint16_t *); |
376 | #ifdef __UFETCHSTORE_PRIVATE | | 407 | int _ufetch_32(const uint32_t *, uint32_t *); |
377 | int _ufetch_8(const uint8_t *uaddr, uint8_t *valp); | | | |
378 | int _ufetch_16(const uint16_t *uaddr, uint16_t *valp); | | | |
379 | int _ufetch_32(const uint32_t *uaddr, uint32_t *valp); | | | |
380 | #ifdef _LP64 | | 408 | #ifdef _LP64 |
381 | int _ufetch_64(const uint64_t *uaddr, uint64_t *valp); | | 409 | int _ufetch_64(const uint64_t *, uint64_t *); |
382 | #endif | | 410 | #endif |
383 | | | 411 | int _ustore_8(uint8_t *, uint8_t); |
384 | int _ustore_8(uint8_t *uaddr, uint8_t val); | | 412 | int _ustore_16(uint16_t *, uint16_t); |
385 | int _ustore_16(uint16_t *uaddr, uint16_t val); | | 413 | int _ustore_32(uint32_t *, uint32_t); |
386 | int _ustore_32(uint32_t *uaddr, uint32_t val); | | | |
387 | #ifdef _LP64 | | 414 | #ifdef _LP64 |
388 | int _ustore_64(uint64_t *uaddr, uint64_t val); | | 415 | int _ustore_64(uint64_t *, uint64_t); |
| | | 416 | #endif |
389 | #endif | | 417 | #endif |
| | | 418 | |
390 | #endif /* __UFETCHSTORE_PRIVATE */ | | 419 | #endif /* __UFETCHSTORE_PRIVATE */ |
391 | | | 420 | |
392 | void hardclock(struct clockframe *); | | 421 | void hardclock(struct clockframe *); |
393 | void softclock(void *); | | 422 | void softclock(void *); |
394 | void statclock(struct clockframe *); | | 423 | void statclock(struct clockframe *); |
395 | | | 424 | |
396 | #ifdef NTP | | 425 | #ifdef NTP |
397 | void ntp_init(void); | | 426 | void ntp_init(void); |
398 | #ifdef PPS_SYNC | | 427 | #ifdef PPS_SYNC |
399 | struct timespec; | | 428 | struct timespec; |
400 | void hardpps(struct timespec *, long); | | 429 | void hardpps(struct timespec *, long); |
401 | #endif /* PPS_SYNC */ | | 430 | #endif /* PPS_SYNC */ |
402 | #else | | 431 | #else |