From laffer1 at midnightbsd.org Sun Feb 16 16:41:01 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 16:41:01 -0500 (EST) Subject: [Midnightbsd-cvs] src [12367] trunk/sys/sys: sync Message-ID: <202002162141.01GLf1Fn026257@stargazer.midnightbsd.org> Revision: 12367 http://svnweb.midnightbsd.org/src/?rev=12367 Author: laffer1 Date: 2020-02-16 16:41:01 -0500 (Sun, 16 Feb 2020) Log Message: ----------- sync Modified Paths: -------------- trunk/sys/sys/_cpuset.h trunk/sys/sys/_kstack_cache.h Modified: trunk/sys/sys/_cpuset.h =================================================================== --- trunk/sys/sys/_cpuset.h 2020-02-09 18:38:04 UTC (rev 12366) +++ trunk/sys/sys/_cpuset.h 2020-02-16 21:41:01 UTC (rev 12367) @@ -27,7 +27,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/sys/_cpuset.h 271172 2014-09-05 15:45:20Z jhb $ + * $FreeBSD: stable/11/sys/sys/_cpuset.h 331722 2018-03-29 02:50:57Z eadler $ */ #ifndef _SYS__CPUSET_H_ @@ -45,13 +45,7 @@ #define CPU_SETSIZE CPU_MAXSIZE #endif -#define _NCPUBITS _BITSET_BITS -#define _NCPUWORDS __bitset_words(CPU_SETSIZE) - BITSET_DEFINE(_cpuset, CPU_SETSIZE); typedef struct _cpuset cpuset_t; -#define CPUSET_FSET BITSET_FSET(_NCPUWORDS) -#define CPUSET_T_INITIALIZER BITSET_T_INITIALIZER - #endif /* !_SYS__CPUSET_H_ */ Modified: trunk/sys/sys/_kstack_cache.h =================================================================== --- trunk/sys/sys/_kstack_cache.h 2020-02-09 18:38:04 UTC (rev 12366) +++ trunk/sys/sys/_kstack_cache.h 2020-02-16 21:41:01 UTC (rev 12367) @@ -1,3 +1,4 @@ +/* $MidnightBSD$ */ /*- * Copyright (c) 2009 Konstantin Belousov * @@ -25,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $MidnightBSD$ + * $FreeBSD: stable/11/sys/sys/_kstack_cache.h 331722 2018-03-29 02:50:57Z eadler $ */ #ifndef _SYS__KSTACK_CACHE_H @@ -38,6 +39,10 @@ extern struct kstack_cache_entry *kstack_cache; +#ifndef KSTACK_MAX_PAGES +#define KSTACK_MAX_PAGES 32 #endif +#endif + From laffer1 at midnightbsd.org Sun Feb 16 16:51:02 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 16:51:02 -0500 (EST) Subject: [Midnightbsd-cvs] src [12368] trunk/sys/sys: Sync with FreeBSD 11-stable Message-ID: <202002162151.01GLp2h4027994@stargazer.midnightbsd.org> Revision: 12368 http://svnweb.midnightbsd.org/src/?rev=12368 Author: laffer1 Date: 2020-02-16 16:51:02 -0500 (Sun, 16 Feb 2020) Log Message: ----------- Sync with FreeBSD 11-stable Modified Paths: -------------- trunk/sys/sys/racct.h trunk/sys/sys/random.h trunk/sys/sys/rangelock.h trunk/sys/sys/rctl.h trunk/sys/sys/reboot.h trunk/sys/sys/refcount.h trunk/sys/sys/regression.h trunk/sys/sys/resource.h trunk/sys/sys/resourcevar.h Modified: trunk/sys/sys/racct.h =================================================================== --- trunk/sys/sys/racct.h 2020-02-16 21:41:01 UTC (rev 12367) +++ trunk/sys/sys/racct.h 2020-02-16 21:51:02 UTC (rev 12368) @@ -27,7 +27,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/sys/racct.h 299616 2016-05-13 08:17:42Z ngie $ + * $FreeBSD: stable/11/sys/sys/racct.h 331722 2018-03-29 02:50:57Z eadler $ */ /* @@ -38,9 +38,12 @@ #define _RACCT_H_ #include +#include #include -#include +#include +#include +struct buf; struct proc; struct rctl_rule_link; struct ucred; @@ -70,7 +73,11 @@ #define RACCT_SHMSIZE 18 #define RACCT_WALLCLOCK 19 #define RACCT_PCTCPU 20 -#define RACCT_MAX RACCT_PCTCPU +#define RACCT_READBPS 21 +#define RACCT_WRITEBPS 22 +#define RACCT_READIOPS 23 +#define RACCT_WRITEIOPS 24 +#define RACCT_MAX RACCT_WRITEIOPS /* * Resource properties. @@ -98,7 +105,7 @@ /* * Resource usage can drop, as opposed to only grow. When the process - * terminates, its resource usage is freed from the respective + * terminates, its resource usage is subtracted from the respective * per-credential racct containers. */ #define RACCT_IS_RECLAIMABLE(X) (racct_types[X] & RACCT_RECLAIMABLE) @@ -126,8 +133,7 @@ * When a process terminates, its resource usage is not automatically * subtracted from per-credential racct containers. Instead, the resource * usage of per-credential racct containers decays in time. - * Resource usage can olso drop for such resource. - * So far, the only such resource is RACCT_PCTCPU. + * Resource usage can also drop for such resource. */ #define RACCT_IS_DECAYING(X) (racct_types[X] & RACCT_DECAYING) @@ -147,9 +153,20 @@ LIST_HEAD(, rctl_rule_link) r_rule_links; }; +SYSCTL_DECL(_kern_racct); + +#ifdef RACCT + +extern struct mtx racct_lock; + +#define RACCT_LOCK() mtx_lock(&racct_lock) +#define RACCT_UNLOCK() mtx_unlock(&racct_lock) +#define RACCT_LOCK_ASSERT() mtx_assert(&racct_lock, MA_OWNED) + int racct_add(struct proc *p, int resource, uint64_t amount); void racct_add_cred(struct ucred *cred, int resource, uint64_t amount); void racct_add_force(struct proc *p, int resource, uint64_t amount); +void racct_add_buf(struct proc *p, const struct buf *bufp, int is_write); int racct_set(struct proc *p, int resource, uint64_t amount); void racct_set_force(struct proc *p, int resource, uint64_t amount); void racct_sub(struct proc *p, int resource, uint64_t amount); @@ -167,5 +184,83 @@ void racct_proc_ucred_changed(struct proc *p, struct ucred *oldcred, struct ucred *newcred); void racct_move(struct racct *dest, struct racct *src); +void racct_proc_throttle(struct proc *p, int timeout); +#else + +static inline int +racct_add(struct proc *p, int resource, uint64_t amount) +{ + + return (0); +} + +static inline void +racct_add_cred(struct ucred *cred, int resource, uint64_t amount) +{ +} + +static inline void +racct_add_force(struct proc *p, int resource, uint64_t amount) +{ +} + +static inline int +racct_set(struct proc *p, int resource, uint64_t amount) +{ + + return (0); +} + +static inline void +racct_set_force(struct proc *p, int resource, uint64_t amount) +{ +} + +static inline void +racct_sub(struct proc *p, int resource, uint64_t amount) +{ +} + +static inline void +racct_sub_cred(struct ucred *cred, int resource, uint64_t amount) +{ +} + +static inline uint64_t +racct_get_limit(struct proc *p, int resource) +{ + + return (UINT64_MAX); +} + +static inline uint64_t +racct_get_available(struct proc *p, int resource) +{ + + return (UINT64_MAX); +} + +#define racct_create(x) +#define racct_destroy(x) + +static inline int +racct_proc_fork(struct proc *parent, struct proc *child) +{ + + return (0); +} + +static inline void +racct_proc_fork_done(struct proc *child) +{ +} + +static inline void +racct_proc_exit(struct proc *p) +{ +} + +#endif + #endif /* !_RACCT_H_ */ Modified: trunk/sys/sys/random.h =================================================================== --- trunk/sys/sys/random.h 2020-02-16 21:41:01 UTC (rev 12367) +++ trunk/sys/sys/random.h 2020-02-16 21:51:02 UTC (rev 12368) @@ -1,6 +1,6 @@ /* $MidnightBSD$ */ /*- - * Copyright (c) 2000-2013 Mark R. V. Murray + * Copyright (c) 2000-2015 Mark R. V. Murray * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/sys/random.h 268933 2014-07-21 00:21:56Z jhb $ + * $FreeBSD: stable/11/sys/sys/random.h 346725 2019-04-26 01:58:36Z mw $ */ #ifndef _SYS_RANDOM_H_ @@ -32,15 +32,44 @@ #ifdef _KERNEL -int read_random(void *, int); +#include +#if !defined(KLD_MODULE) +#if defined(RANDOM_LOADABLE) && defined(RANDOM_YARROW) +#error "Cannot define both RANDOM_LOADABLE and RANDOM_YARROW" +#endif +#endif + +struct uio; + +#if defined(DEV_RANDOM) +u_int read_random(void *, u_int); +int read_random_uio(struct uio *, bool); +#else +static __inline int +read_random_uio(void *a __unused, u_int b __unused) +{ + return (0); +} +static __inline u_int +read_random(void *a __unused, u_int b __unused) +{ + return (0); +} +#endif + /* - * Note: if you add or remove members of esource, remember to also update the - * KASSERT regarding what valid members are in random_harvest_internal(). + * Note: if you add or remove members of random_entropy_source, remember to also update the + * KASSERT regarding what valid members are in random_harvest_internal(), and remember the + * strings in the static array random_source_descr[] in random_harvestq.c. + * + * NOTE: complain loudly to markm@ or on the lists if this enum gets more than 32 + * distinct values (0-31)! ENTROPYSOURCE may be == 32, but not > 32. */ -enum esource { +enum random_entropy_source { RANDOM_START = 0, RANDOM_CACHED = 0, + /* Environmental sources */ RANDOM_ATTACH, RANDOM_KEYBOARD, RANDOM_MOUSE, @@ -49,6 +78,10 @@ RANDOM_NET_NG, RANDOM_INTERRUPT, RANDOM_SWI, + RANDOM_FS_ATIME, + RANDOM_UMA, /* Special!! UMA/SLAB Allocator */ + RANDOM_ENVIRONMENTAL_END = RANDOM_UMA, + /* Fast hardware random-number sources from here on. */ RANDOM_PURE_OCTEON, RANDOM_PURE_SAFE, RANDOM_PURE_GLXSB, @@ -58,23 +91,29 @@ RANDOM_PURE_NEHEMIAH, RANDOM_PURE_RNDTEST, RANDOM_PURE_VIRTIO, + RANDOM_PURE_BROADCOM, + RANDOM_PURE_TPM, ENTROPYSOURCE }; -void random_harvest(void *, u_int, u_int, enum esource); -/* Allow the sysadmin to select the broad category of - * entropy types to harvest - */ -struct harvest_select { - int ethernet; - int point_to_point; - int interrupt; - int swi; - int namei; -}; +#define RANDOM_HARVEST_EVERYTHING_MASK ((1 << (RANDOM_ENVIRONMENTAL_END + 1)) - 1) -extern struct harvest_select harvest; +#if defined(DEV_RANDOM) +void random_harvest_queue(const void *, u_int, u_int, enum random_entropy_source); +void random_harvest_fast(const void *, u_int, u_int, enum random_entropy_source); +void random_harvest_direct(const void *, u_int, u_int, enum random_entropy_source); +#else +#define random_harvest_queue(a, b, c, d) do {} while (0) +#define random_harvest_fast(a, b, c, d) do {} while (0) +#define random_harvest_direct(a, b, c, d) do {} while (0) +#endif +#if defined(RANDOM_ENABLE_UMA) +#define random_harvest_fast_uma(a, b, c, d) random_harvest_fast(a, b, c, d) +#else /* !defined(RANDOM_ENABLE_UMA) */ +#define random_harvest_fast_uma(a, b, c, d) do {} while (0) +#endif /* defined(RANDOM_ENABLE_UMA) */ + #endif /* _KERNEL */ #endif /* _SYS_RANDOM_H_ */ Modified: trunk/sys/sys/rangelock.h =================================================================== --- trunk/sys/sys/rangelock.h 2020-02-16 21:41:01 UTC (rev 12367) +++ trunk/sys/sys/rangelock.h 2020-02-16 21:51:02 UTC (rev 12368) @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/sys/rangelock.h 254380 2013-08-15 20:19:17Z cperciva $ + * $FreeBSD: stable/11/sys/sys/rangelock.h 355690 2019-12-13 04:03:03Z kevans $ */ #ifndef _SYS_RANGELOCK_H @@ -77,7 +77,30 @@ void *rangelock_wlock(struct rangelock *lock, off_t start, off_t end, struct mtx *ilk); void rlqentry_free(struct rl_q_entry *rlqe); +#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) +void _rangelock_cookie_assert(void *cookie, int what, const char *file, + int line); +#endif +#ifdef INVARIANTS +#define rangelock_cookie_assert_(cookie, what, file, line) \ + _rangelock_cookie_assert((cookie), (what), (file), (line)) +#else +#define rangelock_cookie_assert_(cookie, what, file, line) (void)0 +#endif + +#define rangelock_cookie_assert(cookie, what) \ + rangelock_cookie_assert_((cookie), (what), __FILE__, __LINE__) + +/* + * Assertion flags. + */ +#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) +#define RCA_LOCKED 0x0001 +#define RCA_RLOCKED 0x0002 +#define RCA_WLOCKED 0x0004 +#endif + #endif /* _KERNEL */ #endif /* _SYS_RANGELOCK_H */ Modified: trunk/sys/sys/rctl.h =================================================================== --- trunk/sys/sys/rctl.h 2020-02-16 21:41:01 UTC (rev 12367) +++ trunk/sys/sys/rctl.h 2020-02-16 21:51:02 UTC (rev 12368) @@ -27,7 +27,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/sys/rctl.h 242139 2012-10-26 16:01:08Z trasz $ + * $FreeBSD: stable/11/sys/sys/rctl.h 331722 2018-03-29 02:50:57Z eadler $ */ /* @@ -130,7 +130,8 @@ #define RCTL_ACTION_DENY (RCTL_ACTION_SIGNAL_MAX + 1) #define RCTL_ACTION_LOG (RCTL_ACTION_SIGNAL_MAX + 2) #define RCTL_ACTION_DEVCTL (RCTL_ACTION_SIGNAL_MAX + 3) -#define RCTL_ACTION_MAX RCTL_ACTION_DEVCTL +#define RCTL_ACTION_THROTTLE (RCTL_ACTION_SIGNAL_MAX + 4) +#define RCTL_ACTION_MAX RCTL_ACTION_THROTTLE #define RCTL_AMOUNT_UNDEFINED -1 @@ -141,6 +142,7 @@ int rctl_rule_add(struct rctl_rule *rule); int rctl_rule_remove(struct rctl_rule *filter); int rctl_enforce(struct proc *p, int resource, uint64_t amount); +void rctl_throttle_decay(struct racct *racct, int resource); int64_t rctl_pcpu_available(const struct proc *p); uint64_t rctl_get_limit(struct proc *p, int resource); uint64_t rctl_get_available(struct proc *p, int resource); Modified: trunk/sys/sys/reboot.h =================================================================== --- trunk/sys/sys/reboot.h 2020-02-16 21:41:01 UTC (rev 12367) +++ trunk/sys/sys/reboot.h 2020-02-16 21:51:02 UTC (rev 12368) @@ -28,7 +28,7 @@ * SUCH DAMAGE. * * @(#)reboot.h 8.3 (Berkeley) 12/13/94 - * $FreeBSD: stable/10/sys/sys/reboot.h 293743 2016-01-12 10:11:29Z trasz $ + * $FreeBSD: stable/11/sys/sys/reboot.h 344378 2019-02-20 19:19:24Z kevans $ */ #ifndef _SYS_REBOOT_H_ @@ -61,6 +61,7 @@ #define RB_RESERVED2 0x80000 /* reserved for internal use of boot blocks */ #define RB_PAUSE 0x100000 /* pause after each output line during probe */ #define RB_REROOT 0x200000 /* unmount the rootfs and mount it again */ +#define RB_PROBE 0x10000000 /* Probe multiple consoles */ #define RB_MULTIPLE 0x20000000 /* use multiple consoles */ #define RB_BOOTINFO 0x80000000 /* have `struct bootinfo *' arg */ Modified: trunk/sys/sys/refcount.h =================================================================== --- trunk/sys/sys/refcount.h 2020-02-16 21:41:01 UTC (rev 12367) +++ trunk/sys/sys/refcount.h 2020-02-16 21:51:02 UTC (rev 12368) @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/sys/refcount.h 262192 2014-02-18 20:27:17Z jhb $ + * $FreeBSD: stable/11/sys/sys/refcount.h 339862 2018-10-29 14:37:27Z hselasky $ */ #ifndef __SYS_REFCOUNT_H__ @@ -51,7 +51,7 @@ { KASSERT(*count < UINT_MAX, ("refcount %p overflowed", count)); - atomic_add_acq_int(count, 1); + atomic_add_int(count, 1); } static __inline int @@ -59,10 +59,56 @@ { u_int old; - /* XXX: Should this have a rel membar? */ + atomic_thread_fence_rel(); old = atomic_fetchadd_int(count, -1); - KASSERT(old > 0, ("negative refcount %p", count)); - return (old == 1); + KASSERT(old > 0, ("refcount %p is zero", count)); + if (old > 1) + return (0); + + /* + * Last reference. Signal the user to call the destructor. + * + * Ensure that the destructor sees all updates. The fence_rel + * at the start of the function synchronized with this fence. + */ + atomic_thread_fence_acq(); + return (1); } +/* + * This functions returns non-zero if the refcount was + * incremented. Else zero is returned. + * + * A temporary hack until refcount_* APIs are sorted out. + */ +static __inline __result_use_check int +refcount_acquire_if_not_zero(volatile u_int *count) +{ + u_int old; + + old = *count; + for (;;) { + KASSERT(old < UINT_MAX, ("refcount %p overflowed", count)); + if (old == 0) + return (0); + if (atomic_fcmpset_int(count, &old, old + 1)) + return (1); + } +} + +static __inline __result_use_check int +refcount_release_if_not_last(volatile u_int *count) +{ + u_int old; + + old = *count; + for (;;) { + KASSERT(old > 0, ("refcount %p is zero", count)); + if (old == 1) + return (0); + if (atomic_fcmpset_int(count, &old, old - 1)) + return (1); + } +} + #endif /* ! __SYS_REFCOUNT_H__ */ Modified: trunk/sys/sys/regression.h =================================================================== --- trunk/sys/sys/regression.h 2020-02-16 21:41:01 UTC (rev 12367) +++ trunk/sys/sys/regression.h 2020-02-16 21:51:02 UTC (rev 12368) @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/sys/regression.h 129096 2004-05-10 18:38:07Z rwatson $ + * $FreeBSD: stable/11/sys/sys/regression.h 331722 2018-03-29 02:50:57Z eadler $ */ #ifndef _SYS_REGRESSION_H_ #define _SYS_REGRESSION_H_ Modified: trunk/sys/sys/resource.h =================================================================== --- trunk/sys/sys/resource.h 2020-02-16 21:41:01 UTC (rev 12367) +++ trunk/sys/sys/resource.h 2020-02-16 21:51:02 UTC (rev 12368) @@ -28,7 +28,7 @@ * SUCH DAMAGE. * * @(#)resource.h 8.4 (Berkeley) 1/9/95 - * $FreeBSD: stable/10/sys/sys/resource.h 314392 2017-02-28 15:03:34Z kib $ + * $FreeBSD: stable/11/sys/sys/resource.h 331722 2018-03-29 02:50:57Z eadler $ */ #ifndef _SYS_RESOURCE_H_ @@ -38,6 +38,16 @@ #include #include +#ifndef _ID_T_DECLARED +typedef __id_t id_t; +#define _ID_T_DECLARED +#endif + +#ifndef _RLIM_T_DECLARED +typedef __rlim_t rlim_t; +#define _RLIM_T_DECLARED +#endif + /* * Process priority specifications to get/setpriority. */ @@ -104,10 +114,12 @@ #define RLIMIT_AS RLIMIT_VMEM /* standard name for RLIMIT_VMEM */ #define RLIMIT_NPTS 11 /* pseudo-terminals */ #define RLIMIT_SWAP 12 /* swap used */ +#define RLIMIT_KQUEUES 13 /* kqueues allocated */ +#define RLIMIT_UMTXP 14 /* process-shared umtx */ -#define RLIM_NLIMITS 13 /* number of resource limits */ +#define RLIM_NLIMITS 15 /* number of resource limits */ -#define RLIM_INFINITY ((rlim_t)(((uint64_t)1 << 63) - 1)) +#define RLIM_INFINITY ((rlim_t)(((__uint64_t)1 << 63) - 1)) #define RLIM_SAVED_MAX RLIM_INFINITY #define RLIM_SAVED_CUR RLIM_INFINITY @@ -130,14 +142,11 @@ "vmem", "npts", "swap", + "kqueues", + "umtx", }; #endif -#ifndef _RLIM_T_DECLARED -typedef __rlim_t rlim_t; -#define _RLIM_T_DECLARED -#endif - struct rlimit { rlim_t rlim_cur; /* current (soft) limit */ rlim_t rlim_max; /* maximum value for rlim_cur */ Modified: trunk/sys/sys/resourcevar.h =================================================================== --- trunk/sys/sys/resourcevar.h 2020-02-16 21:41:01 UTC (rev 12367) +++ trunk/sys/sys/resourcevar.h 2020-02-16 21:51:02 UTC (rev 12368) @@ -28,7 +28,7 @@ * SUCH DAMAGE. * * @(#)resourcevar.h 8.4 (Berkeley) 1/9/95 - * $FreeBSD: stable/10/sys/sys/resourcevar.h 230470 2012-01-22 20:25:00Z trociny $ + * $FreeBSD: stable/11/sys/sys/resourcevar.h 331722 2018-03-29 02:50:57Z eadler $ */ #ifndef _SYS_RESOURCEVAR_H_ @@ -48,21 +48,22 @@ * Locking key: * b - created at fork, never changes * c - locked by proc mtx - * j - locked by proc slock * k - only accessed by curthread + * w - locked by proc itim lock + * w2 - locked by proc prof lock */ struct pstats { #define pstat_startzero p_cru struct rusage p_cru; /* Stats for reaped children. */ - struct itimerval p_timer[3]; /* (j) Virtual-time timers. */ + struct itimerval p_timer[3]; /* (w) Virtual-time timers. */ #define pstat_endzero pstat_startcopy #define pstat_startcopy p_prof struct uprof { /* Profile arguments. */ - caddr_t pr_base; /* (c + j) Buffer base. */ - u_long pr_size; /* (c + j) Buffer size. */ - u_long pr_off; /* (c + j) PC offset. */ - u_long pr_scale; /* (c + j) PC scaling. */ + caddr_t pr_base; /* (c + w2) Buffer base. */ + u_long pr_size; /* (c + w2) Buffer size. */ + u_long pr_off; /* (c + w2) PC offset. */ + u_long pr_scale; /* (c + w2) PC scaling. */ } p_prof; #define pstat_endcopy p_start struct timeval p_start; /* (b) Starting time. */ @@ -90,7 +91,7 @@ * Locking guide: * (a) Constant from inception * (b) Lockless, updated using atomics - * (c) Locked by global uihashtbl_mtx + * (c) Locked by global uihashtbl_lock * (d) Locked by the ui_vmsize_mtx */ struct uidinfo { @@ -100,9 +101,13 @@ long ui_sbsize; /* (b) socket buffer space consumed */ long ui_proccnt; /* (b) number of processes */ long ui_ptscnt; /* (b) number of pseudo-terminals */ + long ui_kqcnt; /* (b) number of kqueues */ + long ui_umtxcnt; /* (b) number of shared umtxs */ uid_t ui_uid; /* (a) uid */ u_int ui_ref; /* (b) reference count */ +#ifdef RACCT struct racct *ui_racct; /* (a) resource accounting */ +#endif }; #define UIDINFO_VMSIZE_LOCK(ui) mtx_lock(&((ui)->ui_vmsize_mtx)) @@ -116,10 +121,12 @@ void addupc_task(struct thread *td, uintfptr_t pc, u_int ticks); void calccru(struct proc *p, struct timeval *up, struct timeval *sp); void calcru(struct proc *p, struct timeval *up, struct timeval *sp); +int chgkqcnt(struct uidinfo *uip, int diff, rlim_t max); int chgproccnt(struct uidinfo *uip, int diff, rlim_t maxval); int chgsbsize(struct uidinfo *uip, u_int *hiwat, u_int to, rlim_t maxval); int chgptscnt(struct uidinfo *uip, int diff, rlim_t maxval); +int chgumtxcnt(struct uidinfo *uip, int diff, rlim_t maxval); int fuswintr(void *base); int kern_proc_setrlimit(struct thread *td, struct proc *p, u_int which, struct rlimit *limp); @@ -126,13 +133,16 @@ struct plimit *lim_alloc(void); void lim_copy(struct plimit *dst, struct plimit *src); -rlim_t lim_cur(struct proc *p, int which); +rlim_t lim_cur(struct thread *td, int which); +rlim_t lim_cur_proc(struct proc *p, int which); void lim_fork(struct proc *p1, struct proc *p2); void lim_free(struct plimit *limp); struct plimit *lim_hold(struct plimit *limp); -rlim_t lim_max(struct proc *p, int which); -void lim_rlimit(struct proc *p, int which, struct rlimit *rlp); +rlim_t lim_max(struct thread *td, int which); +rlim_t lim_max_proc(struct proc *p, int which); +void lim_rlimit(struct thread *td, int which, struct rlimit *rlp); +void lim_rlimit_proc(struct proc *p, int which, struct rlimit *rlp); void ruadd(struct rusage *ru, struct rusage_ext *rux, struct rusage *ru2, struct rusage_ext *rux2); void rucollect(struct rusage *ru, struct rusage *ru2); @@ -147,8 +157,11 @@ void uifree(struct uidinfo *uip); void uihashinit(void); void uihold(struct uidinfo *uip); +#ifdef RACCT void ui_racct_foreach(void (*callback)(struct racct *racct, - void *arg2, void *arg3), void *arg2, void *arg3); + void *arg2, void *arg3), void (*pre)(void), void (*post)(void), + void *arg2, void *arg3); +#endif #endif /* _KERNEL */ #endif /* !_SYS_RESOURCEVAR_H_ */ From laffer1 at midnightbsd.org Sun Feb 16 16:59:53 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 16:59:53 -0500 (EST) Subject: [Midnightbsd-cvs] src [12369] trunk/sys/sys: Sync with FreeBSD 11-stable Message-ID: <202002162159.01GLxrVj028979@stargazer.midnightbsd.org> Revision: 12369 http://svnweb.midnightbsd.org/src/?rev=12369 Author: laffer1 Date: 2020-02-16 16:59:52 -0500 (Sun, 16 Feb 2020) Log Message: ----------- Sync with FreeBSD 11-stable Modified Paths: -------------- trunk/sys/sys/pctrie.h trunk/sys/sys/pmc.h trunk/sys/sys/pmckern.h trunk/sys/sys/pmclog.h trunk/sys/sys/posix4.h trunk/sys/sys/priv.h trunk/sys/sys/proc.h trunk/sys/sys/procctl.h trunk/sys/sys/procdesc.h trunk/sys/sys/protosw.h trunk/sys/sys/ptio.h trunk/sys/sys/ptrace.h trunk/sys/sys/queue.h Modified: trunk/sys/sys/pctrie.h =================================================================== --- trunk/sys/sys/pctrie.h 2020-02-16 21:51:02 UTC (rev 12368) +++ trunk/sys/sys/pctrie.h 2020-02-16 21:59:52 UTC (rev 12369) @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/sys/pctrie.h 260266 2014-01-04 17:36:13Z dim $ + * $FreeBSD: stable/11/sys/sys/pctrie.h 331722 2018-03-29 02:50:57Z eadler $ */ #ifndef _SYS_PCTRIE_H_ @@ -77,7 +77,7 @@ return name##_PCTRIE_VAL2PTR(pctrie_lookup(ptree, key)); \ } \ \ -static __inline struct type * \ +static __inline __unused struct type * \ name##_PCTRIE_LOOKUP_LE(struct pctrie *ptree, uint64_t key) \ { \ \ @@ -120,5 +120,32 @@ size_t pctrie_node_size(void); int pctrie_zone_init(void *mem, int size, int flags); +static __inline void +pctrie_init(struct pctrie *ptree) +{ + + ptree->pt_root = 0; +} + +static __inline boolean_t +pctrie_is_empty(struct pctrie *ptree) +{ + + return (ptree->pt_root == 0); +} + +/* + * These widths should allow the pointers to a node's children to fit within + * a single cache line. The extra levels from a narrow width should not be + * a problem thanks to path compression. + */ +#ifdef __LP64__ +#define PCTRIE_WIDTH 4 +#else +#define PCTRIE_WIDTH 3 +#endif + +#define PCTRIE_COUNT (1 << PCTRIE_WIDTH) + #endif /* _KERNEL */ #endif /* !_SYS_PCTRIE_H_ */ Modified: trunk/sys/sys/pmc.h =================================================================== --- trunk/sys/sys/pmc.h 2020-02-16 21:51:02 UTC (rev 12368) +++ trunk/sys/sys/pmc.h 2020-02-16 21:59:52 UTC (rev 12369) @@ -28,7 +28,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/sys/pmc.h 320113 2017-06-19 15:34:07Z avg $ + * $FreeBSD: stable/11/sys/sys/pmc.h 339767 2018-10-26 05:12:56Z mmacy $ */ #ifndef _SYS_PMC_H_ @@ -74,6 +74,7 @@ #define __PMC_CPUS() \ __PMC_CPU(AMD_K7, 0x00, "AMD K7") \ __PMC_CPU(AMD_K8, 0x01, "AMD K8") \ + __PMC_CPU(AMD_F17H, 0x02, "AMD F17H") \ __PMC_CPU(INTEL_P5, 0x80, "Intel Pentium") \ __PMC_CPU(INTEL_P6, 0x81, "Intel Pentium Pro") \ __PMC_CPU(INTEL_CL, 0x82, "Intel Celeron") \ @@ -103,9 +104,20 @@ __PMC_CPU(INTEL_XSCALE, 0x100, "Intel XScale") \ __PMC_CPU(MIPS_24K, 0x200, "MIPS 24K") \ __PMC_CPU(MIPS_OCTEON, 0x201, "Cavium Octeon") \ + __PMC_CPU(MIPS_74K, 0x202, "MIPS 74K") \ __PMC_CPU(PPC_7450, 0x300, "PowerPC MPC7450") \ + __PMC_CPU(PPC_E500, 0x340, "PowerPC e500 Core") \ + __PMC_CPU(PPC_MPC85XX, 0x340, "Freescale PowerPC MPC85XX") \ __PMC_CPU(PPC_970, 0x380, "IBM PowerPC 970") \ - __PMC_CPU(GENERIC, 0x400, "Generic") + __PMC_CPU(GENERIC, 0x400, "Generic") \ + __PMC_CPU(ARMV7_CORTEX_A5, 0x500, "ARMv7 Cortex A5") \ + __PMC_CPU(ARMV7_CORTEX_A7, 0x501, "ARMv7 Cortex A7") \ + __PMC_CPU(ARMV7_CORTEX_A8, 0x502, "ARMv7 Cortex A8") \ + __PMC_CPU(ARMV7_CORTEX_A9, 0x503, "ARMv7 Cortex A9") \ + __PMC_CPU(ARMV7_CORTEX_A15, 0x504, "ARMv7 Cortex A15") \ + __PMC_CPU(ARMV7_CORTEX_A17, 0x505, "ARMv7 Cortex A17") \ + __PMC_CPU(ARMV8_CORTEX_A53, 0x600, "ARMv8 Cortex A53") \ + __PMC_CPU(ARMV8_CORTEX_A57, 0x601, "ARMv8 Cortex A57") enum pmc_cputype { #undef __PMC_CPU @@ -121,31 +133,36 @@ */ #define __PMC_CLASSES() \ - __PMC_CLASS(TSC) /* CPU Timestamp counter */ \ - __PMC_CLASS(K7) /* AMD K7 performance counters */ \ - __PMC_CLASS(K8) /* AMD K8 performance counters */ \ - __PMC_CLASS(P5) /* Intel Pentium counters */ \ - __PMC_CLASS(P6) /* Intel Pentium Pro counters */ \ - __PMC_CLASS(P4) /* Intel Pentium-IV counters */ \ - __PMC_CLASS(IAF) /* Intel Core2/Atom, fixed function */ \ - __PMC_CLASS(IAP) /* Intel Core...Atom, programmable */ \ - __PMC_CLASS(UCF) /* Intel Uncore fixed function */ \ - __PMC_CLASS(UCP) /* Intel Uncore programmable */ \ - __PMC_CLASS(XSCALE) /* Intel XScale counters */ \ - __PMC_CLASS(MIPS24K) /* MIPS 24K */ \ - __PMC_CLASS(OCTEON) /* Cavium Octeon */ \ - __PMC_CLASS(PPC7450) /* Motorola MPC7450 class */ \ - __PMC_CLASS(PPC970) /* IBM PowerPC 970 class */ \ - __PMC_CLASS(SOFT) /* Software events */ + __PMC_CLASS(TSC, 0x00, "CPU Timestamp counter") \ + __PMC_CLASS(K7, 0x01, "AMD K7 performance counters") \ + __PMC_CLASS(K8, 0x02, "AMD K8 performance counters") \ + __PMC_CLASS(P5, 0x03, "Intel Pentium counters") \ + __PMC_CLASS(P6, 0x04, "Intel Pentium Pro counters") \ + __PMC_CLASS(P4, 0x05, "Intel Pentium-IV counters") \ + __PMC_CLASS(IAF, 0x06, "Intel Core2/Atom, fixed function") \ + __PMC_CLASS(IAP, 0x07, "Intel Core...Atom, programmable") \ + __PMC_CLASS(UCF, 0x08, "Intel Uncore fixed function") \ + __PMC_CLASS(UCP, 0x09, "Intel Uncore programmable") \ + __PMC_CLASS(XSCALE, 0x0A, "Intel XScale counters") \ + __PMC_CLASS(MIPS24K, 0x0B, "MIPS 24K") \ + __PMC_CLASS(OCTEON, 0x0C, "Cavium Octeon") \ + __PMC_CLASS(PPC7450, 0x0D, "Motorola MPC7450 class") \ + __PMC_CLASS(PPC970, 0x0E, "IBM PowerPC 970 class") \ + __PMC_CLASS(SOFT, 0x0F, "Software events") \ + __PMC_CLASS(ARMV7, 0x10, "ARMv7") \ + __PMC_CLASS(ARMV8, 0x11, "ARMv8") \ + __PMC_CLASS(MIPS74K, 0x12, "MIPS 74K") \ + __PMC_CLASS(E500, 0x13, "Freescale e500 class") \ + __PMC_CLASS(F17H, 0x14, "AMD F17H performance counters") enum pmc_class { #undef __PMC_CLASS -#define __PMC_CLASS(N) PMC_CLASS_##N , +#define __PMC_CLASS(S,V,D) PMC_CLASS_##S = V, __PMC_CLASSES() }; #define PMC_CLASS_FIRST PMC_CLASS_TSC -#define PMC_CLASS_LAST PMC_CLASS_SOFT +#define PMC_CLASS_LAST PMC_CLASS_F17H /* * A PMC can be in the following states: @@ -1019,7 +1036,7 @@ #define KTR_PMC KTR_SUBSYS #define PMC_DEBUG_STRSIZE 128 -#define PMC_DEBUG_DEFAULT_FLAGS { 0, 0, 0, 0, 0, 0, 0, 0 } +#define PMC_DEBUG_DEFAULT_FLAGS { 0, 0, 0, 0, 0, 0, 0, 0, 0 } #define PMCDBG0(M, N, L, F) do { \ if (pmc_debugflags.pdb_ ## M & (1 << PMC_DEBUG_MIN_ ## N)) \ Modified: trunk/sys/sys/pmckern.h =================================================================== --- trunk/sys/sys/pmckern.h 2020-02-16 21:51:02 UTC (rev 12368) +++ trunk/sys/sys/pmckern.h 2020-02-16 21:59:52 UTC (rev 12369) @@ -28,7 +28,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/sys/pmckern.h 254813 2013-08-24 21:13:38Z markj $ + * $FreeBSD: stable/11/sys/sys/pmckern.h 331722 2018-03-29 02:50:57Z eadler $ */ /* @@ -111,7 +111,7 @@ #ifdef PMC_FAKE_TRAPFRAME #define PMC_SOFT_CALL(pr, mo, fu, na) \ do { \ - if (pmc_##pr##_##mo##_##fu##_##na.ps_running) { \ + if (__predict_false(pmc_##pr##_##mo##_##fu##_##na.ps_running)) { \ struct pmckern_soft ks; \ register_t intr; \ intr = intr_disable(); \ @@ -136,7 +136,7 @@ */ #define PMC_SOFT_CALL_TF(pr, mo, fu, na, tf) \ do { \ - if (pmc_##pr##_##mo##_##fu##_##na.ps_running) { \ + if (__predict_false(pmc_##pr##_##mo##_##fu##_##na.ps_running)) { \ struct pmckern_soft ks; \ register_t intr; \ intr = intr_disable(); \ @@ -175,6 +175,9 @@ /* PMC soft per cpu trapframe */ extern struct trapframe pmc_tf[MAXCPU]; +/* Quick check if preparatory work is necessary */ +#define PMC_HOOK_INSTALLED(cmd) __predict_false(pmc_hook != NULL) + /* Hook invocation; for use within the kernel */ #define PMC_CALL_HOOK(t, cmd, arg) \ do { \ Modified: trunk/sys/sys/pmclog.h =================================================================== --- trunk/sys/sys/pmclog.h 2020-02-16 21:51:02 UTC (rev 12368) +++ trunk/sys/sys/pmclog.h 2020-02-16 21:59:52 UTC (rev 12369) @@ -28,7 +28,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/sys/pmclog.h 233628 2012-03-28 20:58:30Z fabient $ + * $FreeBSD: stable/11/sys/sys/pmclog.h 331722 2018-03-29 02:50:57Z eadler $ */ #ifndef _SYS_PMCLOG_H_ @@ -261,6 +261,8 @@ int pmclog_flush(struct pmc_owner *_po); int pmclog_close(struct pmc_owner *_po); void pmclog_initialize(void); +int pmclog_proc_create(struct thread *td, void **handlep); +void pmclog_proc_ignite(void *handle, struct pmc_owner *po); void pmclog_process_callchain(struct pmc *_pm, struct pmc_sample *_ps); void pmclog_process_closelog(struct pmc_owner *po); void pmclog_process_dropnotify(struct pmc_owner *po); Modified: trunk/sys/sys/posix4.h =================================================================== --- trunk/sys/sys/posix4.h 2020-02-16 21:51:02 UTC (rev 12368) +++ trunk/sys/sys/posix4.h 2020-02-16 21:59:52 UTC (rev 12369) @@ -32,7 +32,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/sys/posix4.h 287507 2015-09-06 17:32:33Z kib $ + * $FreeBSD: stable/11/sys/sys/posix4.h 331722 2018-03-29 02:50:57Z eadler $ */ #include Modified: trunk/sys/sys/priv.h =================================================================== --- trunk/sys/sys/priv.h 2020-02-16 21:51:02 UTC (rev 12368) +++ trunk/sys/sys/priv.h 2020-02-16 21:59:52 UTC (rev 12369) @@ -27,7 +27,7 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/sys/priv.h 325099 2017-10-29 09:48:28Z kib $ + * $FreeBSD: stable/11/sys/sys/priv.h 332991 2018-04-25 12:21:13Z kib $ */ /* @@ -46,8 +46,9 @@ * loadable kernel module ABI, and should not be changed across minor * releases. * - * When adding a new privilege, remember to determine if it's appropriate for - * use in jail, and update the privilege switch in kern_jail.c as necessary. + * When adding a new privilege, remember to determine if it's appropriate + * for use in jail, and update the privilege switch in prison_priv_check() + * in kern_jail.c as necessary. */ /* @@ -342,6 +343,8 @@ #define PRIV_NET_SETIFDESCR 418 /* Set interface description. */ #define PRIV_NET_SETIFFIB 419 /* Set interface fib. */ #define PRIV_NET_VXLAN 420 /* Administer vxlan. */ +#define PRIV_NET_SETLANPCP 421 /* Set LAN priority. */ +#define PRIV_NET_SETVLANPCP PRIV_NET_SETLANPCP /* Alias Set VLAN priority */ /* * 802.11-related privileges. @@ -350,9 +353,9 @@ #define PRIV_NET80211_MANAGE 441 /* Administer 802.11. */ /* - * AppleTalk privileges. + * Placeholder for AppleTalk privileges, not supported anymore. */ -#define PRIV_NETATALK_RESERVEDPORT 450 /* Bind low port number. */ +#define _PRIV_NETATALK_RESERVEDPORT 450 /* Bind low port number. */ /* * ATM privileges. @@ -393,12 +396,13 @@ #define PRIV_NETINET_REUSEPORT 504 /* Allow [rapid] port/address reuse. */ #define PRIV_NETINET_SETHDROPTS 505 /* Set certain IPv4/6 header options. */ #define PRIV_NETINET_BINDANY 506 /* Allow bind to any address. */ +#define PRIV_NETINET_HASHKEY 507 /* Get and set hash keys for IPv4/6. */ /* - * IPX/SPX privileges. + * Placeholders for IPX/SPX privileges, not supported any more. */ -#define PRIV_NETIPX_RESERVEDPORT 520 /* Bind low port number. */ -#define PRIV_NETIPX_RAW 521 /* Open netipx raw socket. */ +#define _PRIV_NETIPX_RESERVEDPORT 520 /* Bind low port number. */ +#define _PRIV_NETIPX_RAW 521 /* Open netipx raw socket. */ /* * NCP privileges. Modified: trunk/sys/sys/proc.h =================================================================== --- trunk/sys/sys/proc.h 2020-02-16 21:51:02 UTC (rev 12368) +++ trunk/sys/sys/proc.h 2020-02-16 21:59:52 UTC (rev 12369) @@ -33,7 +33,7 @@ * SUCH DAMAGE. * * @(#)proc.h 8.15 (Berkeley) 5/19/95 - * $FreeBSD: stable/10/sys/sys/proc.h 318743 2017-05-23 12:40:50Z badger $ + * $FreeBSD: stable/11/sys/sys/proc.h 353789 2019-10-21 01:24:21Z kevans $ */ #ifndef _SYS_PROC_H_ @@ -64,6 +64,7 @@ #endif #include #include +#include #include /* Machine-dependent proc substruct. */ /* @@ -142,6 +143,7 @@ * j - locked by proc slock * k - only accessed by curthread * k*- only accessed by curthread and from an interrupt + * kx- only accessed by curthread and by debugger * l - the attaching proc or attaching proc parent * m - Giant * n - not locked, lazy @@ -148,7 +150,10 @@ * o - ktrace lock * q - td_contested lock * r - p_peers lock + * s - see sleepq_switch(), sleeping_on_old_rtc(), and sleep(9) * t - thread lock + * u - process stat lock + * w - process timer lock * x - created at fork, only changes during single threading in exec * y - created at first aio, doesn't change until exit or exec at which * point we are single-threaded and only curthread changes it @@ -159,6 +164,7 @@ * for write access. */ struct cpuset; +struct filecaps; struct filemon; struct kaioinfo; struct kaudit_record; @@ -177,6 +183,8 @@ struct thread; struct trapframe; struct turnstile; +struct vm_map; +struct vm_map_entry; /* * XXX: Does this belong in resource.h or resourcevar.h instead? @@ -186,14 +194,14 @@ * userland asks for rusage info. Backwards compatibility prevents putting * this directly in the user-visible rusage struct. * - * Locking for p_rux: (cj) means (j) for p_rux and (c) for p_crux. + * Locking for p_rux: (cu) means (u) for p_rux and (c) for p_crux. * Locking for td_rux: (t) for all fields. */ struct rusage_ext { - uint64_t rux_runtime; /* (cj) Real time. */ - uint64_t rux_uticks; /* (cj) Statclock hits in user mode. */ - uint64_t rux_sticks; /* (cj) Statclock hits in sys mode. */ - uint64_t rux_iticks; /* (cj) Statclock hits in intr mode. */ + uint64_t rux_runtime; /* (cu) Real time. */ + uint64_t rux_uticks; /* (cu) Statclock hits in user mode. */ + uint64_t rux_sticks; /* (cu) Statclock hits in sys mode. */ + uint64_t rux_iticks; /* (cu) Statclock hits in intr mode. */ uint64_t rux_uu; /* (c) Previous user time in usec. */ uint64_t rux_su; /* (c) Previous sys time in usec. */ uint64_t rux_tu; /* (c) Previous total time in usec. */ @@ -218,9 +226,10 @@ struct turnstile *td_turnstile; /* (k) Associated turnstile. */ struct rl_q_entry *td_rlqe; /* (k) Associated range lock entry. */ struct umtx_q *td_umtxq; /* (c?) Link for when we're blocked. */ + struct vm_domain_policy td_vm_dom_policy; /* (c) current numa domain policy */ lwpid_t td_tid; /* (b) Thread ID. */ - uint64_t padding1[4]; - void *padding2[4]; + uint64_t td_padding1[4]; + void *td_padding2[4]; u_char td_lend_user_pri; /* (t) Lend user pri. */ /* Cleared during fork1() */ @@ -232,11 +241,9 @@ int td_sqqueue; /* (t) Sleepqueue queue blocked on. */ void *td_wchan; /* (t) Sleep address. */ const char *td_wmesg; /* (t) Reason for sleep. */ - u_char td_lastcpu; /* (t) Last cpu we were on. */ - u_char td_oncpu; /* (t) Which cpu we are on. */ volatile u_char td_owepreempt; /* (k*) Preempt on last critical_exit */ u_char td_tsqueue; /* (t) Turnstile queue blocked on. */ - short td_locks; /* (k) Count of non-spin locks. */ + short td_locks; /* (k) Debug: count of non-spin locks */ short td_rw_rlocks; /* (k) Count of rwlock read locks. */ short td_lk_slocks; /* (k) Count of lockmgr shared locks. */ short td_stopsched; /* (k) Scheduler stopped. */ @@ -247,10 +254,11 @@ int td_intr_nesting_level; /* (k) Interrupt recursion. */ int td_pinned; /* (k) Temporary cpu pin count. */ struct ucred *td_ucred; /* (k) Reference to credentials. */ - u_int td_estcpu; /* (t) estimated cpu utilization */ + struct plimit *td_limit; /* (k) Resource limits. */ int td_slptick; /* (t) Time at sleep. */ int td_blktick; /* (t) Time spent blocked. */ int td_swvoltick; /* (t) Time at last SW_VOL switch. */ + int td_swinvoltick; /* (t) Time at last SW_INVOL switch. */ u_int td_cow; /* (*) Number of copy-on-write faults */ struct rusage td_ru; /* (t) rusage information. */ struct rusage_ext td_rux; /* (t) Internal rusage information. */ @@ -270,7 +278,7 @@ char td_name[MAXCOMLEN + 1]; /* (*) Thread name. */ struct file *td_fpop; /* (k) file referencing cdev under op */ int td_dbgflags; /* (c) Userland debugger flags */ - struct ksiginfo td_dbgksi; /* (c) ksi reflected to debugger. */ + struct ksiginfo td_padding3; int td_ng_outbound; /* (k) Thread entered ng from above. */ struct osd td_osd; /* (k) Object specific data. */ struct vm_map_entry *td_map_def_user; /* (k) Deferred entries. */ @@ -278,6 +286,8 @@ u_int td_vp_reserv; /* (k) Count of reserved vnodes. */ int td_no_sleeping; /* (k) Sleeping disabled count. */ int td_dom_rr_idx; /* (k) RR Numa domain selection. */ + void *td_su; /* (k) FFS SU private */ + int td_rtcgen; /* (s) rtc_generation of abs. sleep */ #define td_endzero td_sigmask /* Copied during fork1() or create_thread(). */ @@ -289,6 +299,11 @@ u_char td_pri_class; /* (t) Scheduling class. */ u_char td_user_pri; /* (t) User pri from estcpu and nice. */ u_char td_base_user_pri; /* (t) Base user pri */ + u_int td_padding4; + u_int td_padding5; + uintptr_t td_rb_list; /* (k) Robust list head. */ + uintptr_t td_rbp_list; /* (k) Robust priv list head. */ + uintptr_t td_rb_inact; /* (k) Current in-action mutex loc. */ #define td_endcopy td_pcb /* @@ -303,7 +318,12 @@ TDS_RUNQ, TDS_RUNNING } td_state; /* (t) thread state */ - register_t td_retval[2]; /* (k) Syscall aux returns. */ + union { + register_t tdu_retval[2]; + off_t tdu_off; + } td_uretoff; /* (k) Syscall aux returns. */ +#define td_retval td_uretoff.tdu_retval + u_int td_cowgen; /* (k) Generation of COW pointers. */ struct callout td_slpcallout; /* (h) Callout for sleep. */ struct trapframe *td_frame; /* (k) */ struct vm_object *td_kstack_obj;/* (a) Kstack object. */ @@ -311,7 +331,6 @@ int td_kstack_pages; /* (a) Size of the kstack. */ volatile u_int td_critnest; /* (k*) Critical section nest level. */ struct mdthread td_md; /* (k) Any machine-dependent fields. */ - struct td_sched *td_sched; /* (*) Scheduler-specific data. */ struct kaudit_record *td_ar; /* (k) Active audit record, if any. */ struct lpohead td_lprof[2]; /* (a) lock profiling objects. */ struct kdtrace_thread *td_dtrace; /* (*) DTrace-specific data. */ @@ -322,15 +341,24 @@ struct proc *td_rfppwait_p; /* (k) The vforked child */ struct vm_page **td_ma; /* (k) uio pages held */ int td_ma_cnt; /* (k) size of *td_ma */ - void *td_su; /* (k) FFS SU private */ - u_int td_dbg_sc_code; /* (c) Syscall code to debugger. */ - u_int td_dbg_sc_narg; /* (c) Syscall arg count to debugger.*/ void *td_emuldata; /* Emulator state data */ + int td_lastcpu; /* (t) Last cpu we were on. */ + int td_oncpu; /* (t) Which cpu we are on. */ sbintime_t td_sleeptimo; /* (t) Sleep timeout. */ sigqueue_t td_sigqueue; /* (c) Sigs arrived, not delivered. */ #define td_siglist td_sigqueue.sq_signals + struct syscall_args td_sa; /* (kx) Syscall parameters. Copied on + fork for child tracing. */ + siginfo_t td_si; /* (c) For debugger or core file */ + void *td_lkpi_task; /* LinuxKPI task struct pointer */ + size_t td_vslock_sz; /* (k) amount of vslock-ed space */ }; +struct thread0_storage { + struct thread t0st_thread; + uint64_t t0st_sched[10]; +}; + struct mtx *thread_lock_block(struct thread *); void thread_lock_unblock(struct thread *, struct mtx *); void thread_lock_set(struct thread *, struct mtx *); @@ -348,8 +376,18 @@ KASSERT((__m == &blocked_lock || __m == (lock)), \ ("Thread %p lock %p does not match %p", td, __m, (lock))); \ } while (0) + +#define TD_LOCKS_INC(td) ((td)->td_locks++) +#define TD_LOCKS_DEC(td) do { \ + KASSERT(SCHEDULER_STOPPED_TD(td) || (td)->td_locks > 0, \ + ("thread %p owns no locks", (td))); \ + (td)->td_locks--; \ +} while (0) #else #define THREAD_LOCKPTR_ASSERT(td, lock) + +#define TD_LOCKS_INC(td) +#define TD_LOCKS_DEC(td) #endif /* @@ -375,9 +413,9 @@ #define TDF_NEEDRESCHED 0x00010000 /* Thread needs to yield. */ #define TDF_NEEDSIGCHK 0x00020000 /* Thread may need signal delivery. */ #define TDF_NOLOAD 0x00040000 /* Ignore during load avg calculations. */ -#define TDF_UNUSED19 0x00080000 /* --available-- */ +#define TDF_SERESTART 0x00080000 /* ERESTART on stop attempts. */ #define TDF_THRWAKEUP 0x00100000 /* Libthr thread must not suspend itself. */ -#define TDF_UNUSED21 0x00200000 /* --available-- */ +#define TDF_SEINTR 0x00200000 /* EINTR on stop attempts. */ #define TDF_SWAPINREQ 0x00400000 /* Swapin request due to wakeup. */ #define TDF_UNUSED23 0x00800000 /* --available-- */ #define TDF_SCHED0 0x01000000 /* Reserved for scheduler private use */ @@ -404,6 +442,7 @@ #define TDB_EXIT 0x00000400 /* Exiting LWP indicator for ptrace() */ #define TDB_VFORK 0x00000800 /* vfork indicator for ptrace() */ #define TDB_FSTP 0x00001000 /* The thread is PT_ATTACH leader */ +#define TDB_STEP 0x00002000 /* (x86) PSL_T set for PT_STEP */ /* * "Private" flags kept in td_pflags: @@ -438,7 +477,7 @@ #define TDP_RESETSPUR 0x04000000 /* Reset spurious page fault history. */ #define TDP_NERRNO 0x08000000 /* Last errno is already in td_errno */ #define TDP_UIOHELD 0x10000000 /* Current uio has pages held in td_ma */ -#define TDP_UNUSED29 0x20000000 /* --available-- */ +#define TDP_FORKING 0x20000000 /* Thread is being created through fork() */ #define TDP_EXECVMSPC 0x40000000 /* Execve destroyed old vmspace */ /* @@ -499,6 +538,11 @@ #define TD_SET_RUNQ(td) (td)->td_state = TDS_RUNQ #define TD_SET_CAN_RUN(td) (td)->td_state = TDS_CAN_RUN +#define TD_SBDRY_INTR(td) \ + (((td)->td_flags & (TDF_SEINTR | TDF_SERESTART)) != 0) +#define TD_SBDRY_ERRNO(td) \ + (((td)->td_flags & TDF_SEINTR) != 0 ? EINTR : ERESTART) + /* * Process structure. */ @@ -510,7 +554,7 @@ struct filedesc *p_fd; /* (b) Open files. */ struct filedesc_to_leader *p_fdtol; /* (b) Tracking node */ struct pstats *p_stats; /* (b) Accounting/statistics (CPU). */ - struct plimit *p_limit; /* (c) Process limits. */ + struct plimit *p_limit; /* (c) Resource limits. */ struct callout p_limco; /* (c) Limit callout handle */ struct sigacts *p_sigacts; /* (x) Signal actions, state (CPU). */ @@ -527,7 +571,15 @@ struct proc *p_pptr; /* (c + e) Pointer to parent process. */ LIST_ENTRY(proc) p_sibling; /* (e) List of sibling processes. */ LIST_HEAD(, proc) p_children; /* (e) Pointer to list of children. */ + struct proc *p_reaper; /* (e) My reaper. */ + LIST_HEAD(, proc) p_reaplist; /* (e) List of my descendants + (if I am reaper). */ + LIST_ENTRY(proc) p_reapsibling; /* (e) List of siblings - descendants of + the same reaper. */ struct mtx p_mtx; /* (n) Lock for this struct. */ + struct mtx p_statmtx; /* Lock for the stats */ + struct mtx p_itimmtx; /* Lock for the virt/prof timers */ + struct mtx p_profmtx; /* Lock for the profiling */ struct ksiginfo *p_ksi; /* Locked by parent proc lock */ uint64_t padding1[4]; void *padding2[4]; @@ -537,9 +589,10 @@ pid_t p_oppid; /* (c + e) Save ppid in ptrace. XXX */ struct vmspace *p_vmspace; /* (b) Address space. */ u_int p_swtick; /* (c) Tick when swapped in or out. */ + u_int p_cowgen; /* (c) Generation of COW pointers. */ struct itimerval p_realtimer; /* (c) Alarm timer. */ struct rusage p_ru; /* (a) Exit information. */ - struct rusage_ext p_rux; /* (cj) Internal resource usage. */ + struct rusage_ext p_rux; /* (cu) Internal resource usage. */ struct rusage_ext p_crux; /* (c) Internal child resource usage. */ int p_profthreads; /* (c) Num threads in addupc_task. */ volatile int p_exitthreads; /* (j) Number of threads exiting */ @@ -565,7 +618,9 @@ int p_pendingcnt; /* how many signals are pending */ struct itimers *p_itimers; /* (c) POSIX interval timers. */ struct procdesc *p_procdesc; /* (e) Process descriptor, if any. */ + u_int p_treeflag; /* (e) P_TREE flags */ int p_pendingexits; /* (c) Count of pending thread exits. */ + struct filemon *p_filemon; /* (c) filemon-specific data. */ /* End area that is zeroed on creation. */ #define p_endzero p_magic @@ -575,18 +630,21 @@ int p_osrel; /* (x) osreldate for the binary (from ELF note, if any) */ char p_comm[MAXCOMLEN + 1]; /* (x) Process name. */ - void *p_pad0; struct sysentvec *p_sysent; /* (b) Syscall dispatch info. */ struct pargs *p_args; /* (c) Process arguments. */ rlim_t p_cpulimit; /* (c) Current CPU limit in seconds. */ signed char p_nice; /* (c) Process "nice" value. */ int p_fibnum; /* in this routing domain XXX MRT */ - + pid_t p_reapsubtree; /* (e) Pid of the direct child of the + reaper which spawned + our subtree. */ /* End area that is copied on creation. */ -#define p_endcopy p_xstat +#define p_endcopy p_xexit - u_short p_xstat; /* (c) Exit status; also stop sig. */ - struct knlist p_klist; /* (c) Knotes attached to this proc. */ + u_int p_xexit; /* (c) Exit code. */ + u_int p_xsig; /* (c) Stop/kill sig. */ + struct pgrp *p_pgrp; /* (c + e) Pointer to process group. */ + struct knlist *p_klist; /* (c) Knotes attached to this proc. */ int p_numthreads; /* (c) Number of threads. */ struct mdproc p_md; /* Any machine-dependent fields. */ struct callout p_itcallout; /* (h + c) Interval timer callout. */ @@ -595,16 +653,15 @@ struct proc *p_leader; /* (b) */ void *p_emuldata; /* (c) Emulator state data. */ struct label *p_label; /* (*) Proc (not subject) MAC label. */ - struct p_sched *p_sched; /* (*) Scheduler-specific data. */ STAILQ_HEAD(, ktr_request) p_ktr; /* (o) KTR event queue. */ LIST_HEAD(, mqueue_notifier) p_mqnotifier; /* (c) mqueue notifiers.*/ struct kdtrace_proc *p_dtrace; /* (*) DTrace-specific data. */ struct cv p_pwait; /* (*) wait cv for exit/exec. */ - struct cv p_dbgwait; /* (*) wait cv for debugger attach - after fork. */ + struct cv p_pad_dbgwait; uint64_t p_prev_runtime; /* (c) Resource usage accounting. */ struct racct *p_racct; /* (b) Resource accounting. */ - u_char p_throttled; /* (c) Flag for racct pcpu throttling */ + int p_throttled; /* (c) Flag for racct pcpu throttling */ + struct vm_domain_policy p_vm_dom_policy; /* (c) process default VM domain, or -1 */ /* * An orphan is the child that has beed re-parented to the * debugger as a result of attaching to it. Need to keep @@ -613,49 +670,41 @@ */ LIST_ENTRY(proc) p_orphan; /* (e) List of orphan processes. */ LIST_HEAD(, proc) p_orphans; /* (e) Pointer to list of orphans. */ - u_int p_treeflag; /* (e) P_TREE flags */ - struct proc *p_reaper; /* (e) My reaper. */ - LIST_HEAD(, proc) p_reaplist; /* (e) List of my descendants - (if I am reaper). */ - LIST_ENTRY(proc) p_reapsibling; /* (e) List of siblings - descendants of - the same reaper. */ - pid_t p_reapsubtree; /* (e) Pid of the direct child of the - reaper which spawned - our subtree. */ - struct pgrp *p_pgrp; /* (c + e) Pointer to process group. */ - struct filemon *p_filemon; /* (c) filemon-specific data. */ - u_int p_ptevents; /* (c) ptrace() event mask. */ + u_int p_ptevents; /* (c + e) ptrace() event mask. */ uint16_t p_elf_machine; /* (x) ELF machine type */ uint64_t p_elf_flags; /* (x) ELF flags */ sigqueue_t p_sigqueue; /* (c) Sigs not delivered to a td. */ #define p_siglist p_sigqueue.sq_signals + int p_pdeathsig; /* (c) Signal from parent on exit. */ }; #define p_session p_pgrp->pg_session #define p_pgid p_pgrp->pg_id -#define NOCPU 0xff /* For when we aren't on a CPU. */ +#define NOCPU (-1) /* For when we aren't on a CPU. */ +#define NOCPU_OLD (255) +#define MAXCPU_OLD (254) #define PROC_SLOCK(p) mtx_lock_spin(&(p)->p_slock) #define PROC_SUNLOCK(p) mtx_unlock_spin(&(p)->p_slock) #define PROC_SLOCK_ASSERT(p, type) mtx_assert(&(p)->p_slock, (type)) -#define PROC_STATLOCK(p) mtx_lock_spin(&(p)->p_slock) -#define PROC_STATUNLOCK(p) mtx_unlock_spin(&(p)->p_slock) -#define PROC_STATLOCK_ASSERT(p, type) mtx_assert(&(p)->p_slock, (type)) +#define PROC_STATLOCK(p) mtx_lock_spin(&(p)->p_statmtx) +#define PROC_STATUNLOCK(p) mtx_unlock_spin(&(p)->p_statmtx) +#define PROC_STATLOCK_ASSERT(p, type) mtx_assert(&(p)->p_statmtx, (type)) -#define PROC_ITIMLOCK(p) mtx_lock_spin(&(p)->p_slock) -#define PROC_ITIMUNLOCK(p) mtx_unlock_spin(&(p)->p_slock) -#define PROC_ITIMLOCK_ASSERT(p, type) mtx_assert(&(p)->p_slock, (type)) +#define PROC_ITIMLOCK(p) mtx_lock_spin(&(p)->p_itimmtx) +#define PROC_ITIMUNLOCK(p) mtx_unlock_spin(&(p)->p_itimmtx) +#define PROC_ITIMLOCK_ASSERT(p, type) mtx_assert(&(p)->p_itimmtx, (type)) -#define PROC_PROFLOCK(p) mtx_lock_spin(&(p)->p_slock) -#define PROC_PROFUNLOCK(p) mtx_unlock_spin(&(p)->p_slock) -#define PROC_PROFLOCK_ASSERT(p, type) mtx_assert(&(p)->p_slock, (type)) +#define PROC_PROFLOCK(p) mtx_lock_spin(&(p)->p_profmtx) +#define PROC_PROFUNLOCK(p) mtx_unlock_spin(&(p)->p_profmtx) +#define PROC_PROFLOCK_ASSERT(p, type) mtx_assert(&(p)->p_profmtx, (type)) /* These flags are kept in p_flag. */ #define P_ADVLOCK 0x00001 /* Process may hold a POSIX advisory lock. */ #define P_CONTROLT 0x00002 /* Has a controlling terminal. */ -#define P_KTHREAD 0x00004 /* Kernel thread (*). */ +#define P_KPROC 0x00004 /* Kernel process. */ #define P_UNUSED3 0x00008 /* --available-- */ #define P_PPWAIT 0x00010 /* Parent is waiting for child to exec/exit. */ #define P_PROFIL 0x00020 /* Has started profiling. */ @@ -678,7 +727,7 @@ #define P_SINGLE_BOUNDARY 0x400000 /* Threads should suspend at user boundary. */ #define P_HWPMC 0x800000 /* Process is using HWPMCs */ #define P_JAILED 0x1000000 /* Process is in jail. */ -#define P_TOTAL_STOP 0x2000000 /* Stopped in proc_stop_total. */ +#define P_TOTAL_STOP 0x2000000 /* Stopped in stop_all_proc. */ #define P_INEXEC 0x4000000 /* Process is in execve(). */ #define P_STATCHILD 0x8000000 /* Child process stopped or exited. */ #define P_INMEM 0x10000000 /* Loaded into memory. */ @@ -696,6 +745,9 @@ #define P2_NOTRACE_EXEC 0x00000004 /* Keep P2_NOPTRACE on exec(2). */ #define P2_AST_SU 0x00000008 /* Handles SU ast for kthreads. */ #define P2_PTRACE_FSTP 0x00000010 /* SIGSTOP from PT_ATTACH not yet handled. */ +#define P2_TRAPCAP 0x00000020 /* SIGTRAP on ENOTCAPABLE */ +#define P2_STKGAP_DISABLE 0x00000800 /* Disable stack gap for MAP_STACK */ +#define P2_STKGAP_DISABLE_EXEC 0x00001000 /* Stack gap disabled after exec */ /* Flags protected by proctree_lock, kept in p_treeflags. */ #define P_TREE_ORPHANED 0x00000001 /* Reparented, on orphan list */ @@ -772,6 +824,8 @@ #define STOPEVENT(p, e, v) do { \ + WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, \ + "checking stopevent %d", (e)); \ if ((p)->p_stops & (e)) { \ PROC_LOCK(p); \ stopevent((p), (e), (v)); \ @@ -814,7 +868,20 @@ #define SESS_LOCKED(s) mtx_owned(&(s)->s_mtx) #define SESS_LOCK_ASSERT(s, type) mtx_assert(&(s)->s_mtx, (type)) -/* Hold process U-area in memory, normally for ptrace/procfs work. */ +/* + * Non-zero p_lock ensures that: + * - exit1() is not performed until p_lock reaches zero; + * - the process' threads stack are not swapped out if they are currently + * not (P_INMEM). + * + * PHOLD() asserts that the process (except the current process) is + * not exiting, increments p_lock and swaps threads stacks into memory, + * if needed. + * _PHOLD() is same as PHOLD(), it takes the process locked. + * _PHOLD_LITE() also takes the process locked, but comparing with + * _PHOLD(), it only guarantees that exit1() is not executed, + * faultin() is not called. + */ #define PHOLD(p) do { \ PROC_LOCK(p); \ _PHOLD(p); \ @@ -823,14 +890,20 @@ #define _PHOLD(p) do { \ PROC_LOCK_ASSERT((p), MA_OWNED); \ KASSERT(!((p)->p_flag & P_WEXIT) || (p) == curproc, \ - ("PHOLD of exiting process")); \ + ("PHOLD of exiting process %p", p)); \ (p)->p_lock++; \ if (((p)->p_flag & P_INMEM) == 0) \ faultin((p)); \ } while (0) -#define PROC_ASSERT_HELD(p) do { \ - KASSERT((p)->p_lock > 0, ("process not held")); \ +#define _PHOLD_LITE(p) do { \ + PROC_LOCK_ASSERT((p), MA_OWNED); \ + KASSERT(!((p)->p_flag & P_WEXIT) || (p) == curproc, \ + ("PHOLD of exiting process %p", p)); \ + (p)->p_lock++; \ } while (0) +#define PROC_ASSERT_HELD(p) do { \ + KASSERT((p)->p_lock > 0, ("process %p not held", p)); \ +} while (0) #define PRELE(p) do { \ PROC_LOCK((p)); \ @@ -844,10 +917,15 @@ if (((p)->p_flag & P_WEXIT) && (p)->p_lock == 0) \ wakeup(&(p)->p_lock); \ } while (0) -#define PROC_ASSERT_NOT_HELD(p) do { \ - KASSERT((p)->p_lock == 0, ("process held")); \ +#define PROC_ASSERT_NOT_HELD(p) do { \ + KASSERT((p)->p_lock == 0, ("process %p held", p)); \ } while (0) +#define PROC_UPDATE_COW(p) do { \ + PROC_LOCK_ASSERT((p), MA_OWNED); \ + (p)->p_cowgen++; \ +} while (0) + /* Check whether a thread is safe to be swapped out. */ #define thread_safetoswapout(td) ((td)->td_flags & TDF_CANSWAP) @@ -875,7 +953,8 @@ extern struct sx proctree_lock; extern struct mtx ppeers_lock; extern struct proc proc0; /* Process slot for swapper. */ -extern struct thread thread0; /* Primary thread in proc0. */ +extern struct thread0_storage thread0_st; /* Primary thread in proc0. */ +#define thread0 (thread0_st.t0st_thread) extern struct vmspace vmspace0; /* VM space for proc0. */ extern int hogticks; /* Limit on kernel cpu hogs. */ extern int lastpid; @@ -897,6 +976,18 @@ struct pgrp *pgfind(pid_t); /* Find process group by id. */ struct proc *zpfind(pid_t); /* Find zombie process by id. */ +struct fork_req { + int fr_flags; + int fr_pages; + int *fr_pidp; + struct proc **fr_procp; + int *fr_pd_fd; + int fr_pd_flags; + struct filecaps *fr_pd_fcaps; + int fr_flags2; +#define FR2_DROPSIG_CAUGHT 0x00001 /* Drop caught non-DFL signals */ +}; + /* * pget() flags. */ @@ -920,13 +1011,16 @@ int enterthispgrp(struct proc *p, struct pgrp *pgrp); void faultin(struct proc *p); void fixjobc(struct proc *p, struct pgrp *pgrp, int entering); -int fork1(struct thread *, int, int, struct proc **, int *, int); +int fork1(struct thread *, struct fork_req *); void fork_exit(void (*)(void *, struct trapframe *), void *, struct trapframe *); void fork_return(struct thread *, struct trapframe *); int inferior(struct proc *p); +void kern_proc_vmmap_resident(struct vm_map *map, struct vm_map_entry *entry, + int *resident_count, bool *super); void kern_yield(int); void kick_proc0(void); +void killjobc(void); int leavepgrp(struct proc *p); int maybe_preempt(struct thread *td); void maybe_yield(void); @@ -949,6 +1043,7 @@ void proc_reap(struct thread *td, struct proc *p, int *status, int options); void proc_reparent(struct proc *child, struct proc *newparent); void proc_set_traced(struct proc *p, bool stop); +void proc_wkilled(struct proc *p); struct pstats *pstats_alloc(void); void pstats_fork(struct pstats *src, struct pstats *dst); void pstats_free(struct pstats *ps); @@ -975,13 +1070,13 @@ void userret(struct thread *, struct trapframe *); void cpu_exit(struct thread *); -void exit1(struct thread *, int) __dead2; -int cpu_fetch_syscall_args(struct thread *td, struct syscall_args *sa); +void exit1(struct thread *, int, int) __dead2; +void cpu_copy_thread(struct thread *td, struct thread *td0); +int cpu_fetch_syscall_args(struct thread *td); void cpu_fork(struct thread *, struct proc *, struct thread *, int); -void cpu_set_fork_handler(struct thread *, void (*)(void *), void *); +void cpu_fork_kthread_handler(struct thread *, void (*)(void *), void *); void cpu_set_syscall_retval(struct thread *, int); -void cpu_set_upcall(struct thread *td, struct thread *td0); -void cpu_set_upcall_kse(struct thread *, void (*)(void *), void *, +void cpu_set_upcall(struct thread *, void (*)(void *), void *, stack_t *); int cpu_set_user_tls(struct thread *, void *tls_base); void cpu_thread_alloc(struct thread *); @@ -992,6 +1087,10 @@ void cpu_thread_swapout(struct thread *); struct thread *thread_alloc(int pages); int thread_alloc_stack(struct thread *, int pages); +void thread_cow_get_proc(struct thread *newtd, struct proc *p); +void thread_cow_get(struct thread *newtd, struct thread *td); +void thread_cow_free(struct thread *td); +void thread_cow_update(struct thread *td); int thread_create(struct thread *td, struct rtprio *rtp, int (*initialize_thread)(struct thread *, void *), void *thunk); void thread_exit(void) __dead2; @@ -1036,6 +1135,22 @@ curthread->td_pflags &= save; } +static __inline __pure2 struct td_sched * +td_get_sched(struct thread *td) +{ + + return ((struct td_sched *)&td[1]); +} + +extern void (*softdep_ast_cleanup)(struct thread *); +static __inline void +td_softdep_cleanup(struct thread *td) +{ + + if (td->td_su != NULL && softdep_ast_cleanup != NULL) + softdep_ast_cleanup(td); +} + #endif /* _KERNEL */ #endif /* !_SYS_PROC_H_ */ Modified: trunk/sys/sys/procctl.h =================================================================== --- trunk/sys/sys/procctl.h 2020-02-16 21:51:02 UTC (rev 12368) +++ trunk/sys/sys/procctl.h 2020-02-16 21:59:52 UTC (rev 12369) @@ -1,9 +1,13 @@ /* $MidnightBSD$ */ /*- * Copyright (c) 2013 Hudson River Trading LLC + * Copyright (c) 2014, 2016 The FreeBSD Foundation * Written by: John H. Baldwin * All rights reserved. * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -25,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/sys/procctl.h 326397 2017-11-30 14:38:07Z kib $ + * $FreeBSD: stable/11/sys/sys/procctl.h 352125 2019-09-10 07:29:21Z kib $ */ #ifndef _SYS_PROCCTL_H_ @@ -44,6 +48,12 @@ #define PROC_REAP_KILL 6 /* kill descendants */ #define PROC_TRACE_CTL 7 /* en/dis ptrace and coredumps */ #define PROC_TRACE_STATUS 8 /* query tracing status */ +#define PROC_TRAPCAP_CTL 9 /* trap capability errors */ +#define PROC_TRAPCAP_STATUS 10 /* query trap capability status */ +#define PROC_PDEATHSIG_CTL 11 /* set parent death signal */ +#define PROC_PDEATHSIG_STATUS 12 /* get parent death signal */ +#define PROC_STACKGAP_CTL 17 /* en/dis stack gap on MAP_STACK */ +#define PROC_STACKGAP_STATUS 18 /* query stack gap */ /* Operations for PROC_SPROTECT (passed in integer arg). */ #define PPROT_OP(x) ((x) & 0xf) @@ -104,6 +114,14 @@ #define PROC_TRACE_CTL_DISABLE 2 #define PROC_TRACE_CTL_DISABLE_EXEC 3 +#define PROC_TRAPCAP_CTL_ENABLE 1 +#define PROC_TRAPCAP_CTL_DISABLE 2 + +#define PROC_STACKGAP_ENABLE 0x0001 +#define PROC_STACKGAP_DISABLE 0x0002 +#define PROC_STACKGAP_ENABLE_EXEC 0x0004 +#define PROC_STACKGAP_DISABLE_EXEC 0x0008 + #ifndef _KERNEL __BEGIN_DECLS int procctl(idtype_t, id_t, int, void *); Modified: trunk/sys/sys/procdesc.h =================================================================== --- trunk/sys/sys/procdesc.h 2020-02-16 21:51:02 UTC (rev 12368) +++ trunk/sys/sys/procdesc.h 2020-02-16 21:59:52 UTC (rev 12369) @@ -27,7 +27,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/sys/procdesc.h 269619 2014-08-06 00:35:32Z emaste $ + * $FreeBSD: stable/11/sys/sys/procdesc.h 331722 2018-03-29 02:50:57Z eadler $ */ #ifndef _SYS_PROCDESC_H_ @@ -34,6 +34,7 @@ #define _SYS_PROCDESC_H_ #ifdef _KERNEL + #include /* struct selinfo */ #include #include @@ -68,6 +69,7 @@ * In-flight data and notification of events. */ int pd_flags; /* (p) PD_ flags. */ + u_short pd_xstat; /* (p) Exit status. */ struct selinfo pd_selinfo; /* (p) Event notification. */ struct mtx pd_lock; /* Protect data + events. */ }; @@ -100,15 +102,28 @@ pid_t procdesc_pid(struct file *); void procdesc_reap(struct proc *); +int procdesc_falloc(struct thread *, struct file **, int *, int, + struct filecaps *); + #else /* !_KERNEL */ +#include + +#ifndef _PID_T_DECLARED +typedef __pid_t pid_t; +#define _PID_T_DECLARED +#endif + +struct rusage; + /* * Process descriptor system calls. */ -struct rusage; -int pdfork(int *, int); +__BEGIN_DECLS +pid_t pdfork(int *, int); int pdkill(int, int); int pdgetpid(int, pid_t *); +__END_DECLS #endif /* _KERNEL */ @@ -116,5 +131,8 @@ * Flags which can be passed to pdfork(2). */ #define PD_DAEMON 0x00000001 /* Don't exit when procdesc closes. */ +#define PD_CLOEXEC 0x00000002 /* Close file descriptor on exec. */ +#define PD_ALLOWED_AT_FORK (PD_DAEMON | PD_CLOEXEC) + #endif /* !_SYS_PROCDESC_H_ */ Modified: trunk/sys/sys/protosw.h =================================================================== --- trunk/sys/sys/protosw.h 2020-02-16 21:51:02 UTC (rev 12368) +++ trunk/sys/sys/protosw.h 2020-02-16 21:59:52 UTC (rev 12369) @@ -28,7 +28,7 @@ * SUCH DAMAGE. * * @(#)protosw.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD: stable/10/sys/sys/protosw.h 247667 2013-03-02 21:11:30Z pjd $ + * $FreeBSD: stable/11/sys/sys/protosw.h 331722 2018-03-29 02:50:57Z eadler $ */ #ifndef _SYS_PROTOSW_H_ @@ -35,6 +35,7 @@ #define _SYS_PROTOSW_H_ /* Forward declare these structures referenced from prototypes below. */ +struct kaiocb; struct mbuf; struct thread; struct sockaddr; @@ -65,13 +66,11 @@ * similar to the vnode VOP interface. */ /* USE THESE FOR YOUR PROTOTYPES ! */ -typedef void pr_input_t (struct mbuf *, int); -typedef int pr_input6_t (struct mbuf **, int*, int); /* XXX FIX THIS */ -typedef int pr_output_t (struct mbuf *, struct socket *); +typedef int pr_input_t (struct mbuf **, int*, int); +typedef int pr_output_t (struct mbuf *, struct socket *, ...); typedef void pr_ctlinput_t (int, struct sockaddr *, void *); typedef int pr_ctloutput_t (struct socket *, struct sockopt *); typedef void pr_init_t (void); -typedef void pr_destroy_t (void); typedef void pr_fasttimo_t (void); typedef void pr_slowtimo_t (void); typedef void pr_drain_t (void); @@ -88,7 +87,6 @@ pr_ctloutput_t *pr_ctloutput; /* control output (from above) */ /* utility hooks */ pr_init_t *pr_init; - pr_destroy_t *pr_destroy; pr_fasttimo_t *pr_fasttimo; /* fast timeout (200ms) */ pr_slowtimo_t *pr_slowtimo; /* slow timeout (500ms) */ pr_drain_t *pr_drain; /* flush any excess space possible */ @@ -210,6 +208,8 @@ #define PRUS_OOB 0x1 #define PRUS_EOF 0x2 #define PRUS_MORETOCOME 0x4 +#define PRUS_NOTREADY 0x8 + int (*pru_ready)(struct socket *so, struct mbuf *m, int count); int (*pru_sense)(struct socket *so, struct stat *sb); int (*pru_shutdown)(struct socket *so); int (*pru_flush)(struct socket *so, int direction); @@ -228,6 +228,7 @@ struct thread *td); int (*pru_connectat)(int fd, struct socket *so, struct sockaddr *nam, struct thread *td); + int (*pru_aio_queue)(struct socket *so, struct kaiocb *job); }; /* @@ -234,6 +235,7 @@ * All nonvoid pru_*() functions below return EOPNOTSUPP. */ int pru_accept_notsupp(struct socket *so, struct sockaddr **nam); +int pru_aio_queue_notsupp(struct socket *so, struct kaiocb *job); int pru_attach_notsupp(struct socket *so, int proto, struct thread *td); int pru_bind_notsupp(struct socket *so, struct sockaddr *nam, struct thread *td); @@ -253,6 +255,7 @@ int pru_rcvoob_notsupp(struct socket *so, struct mbuf *m, int flags); int pru_send_notsupp(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, struct thread *td); +int pru_ready_notsupp(struct socket *so, struct mbuf *m, int count); int pru_sense_null(struct socket *so, struct stat *sb); int pru_shutdown_notsupp(struct socket *so); int pru_sockaddr_notsupp(struct socket *so, struct sockaddr **nam); @@ -276,8 +279,8 @@ #define PRC_IFDOWN 0 /* interface transition */ #define PRC_ROUTEDEAD 1 /* select new route if possible ??? */ #define PRC_IFUP 2 /* interface has come back up */ -#define PRC_QUENCH2 3 /* DEC congestion bit says slow down */ -#define PRC_QUENCH 4 /* some one said to slow down */ +/* was PRC_QUENCH2 3 DEC congestion bit says slow down */ +/* was PRC_QUENCH 4 Deprecated by RFC 6633 */ #define PRC_MSGSIZE 5 /* message size forced drop */ #define PRC_HOSTDEAD 6 /* host appears to be down */ #define PRC_HOSTUNREACH 7 /* deprecated (use PRC_UNREACH_HOST) */ Modified: trunk/sys/sys/ptio.h =================================================================== --- trunk/sys/sys/ptio.h 2020-02-16 21:51:02 UTC (rev 12368) +++ trunk/sys/sys/ptio.h 2020-02-16 21:59:52 UTC (rev 12369) @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/sys/ptio.h 50477 1999-08-28 01:08:13Z peter $ + * $FreeBSD: stable/11/sys/sys/ptio.h 331722 2018-03-29 02:50:57Z eadler $ */ #ifndef _SYS_PTIO_H_ Modified: trunk/sys/sys/ptrace.h =================================================================== --- trunk/sys/sys/ptrace.h 2020-02-16 21:51:02 UTC (rev 12368) +++ trunk/sys/sys/ptrace.h 2020-02-16 21:59:52 UTC (rev 12369) @@ -28,7 +28,7 @@ * SUCH DAMAGE. * * @(#)ptrace.h 8.2 (Berkeley) 1/4/94 - * $FreeBSD: stable/10/sys/sys/ptrace.h 304499 2016-08-19 20:17:57Z jhb $ + * $FreeBSD: stable/11/sys/sys/ptrace.h 331722 2018-03-29 02:50:57Z eadler $ */ #ifndef _SYS_PTRACE_H_ @@ -70,6 +70,8 @@ #define PT_GET_EVENT_MASK 25 /* get mask of optional events */ #define PT_SET_EVENT_MASK 26 /* set mask of optional events */ +#define PT_GET_SC_ARGS 27 /* fetch syscall args */ + #define PT_GETREGS 33 /* get general-purpose registers */ #define PT_SETREGS 34 /* set general-purpose registers */ #define PT_GETFPREGS 35 /* get floating-point registers */ @@ -137,6 +139,21 @@ u_int pl_syscall_narg; }; +#if defined(_WANT_LWPINFO32) || (defined(_KERNEL) && defined(__LP64__)) +struct ptrace_lwpinfo32 { + lwpid_t pl_lwpid; /* LWP described. */ + int pl_event; /* Event that stopped the LWP. */ + int pl_flags; /* LWP flags. */ + sigset_t pl_sigmask; /* LWP signal mask */ + sigset_t pl_siglist; /* LWP pending signal */ + struct siginfo32 pl_siginfo; /* siginfo for signal */ + char pl_tdname[MAXCOMLEN + 1]; /* LWP name. */ + pid_t pl_child_pid; /* New child pid */ + u_int pl_syscall_code; + u_int pl_syscall_narg; +}; +#endif + /* Argument structure for PT_VM_ENTRY. */ struct ptrace_vm_entry { int pve_entry; /* Entry number used for iteration. */ @@ -179,6 +196,10 @@ int proc_write_dbregs(struct thread *_td, struct dbreg *_dbreg); int proc_sstep(struct thread *_td); int proc_rwmem(struct proc *_p, struct uio *_uio); +ssize_t proc_readmem(struct thread *_td, struct proc *_p, vm_offset_t _va, + void *_buf, size_t _len); +ssize_t proc_writemem(struct thread *_td, struct proc *_p, vm_offset_t _va, + void *_buf, size_t _len); #ifdef COMPAT_FREEBSD32 struct reg32; struct fpreg32; Modified: trunk/sys/sys/queue.h =================================================================== --- trunk/sys/sys/queue.h 2020-02-16 21:51:02 UTC (rev 12368) +++ trunk/sys/sys/queue.h 2020-02-16 21:59:52 UTC (rev 12369) @@ -28,7 +28,7 @@ * SUCH DAMAGE. * * @(#)queue.h 8.5 (Berkeley) 8/20/94 - * $FreeBSD: stable/10/sys/sys/queue.h 307534 2016-10-17 21:49:54Z mckusick $ + * $FreeBSD: stable/11/sys/sys/queue.h 354405 2019-11-06 18:02:18Z mav $ */ #ifndef _SYS_QUEUE_H_ @@ -94,6 +94,7 @@ * _NEXT + + + + * _PREV - + - + * _LAST - - + + + * _LAST_FAST - - - + * _FOREACH + + + + * _FOREACH_FROM + + + + * _FOREACH_SAFE + + + + @@ -745,11 +746,25 @@ #define TAILQ_LAST(head, headname) \ (*(((struct headname *)((head)->tqh_last))->tqh_last)) +/* + * The FAST function is fast in that it causes no data access other + * then the access to the head. The standard LAST function above + * will cause a data access of both the element you want and + * the previous element. FAST is very useful for instances when + * you may want to prefetch the last data element. + */ +#define TAILQ_LAST_FAST(head, type, field) \ + (TAILQ_EMPTY(head) ? NULL : __containerof((head)->tqh_last, QUEUE_TYPEOF(type), field.tqe_next)) + #define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) #define TAILQ_PREV(elm, headname, field) \ (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) +#define TAILQ_PREV_FAST(elm, head, type, field) \ + ((elm)->field.tqe_prev == &(head)->tqh_first ? NULL : \ + __containerof((elm)->field.tqe_prev, QUEUE_TYPEOF(type), field.tqe_next)) + #define TAILQ_REMOVE(head, elm, field) do { \ QMD_SAVELINK(oldnext, (elm)->field.tqe_next); \ QMD_SAVELINK(oldprev, (elm)->field.tqe_prev); \ From laffer1 at midnightbsd.org Sun Feb 16 17:00:35 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 17:00:35 -0500 (EST) Subject: [Midnightbsd-cvs] src [12370] trunk/sys/sys: Sync with FreeBSD 11-stable Message-ID: <202002162200.01GM0ZBs029699@stargazer.midnightbsd.org> Revision: 12370 http://svnweb.midnightbsd.org/src/?rev=12370 Author: laffer1 Date: 2020-02-16 17:00:35 -0500 (Sun, 16 Feb 2020) Log Message: ----------- Sync with FreeBSD 11-stable Modified Paths: -------------- trunk/sys/sys/namei.h trunk/sys/sys/nlist_aout.h trunk/sys/sys/nv.h trunk/sys/sys/osd.h Added Paths: ----------- trunk/sys/sys/numa.h Modified: trunk/sys/sys/namei.h =================================================================== --- trunk/sys/sys/namei.h 2020-02-16 21:59:52 UTC (rev 12369) +++ trunk/sys/sys/namei.h 2020-02-16 22:00:35 UTC (rev 12370) @@ -28,7 +28,7 @@ * SUCH DAMAGE. * * @(#)namei.h 8.5 (Berkeley) 1/9/95 - * $FreeBSD: stable/10/sys/sys/namei.h 255219 2013-09-05 00:09:56Z pjd $ + * $FreeBSD: stable/11/sys/sys/namei.h 331722 2018-03-29 02:50:57Z eadler $ */ #ifndef _SYS_NAMEI_H_ @@ -54,9 +54,11 @@ char *cn_pnbuf; /* pathname buffer */ char *cn_nameptr; /* pointer to looked up name */ long cn_namelen; /* length of looked up component */ - long cn_consume; /* chars to consume in lookup() */ }; +struct nameicap_tracker; +TAILQ_HEAD(nameicap_tracker_head, nameicap_tracker); + /* * Encapsulation of namei parameters. */ @@ -74,7 +76,7 @@ struct vnode *ni_rootdir; /* logical root directory */ struct vnode *ni_topdir; /* logical top directory */ int ni_dirfd; /* starting directory for *at functions */ - int ni_strictrelative; /* relative lookup only; no '..' */ + int ni_lcf; /* local call flags */ /* * Results: returned from namei */ @@ -96,6 +98,7 @@ * through the VOP interface. */ struct componentname ni_cnd; + struct nameicap_tracker_head ni_cap_tracker; }; #ifdef _KERNEL @@ -154,6 +157,12 @@ #define PARAMASK 0x3ffffe00 /* mask of parameter descriptors */ /* + * Flags in ni_lcf, valid for the duration of the namei call. + */ +#define NI_LCF_STRICTRELATIVE 0x0001 /* relative lookup only */ +#define NI_LCF_CAP_DOTDOT 0x0002 /* ".." in strictrelative case */ + +/* * Initialization of a nameidata structure. */ #define NDINIT(ndp, op, flags, segflg, namep, td) \ Modified: trunk/sys/sys/nlist_aout.h =================================================================== --- trunk/sys/sys/nlist_aout.h 2020-02-16 21:59:52 UTC (rev 12369) +++ trunk/sys/sys/nlist_aout.h 2020-02-16 22:00:35 UTC (rev 12370) @@ -34,7 +34,7 @@ * * @(#)nlist.h 8.2 (Berkeley) 1/21/94 * - * $FreeBSD: stable/10/sys/sys/nlist_aout.h 208986 2010-06-10 14:19:51Z bz $ + * $FreeBSD: stable/11/sys/sys/nlist_aout.h 331722 2018-03-29 02:50:57Z eadler $ */ #ifndef _SYS_NLIST_AOUT_H_ @@ -57,8 +57,6 @@ } n_un; #else const char *n_name; /* symbol name (in memory) */ - int : 8 * (sizeof(long) > sizeof(char *) ? - sizeof(long) - sizeof(char *) : sizeof(char *) - sizeof(long)); #endif unsigned char n_type; /* type defines */ char n_other; /* ".type" and binding information */ Added: trunk/sys/sys/numa.h =================================================================== --- trunk/sys/sys/numa.h (rev 0) +++ trunk/sys/sys/numa.h 2020-02-16 22:00:35 UTC (rev 12370) @@ -0,0 +1,42 @@ +/* $MidnightBSD$ */ +/* + * Copyright (c) 2015 Adrian Chadd . + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: stable/11/sys/sys/numa.h 285387 2015-07-11 15:21:37Z adrian $ + */ +#ifndef __SYS_NUMA_H__ +#define __SYS_NUMA_H__ + +#include + +extern int numa_setaffinity(cpuwhich_t which, id_t id, + struct vm_domain_policy_entry *vd); +extern int numa_getaffinity(cpuwhich_t which, id_t id, + struct vm_domain_policy_entry *vd); + +#endif /* __SYS_NUMA_H__ */ Property changes on: trunk/sys/sys/numa.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +MidnightBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Modified: trunk/sys/sys/nv.h =================================================================== --- trunk/sys/sys/nv.h 2020-02-16 21:59:52 UTC (rev 12369) +++ trunk/sys/sys/nv.h 2020-02-16 22:00:35 UTC (rev 12370) @@ -1,6 +1,7 @@ /* $MidnightBSD$ */ /*- * Copyright (c) 2009-2013 The FreeBSD Foundation + * Copyright (c) 2013-2015 Mariusz Zaborski * All rights reserved. * * This software was developed by Pawel Jakub Dawidek under sponsorship from @@ -27,7 +28,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/sys/nv.h 292973 2015-12-31 03:28:14Z ngie $ + * $FreeBSD: stable/11/sys/sys/nv.h 336346 2018-07-16 15:02:21Z kevans $ */ #ifndef _NV_H_ @@ -60,11 +61,20 @@ #define NV_TYPE_NVLIST 5 #define NV_TYPE_DESCRIPTOR 6 #define NV_TYPE_BINARY 7 +#define NV_TYPE_BOOL_ARRAY 8 +#define NV_TYPE_NUMBER_ARRAY 9 +#define NV_TYPE_STRING_ARRAY 10 +#define NV_TYPE_NVLIST_ARRAY 11 +#define NV_TYPE_DESCRIPTOR_ARRAY 12 /* * Perform case-insensitive lookups of provided names. */ #define NV_FLAG_IGNORE_CASE 0x01 +/* + * Names don't have to be unique. + */ +#define NV_FLAG_NO_UNIQUE 0x02 #if defined(_KERNEL) && defined(MALLOC_DECLARE) MALLOC_DECLARE(M_NVLIST); @@ -88,16 +98,21 @@ size_t nvlist_size(const nvlist_t *nvl); void *nvlist_pack(const nvlist_t *nvl, size_t *sizep); -nvlist_t *nvlist_unpack(const void *buf, size_t size); +nvlist_t *nvlist_unpack(const void *buf, size_t size, int flags); int nvlist_send(int sock, const nvlist_t *nvl); -nvlist_t *nvlist_recv(int sock); -nvlist_t *nvlist_xfer(int sock, nvlist_t *nvl); +nvlist_t *nvlist_recv(int sock, int flags); +nvlist_t *nvlist_xfer(int sock, nvlist_t *nvl, int flags); const char *nvlist_next(const nvlist_t *nvl, int *typep, void **cookiep); const nvlist_t *nvlist_get_parent(const nvlist_t *nvl, void **cookiep); +const nvlist_t *nvlist_get_array_next(const nvlist_t *nvl); +bool nvlist_in_array(const nvlist_t *nvl); + +const nvlist_t *nvlist_get_pararr(const nvlist_t *nvl, void **cookiep); + /* * The nvlist_exists functions check if the given name (optionally of the given * type) exists on nvlist. @@ -111,10 +126,15 @@ bool nvlist_exists_number(const nvlist_t *nvl, const char *name); bool nvlist_exists_string(const nvlist_t *nvl, const char *name); bool nvlist_exists_nvlist(const nvlist_t *nvl, const char *name); +bool nvlist_exists_binary(const nvlist_t *nvl, const char *name); +bool nvlist_exists_bool_array(const nvlist_t *nvl, const char *name); +bool nvlist_exists_number_array(const nvlist_t *nvl, const char *name); +bool nvlist_exists_string_array(const nvlist_t *nvl, const char *name); +bool nvlist_exists_nvlist_array(const nvlist_t *nvl, const char *name); #ifndef _KERNEL bool nvlist_exists_descriptor(const nvlist_t *nvl, const char *name); +bool nvlist_exists_descriptor_array(const nvlist_t *nvl, const char *name); #endif -bool nvlist_exists_binary(const nvlist_t *nvl, const char *name); /* * The nvlist_add functions add the given name/value pair. @@ -127,15 +147,28 @@ void nvlist_add_number(nvlist_t *nvl, const char *name, uint64_t value); void nvlist_add_string(nvlist_t *nvl, const char *name, const char *value); void nvlist_add_stringf(nvlist_t *nvl, const char *name, const char *valuefmt, ...) __printflike(3, 4); -#ifdef _VA_LIST_DECLARED +#if !defined(_KERNEL) || defined(_VA_LIST_DECLARED) void nvlist_add_stringv(nvlist_t *nvl, const char *name, const char *valuefmt, va_list valueap) __printflike(3, 0); #endif void nvlist_add_nvlist(nvlist_t *nvl, const char *name, const nvlist_t *value); +void nvlist_add_binary(nvlist_t *nvl, const char *name, const void *value, size_t size); +void nvlist_add_bool_array(nvlist_t *nvl, const char *name, const bool *value, size_t nitems); +void nvlist_add_number_array(nvlist_t *nvl, const char *name, const uint64_t *value, size_t nitems); +void nvlist_add_string_array(nvlist_t *nvl, const char *name, const char * const *value, size_t nitems); +void nvlist_add_nvlist_array(nvlist_t *nvl, const char *name, const nvlist_t * const *value, size_t nitems); #ifndef _KERNEL void nvlist_add_descriptor(nvlist_t *nvl, const char *name, int value); +void nvlist_add_descriptor_array(nvlist_t *nvl, const char *name, const int *value, size_t nitems); #endif -void nvlist_add_binary(nvlist_t *nvl, const char *name, const void *value, size_t size); +void nvlist_append_bool_array(nvlist_t *nvl, const char *name, const bool value); +void nvlist_append_number_array(nvlist_t *nvl, const char *name, const uint64_t value); +void nvlist_append_string_array(nvlist_t *nvl, const char *name, const char * const value); +void nvlist_append_nvlist_array(nvlist_t *nvl, const char *name, const nvlist_t * const value); +#ifndef _KERNEL +void nvlist_append_descriptor_array(nvlist_t *nvl, const char *name, int value); +#endif + /* * The nvlist_move functions add the given name/value pair. * The functions consumes provided buffer. @@ -143,10 +176,15 @@ void nvlist_move_string(nvlist_t *nvl, const char *name, char *value); void nvlist_move_nvlist(nvlist_t *nvl, const char *name, nvlist_t *value); +void nvlist_move_binary(nvlist_t *nvl, const char *name, void *value, size_t size); +void nvlist_move_bool_array(nvlist_t *nvl, const char *name, bool *value, size_t nitems); +void nvlist_move_string_array(nvlist_t *nvl, const char *name, char **value, size_t nitems); +void nvlist_move_nvlist_array(nvlist_t *nvl, const char *name, nvlist_t **value, size_t nitems); +void nvlist_move_number_array(nvlist_t *nvl, const char *name, uint64_t *value, size_t nitems); #ifndef _KERNEL void nvlist_move_descriptor(nvlist_t *nvl, const char *name, int value); +void nvlist_move_descriptor_array(nvlist_t *nvl, const char *name, int *value, size_t nitems); #endif -void nvlist_move_binary(nvlist_t *nvl, const char *name, void *value, size_t size); /* * The nvlist_get functions returns value associated with the given name. @@ -154,14 +192,19 @@ * not be freed by the caller. */ -bool nvlist_get_bool(const nvlist_t *nvl, const char *name); -uint64_t nvlist_get_number(const nvlist_t *nvl, const char *name); -const char *nvlist_get_string(const nvlist_t *nvl, const char *name); -const nvlist_t *nvlist_get_nvlist(const nvlist_t *nvl, const char *name); +bool nvlist_get_bool(const nvlist_t *nvl, const char *name); +uint64_t nvlist_get_number(const nvlist_t *nvl, const char *name); +const char *nvlist_get_string(const nvlist_t *nvl, const char *name); +const nvlist_t *nvlist_get_nvlist(const nvlist_t *nvl, const char *name); +const void *nvlist_get_binary(const nvlist_t *nvl, const char *name, size_t *sizep); +const bool *nvlist_get_bool_array(const nvlist_t *nvl, const char *name, size_t *nitemsp); +const uint64_t *nvlist_get_number_array(const nvlist_t *nvl, const char *name, size_t *nitemsp); +const char * const *nvlist_get_string_array(const nvlist_t *nvl, const char *name, size_t *nitemsp); +const nvlist_t * const *nvlist_get_nvlist_array(const nvlist_t *nvl, const char *name, size_t *nitemsp); #ifndef _KERNEL -int nvlist_get_descriptor(const nvlist_t *nvl, const char *name); +int nvlist_get_descriptor(const nvlist_t *nvl, const char *name); +const int *nvlist_get_descriptor_array(const nvlist_t *nvl, const char *name, size_t *nitemsp); #endif -const void *nvlist_get_binary(const nvlist_t *nvl, const char *name, size_t *sizep); /* * The nvlist_take functions returns value associated with the given name and @@ -169,14 +212,19 @@ * The caller is responsible for freeing received data. */ -bool nvlist_take_bool(nvlist_t *nvl, const char *name); -uint64_t nvlist_take_number(nvlist_t *nvl, const char *name); -char *nvlist_take_string(nvlist_t *nvl, const char *name); -nvlist_t *nvlist_take_nvlist(nvlist_t *nvl, const char *name); +bool nvlist_take_bool(nvlist_t *nvl, const char *name); +uint64_t nvlist_take_number(nvlist_t *nvl, const char *name); +char *nvlist_take_string(nvlist_t *nvl, const char *name); +nvlist_t *nvlist_take_nvlist(nvlist_t *nvl, const char *name); +void *nvlist_take_binary(nvlist_t *nvl, const char *name, size_t *sizep); +bool *nvlist_take_bool_array(nvlist_t *nvl, const char *name, size_t *nitemsp); +uint64_t *nvlist_take_number_array(nvlist_t *nvl, const char *name, size_t *nitemsp); +char **nvlist_take_string_array(nvlist_t *nvl, const char *name, size_t *nitemsp); +nvlist_t **nvlist_take_nvlist_array(nvlist_t *nvl, const char *name, size_t *nitemsp); #ifndef _KERNEL int nvlist_take_descriptor(nvlist_t *nvl, const char *name); +int *nvlist_take_descriptor_array(nvlist_t *nvl, const char *name, size_t *nitemsp); #endif -void *nvlist_take_binary(nvlist_t *nvl, const char *name, size_t *sizep); /* * The nvlist_free functions removes the given name/value pair from the nvlist @@ -191,10 +239,16 @@ void nvlist_free_number(nvlist_t *nvl, const char *name); void nvlist_free_string(nvlist_t *nvl, const char *name); void nvlist_free_nvlist(nvlist_t *nvl, const char *name); +void nvlist_free_binary(nvlist_t *nvl, const char *name); +void nvlist_free_bool_array(nvlist_t *nvl, const char *name); +void nvlist_free_number_array(nvlist_t *nvl, const char *name); +void nvlist_free_string_array(nvlist_t *nvl, const char *name); +void nvlist_free_nvlist_array(nvlist_t *nvl, const char *name); +void nvlist_free_binary_array(nvlist_t *nvl, const char *name); #ifndef _KERNEL void nvlist_free_descriptor(nvlist_t *nvl, const char *name); +void nvlist_free_descriptor_array(nvlist_t *nvl, const char *name); #endif -void nvlist_free_binary(nvlist_t *nvl, const char *name); __END_DECLS Modified: trunk/sys/sys/osd.h =================================================================== --- trunk/sys/sys/osd.h 2020-02-16 21:59:52 UTC (rev 12369) +++ trunk/sys/sys/osd.h 2020-02-16 22:00:35 UTC (rev 12370) @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/sys/osd.h 298834 2016-04-30 04:01:22Z jamie $ + * $FreeBSD: stable/11/sys/sys/osd.h 331722 2018-03-29 02:50:57Z eadler $ */ #ifndef _SYS_OSD_H_ @@ -60,10 +60,10 @@ void osd_deregister(u_int type, u_int slot); int osd_set(u_int type, struct osd *osd, u_int slot, void *value); -void *osd_reserve(u_int slot); -int osd_set_reserved(u_int type, struct osd *osd, u_int slot, void *rsv, +void **osd_reserve(u_int slot); +int osd_set_reserved(u_int type, struct osd *osd, u_int slot, void **rsv, void *value); -void osd_free_reserved(void *rsv); +void osd_free_reserved(void **rsv); void *osd_get(u_int type, struct osd *osd, u_int slot); void osd_del(u_int type, struct osd *osd, u_int slot); int osd_call(u_int type, u_int method, void *obj, void *data); From laffer1 at midnightbsd.org Sun Feb 16 17:18:25 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 17:18:25 -0500 (EST) Subject: [Midnightbsd-cvs] src [12371] trunk/sys/sys/mutex.h: Sync with FreeBSD 11-stable Message-ID: <202002162218.01GMIPnn032449@stargazer.midnightbsd.org> Revision: 12371 http://svnweb.midnightbsd.org/src/?rev=12371 Author: laffer1 Date: 2020-02-16 17:18:24 -0500 (Sun, 16 Feb 2020) Log Message: ----------- Sync with FreeBSD 11-stable Modified Paths: -------------- trunk/sys/sys/mutex.h Modified: trunk/sys/sys/mutex.h =================================================================== --- trunk/sys/sys/mutex.h 2020-02-16 22:00:35 UTC (rev 12370) +++ trunk/sys/sys/mutex.h 2020-02-16 22:18:24 UTC (rev 12371) @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * from BSDI $Id: mutex.h,v 2.7.2.35 2000/04/27 03:10:26 cp Exp $ - * $FreeBSD: stable/10/sys/sys/mutex.h 323870 2017-09-21 19:24:11Z marius $ + * $FreeBSD: stable/11/sys/sys/mutex.h 331722 2018-03-29 02:50:57Z eadler $ */ #ifndef _SYS_MUTEX_H_ @@ -66,17 +66,13 @@ * State bits kept in mutex->mtx_lock, for the DEFAULT lock type. None of this, * with the exception of MTX_UNOWNED, applies to spin locks. */ +#define MTX_UNOWNED 0x00000000 /* Cookie for free mutex */ #define MTX_RECURSED 0x00000001 /* lock recursed (for MTX_DEF only) */ #define MTX_CONTESTED 0x00000002 /* lock contested (for MTX_DEF only) */ -#define MTX_UNOWNED 0x00000004 /* Cookie for free mutex */ -#define MTX_FLAGMASK (MTX_RECURSED | MTX_CONTESTED | MTX_UNOWNED) +#define MTX_DESTROYED 0x00000004 /* lock destroyed */ +#define MTX_FLAGMASK (MTX_RECURSED | MTX_CONTESTED | MTX_DESTROYED) /* - * Value stored in mutex->mtx_lock to denote a destroyed mutex. - */ -#define MTX_DESTROYED (MTX_CONTESTED | MTX_UNOWNED) - -/* * Prototypes * * NOTE: Functions prepended with `_' (underscore) are exported to other parts @@ -96,17 +92,28 @@ int opts); void _mtx_destroy(volatile uintptr_t *c); void mtx_sysinit(void *arg); +int _mtx_trylock_flags_int(struct mtx *m, int opts LOCK_FILE_LINE_ARG_DEF); int _mtx_trylock_flags_(volatile uintptr_t *c, int opts, const char *file, int line); void mutex_init(void); -void __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t tid, int opts, +#if LOCK_DEBUG > 0 +void __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v, int opts, const char *file, int line); -void __mtx_unlock_sleep(volatile uintptr_t *c, int opts, const char *file, - int line); +void __mtx_unlock_sleep(volatile uintptr_t *c, uintptr_t v, int opts, + const char *file, int line); +#else +void __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v); +void __mtx_unlock_sleep(volatile uintptr_t *c, uintptr_t v); +#endif + #ifdef SMP -void _mtx_lock_spin_cookie(volatile uintptr_t *c, uintptr_t tid, int opts, +#if LOCK_DEBUG > 0 +void _mtx_lock_spin_cookie(volatile uintptr_t *c, uintptr_t v, int opts, const char *file, int line); +#else +void _mtx_lock_spin_cookie(volatile uintptr_t *c, uintptr_t v); #endif +#endif void __mtx_lock_flags(volatile uintptr_t *c, int opts, const char *file, int line); void __mtx_unlock_flags(volatile uintptr_t *c, int opts, const char *file, @@ -122,11 +129,31 @@ int line); #endif void thread_lock_flags_(struct thread *, int, const char *, int); +#if LOCK_DEBUG > 0 +void _thread_lock(struct thread *td, int opts, const char *file, int line); +#else +void _thread_lock(struct thread *); +#endif +#if defined(LOCK_PROFILING) || defined(KLD_MODULE) #define thread_lock(tdp) \ thread_lock_flags_((tdp), 0, __FILE__, __LINE__) +#elif LOCK_DEBUG > 0 +#define thread_lock(tdp) \ + _thread_lock((tdp), 0, __FILE__, __LINE__) +#else +#define thread_lock(tdp) \ + _thread_lock((tdp)) +#endif + +#if LOCK_DEBUG > 0 #define thread_lock_flags(tdp, opt) \ thread_lock_flags_((tdp), (opt), __FILE__, __LINE__) +#else +#define thread_lock_flags(tdp, opt) \ + _thread_lock(tdp) +#endif + #define thread_unlock(tdp) \ mtx_unlock_spin((tdp)->td_lock) @@ -141,14 +168,26 @@ _mtx_destroy(&(m)->mtx_lock) #define mtx_trylock_flags_(m, o, f, l) \ _mtx_trylock_flags_(&(m)->mtx_lock, o, f, l) -#define _mtx_lock_sleep(m, t, o, f, l) \ - __mtx_lock_sleep(&(m)->mtx_lock, t, o, f, l) -#define _mtx_unlock_sleep(m, o, f, l) \ - __mtx_unlock_sleep(&(m)->mtx_lock, o, f, l) +#if LOCK_DEBUG > 0 +#define _mtx_lock_sleep(m, v, o, f, l) \ + __mtx_lock_sleep(&(m)->mtx_lock, v, o, f, l) +#define _mtx_unlock_sleep(m, v, o, f, l) \ + __mtx_unlock_sleep(&(m)->mtx_lock, v, o, f, l) +#else +#define _mtx_lock_sleep(m, v, o, f, l) \ + __mtx_lock_sleep(&(m)->mtx_lock, v) +#define _mtx_unlock_sleep(m, v, o, f, l) \ + __mtx_unlock_sleep(&(m)->mtx_lock, v) +#endif #ifdef SMP -#define _mtx_lock_spin(m, t, o, f, l) \ - _mtx_lock_spin_cookie(&(m)->mtx_lock, t, o, f, l) +#if LOCK_DEBUG > 0 +#define _mtx_lock_spin(m, v, o, f, l) \ + _mtx_lock_spin_cookie(&(m)->mtx_lock, v, o, f, l) +#else +#define _mtx_lock_spin(m, v, o, f, l) \ + _mtx_lock_spin_cookie(&(m)->mtx_lock, v) #endif +#endif #define _mtx_lock_flags(m, o, f, l) \ __mtx_lock_flags(&(m)->mtx_lock, o, f, l) #define _mtx_unlock_flags(m, o, f, l) \ @@ -172,6 +211,9 @@ #define _mtx_obtain_lock(mp, tid) \ atomic_cmpset_acq_ptr(&(mp)->mtx_lock, MTX_UNOWNED, (tid)) +#define _mtx_obtain_lock_fetch(mp, vp, tid) \ + atomic_fcmpset_acq_ptr(&(mp)->mtx_lock, vp, (tid)) + /* Try to release mtx_lock if it is unrecursed and uncontested. */ #define _mtx_release_lock(mp, tid) \ atomic_cmpset_rel_ptr(&(mp)->mtx_lock, (tid), MTX_UNOWNED) @@ -180,6 +222,9 @@ #define _mtx_release_lock_quick(mp) \ atomic_store_rel_ptr(&(mp)->mtx_lock, MTX_UNOWNED) +#define _mtx_release_lock_fetch(mp, vp) \ + atomic_fcmpset_rel_ptr(&(mp)->mtx_lock, (vp), MTX_UNOWNED) + /* * Full lock operations that are suitable to be inlined in non-debug * kernels. If the lock cannot be acquired or released trivially then @@ -189,12 +234,11 @@ /* Lock a normal mutex. */ #define __mtx_lock(mp, tid, opts, file, line) do { \ uintptr_t _tid = (uintptr_t)(tid); \ + uintptr_t _v = MTX_UNOWNED; \ \ - if (((mp)->mtx_lock != MTX_UNOWNED || !_mtx_obtain_lock((mp), _tid)))\ - _mtx_lock_sleep((mp), _tid, (opts), (file), (line)); \ - else \ - LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_MTX_LOCK_ACQUIRE, \ - mp, 0, 0, (file), (line)); \ + if (__predict_false(LOCKSTAT_PROFILE_ENABLED(adaptive__acquire) ||\ + !_mtx_obtain_lock_fetch((mp), &_v, _tid))) \ + _mtx_lock_sleep((mp), _v, (opts), (file), (line)); \ } while (0) /* @@ -206,16 +250,12 @@ #ifdef SMP #define __mtx_lock_spin(mp, tid, opts, file, line) do { \ uintptr_t _tid = (uintptr_t)(tid); \ + uintptr_t _v = MTX_UNOWNED; \ \ spinlock_enter(); \ - if (((mp)->mtx_lock != MTX_UNOWNED || !_mtx_obtain_lock((mp), _tid))) {\ - if ((mp)->mtx_lock == _tid) \ - (mp)->mtx_recurse++; \ - else \ - _mtx_lock_spin((mp), _tid, (opts), (file), (line)); \ - } else \ - LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_MTX_SPIN_LOCK_ACQUIRE, \ - mp, 0, 0, (file), (line)); \ + if (__predict_false(LOCKSTAT_PROFILE_ENABLED(spin__acquire) || \ + !_mtx_obtain_lock_fetch((mp), &_v, _tid))) \ + _mtx_lock_spin((mp), _v, (opts), (file), (line)); \ } while (0) #define __mtx_trylock_spin(mp, tid, opts, file, line) __extension__ ({ \ uintptr_t _tid = (uintptr_t)(tid); \ @@ -226,7 +266,7 @@ spinlock_exit(); \ _ret = 0; \ } else { \ - LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_MTX_SPIN_LOCK_ACQUIRE, \ + LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(spin__acquire, \ mp, 0, 0, file, line); \ _ret = 1; \ } \ @@ -262,10 +302,11 @@ /* Unlock a normal mutex. */ #define __mtx_unlock(mp, tid, opts, file, line) do { \ - uintptr_t _tid = (uintptr_t)(tid); \ + uintptr_t _v = (uintptr_t)(tid); \ \ - if ((mp)->mtx_lock != _tid || !_mtx_release_lock((mp), _tid)) \ - _mtx_unlock_sleep((mp), (opts), (file), (line)); \ + if (__predict_false(LOCKSTAT_PROFILE_ENABLED(adaptive__release) ||\ + !_mtx_release_lock_fetch((mp), &_v))) \ + _mtx_unlock_sleep((mp), _v, (opts), (file), (line)); \ } while (0) /* @@ -283,11 +324,10 @@ if (mtx_recursed((mp))) \ (mp)->mtx_recurse--; \ else { \ - LOCKSTAT_PROFILE_RELEASE_LOCK(LS_MTX_SPIN_UNLOCK_RELEASE, \ - mp); \ + LOCKSTAT_PROFILE_RELEASE_LOCK(spin__release, mp); \ _mtx_release_lock_quick((mp)); \ - } \ - spinlock_exit(); \ + } \ + spinlock_exit(); \ } while (0) #else /* SMP */ #define __mtx_unlock_spin(mp) do { \ @@ -294,10 +334,9 @@ if (mtx_recursed((mp))) \ (mp)->mtx_recurse--; \ else { \ - LOCKSTAT_PROFILE_RELEASE_LOCK(LS_MTX_SPIN_UNLOCK_RELEASE, \ - mp); \ + LOCKSTAT_PROFILE_RELEASE_LOCK(spin__release, mp); \ (mp)->mtx_lock = MTX_UNOWNED; \ - } \ + } \ spinlock_exit(); \ } while (0) #endif /* SMP */ @@ -360,12 +399,8 @@ mtx_unlock_spin(mtx_pool_find((pool), (ptr))) /* - * mtxpool_lockbuilder is a pool of sleep locks that is not witness - * checked and should only be used for building higher level locks. - * * mtxpool_sleep is a general purpose pool of sleep mutexes. */ -extern struct mtx_pool *mtxpool_lockbuilder; extern struct mtx_pool *mtxpool_sleep; #ifndef LOCK_DEBUG @@ -425,10 +460,16 @@ _sleep((chan), &(mtx)->lock_object, (pri), (wmesg), \ tick_sbt * (timo), 0, C_HARDCLOCK) -#define mtx_initialized(m) lock_initalized(&(m)->lock_object) +#define MTX_READ_VALUE(m) ((m)->mtx_lock) -#define mtx_owned(m) (((m)->mtx_lock & ~MTX_FLAGMASK) == (uintptr_t)curthread) +#define mtx_initialized(m) lock_initialized(&(m)->lock_object) +#define lv_mtx_owner(v) ((struct thread *)((v) & ~MTX_FLAGMASK)) + +#define mtx_owner(m) lv_mtx_owner(MTX_READ_VALUE(m)) + +#define mtx_owned(m) (mtx_owner(m) == curthread) + #define mtx_recursed(m) ((m)->mtx_recurse != 0) #define mtx_name(m) ((m)->lock_object.lo_name) From laffer1 at midnightbsd.org Sun Feb 16 17:28:13 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 17:28:13 -0500 (EST) Subject: [Midnightbsd-cvs] src [12372] trunk/sys/sys: Sync with FreeBSD 11-stable Message-ID: <202002162228.01GMSDbt034134@stargazer.midnightbsd.org> Revision: 12372 http://svnweb.midnightbsd.org/src/?rev=12372 Author: laffer1 Date: 2020-02-16 17:28:12 -0500 (Sun, 16 Feb 2020) Log Message: ----------- Sync with FreeBSD 11-stable Modified Paths: -------------- trunk/sys/sys/mouse.h trunk/sys/sys/msg.h trunk/sys/sys/msgbuf.h Modified: trunk/sys/sys/mouse.h =================================================================== --- trunk/sys/sys/mouse.h 2020-02-16 22:18:24 UTC (rev 12371) +++ trunk/sys/sys/mouse.h 2020-02-16 22:28:12 UTC (rev 12372) @@ -21,7 +21,7 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/sys/mouse.h 281708 2015-04-18 21:24:46Z rpaulo $ + * $FreeBSD: stable/11/sys/sys/mouse.h 344165 2019-02-15 20:46:03Z wulf $ */ #ifndef _SYS_MOUSE_H_ @@ -109,6 +109,9 @@ int capPalmDetect; int capPassthrough; int capMiddle; + int capLowPower; + int capMultiFingerReport; + int capBallistics; int nExtendedButtons; int nExtendedQueries; int capClickPad; @@ -126,6 +129,15 @@ int verticalScroll; int horizontalScroll; int verticalWheel; + int capEWmode; + int minimumXCoord; + int minimumYCoord; + int maximumXCoord; + int maximumYCoord; + int infoXupmm; + int infoYupmm; + int forcePad; + int topButtonPad; } synapticshw_t; /* iftype */ @@ -161,6 +173,7 @@ #define MOUSE_MODEL_4DPLUS 12 #define MOUSE_MODEL_SYNAPTICS 13 #define MOUSE_MODEL_TRACKPOINT 14 +#define MOUSE_MODEL_ELANTECH 15 typedef struct mousemode { int protocol; /* MOUSE_PROTO_XXX */ @@ -231,6 +244,9 @@ /* Synaptics Touchpad */ #define MOUSE_SYNAPTICS_PACKETSIZE 6 /* '3' works better */ +/* Elantech Touchpad */ +#define MOUSE_ELANTECH_PACKETSIZE 6 + /* Microsoft Serial mouse data packet */ #define MOUSE_MSS_PACKETSIZE 3 #define MOUSE_MSS_SYNCMASK 0x40 Modified: trunk/sys/sys/msg.h =================================================================== --- trunk/sys/sys/msg.h 2020-02-16 22:18:24 UTC (rev 12371) +++ trunk/sys/sys/msg.h 2020-02-16 22:28:12 UTC (rev 12372) @@ -1,4 +1,5 @@ /* $MidnightBSD$ */ +/* $FreeBSD: stable/11/sys/sys/msg.h 347995 2019-05-20 16:31:45Z kib $ */ /* $NetBSD: msg.h,v 1.4 1994/06/29 06:44:43 cgd Exp $ */ /*- @@ -25,6 +26,9 @@ #include #include +#ifdef _WANT_SYSVMSG_INTERNALS +#define _WANT_SYSVIPC_INTERNALS +#endif #include /* @@ -116,7 +120,6 @@ #endif #ifdef _KERNEL - struct msg { struct msg *msg_next; /* next msg in the chain */ long msg_type; /* type of this message */ @@ -126,7 +129,9 @@ short msg_spot; /* location of start of msg in buffer */ struct label *label; /* MAC Framework label */ }; +#endif +#if defined(_KERNEL) || defined(_WANT_SYSVMSG_INTERNALS) /* * Based on the configuration parameters described in an SVR2 (yes, two) * config(1m) man page. @@ -145,7 +150,6 @@ msgssz, /* size of a message segment (see notes above) */ msgseg; /* number of message segments */ }; -extern struct msginfo msginfo; /* * Kernel wrapper for the user-level structure. @@ -162,9 +166,13 @@ struct label *label; /* MAC label */ struct ucred *cred; /* creator's credentials */ }; +#endif -#else /* !_KERNEL */ +#ifdef _KERNEL +extern struct msginfo msginfo; +#else /* _KERNEL */ + __BEGIN_DECLS int msgctl(int, int, struct msqid_ds *); int msgget(key_t, int); @@ -175,7 +183,6 @@ int msgsys(int, ...); #endif __END_DECLS +#endif /* !_KERNEL */ -#endif /* _KERNEL */ - #endif /* !_SYS_MSG_H_ */ Modified: trunk/sys/sys/msgbuf.h =================================================================== --- trunk/sys/sys/msgbuf.h 2020-02-16 22:18:24 UTC (rev 12371) +++ trunk/sys/sys/msgbuf.h 2020-02-16 22:28:12 UTC (rev 12372) @@ -28,7 +28,7 @@ * SUCH DAMAGE. * * @(#)msgbuf.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD: stable/10/sys/sys/msgbuf.h 233135 2012-03-19 00:36:32Z eadler $ + * $FreeBSD: stable/11/sys/sys/msgbuf.h 338109 2018-08-20 17:27:30Z kevans $ */ #ifndef _SYS_MSGBUF_H_ @@ -67,7 +67,7 @@ void msgbufinit(void *ptr, int size); void msgbuf_addchar(struct msgbuf *mbp, int c); -void msgbuf_addstr(struct msgbuf *mbp, int pri, char *str, int filter_cr); +void msgbuf_addstr(struct msgbuf *mbp, int pri, const char *str, int filter_cr); void msgbuf_clear(struct msgbuf *mbp); void msgbuf_copy(struct msgbuf *src, struct msgbuf *dst); int msgbuf_getbytes(struct msgbuf *mbp, char *buf, int buflen); From laffer1 at midnightbsd.org Sun Feb 16 17:29:27 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 17:29:27 -0500 (EST) Subject: [Midnightbsd-cvs] src [12373] trunk/sys/sys: Sync with FreeBSD 11-stable Message-ID: <202002162229.01GMTRTg034214@stargazer.midnightbsd.org> Revision: 12373 http://svnweb.midnightbsd.org/src/?rev=12373 Author: laffer1 Date: 2020-02-16 17:29:26 -0500 (Sun, 16 Feb 2020) Log Message: ----------- Sync with FreeBSD 11-stable Modified Paths: -------------- trunk/sys/sys/md4.h trunk/sys/sys/md5.h Modified: trunk/sys/sys/md4.h =================================================================== --- trunk/sys/sys/md4.h 2020-02-16 22:28:12 UTC (rev 12372) +++ trunk/sys/sys/md4.h 2020-02-16 22:29:26 UTC (rev 12373) @@ -1,5 +1,6 @@ +/* $MidnightBSD$ */ /* MD4.H - header file for MD4C.C - * $MidnightBSD$ + * $FreeBSD: stable/11/sys/sys/md4.h 309023 2016-11-22 20:28:17Z asomers $ */ /*- @@ -39,10 +40,12 @@ void MD4Init(MD4_CTX *); void MD4Update(MD4_CTX *, const unsigned char *, unsigned int); void MD4Pad(MD4_CTX *); -void MD4Final(unsigned char [16], MD4_CTX *); +void MD4Final(unsigned char [__min_size(16)], MD4_CTX *); +#ifndef _KERNEL char * MD4End(MD4_CTX *, char *); char * MD4File(const char *, char *); char * MD4Data(const unsigned char *, unsigned int, char *); +#endif __END_DECLS #endif /* _MD4_H_ */ Modified: trunk/sys/sys/md5.h =================================================================== --- trunk/sys/sys/md5.h 2020-02-16 22:28:12 UTC (rev 12372) +++ trunk/sys/sys/md5.h 2020-02-16 22:29:26 UTC (rev 12373) @@ -1,5 +1,6 @@ +/* $MidnightBSD$ */ /* MD5.H - header file for MD5C.C - * $MidnightBSD$ + * $FreeBSD: stable/11/sys/sys/md5.h 310372 2016-12-21 18:42:04Z emaste $ */ /*- @@ -44,10 +45,14 @@ __BEGIN_DECLS void MD5Init (MD5_CTX *); void MD5Update (MD5_CTX *, const void *, unsigned int); -void MD5Final (unsigned char [16], MD5_CTX *); +void MD5Final (unsigned char[__min_size(MD5_DIGEST_LENGTH)], MD5_CTX *); +#ifndef _KERNEL char * MD5End(MD5_CTX *, char *); +char * MD5Fd(int, char *); +char * MD5FdChunk(int, char *, off_t, off_t); char * MD5File(const char *, char *); char * MD5FileChunk(const char *, char *, off_t, off_t); char * MD5Data(const void *, unsigned int, char *); +#endif __END_DECLS #endif /* _SYS_MD5_H_ */ From laffer1 at midnightbsd.org Sun Feb 16 17:29:51 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 17:29:51 -0500 (EST) Subject: [Midnightbsd-cvs] src [12374] trunk/sys/sys/mbpool.h: Sync with FreeBSD 11-stable Message-ID: <202002162229.01GMTpCV034275@stargazer.midnightbsd.org> Revision: 12374 http://svnweb.midnightbsd.org/src/?rev=12374 Author: laffer1 Date: 2020-02-16 17:29:51 -0500 (Sun, 16 Feb 2020) Log Message: ----------- Sync with FreeBSD 11-stable Modified Paths: -------------- trunk/sys/sys/mbpool.h Modified: trunk/sys/sys/mbpool.h =================================================================== --- trunk/sys/sys/mbpool.h 2020-02-16 22:29:26 UTC (rev 12373) +++ trunk/sys/sys/mbpool.h 2020-02-16 22:29:51 UTC (rev 12374) @@ -35,7 +35,7 @@ * interfaces on 64bit machines). This assists network interfaces that may need * huge numbers of mbufs. * - * $FreeBSD: stable/10/sys/sys/mbpool.h 254842 2013-08-25 10:57:09Z andre $ + * $FreeBSD: stable/11/sys/sys/mbpool.h 268529 2014-07-11 13:58:48Z glebius $ */ #ifndef _SYS_MBPOOL_H_ #define _SYS_MBPOOL_H_ @@ -70,7 +70,7 @@ void mbp_free(struct mbpool *, void *); /* free a chunk that is an external mbuf */ -int mbp_ext_free(struct mbuf *, void *, void *); +void mbp_ext_free(struct mbuf *, void *, void *); /* free all buffers that are marked to be on the card */ void mbp_card_free(struct mbpool *); From laffer1 at midnightbsd.org Sun Feb 16 17:32:15 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 17:32:15 -0500 (EST) Subject: [Midnightbsd-cvs] src [12375] trunk/sys/sys/mount.h: Sync with FreeBSD 11-stable Message-ID: <202002162232.01GMWFLd035042@stargazer.midnightbsd.org> Revision: 12375 http://svnweb.midnightbsd.org/src/?rev=12375 Author: laffer1 Date: 2020-02-16 17:32:14 -0500 (Sun, 16 Feb 2020) Log Message: ----------- Sync with FreeBSD 11-stable Modified Paths: -------------- trunk/sys/sys/mount.h Modified: trunk/sys/sys/mount.h =================================================================== --- trunk/sys/sys/mount.h 2020-02-16 22:29:51 UTC (rev 12374) +++ trunk/sys/sys/mount.h 2020-02-16 22:32:14 UTC (rev 12375) @@ -28,7 +28,7 @@ * SUCH DAMAGE. * * @(#)mount.h 8.21 (Berkeley) 5/20/95 - * $FreeBSD: stable/10/sys/sys/mount.h 309530 2016-12-04 13:56:15Z kib $ + * $FreeBSD: stable/11/sys/sys/mount.h 340232 2018-11-07 18:32:10Z kib $ */ #ifndef _SYS_MOUNT_H_ @@ -313,8 +313,10 @@ * External filesystem command modifier flags. * Unmount can use the MNT_FORCE flag. * XXX: These are not STATES and really should be somewhere else. - * XXX: MNT_BYFSID collides with MNT_ACLS, but because MNT_ACLS is only used for - * mount(2) and MNT_BYFSID is only used for unmount(2) it's harmless. + * XXX: MNT_BYFSID and MNT_NONBUSY collide with MNT_ACLS and MNT_MULTILABEL, + * but because MNT_ACLS and MNT_MULTILABEL are only used for mount(2), + * and MNT_BYFSID and MNT_NONBUSY are only used for unmount(2), + * it's harmless. */ #define MNT_UPDATE 0x0000000000010000ULL /* not real mount, just update */ #define MNT_DELEXPORT 0x0000000000020000ULL /* delete export host lists */ @@ -321,9 +323,11 @@ #define MNT_RELOAD 0x0000000000040000ULL /* reload filesystem data */ #define MNT_FORCE 0x0000000000080000ULL /* force unmount or readonly */ #define MNT_SNAPSHOT 0x0000000001000000ULL /* snapshot the filesystem */ +#define MNT_NONBUSY 0x0000000004000000ULL /* check vnode use counts. */ #define MNT_BYFSID 0x0000000008000000ULL /* specify filesystem by ID. */ #define MNT_CMDFLAGS (MNT_UPDATE | MNT_DELEXPORT | MNT_RELOAD | \ - MNT_FORCE | MNT_SNAPSHOT | MNT_BYFSID) + MNT_FORCE | MNT_SNAPSHOT | MNT_NONBUSY | \ + MNT_BYFSID) /* * Internal filesystem control flags stored in mnt_kern_flag. * @@ -513,7 +517,8 @@ #define VFCF_UNICODE 0x00200000 /* stores file names as Unicode */ #define VFCF_JAIL 0x00400000 /* can be mounted from within a jail */ #define VFCF_DELEGADMIN 0x00800000 /* supports delegated administration */ -#define VFCF_SBDRY 0x01000000 /* defer stop requests */ +#define VFCF_SBDRY 0x01000000 /* Stop at Boundary: defer stop requests + to kernel->user (AST) transition */ typedef uint32_t fsctlop_t; @@ -590,9 +595,9 @@ #ifdef MALLOC_DECLARE MALLOC_DECLARE(M_MOUNT); +MALLOC_DECLARE(M_STATFS); #endif extern int maxvfsconf; /* highest defined filesystem type */ -extern int nfs_mount_type; /* vfc_typenum for nfs, or -1 */ TAILQ_HEAD(vfsconfhead, vfsconf); extern struct vfsconfhead vfsconf; @@ -656,15 +661,15 @@ #define VFS_PROLOGUE(MP) do { \ struct mount *mp__; \ - int _enable_stops; \ + int _prev_stops; \ \ mp__ = (MP); \ - _enable_stops = (mp__ != NULL && \ - (mp__->mnt_vfc->vfc_flags & VFCF_SBDRY) && sigdeferstop()) + _prev_stops = sigdeferstop((mp__ != NULL && \ + (mp__->mnt_vfc->vfc_flags & VFCF_SBDRY) != 0) ? \ + SIGDEFERSTOP_SILENT : SIGDEFERSTOP_NOP); #define VFS_EPILOGUE(MP) \ - if (_enable_stops) \ - sigallowstop(); \ + sigallowstop(_prev_stops); \ } while (0) #define VFS_MOUNT(MP) ({ \ @@ -827,8 +832,6 @@ }; \ DECLARE_MODULE(fsname, fsname ## _mod, SI_SUB_VFS, SI_ORDER_MIDDLE) -extern char *mountrootfsname; - /* * exported vnode operations */ From laffer1 at midnightbsd.org Sun Feb 16 17:32:40 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 17:32:40 -0500 (EST) Subject: [Midnightbsd-cvs] src [12376] trunk/sys/sys/mman.h: Sync with FreeBSD 11-stable Message-ID: <202002162232.01GMWeKV035099@stargazer.midnightbsd.org> Revision: 12376 http://svnweb.midnightbsd.org/src/?rev=12376 Author: laffer1 Date: 2020-02-16 17:32:40 -0500 (Sun, 16 Feb 2020) Log Message: ----------- Sync with FreeBSD 11-stable Modified Paths: -------------- trunk/sys/sys/mman.h Modified: trunk/sys/sys/mman.h =================================================================== --- trunk/sys/sys/mman.h 2020-02-16 22:32:14 UTC (rev 12375) +++ trunk/sys/sys/mman.h 2020-02-16 22:32:40 UTC (rev 12376) @@ -28,7 +28,7 @@ * SUCH DAMAGE. * * @(#)mman.h 8.2 (Berkeley) 1/9/95 - * $FreeBSD: stable/10/sys/sys/mman.h 321717 2017-07-30 10:36:20Z kib $ + * $FreeBSD: stable/11/sys/sys/mman.h 331722 2018-03-29 02:50:57Z eadler $ */ #ifndef _SYS_MMAN_H_ @@ -71,8 +71,8 @@ #define MAP_FIXED 0x0010 /* map addr must be exactly as requested */ #if __BSD_VISIBLE -#define MAP_RENAME 0x0020 /* Sun: rename private pages to file */ -#define MAP_NORESERVE 0x0040 /* Sun: don't reserve needed swap area */ +#define MAP_RESERVED0020 0x0020 /* previously unimplemented MAP_RENAME */ +#define MAP_RESERVED0040 0x0040 /* previously unimplemented MAP_NORESERVE */ #define MAP_RESERVED0080 0x0080 /* previously misimplemented MAP_INHERIT */ #define MAP_RESERVED0100 0x0100 /* previously unimplemented MAP_NOEXTEND */ #define MAP_HASSEMAPHORE 0x0200 /* region may contain semaphores */ @@ -233,12 +233,16 @@ #endif #ifdef _KERNEL -int shm_mmap(struct shmfd *shmfd, vm_size_t objsize, vm_ooffset_t foff, - vm_object_t *obj); int shm_map(struct file *fp, size_t size, off_t offset, void **memp); int shm_unmap(struct file *fp, void *mem, size_t size); -void shm_path(struct shmfd *shmfd, char *path, size_t size); +int shm_access(struct shmfd *shmfd, struct ucred *ucred, int flags); +struct shmfd *shm_alloc(struct ucred *ucred, mode_t mode); +struct shmfd *shm_hold(struct shmfd *shmfd); +void shm_drop(struct shmfd *shmfd); +int shm_dotruncate(struct shmfd *shmfd, off_t length); + +extern struct fileops shm_ops; #else /* !_KERNEL */ __BEGIN_DECLS From laffer1 at midnightbsd.org Sun Feb 16 17:33:15 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 17:33:15 -0500 (EST) Subject: [Midnightbsd-cvs] src [12377] trunk/sys/sys/jail.h: Sync with FreeBSD 11-stable Message-ID: <202002162233.01GMXF8A035172@stargazer.midnightbsd.org> Revision: 12377 http://svnweb.midnightbsd.org/src/?rev=12377 Author: laffer1 Date: 2020-02-16 17:33:15 -0500 (Sun, 16 Feb 2020) Log Message: ----------- Sync with FreeBSD 11-stable Modified Paths: -------------- trunk/sys/sys/jail.h Modified: trunk/sys/sys/jail.h =================================================================== --- trunk/sys/sys/jail.h 2020-02-16 22:32:40 UTC (rev 12376) +++ trunk/sys/sys/jail.h 2020-02-16 22:33:15 UTC (rev 12377) @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/sys/jail.h 298833 2016-04-30 03:19:07Z jamie $ + * $FreeBSD: stable/11/sys/sys/jail.h 339446 2018-10-20 16:20:36Z jamie $ */ #ifndef _SYS_JAIL_H_ @@ -204,8 +204,6 @@ #define PR_IP4_USER 0x00000004 /* Restrict IPv4 addresses */ #define PR_IP6_USER 0x00000008 /* Restrict IPv6 addresses */ #define PR_VNET 0x00000010 /* Virtual network stack */ -#define PR_IP4_DISABLE 0x00000020 /* Disable IPv4 */ -#define PR_IP6_DISABLE 0x00000040 /* Disable IPv6 */ #define PR_IP4_SADDRSEL 0x00000080 /* Do IPv4 src addr sel. or use the */ /* primary jail address. */ #define PR_IP6_SADDRSEL 0x00000100 /* Do IPv6 src addr sel. or use the */ @@ -233,7 +231,8 @@ #define PR_ALLOW_MOUNT_FDESCFS 0x1000 #define PR_ALLOW_MOUNT_LINPROCFS 0x2000 #define PR_ALLOW_MOUNT_LINSYSFS 0x4000 -#define PR_ALLOW_ALL 0x7fff +#define PR_ALLOW_READ_MSGBUF 0x8000 +#define PR_ALLOW_ALL 0xffff /* * OSD methods @@ -391,15 +390,21 @@ int prison_get_ip4(struct ucred *cred, struct in_addr *ia); int prison_local_ip4(struct ucred *cred, struct in_addr *ia); int prison_remote_ip4(struct ucred *cred, struct in_addr *ia); -int prison_check_ip4(struct ucred *cred, struct in_addr *ia); +int prison_check_ip4(const struct ucred *, const struct in_addr *); +int prison_check_ip4_locked(const struct prison *, const struct in_addr *); int prison_saddrsel_ip4(struct ucred *, struct in_addr *); +int prison_restrict_ip4(struct prison *, struct in_addr *); +int prison_qcmp_v4(const void *, const void *); #ifdef INET6 int prison_equal_ip6(struct prison *, struct prison *); int prison_get_ip6(struct ucred *, struct in6_addr *); int prison_local_ip6(struct ucred *, struct in6_addr *, int); int prison_remote_ip6(struct ucred *, struct in6_addr *); -int prison_check_ip6(struct ucred *, struct in6_addr *); +int prison_check_ip6(const struct ucred *, const struct in6_addr *); +int prison_check_ip6_locked(const struct prison *, const struct in6_addr *); int prison_saddrsel_ip6(struct ucred *, struct in6_addr *); +int prison_restrict_ip6(struct prison *, struct in6_addr *); +int prison_qcmp_v6(const void *, const void *); #endif int prison_check_af(struct ucred *cred, int af); int prison_if(struct ucred *cred, struct sockaddr *sa); @@ -407,7 +412,8 @@ int prison_priv_check(struct ucred *cred, int priv); int sysctl_jail_param(SYSCTL_HANDLER_ARGS); void prison_racct_foreach(void (*callback)(struct racct *racct, - void *arg2, void *arg3), void *arg2, void *arg3); + void *arg2, void *arg3), void (*pre)(void), void (*post)(void), + void *arg2, void *arg3); struct prison_racct *prison_racct_find(const char *name); void prison_racct_hold(struct prison_racct *prr); void prison_racct_free(struct prison_racct *prr); From laffer1 at midnightbsd.org Sun Feb 16 17:35:11 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 17:35:11 -0500 (EST) Subject: [Midnightbsd-cvs] src [12378] trunk/sys/sys/mbuf.h: Sync with FreeBSD 11-stable Message-ID: <202002162235.01GMZBXH035892@stargazer.midnightbsd.org> Revision: 12378 http://svnweb.midnightbsd.org/src/?rev=12378 Author: laffer1 Date: 2020-02-16 17:35:10 -0500 (Sun, 16 Feb 2020) Log Message: ----------- Sync with FreeBSD 11-stable Modified Paths: -------------- trunk/sys/sys/mbuf.h Modified: trunk/sys/sys/mbuf.h =================================================================== --- trunk/sys/sys/mbuf.h 2020-02-16 22:33:15 UTC (rev 12377) +++ trunk/sys/sys/mbuf.h 2020-02-16 22:35:10 UTC (rev 12378) @@ -29,7 +29,7 @@ * SUCH DAMAGE. * * @(#)mbuf.h 8.5 (Berkeley) 2/19/95 - * $FreeBSD: stable/10/sys/sys/mbuf.h 282786 2015-05-12 00:27:20Z hiren $ + * $FreeBSD: stable/11/sys/sys/mbuf.h 338618 2018-09-12 19:13:32Z markj $ */ #ifndef _SYS_MBUF_H_ @@ -45,6 +45,32 @@ #endif #endif +#ifdef _KERNEL +#include + +#define MBUF_PROBE1(probe, arg0) \ + SDT_PROBE1(sdt, , , probe, arg0) +#define MBUF_PROBE2(probe, arg0, arg1) \ + SDT_PROBE2(sdt, , , probe, arg0, arg1) +#define MBUF_PROBE3(probe, arg0, arg1, arg2) \ + SDT_PROBE3(sdt, , , probe, arg0, arg1, arg2) +#define MBUF_PROBE4(probe, arg0, arg1, arg2, arg3) \ + SDT_PROBE4(sdt, , , probe, arg0, arg1, arg2, arg3) +#define MBUF_PROBE5(probe, arg0, arg1, arg2, arg3, arg4) \ + SDT_PROBE5(sdt, , , probe, arg0, arg1, arg2, arg3, arg4) + +SDT_PROBE_DECLARE(sdt, , , m__init); +SDT_PROBE_DECLARE(sdt, , , m__gethdr); +SDT_PROBE_DECLARE(sdt, , , m__get); +SDT_PROBE_DECLARE(sdt, , , m__getcl); +SDT_PROBE_DECLARE(sdt, , , m__clget); +SDT_PROBE_DECLARE(sdt, , , m__cljget); +SDT_PROBE_DECLARE(sdt, , , m__cljset); +SDT_PROBE_DECLARE(sdt, , , m__free); +SDT_PROBE_DECLARE(sdt, , , m__freem); + +#endif /* _KERNEL */ + /* * Mbufs are of a single size, MSIZE (sys/param.h), which includes overhead. * An mbuf may add a single "mbuf cluster" of size MCLBYTES (also in @@ -61,9 +87,15 @@ * MLEN is data length in a normal mbuf. * MHLEN is data length in an mbuf with pktheader. * MINCLSIZE is a smallest amount of data that should be put into cluster. + * + * Compile-time assertions in uipc_mbuf.c test these values to ensure that + * they are sensible. */ -#define MLEN ((int)(MSIZE - sizeof(struct m_hdr))) -#define MHLEN ((int)(MLEN - sizeof(struct pkthdr))) +struct mbuf; +#define MHSIZE offsetof(struct mbuf, m_dat) +#define MPKTHSIZE offsetof(struct mbuf, m_pktdat) +#define MLEN ((int)(MSIZE - MHSIZE)) +#define MHLEN ((int)(MSIZE - MPKTHSIZE)) #define MINCLSIZE (MHLEN + 1) #ifdef _KERNEL @@ -88,23 +120,6 @@ #endif /* _KERNEL */ /* - * Header present at the beginning of every mbuf. - * Size ILP32: 24 - * LP64: 32 - */ -struct m_hdr { - struct mbuf *mh_next; /* next buffer in chain */ - struct mbuf *mh_nextpkt; /* next chain in queue/record */ - caddr_t mh_data; /* location of data */ - int32_t mh_len; /* amount of data in this mbuf */ - uint32_t mh_type:8, /* type of data in this mbuf */ - mh_flags:24; /* flags; see below */ -#if !defined(__LP64__) - uint32_t mh_pad; /* pad for 64bit alignment */ -#endif -}; - -/* * Packet tag structure (see below for details). */ struct m_tag { @@ -119,6 +134,8 @@ * Record/packet header in first mbuf of chain; valid only if M_PKTHDR is set. * Size ILP32: 48 * LP64: 56 + * Compile-time assertions in uipc_mbuf.c test these values to ensure that + * they are correct. */ struct pkthdr { struct ifnet *rcvif; /* rcv interface */ @@ -136,7 +153,7 @@ uint8_t l4hlen; /* layer 4 header length */ uint8_t l5hlen; /* layer 5 header length */ union { - uint8_t eigth[8]; + uint8_t eight[8]; uint16_t sixteen[4]; uint32_t thirtytwo[2]; uint64_t sixtyfour[1]; @@ -146,7 +163,7 @@ /* Layer specific non-persistent local storage for reassembly, etc. */ union { - uint8_t eigth[8]; + uint8_t eight[8]; uint16_t sixteen[4]; uint32_t thirtytwo[2]; uint64_t sixtyfour[1]; @@ -166,14 +183,19 @@ * set. * Size ILP32: 28 * LP64: 48 + * Compile-time assertions in uipc_mbuf.c test these values to ensure that + * they are correct. */ struct m_ext { - volatile u_int *ref_cnt; /* pointer to ref count info */ + union { + volatile u_int ext_count; /* value of ref count info */ + volatile u_int *ext_cnt; /* pointer to ref count info */ + }; caddr_t ext_buf; /* start of buffer */ uint32_t ext_size; /* size of buffer, for ext_free */ uint32_t ext_type:8, /* type of external storage */ ext_flags:24; /* external storage mbuf flags */ - int (*ext_free) /* free routine if not the usual */ + void (*ext_free) /* free routine if not the usual */ (struct mbuf *, void *, void *); void *ext_arg1; /* optional argument pointer */ void *ext_arg2; /* optional argument pointer */ @@ -184,39 +206,50 @@ * purposes. */ struct mbuf { - struct m_hdr m_hdr; + /* + * Header present at the beginning of every mbuf. + * Size ILP32: 24 + * LP64: 32 + * Compile-time assertions in uipc_mbuf.c test these values to ensure + * that they are correct. + */ + union { /* next buffer in chain */ + struct mbuf *m_next; + SLIST_ENTRY(mbuf) m_slist; + STAILQ_ENTRY(mbuf) m_stailq; + }; + union { /* next chain in queue/record */ + struct mbuf *m_nextpkt; + SLIST_ENTRY(mbuf) m_slistpkt; + STAILQ_ENTRY(mbuf) m_stailqpkt; + }; + caddr_t m_data; /* location of data */ + int32_t m_len; /* amount of data in this mbuf */ + uint32_t m_type:8, /* type of data in this mbuf */ + m_flags:24; /* flags; see below */ +#if !defined(__LP64__) + uint32_t m_pad; /* pad for 64bit alignment */ +#endif + + /* + * A set of optional headers (packet header, external storage header) + * and internal data storage. Historically, these arrays were sized + * to MHLEN (space left after a packet header) and MLEN (space left + * after only a regular mbuf header); they are now variable size in + * order to support future work on variable-size mbufs. + */ union { struct { - struct pkthdr MH_pkthdr; /* M_PKTHDR set */ + struct pkthdr m_pkthdr; /* M_PKTHDR set */ union { - struct m_ext MH_ext; /* M_EXT set */ - char MH_databuf[MHLEN]; - } MH_dat; - } MH; - char M_databuf[MLEN]; /* !M_PKTHDR, !M_EXT */ - } M_dat; + struct m_ext m_ext; /* M_EXT set */ + char m_pktdat[0]; + }; + }; + char m_dat[0]; /* !M_PKTHDR, !M_EXT */ + }; }; -#define m_next m_hdr.mh_next -#define m_len m_hdr.mh_len -#define m_data m_hdr.mh_data -#define m_type m_hdr.mh_type -#define m_flags m_hdr.mh_flags -#define m_nextpkt m_hdr.mh_nextpkt -#define m_pkthdr M_dat.MH.MH_pkthdr -#define m_ext M_dat.MH.MH_dat.MH_ext -#define m_pktdat M_dat.MH.MH_dat.MH_databuf -#define m_dat M_dat.M_databuf -/* - * NOTE: forwards compatibility definitions for mbuf(9) - * - * These aren't 1:1 with the macros in r277203; in particular they're exposed - * to both userland and kernel, whereas this is exposed to just _KERNEL -- to - * avoid disruption with existing KBI/KPIs - */ -#define MHSIZE offsetof(struct mbuf, m_dat) -#define MPKTHSIZE offsetof(struct mbuf, m_pktdat) - /* * mbuf flags of global significance and layer crossing. * Those of only protocol/layer specific significance are to be mapped @@ -231,7 +264,7 @@ #define M_MCAST 0x00000020 /* send/received as link-level multicast */ #define M_PROMISC 0x00000040 /* packet was not for us */ #define M_VLANTAG 0x00000080 /* ether_vtag is valid */ -#define M_FLOWID 0x00000100 /* deprecated: flowid is valid */ +#define M_UNUSED_8 0x00000100 /* --available-- */ #define M_NOFREE 0x00000200 /* do not free mbuf, embedded in cluster */ #define M_PROTO1 0x00001000 /* protocol-specific */ @@ -247,6 +280,8 @@ #define M_PROTO11 0x00400000 /* protocol-specific */ #define M_PROTO12 0x00800000 /* protocol-specific */ +#define MB_DTOR_SKIP 0x1 /* don't pollute the cache by touching a freed mbuf */ + /* * Flags to purge when crossing layers. */ @@ -258,7 +293,7 @@ * Flags preserved when copying m_pkthdr. */ #define M_COPYFLAGS \ - (M_PKTHDR|M_EOR|M_RDONLY|M_BCAST|M_MCAST|M_PROMISC|M_VLANTAG|M_FLOWID| \ + (M_PKTHDR|M_EOR|M_RDONLY|M_BCAST|M_MCAST|M_PROMISC|M_VLANTAG| \ M_PROTOFLAGS) /* @@ -266,7 +301,7 @@ */ #define M_FLAG_BITS \ "\20\1M_EXT\2M_PKTHDR\3M_EOR\4M_RDONLY\5M_BCAST\6M_MCAST" \ - "\7M_PROMISC\10M_VLANTAG\11M_FLOWID" + "\7M_PROMISC\10M_VLANTAG" #define M_FLAG_PROTOBITS \ "\15M_PROTO1\16M_PROTO2\17M_PROTO3\20M_PROTO4\21M_PROTO5" \ "\22M_PROTO6\23M_PROTO7\24M_PROTO8\25M_PROTO9\26M_PROTO10" \ @@ -284,32 +319,41 @@ * * Most NICs support RSS, which provides ordering and explicit affinity, and * use the hash m_flag bits to indicate what header fields were covered by - * the hash. M_HASHTYPE_OPAQUE can be set by non-RSS cards or configurations - * that provide an opaque flow identifier, allowing for ordering and - * distribution without explicit affinity. + * the hash. M_HASHTYPE_OPAQUE and M_HASHTYPE_OPAQUE_HASH can be set by non- + * RSS cards or configurations that provide an opaque flow identifier, allowing + * for ordering and distribution without explicit affinity. Additionally, + * M_HASHTYPE_OPAQUE_HASH indicates that the flow identifier has hash + * properties. */ +#define M_HASHTYPE_HASHPROP 0x80 /* has hash properties */ +#define M_HASHTYPE_HASH(t) (M_HASHTYPE_HASHPROP | (t)) +/* Microsoft RSS standard hash types */ #define M_HASHTYPE_NONE 0 -#define M_HASHTYPE_RSS_IPV4 1 /* IPv4 2-tuple */ -#define M_HASHTYPE_RSS_TCP_IPV4 2 /* TCPv4 4-tuple */ -#define M_HASHTYPE_RSS_IPV6 3 /* IPv6 2-tuple */ -#define M_HASHTYPE_RSS_TCP_IPV6 4 /* TCPv6 4-tuple */ -#define M_HASHTYPE_RSS_IPV6_EX 5 /* IPv6 2-tuple + ext hdrs */ -#define M_HASHTYPE_RSS_TCP_IPV6_EX 6 /* TCPv6 4-tiple + ext hdrs */ -#define M_HASHTYPE_OPAQUE 255 /* ordering, not affinity */ +#define M_HASHTYPE_RSS_IPV4 M_HASHTYPE_HASH(1) /* IPv4 2-tuple */ +#define M_HASHTYPE_RSS_TCP_IPV4 M_HASHTYPE_HASH(2) /* TCPv4 4-tuple */ +#define M_HASHTYPE_RSS_IPV6 M_HASHTYPE_HASH(3) /* IPv6 2-tuple */ +#define M_HASHTYPE_RSS_TCP_IPV6 M_HASHTYPE_HASH(4) /* TCPv6 4-tuple */ +#define M_HASHTYPE_RSS_IPV6_EX M_HASHTYPE_HASH(5) /* IPv6 2-tuple + + * ext hdrs */ +#define M_HASHTYPE_RSS_TCP_IPV6_EX M_HASHTYPE_HASH(6) /* TCPv6 4-tuple + + * ext hdrs */ +/* Non-standard RSS hash types */ +#define M_HASHTYPE_RSS_UDP_IPV4 M_HASHTYPE_HASH(7) /* IPv4 UDP 4-tuple*/ +#define M_HASHTYPE_RSS_UDP_IPV4_EX M_HASHTYPE_HASH(8) /* IPv4 UDP 4-tuple + + * ext hdrs */ +#define M_HASHTYPE_RSS_UDP_IPV6 M_HASHTYPE_HASH(9) /* IPv6 UDP 4-tuple*/ +#define M_HASHTYPE_RSS_UDP_IPV6_EX M_HASHTYPE_HASH(10)/* IPv6 UDP 4-tuple + + * ext hdrs */ +#define M_HASHTYPE_OPAQUE 63 /* ordering, not affinity */ +#define M_HASHTYPE_OPAQUE_HASH M_HASHTYPE_HASH(M_HASHTYPE_OPAQUE) + /* ordering+hash, not affinity*/ + #define M_HASHTYPE_CLEAR(m) ((m)->m_pkthdr.rsstype = 0) -/* - * Handle M_FLOWID for legacy drivers still using them. - */ -#define M_HASHTYPE_GET(m) (((m->m_flags & M_FLOWID) && \ - (m)->m_pkthdr.rsstype == M_HASHTYPE_NONE) ? M_HASHTYPE_OPAQUE : \ - (m)->m_pkthdr.rsstype) -#define M_HASHTYPE_SET(m, v) do { \ - if ((v) != M_HASHTYPE_NONE) \ - m->m_flags |= M_FLOWID; \ - (m)->m_pkthdr.rsstype = (v); \ -} while (0) +#define M_HASHTYPE_GET(m) ((m)->m_pkthdr.rsstype) +#define M_HASHTYPE_SET(m, v) ((m)->m_pkthdr.rsstype = (v)) #define M_HASHTYPE_TEST(m, v) (M_HASHTYPE_GET(m) == (v)) +#define M_HASHTYPE_ISHASH(m) (M_HASHTYPE_GET(m) & M_HASHTYPE_HASHPROP) /* * COS/QOS class and quality of service tags. @@ -342,12 +386,13 @@ * External mbuf storage buffer types. */ #define EXT_CLUSTER 1 /* mbuf cluster */ -#define EXT_SFBUF 2 /* sendfile(2)'s sf_bufs */ -#define EXT_JUMBOP 3 /* jumbo cluster 4096 bytes */ +#define EXT_SFBUF 2 /* sendfile(2)'s sf_buf */ +#define EXT_JUMBOP 3 /* jumbo cluster page sized */ #define EXT_JUMBO9 4 /* jumbo cluster 9216 bytes */ #define EXT_JUMBO16 5 /* jumbo cluster 16184 bytes */ #define EXT_PACKET 6 /* mbuf+cluster from packet zone */ #define EXT_MBUF 7 /* external mbuf reference (M_IOVEC) */ +#define EXT_SFBUF_NOCACHE 8 /* sendfile(2)'s sf_buf not to be cached */ #define EXT_VENDOR1 224 /* for vendor-internal use */ #define EXT_VENDOR2 225 /* for vendor-internal use */ @@ -362,14 +407,15 @@ #define EXT_NET_DRV 252 /* custom ext_buf provided by net driver(s) */ #define EXT_MOD_TYPE 253 /* custom module's ext_buf type */ #define EXT_DISPOSABLE 254 /* can throw this buffer away w/page flipping */ -#define EXT_EXTREF 255 /* has externally maintained ref_cnt ptr */ +#define EXT_EXTREF 255 /* has externally maintained ext_cnt ptr */ /* * Flags for external mbuf buffer types. * NB: limited to the lower 24 bits. */ -#define EXT_FLAG_EMBREF 0x000001 /* embedded ref_cnt, notyet */ -#define EXT_FLAG_EXTREF 0x000002 /* external ref_cnt, notyet */ +#define EXT_FLAG_EMBREF 0x000001 /* embedded ext_count */ +#define EXT_FLAG_EXTREF 0x000002 /* external ext_cnt, notyet */ + #define EXT_FLAG_NOFREE 0x000010 /* don't free mbuf to pool, notyet */ #define EXT_FLAG_VENDOR1 0x010000 /* for vendor-internal use */ @@ -392,9 +438,10 @@ "\30EXT_FLAG_EXP4" /* - * Return values for (*ext_free). + * External reference/free functions. */ -#define EXT_FREE_OK 0 /* Normal return */ +void sf_ext_free(void *, void *); +void sf_ext_free_nocache(void *, void *); /* * Flags indicating checksum, segmentation and other offload work to be @@ -404,7 +451,7 @@ * Outbound flags that are set by upper protocol layers requesting lower * layers, or ideally the hardware, to perform these offloading tasks. * For outbound packets this field and its flags can be directly tested - * against if_data.ifi_hwassist. + * against ifnet if_hwassist. */ #define CSUM_IP 0x00000001 /* IP header checksum offload */ #define CSUM_IP_UDP 0x00000002 /* UDP checksum offload */ @@ -426,7 +473,7 @@ #define CSUM_L4_VALID 0x08000000 /* checksum is correct */ #define CSUM_L5_CALC 0x10000000 /* calculated layer 5 csum */ #define CSUM_L5_VALID 0x20000000 /* checksum is correct */ -#define CSUM_COALESED 0x40000000 /* contains merged segments */ +#define CSUM_COALESCED 0x40000000 /* contains merged segments */ /* * CSUM flag description for use with printf(9) %b identifier. @@ -437,7 +484,7 @@ "\12CSUM_IP6_UDP\13CSUM_IP6_TCP\14CSUM_IP6_SCTP\15CSUM_IP6_TSO" \ "\16CSUM_IP6_ISCSI" \ "\31CSUM_L3_CALC\32CSUM_L3_VALID\33CSUM_L4_CALC\34CSUM_L4_VALID" \ - "\35CSUM_L5_CALC\36CSUM_L5_VALID\37CSUM_COALESED" + "\35CSUM_L5_CALC\36CSUM_L5_VALID\37CSUM_COALESCED" /* CSUM flags compatibility mappings. */ #define CSUM_IP_CHECKED CSUM_L3_CALC @@ -456,7 +503,6 @@ #define CSUM_UDP_IPV6 CSUM_IP6_UDP #define CSUM_TCP_IPV6 CSUM_IP6_TCP #define CSUM_SCTP_IPV6 CSUM_IP6_SCTP -#define CSUM_FRAGMENT 0x0 /* Unused */ /* * mbuf types describing the content of the mbuf (including external storage). @@ -478,7 +524,8 @@ #define MT_EXP4 12 /* for experimental use */ #define MT_CONTROL 14 /* extra-data protocol message */ -#define MT_OOBDATA 15 /* expedited data */ +#define MT_EXTCONTROL 15 /* control message with externalized contents */ +#define MT_OOBDATA 16 /* expedited data */ #define MT_NTYPES 16 /* number of mbuf types for mbtypes[] */ #define MT_NOINIT 255 /* Not a type but a flag to allocate @@ -485,14 +532,6 @@ a non-initialized mbuf */ /* - * Compatibility with historic mbuf allocator. - */ -#define MBTOM(how) (how) -#define M_DONTWAIT M_NOWAIT -#define M_TRYWAIT M_WAITOK -#define M_WAIT M_WAITOK - -/* * String names of mbuf-related UMA(9) and malloc(9) types. Exposed to * !_KERNEL so that monitoring tools can look up the zones with * libmemstat(3). @@ -529,10 +568,54 @@ extern uma_zone_t zone_jumbop; extern uma_zone_t zone_jumbo9; extern uma_zone_t zone_jumbo16; -extern uma_zone_t zone_ext_refcnt; +void mb_dupcl(struct mbuf *, struct mbuf *); void mb_free_ext(struct mbuf *); +void m_adj(struct mbuf *, int); +int m_apply(struct mbuf *, int, int, + int (*)(void *, void *, u_int), void *); +int m_append(struct mbuf *, int, c_caddr_t); +void m_cat(struct mbuf *, struct mbuf *); +void m_catpkt(struct mbuf *, struct mbuf *); +int m_clget(struct mbuf *m, int how); +void *m_cljget(struct mbuf *m, int how, int size); +struct mbuf *m_collapse(struct mbuf *, int, int); +void m_copyback(struct mbuf *, int, int, c_caddr_t); +void m_copydata(const struct mbuf *, int, int, caddr_t); +struct mbuf *m_copym(struct mbuf *, int, int, int); +struct mbuf *m_copypacket(struct mbuf *, int); +void m_copy_pkthdr(struct mbuf *, struct mbuf *); +struct mbuf *m_copyup(struct mbuf *, int, int); +struct mbuf *m_defrag(struct mbuf *, int); +void m_demote_pkthdr(struct mbuf *); +void m_demote(struct mbuf *, int, int); +struct mbuf *m_devget(char *, int, int, struct ifnet *, + void (*)(char *, caddr_t, u_int)); +void m_dispose_extcontrolm(struct mbuf *m); +struct mbuf *m_dup(const struct mbuf *, int); +int m_dup_pkthdr(struct mbuf *, const struct mbuf *, int); +void m_extadd(struct mbuf *, caddr_t, u_int, + void (*)(struct mbuf *, void *, void *), void *, void *, + int, int); +u_int m_fixhdr(struct mbuf *); +struct mbuf *m_fragment(struct mbuf *, int, int); +void m_freem(struct mbuf *); +struct mbuf *m_get2(int, int, short, int); +struct mbuf *m_getjcl(int, short, int, int); +struct mbuf *m_getm2(struct mbuf *, int, int, short, int); +struct mbuf *m_getptr(struct mbuf *, int, int *); +u_int m_length(struct mbuf *, struct mbuf **); +int m_mbuftouio(struct uio *, struct mbuf *, int); +void m_move_pkthdr(struct mbuf *, struct mbuf *); int m_pkthdr_init(struct mbuf *, int); +struct mbuf *m_prepend(struct mbuf *, int, int); +void m_print(const struct mbuf *, int); +struct mbuf *m_pulldown(struct mbuf *, int, int, int *); +struct mbuf *m_pullup(struct mbuf *, int); +int m_sanity(struct mbuf *, int); +struct mbuf *m_split(struct mbuf *, int, int); +struct mbuf *m_uiotombuf(struct uio *, int, int, int, int); +struct mbuf *m_unshare(struct mbuf *, int); static __inline int m_gettype(int size) @@ -569,7 +652,7 @@ */ static __inline void m_extaddref(struct mbuf *m, caddr_t buf, u_int size, u_int *ref_cnt, - int (*freef)(struct mbuf *, void *, void *), void *arg1, void *arg2) + void (*freef)(struct mbuf *, void *, void *), void *arg1, void *arg2) { KASSERT(ref_cnt != NULL, ("%s: ref_cnt not provided", __func__)); @@ -577,7 +660,7 @@ atomic_add_int(ref_cnt, 1); m->m_flags |= M_EXT; m->m_ext.ext_buf = buf; - m->m_ext.ref_cnt = ref_cnt; + m->m_ext.ext_cnt = ref_cnt; m->m_data = m->m_ext.ext_buf; m->m_ext.ext_size = size; m->m_ext.ext_free = freef; @@ -622,8 +705,7 @@ * should go away with constant propagation for !MGETHDR. */ static __inline int -m_init(struct mbuf *m, uma_zone_t zone, int size, int how, short type, - int flags) +m_init(struct mbuf *m, int how, short type, int flags) { int error; @@ -633,30 +715,18 @@ m->m_len = 0; m->m_flags = flags; m->m_type = type; - if (flags & M_PKTHDR) { - if ((error = m_pkthdr_init(m, how)) != 0) - return (error); - } + if (flags & M_PKTHDR) + error = m_pkthdr_init(m, how); + else + error = 0; - return (0); + MBUF_PROBE5(m__init, m, how, type, flags, error); + return (error); } static __inline struct mbuf * m_get(int how, short type) { - struct mb_args args; - - args.flags = 0; - args.type = type; - return (uma_zalloc_arg(zone_mbuf, &args, how)); -} - -/* - * XXX This should be deprecated, very little use. - */ -static __inline struct mbuf * -m_getclr(int how, short type) -{ struct mbuf *m; struct mb_args args; @@ -663,8 +733,7 @@ args.flags = 0; args.type = type; m = uma_zalloc_arg(zone_mbuf, &args, how); - if (m != NULL) - bzero(m->m_data, MLEN); + MBUF_PROBE3(m__get, how, type, m); return (m); } @@ -671,86 +740,53 @@ static __inline struct mbuf * m_gethdr(int how, short type) { + struct mbuf *m; struct mb_args args; args.flags = M_PKTHDR; args.type = type; - return (uma_zalloc_arg(zone_mbuf, &args, how)); + m = uma_zalloc_arg(zone_mbuf, &args, how); + MBUF_PROBE3(m__gethdr, how, type, m); + return (m); } static __inline struct mbuf * m_getcl(int how, short type, int flags) { + struct mbuf *m; struct mb_args args; args.flags = flags; args.type = type; - return (uma_zalloc_arg(zone_pack, &args, how)); + m = uma_zalloc_arg(zone_pack, &args, how); + MBUF_PROBE4(m__getcl, how, type, flags, m); + return (m); } -static __inline void -m_clget(struct mbuf *m, int how) -{ - - if (m->m_flags & M_EXT) - printf("%s: %p mbuf already has cluster\n", __func__, m); - m->m_ext.ext_buf = (char *)NULL; - uma_zalloc_arg(zone_clust, m, how); - /* - * On a cluster allocation failure, drain the packet zone and retry, - * we might be able to loosen a few clusters up on the drain. - */ - if ((how & M_NOWAIT) && (m->m_ext.ext_buf == NULL)) { - zone_drain(zone_pack); - uma_zalloc_arg(zone_clust, m, how); - } -} - /* - * m_cljget() is different from m_clget() as it can allocate clusters without - * attaching them to an mbuf. In that case the return value is the pointer - * to the cluster of the requested size. If an mbuf was specified, it gets - * the cluster attached to it and the return value can be safely ignored. - * For size it takes MCLBYTES, MJUMPAGESIZE, MJUM9BYTES, MJUM16BYTES. + * XXX: m_cljset() is a dangerous API. One must attach only a new, + * unreferenced cluster to an mbuf(9). It is not possible to assert + * that, so care can be taken only by users of the API. */ -static __inline void * -m_cljget(struct mbuf *m, int how, int size) -{ - uma_zone_t zone; - - if (m && m->m_flags & M_EXT) - printf("%s: %p mbuf already has cluster\n", __func__, m); - if (m != NULL) - m->m_ext.ext_buf = NULL; - - zone = m_getzone(size); - return (uma_zalloc_arg(zone, m, how)); -} - static __inline void m_cljset(struct mbuf *m, void *cl, int type) { - uma_zone_t zone; int size; switch (type) { case EXT_CLUSTER: size = MCLBYTES; - zone = zone_clust; break; #if MJUMPAGESIZE != MCLBYTES case EXT_JUMBOP: size = MJUMPAGESIZE; - zone = zone_jumbop; break; #endif case EXT_JUMBO9: size = MJUM9BYTES; - zone = zone_jumbo9; break; case EXT_JUMBO16: size = MJUM16BYTES; - zone = zone_jumbo16; break; default: panic("%s: unknown cluster type %d", __func__, type); @@ -761,10 +797,10 @@ m->m_ext.ext_free = m->m_ext.ext_arg1 = m->m_ext.ext_arg2 = NULL; m->m_ext.ext_size = size; m->m_ext.ext_type = type; - m->m_ext.ext_flags = 0; - m->m_ext.ref_cnt = uma_find_refcnt(zone, cl); + m->m_ext.ext_flags = EXT_FLAG_EMBREF; + m->m_ext.ext_count = 1; m->m_flags |= M_EXT; - + MBUF_PROBE3(m__cljset, m, cl, type); } static __inline void @@ -778,7 +814,10 @@ m_clrprotoflags(struct mbuf *m) { - m->m_flags &= ~M_PROTOFLAGS; + while (m) { + m->m_flags &= ~M_PROTOFLAGS; + m = m->m_next; + } } static __inline struct mbuf * @@ -790,6 +829,16 @@ return (m); } +static inline u_int +m_extrefcnt(struct mbuf *m) +{ + + KASSERT(m->m_flags & M_EXT, ("%s: M_EXT missing", __func__)); + + return ((m->m_ext.ext_flags & EXT_FLAG_EMBREF) ? m->m_ext.ext_count : + *m->m_ext.ext_cnt); +} + /* * mbuf, cluster, and external object allocation macros (for compatibility * purposes). @@ -799,8 +848,8 @@ #define MGETHDR(m, how, type) ((m) = m_gethdr((how), (type))) #define MCLGET(m, how) m_clget((m), (how)) #define MEXTADD(m, buf, size, free, arg1, arg2, flags, type) \ - (void )m_extadd((m), (caddr_t)(buf), (size), (free), (arg1), (arg2),\ - (flags), (type), M_NOWAIT) + m_extadd((m), (caddr_t)(buf), (size), (free), (arg1), (arg2), \ + (flags), (type)) #define m_getm(m, len, how, type) \ m_getm2((m), (len), (how), (type), M_PKTHDR) @@ -811,7 +860,7 @@ */ #define M_WRITABLE(m) (!((m)->m_flags & M_RDONLY) && \ (!(((m)->m_flags & M_EXT)) || \ - (*((m)->m_ext.ref_cnt) == 1)) ) \ + (m_extrefcnt(m) == 1))) /* Check if the supplied mbuf has a packet header, or else panic. */ #define M_ASSERTPKTHDR(m) \ @@ -828,41 +877,51 @@ ("%s: attempted use of a free mbuf!", __func__)) /* - * Set the m_data pointer of a newly-allocated mbuf (m_get/MGET) to place an - * object of the specified size at the end of the mbuf, longword aligned. + * Return the address of the start of the buffer associated with an mbuf, + * handling external storage, packet-header mbufs, and regular data mbufs. */ -#define M_ALIGN(m, len) do { \ - KASSERT(!((m)->m_flags & (M_PKTHDR|M_EXT)), \ - ("%s: M_ALIGN not normal mbuf", __func__)); \ - KASSERT((m)->m_data == (m)->m_dat, \ - ("%s: M_ALIGN not a virgin mbuf", __func__)); \ - (m)->m_data += (MLEN - (len)) & ~(sizeof(long) - 1); \ -} while (0) +#define M_START(m) \ + (((m)->m_flags & M_EXT) ? (m)->m_ext.ext_buf : \ + ((m)->m_flags & M_PKTHDR) ? &(m)->m_pktdat[0] : \ + &(m)->m_dat[0]) /* - * As above, for mbufs allocated with m_gethdr/MGETHDR or initialized by - * M_DUP/MOVE_PKTHDR. + * Return the size of the buffer associated with an mbuf, handling external + * storage, packet-header mbufs, and regular data mbufs. */ -#define MH_ALIGN(m, len) do { \ - KASSERT((m)->m_flags & M_PKTHDR && !((m)->m_flags & M_EXT), \ - ("%s: MH_ALIGN not PKTHDR mbuf", __func__)); \ - KASSERT((m)->m_data == (m)->m_pktdat, \ - ("%s: MH_ALIGN not a virgin mbuf", __func__)); \ - (m)->m_data += (MHLEN - (len)) & ~(sizeof(long) - 1); \ -} while (0) +#define M_SIZE(m) \ + (((m)->m_flags & M_EXT) ? (m)->m_ext.ext_size : \ + ((m)->m_flags & M_PKTHDR) ? MHLEN : \ + MLEN) /* - * As above, for mbuf with external storage. + * Set the m_data pointer of a newly allocated mbuf to place an object of the + * specified size at the end of the mbuf, longword aligned. + * + * NB: Historically, we had M_ALIGN(), MH_ALIGN(), and MEXT_ALIGN() as + * separate macros, each asserting that it was called at the proper moment. + * This required callers to themselves test the storage type and call the + * right one. Rather than require callers to be aware of those layout + * decisions, we centralize here. */ -#define MEXT_ALIGN(m, len) do { \ - KASSERT((m)->m_flags & M_EXT, \ - ("%s: MEXT_ALIGN not an M_EXT mbuf", __func__)); \ - KASSERT((m)->m_data == (m)->m_ext.ext_buf, \ - ("%s: MEXT_ALIGN not a virgin mbuf", __func__)); \ - (m)->m_data += ((m)->m_ext.ext_size - (len)) & \ - ~(sizeof(long) - 1); \ -} while (0) +static __inline void +m_align(struct mbuf *m, int len) +{ +#ifdef INVARIANTS + const char *msg = "%s: not a virgin mbuf"; +#endif + int adjust; + KASSERT(m->m_data == M_START(m), (msg, __func__)); + + adjust = M_SIZE(m) - len; + m->m_data += adjust &~ (sizeof(long)-1); +} + +#define M_ALIGN(m, len) m_align(m, len) +#define MH_ALIGN(m, len) m_align(m, len) +#define MEXT_ALIGN(m, len) m_align(m, len) + /* * Compute the amount of space available before the current start of data in * an mbuf. @@ -869,12 +928,13 @@ * * The M_WRITABLE() is a temporary, conservative safety measure: the burden * of checking writability of the mbuf data area rests solely with the caller. + * + * NB: In previous versions, M_LEADINGSPACE() would only check M_WRITABLE() + * for mbufs with external storage. We now allow mbuf-embedded data to be + * read-only as well. */ #define M_LEADINGSPACE(m) \ - ((m)->m_flags & M_EXT ? \ - (M_WRITABLE(m) ? (m)->m_data - (m)->m_ext.ext_buf : 0): \ - (m)->m_flags & M_PKTHDR ? (m)->m_data - (m)->m_pktdat : \ - (m)->m_data - (m)->m_dat) + (M_WRITABLE(m) ? ((m)->m_data - M_START(m)) : 0) /* * Compute the amount of space available after the end of data in an mbuf. @@ -881,12 +941,14 @@ * * The M_WRITABLE() is a temporary, conservative safety measure: the burden * of checking writability of the mbuf data area rests solely with the caller. + * + * NB: In previous versions, M_TRAILINGSPACE() would only check M_WRITABLE() + * for mbufs with external storage. We now allow mbuf-embedded data to be + * read-only as well. */ #define M_TRAILINGSPACE(m) \ - ((m)->m_flags & M_EXT ? \ - (M_WRITABLE(m) ? (m)->m_ext.ext_buf + (m)->m_ext.ext_size \ - - ((m)->m_data + (m)->m_len) : 0) : \ - &(m)->m_dat[MLEN] - ((m)->m_data + (m)->m_len)) + (M_WRITABLE(m) ? \ + ((M_START(m) + M_SIZE(m)) - ((m)->m_data + (m)->m_len)) : 0) /* * Arrange to prepend space of size plen to mbuf m. If a new mbuf must be @@ -928,51 +990,6 @@ extern int max_protohdr; /* Largest protocol header */ extern int nmbclusters; /* Maximum number of clusters */ -struct uio; - -void m_adj(struct mbuf *, int); -void m_align(struct mbuf *, int); -int m_apply(struct mbuf *, int, int, - int (*)(void *, void *, u_int), void *); -int m_append(struct mbuf *, int, c_caddr_t); -void m_cat(struct mbuf *, struct mbuf *); -int m_extadd(struct mbuf *, caddr_t, u_int, - int (*)(struct mbuf *, void *, void *), void *, void *, - int, int, int); -struct mbuf *m_collapse(struct mbuf *, int, int); -void m_copyback(struct mbuf *, int, int, c_caddr_t); -void m_copydata(const struct mbuf *, int, int, caddr_t); -struct mbuf *m_copym(struct mbuf *, int, int, int); -struct mbuf *m_copymdata(struct mbuf *, struct mbuf *, - int, int, int, int); -struct mbuf *m_copypacket(struct mbuf *, int); -void m_copy_pkthdr(struct mbuf *, struct mbuf *); -struct mbuf *m_copyup(struct mbuf *, int, int); -struct mbuf *m_defrag(struct mbuf *, int); -void m_demote(struct mbuf *, int); -struct mbuf *m_devget(char *, int, int, struct ifnet *, - void (*)(char *, caddr_t, u_int)); -struct mbuf *m_dup(struct mbuf *, int); -int m_dup_pkthdr(struct mbuf *, struct mbuf *, int); -u_int m_fixhdr(struct mbuf *); -struct mbuf *m_fragment(struct mbuf *, int, int); -void m_freem(struct mbuf *); -struct mbuf *m_get2(int, int, short, int); -struct mbuf *m_getjcl(int, short, int, int); -struct mbuf *m_getm2(struct mbuf *, int, int, short, int); -struct mbuf *m_getptr(struct mbuf *, int, int *); -u_int m_length(struct mbuf *, struct mbuf **); -int m_mbuftouio(struct uio *, struct mbuf *, int); -void m_move_pkthdr(struct mbuf *, struct mbuf *); -struct mbuf *m_prepend(struct mbuf *, int, int); -void m_print(const struct mbuf *, int); -struct mbuf *m_pulldown(struct mbuf *, int, int, int *); -struct mbuf *m_pullup(struct mbuf *, int); -int m_sanity(struct mbuf *, int); -struct mbuf *m_split(struct mbuf *, int, int); -struct mbuf *m_uiotombuf(struct uio *, int, int, int, int); -struct mbuf *m_unshare(struct mbuf *, int); - /*- * Network packets may have annotations attached by affixing a list of * "packet tags" to the pkthdr structure. Packet tags are dynamically @@ -1060,7 +1077,7 @@ void m_tag_free_default(struct m_tag *); struct m_tag *m_tag_locate(struct mbuf *, u_int32_t, int, struct m_tag *); struct m_tag *m_tag_copy(struct m_tag *, int); -int m_tag_copy_chain(struct mbuf *, struct mbuf *, int); +int m_tag_copy_chain(struct mbuf *, const struct mbuf *, int); void m_tag_delete_nonpersistent(struct mbuf *); /* @@ -1112,7 +1129,7 @@ * Return the next tag in the list of tags associated with an mbuf. */ static __inline struct m_tag * -m_tag_next(struct mbuf *m, struct m_tag *t) +m_tag_next(struct mbuf *m __unused, struct m_tag *t) { return (SLIST_NEXT(t, m_tag_link)); @@ -1159,6 +1176,7 @@ { struct mbuf *n = m->m_next; + MBUF_PROBE1(m__free, m); if ((m->m_flags & (M_PKTHDR|M_NOFREE)) == (M_PKTHDR|M_NOFREE)) m_tag_delete_chain(m, NULL); if (m->m_flags & M_EXT) @@ -1168,7 +1186,7 @@ return (n); } -static int inline +static __inline int rt_m_getfib(struct mbuf *m) { KASSERT(m->m_flags & M_PKTHDR , ("Attempt to get FIB from non header mbuf.")); @@ -1182,8 +1200,15 @@ ((_m)->m_pkthdr.fibnum) = (_fib); \ } while (0) -#endif /* _KERNEL */ +/* flags passed as first argument for "m_ether_tcpip_hash()" */ +#define MBUF_HASHFLAG_L2 (1 << 2) +#define MBUF_HASHFLAG_L3 (1 << 3) +#define MBUF_HASHFLAG_L4 (1 << 4) +/* mbuf hashing helper routines */ +uint32_t m_ether_tcpip_hash_init(void); +uint32_t m_ether_tcpip_hash(const uint32_t, const struct mbuf *, const uint32_t); + #ifdef MBUF_PROFILING void m_profile(struct mbuf *m); #define M_PROFILE(m) m_profile(m) @@ -1191,5 +1216,103 @@ #define M_PROFILE(m) #endif +struct mbufq { + STAILQ_HEAD(, mbuf) mq_head; + int mq_len; + int mq_maxlen; +}; +static inline void +mbufq_init(struct mbufq *mq, int maxlen) +{ + + STAILQ_INIT(&mq->mq_head); + mq->mq_maxlen = maxlen; + mq->mq_len = 0; +} + +static inline struct mbuf * +mbufq_flush(struct mbufq *mq) +{ + struct mbuf *m; + + m = STAILQ_FIRST(&mq->mq_head); + STAILQ_INIT(&mq->mq_head); + mq->mq_len = 0; + return (m); +} + +static inline void +mbufq_drain(struct mbufq *mq) +{ + struct mbuf *m, *n; + + n = mbufq_flush(mq); + while ((m = n) != NULL) { + n = STAILQ_NEXT(m, m_stailqpkt); + m_freem(m); + } +} + +static inline struct mbuf * +mbufq_first(const struct mbufq *mq) +{ + + return (STAILQ_FIRST(&mq->mq_head)); +} + +static inline struct mbuf * +mbufq_last(const struct mbufq *mq) +{ + + return (STAILQ_LAST(&mq->mq_head, mbuf, m_stailqpkt)); +} + +static inline int +mbufq_full(const struct mbufq *mq) +{ + + return (mq->mq_len >= mq->mq_maxlen); +} + +static inline int +mbufq_len(const struct mbufq *mq) +{ + + return (mq->mq_len); +} + +static inline int +mbufq_enqueue(struct mbufq *mq, struct mbuf *m) +{ + + if (mbufq_full(mq)) + return (ENOBUFS); + STAILQ_INSERT_TAIL(&mq->mq_head, m, m_stailqpkt); + mq->mq_len++; + return (0); +} + +static inline struct mbuf * +mbufq_dequeue(struct mbufq *mq) +{ + struct mbuf *m; + + m = STAILQ_FIRST(&mq->mq_head); + if (m) { + STAILQ_REMOVE_HEAD(&mq->mq_head, m_stailqpkt); + m->m_nextpkt = NULL; + mq->mq_len--; + } + return (m); +} + +static inline void +mbufq_prepend(struct mbufq *mq, struct mbuf *m) +{ + + STAILQ_INSERT_HEAD(&mq->mq_head, m, m_stailqpkt); + mq->mq_len++; +} +#endif /* _KERNEL */ #endif /* !_SYS_MBUF_H_ */ From laffer1 at midnightbsd.org Sun Feb 16 17:36:13 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 17:36:13 -0500 (EST) Subject: [Midnightbsd-cvs] src [12379] trunk/sys/sys/module.h: Sync with FreeBSD 11-stable Message-ID: <202002162236.01GMaDwL036015@stargazer.midnightbsd.org> Revision: 12379 http://svnweb.midnightbsd.org/src/?rev=12379 Author: laffer1 Date: 2020-02-16 17:36:13 -0500 (Sun, 16 Feb 2020) Log Message: ----------- Sync with FreeBSD 11-stable Modified Paths: -------------- trunk/sys/sys/module.h Modified: trunk/sys/sys/module.h =================================================================== --- trunk/sys/sys/module.h 2020-02-16 22:35:10 UTC (rev 12378) +++ trunk/sys/sys/module.h 2020-02-16 22:36:13 UTC (rev 12379) @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/sys/module.h 298493 2016-04-22 21:38:37Z emaste $ + * $FreeBSD: stable/11/sys/sys/module.h 331722 2018-03-29 02:50:57Z eadler $ */ #ifndef _SYS_MODULE_H_ @@ -72,7 +72,7 @@ } modspecific_t; /* - * Module dependency declarartion + * Module dependency declaration */ struct mod_depend { int md_ver_minimum; @@ -90,10 +90,19 @@ struct mod_metadata { int md_version; /* structure version MDTV_* */ int md_type; /* type of entry MDT_* */ - void *md_data; /* specific data */ + const void *md_data; /* specific data */ const char *md_cval; /* common string label */ }; +struct mod_pnp_match_info +{ + const char *descr; /* Description of the table */ + const char *bus; /* Name of the bus for this table */ + const void *table; /* Pointer to pnp table */ + int entry_len; /* Length of each entry in the table (may be */ + /* longer than descr describes). */ + int num_entry; /* Number of entries in the table */ +}; #ifdef _KERNEL #include @@ -156,6 +165,44 @@ MODULE_METADATA(_##module##_version, MDT_VERSION, \ &_##module##_version, #module) +/** + * Generic macros to create pnp info hints that modules may export + * to allow external tools to parse their internal device tables + * to make an informed guess about what driver(s) to load. + */ +#define MODULE_PNP_INFO(d, b, unique, t, l, n) \ + static const struct mod_pnp_match_info _module_pnp_##b##_##unique = { \ + .descr = d, \ + .bus = #b, \ + .table = t, \ + .entry_len = l, \ + .num_entry = n \ + }; \ + MODULE_METADATA(_md_##b##_pnpinfo_##unique, MDT_PNP_INFO, \ + &_module_pnp_##b##_##unique, #b); +/** + * descr is a string that describes each entry in the table. The general + * form is (TYPE:pnp_name[/pnp_name];)* + * where TYPE is one of the following: + * U8 uint8_t element + * V8 like U8 and 0xff means match any + * G16 uint16_t element, any value >= matches + * L16 uint16_t element, any value <= matches + * M16 uint16_t element, mask of which of the following fields to use. + * U16 uint16_t element + * V16 like U16 and 0xffff means match any + * U32 uint32_t element + * V32 like U32 and 0xffffffff means match any + * W32 Two 16-bit values with first pnp_name in LSW and second in MSW. + * Z pointer to a string to match exactly + * D like Z, but is the string passed to device_set_descr() + * P A pointer that should be ignored + * E EISA PNP Identifier (in binary, but bus publishes string) + * K Key for whole table. pnp_name=value. must be last, if present. + * + * The pnp_name "#" is reserved for other fields that should be ignored. + */ + extern struct sx modules_sx; #define MOD_XLOCK sx_xlock(&modules_sx) From laffer1 at midnightbsd.org Sun Feb 16 17:37:52 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 17:37:52 -0500 (EST) Subject: [Midnightbsd-cvs] src [12380] trunk/sys/sys/malloc.h: Sync with FreeBSD 11-stable Message-ID: <202002162237.01GMbqvL036104@stargazer.midnightbsd.org> Revision: 12380 http://svnweb.midnightbsd.org/src/?rev=12380 Author: laffer1 Date: 2020-02-16 17:37:51 -0500 (Sun, 16 Feb 2020) Log Message: ----------- Sync with FreeBSD 11-stable Modified Paths: -------------- trunk/sys/sys/malloc.h Modified: trunk/sys/sys/malloc.h =================================================================== --- trunk/sys/sys/malloc.h 2020-02-16 22:36:13 UTC (rev 12379) +++ trunk/sys/sys/malloc.h 2020-02-16 22:37:51 UTC (rev 12380) @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * @(#)malloc.h 8.5 (Berkeley) 5/3/95 - * $FreeBSD: stable/10/sys/sys/malloc.h 328276 2018-01-23 04:37:31Z kp $ + * $FreeBSD: stable/11/sys/sys/malloc.h 331722 2018-03-29 02:50:57Z eadler $ */ #ifndef _SYS_MALLOC_H_ @@ -136,7 +136,7 @@ struct malloc_type type[1] = { \ { NULL, M_MAGIC, shortdesc, NULL } \ }; \ - SYSINIT(type##_init, SI_SUB_KMEM, SI_ORDER_SECOND, malloc_init, \ + SYSINIT(type##_init, SI_SUB_KMEM, SI_ORDER_THIRD, malloc_init, \ type); \ SYSUNINIT(type##_uninit, SI_SUB_KMEM, SI_ORDER_ANY, \ malloc_uninit, type) @@ -148,9 +148,6 @@ MALLOC_DECLARE(M_DEVBUF); MALLOC_DECLARE(M_TEMP); -MALLOC_DECLARE(M_IP6OPT); /* for INET6 */ -MALLOC_DECLARE(M_IP6NDP); /* for INET6 */ - /* * Deprecated macro versions of not-quite-malloc() and free(). */ @@ -175,11 +172,14 @@ void contigfree(void *addr, unsigned long size, struct malloc_type *type); void *contigmalloc(unsigned long size, struct malloc_type *type, int flags, vm_paddr_t low, vm_paddr_t high, unsigned long alignment, - vm_paddr_t boundary) __malloc_like; + vm_paddr_t boundary) __malloc_like __result_use_check + __alloc_size(1) __alloc_align(6); void free(void *addr, struct malloc_type *type); -void *malloc(unsigned long size, struct malloc_type *type, int flags) __malloc_like; +void *malloc(unsigned long size, struct malloc_type *type, int flags) + __malloc_like __result_use_check __alloc_size(1); void *mallocarray(size_t nmemb, size_t size, struct malloc_type *type, - int flags) __malloc_like __result_use_check; + int flags) __malloc_like __result_use_check + __alloc_size2(1, 2); void malloc_init(void *); int malloc_last_fail(void); void malloc_type_allocated(struct malloc_type *type, unsigned long size); @@ -187,9 +187,9 @@ void malloc_type_list(malloc_type_list_func_t *, void *); void malloc_uninit(void *); void *realloc(void *addr, unsigned long size, struct malloc_type *type, - int flags); + int flags) __result_use_check __alloc_size(2); void *reallocf(void *addr, unsigned long size, struct malloc_type *type, - int flags); + int flags) __result_use_check __alloc_size(2); struct malloc_type *malloc_desc2type(const char *desc); From laffer1 at midnightbsd.org Sun Feb 16 17:39:32 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 17:39:32 -0500 (EST) Subject: [Midnightbsd-cvs] src [12381] trunk/sys/sys/lockstat.h: Sync with FreeBSD 11-stable Message-ID: <202002162239.01GMdWO2036201@stargazer.midnightbsd.org> Revision: 12381 http://svnweb.midnightbsd.org/src/?rev=12381 Author: laffer1 Date: 2020-02-16 17:39:31 -0500 (Sun, 16 Feb 2020) Log Message: ----------- Sync with FreeBSD 11-stable Modified Paths: -------------- trunk/sys/sys/lockstat.h Modified: trunk/sys/sys/lockstat.h =================================================================== --- trunk/sys/sys/lockstat.h 2020-02-16 22:37:51 UTC (rev 12380) +++ trunk/sys/sys/lockstat.h 2020-02-16 22:39:31 UTC (rev 12381) @@ -23,190 +23,98 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/sys/lockstat.h 285759 2015-07-21 17:16:37Z markj $ + * $FreeBSD: stable/11/sys/sys/lockstat.h 334437 2018-05-31 15:58:28Z mjg $ */ /* * DTrace lockstat provider definitions - * */ -#ifndef _SYS_LOCKSTAT_H +#ifndef _SYS_LOCKSTAT_H #define _SYS_LOCKSTAT_H -#ifdef _KERNEL +#ifdef _KERNEL -/* - * Spin Locks - */ -#define LS_MTX_SPIN_LOCK_ACQUIRE 0 -#define LS_MTX_SPIN_UNLOCK_RELEASE 1 -#define LS_MTX_SPIN_LOCK_SPIN 2 +#include +#include +#include -/* - * Adaptive Locks - */ -#define LS_MTX_LOCK_ACQUIRE 3 -#define LS_MTX_UNLOCK_RELEASE 4 -#define LS_MTX_LOCK_SPIN 5 -#define LS_MTX_LOCK_BLOCK 6 -#define LS_MTX_TRYLOCK_ACQUIRE 7 +SDT_PROVIDER_DECLARE(lockstat); -/* - * Reader/Writer Locks - */ -#define LS_RW_RLOCK_ACQUIRE 8 -#define LS_RW_RUNLOCK_RELEASE 9 -#define LS_RW_WLOCK_ACQUIRE 10 -#define LS_RW_WUNLOCK_RELEASE 11 -#define LS_RW_RLOCK_SPIN 12 -#define LS_RW_RLOCK_BLOCK 13 -#define LS_RW_WLOCK_SPIN 14 -#define LS_RW_WLOCK_BLOCK 15 -#define LS_RW_TRYUPGRADE_UPGRADE 16 -#define LS_RW_DOWNGRADE_DOWNGRADE 17 +SDT_PROBE_DECLARE(lockstat, , , adaptive__acquire); +SDT_PROBE_DECLARE(lockstat, , , adaptive__release); +SDT_PROBE_DECLARE(lockstat, , , adaptive__spin); +SDT_PROBE_DECLARE(lockstat, , , adaptive__block); -/* - * Shared/Exclusive Locks - */ -#define LS_SX_SLOCK_ACQUIRE 18 -#define LS_SX_SUNLOCK_RELEASE 19 -#define LS_SX_XLOCK_ACQUIRE 20 -#define LS_SX_XUNLOCK_RELEASE 21 -#define LS_SX_SLOCK_SPIN 22 -#define LS_SX_SLOCK_BLOCK 23 -#define LS_SX_XLOCK_SPIN 24 -#define LS_SX_XLOCK_BLOCK 25 -#define LS_SX_TRYUPGRADE_UPGRADE 26 -#define LS_SX_DOWNGRADE_DOWNGRADE 27 +SDT_PROBE_DECLARE(lockstat, , , spin__acquire); +SDT_PROBE_DECLARE(lockstat, , , spin__release); +SDT_PROBE_DECLARE(lockstat, , , spin__spin); -/* - * Thread Locks - */ -#define LS_THREAD_LOCK_SPIN 28 +SDT_PROBE_DECLARE(lockstat, , , rw__acquire); +SDT_PROBE_DECLARE(lockstat, , , rw__release); +SDT_PROBE_DECLARE(lockstat, , , rw__block); +SDT_PROBE_DECLARE(lockstat, , , rw__spin); +SDT_PROBE_DECLARE(lockstat, , , rw__upgrade); +SDT_PROBE_DECLARE(lockstat, , , rw__downgrade); -/* - * Lockmanager Locks - * According to locking(9) Lockmgr locks are "Largely deprecated" - * so no support for these have been added in the lockstat provider. - */ +SDT_PROBE_DECLARE(lockstat, , , sx__acquire); +SDT_PROBE_DECLARE(lockstat, , , sx__release); +SDT_PROBE_DECLARE(lockstat, , , sx__block); +SDT_PROBE_DECLARE(lockstat, , , sx__spin); +SDT_PROBE_DECLARE(lockstat, , , sx__upgrade); +SDT_PROBE_DECLARE(lockstat, , , sx__downgrade); -#define LS_NPROBES 29 +SDT_PROBE_DECLARE(lockstat, , , thread__spin); -#define LS_MTX_LOCK "mtx_lock" -#define LS_MTX_UNLOCK "mtx_unlock" -#define LS_MTX_SPIN_LOCK "mtx_lock_spin" -#define LS_MTX_SPIN_UNLOCK "mtx_unlock_spin" -#define LS_MTX_TRYLOCK "mtx_trylock" -#define LS_RW_RLOCK "rw_rlock" -#define LS_RW_WLOCK "rw_wlock" -#define LS_RW_RUNLOCK "rw_runlock" -#define LS_RW_WUNLOCK "rw_wunlock" -#define LS_RW_TRYUPGRADE "rw_try_upgrade" -#define LS_RW_DOWNGRADE "rw_downgrade" -#define LS_SX_SLOCK "sx_slock" -#define LS_SX_XLOCK "sx_xlock" -#define LS_SX_SUNLOCK "sx_sunlock" -#define LS_SX_XUNLOCK "sx_xunlock" -#define LS_SX_TRYUPGRADE "sx_try_upgrade" -#define LS_SX_DOWNGRADE "sx_downgrade" -#define LS_THREAD_LOCK "thread_lock" +#define LOCKSTAT_WRITER 0 +#define LOCKSTAT_READER 1 -#define LS_ACQUIRE "acquire" -#define LS_RELEASE "release" -#define LS_SPIN "spin" -#define LS_BLOCK "block" -#define LS_UPGRADE "upgrade" -#define LS_DOWNGRADE "downgrade" +extern volatile int lockstat_enabled; -#define LS_TYPE_ADAPTIVE "adaptive" -#define LS_TYPE_SPIN "spin" -#define LS_TYPE_THREAD "thread" -#define LS_TYPE_RW "rw" -#define LS_TYPE_SX "sx" +#ifdef KDTRACE_HOOKS -#define LSA_ACQUIRE (LS_TYPE_ADAPTIVE "-" LS_ACQUIRE) -#define LSA_RELEASE (LS_TYPE_ADAPTIVE "-" LS_RELEASE) -#define LSA_SPIN (LS_TYPE_ADAPTIVE "-" LS_SPIN) -#define LSA_BLOCK (LS_TYPE_ADAPTIVE "-" LS_BLOCK) -#define LSS_ACQUIRE (LS_TYPE_SPIN "-" LS_ACQUIRE) -#define LSS_RELEASE (LS_TYPE_SPIN "-" LS_RELEASE) -#define LSS_SPIN (LS_TYPE_SPIN "-" LS_SPIN) -#define LSR_ACQUIRE (LS_TYPE_RW "-" LS_ACQUIRE) -#define LSR_RELEASE (LS_TYPE_RW "-" LS_RELEASE) -#define LSR_BLOCK (LS_TYPE_RW "-" LS_BLOCK) -#define LSR_SPIN (LS_TYPE_RW "-" LS_SPIN) -#define LSR_UPGRADE (LS_TYPE_RW "-" LS_UPGRADE) -#define LSR_DOWNGRADE (LS_TYPE_RW "-" LS_DOWNGRADE) -#define LSX_ACQUIRE (LS_TYPE_SX "-" LS_ACQUIRE) -#define LSX_RELEASE (LS_TYPE_SX "-" LS_RELEASE) -#define LSX_BLOCK (LS_TYPE_SX "-" LS_BLOCK) -#define LSX_SPIN (LS_TYPE_SX "-" LS_SPIN) -#define LSX_UPGRADE (LS_TYPE_SX "-" LS_UPGRADE) -#define LSX_DOWNGRADE (LS_TYPE_SX "-" LS_DOWNGRADE) -#define LST_SPIN (LS_TYPE_THREAD "-" LS_SPIN) +#define LOCKSTAT_RECORD0(probe, lp) \ + SDT_PROBE1(lockstat, , , probe, lp) -/* - * The following must match the type definition of dtrace_probe. It is - * defined this way to avoid having to rely on CDDL code. - */ -struct lock_object; -extern uint32_t lockstat_probemap[LS_NPROBES]; -typedef void (*lockstat_probe_func_t)(uint32_t, uintptr_t arg0, uintptr_t arg1, - uintptr_t arg2, uintptr_t arg3, uintptr_t arg4); -extern lockstat_probe_func_t lockstat_probe_func; -extern uint64_t lockstat_nsecs(struct lock_object *); -extern int lockstat_enabled; +#define LOCKSTAT_RECORD1(probe, lp, arg1) \ + SDT_PROBE2(lockstat, , , probe, lp, arg1) -#ifdef KDTRACE_HOOKS -/* - * Macros to record lockstat probes. - */ -#define LOCKSTAT_RECORD4(probe, lp, arg1, arg2, arg3, arg4) do { \ - uint32_t id; \ - \ - if ((id = lockstat_probemap[(probe)])) \ - (*lockstat_probe_func)(id, (uintptr_t)(lp), (arg1), (arg2), \ - (arg3), (arg4)); \ -} while (0) +#define LOCKSTAT_RECORD2(probe, lp, arg1, arg2) \ + SDT_PROBE3(lockstat, , , probe, lp, arg1, arg2) -#define LOCKSTAT_RECORD(probe, lp, arg1) \ - LOCKSTAT_RECORD4(probe, lp, arg1, 0, 0, 0) +#define LOCKSTAT_RECORD3(probe, lp, arg1, arg2, arg3) \ + SDT_PROBE4(lockstat, , , probe, lp, arg1, arg2, arg3) -#define LOCKSTAT_RECORD0(probe, lp) \ - LOCKSTAT_RECORD4(probe, lp, 0, 0, 0, 0) +#define LOCKSTAT_RECORD4(probe, lp, arg1, arg2, arg3, arg4) \ + SDT_PROBE5(lockstat, , , probe, lp, arg1, arg2, arg3, arg4) -#define LOCKSTAT_RECORD1(probe, lp, arg1) \ - LOCKSTAT_RECORD4(probe, lp, arg1, 0, 0, 0) +#define LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(probe, lp, c, wt, f, l) do { \ + lock_profile_obtain_lock_success(&(lp)->lock_object, c, wt, f, l); \ + LOCKSTAT_RECORD0(probe, lp); \ +} while (0) -#define LOCKSTAT_RECORD2(probe, lp, arg1, arg2) \ - LOCKSTAT_RECORD4(probe, lp, arg1, arg2, 0, 0) +#define LOCKSTAT_PROFILE_OBTAIN_RWLOCK_SUCCESS(probe, lp, c, wt, f, l, a) do { \ + lock_profile_obtain_lock_success(&(lp)->lock_object, c, wt, f, l); \ + LOCKSTAT_RECORD1(probe, lp, a); \ +} while (0) -#define LOCKSTAT_RECORD3(probe, lp, arg1, arg2, arg3) \ - LOCKSTAT_RECORD4(probe, lp, arg1, arg2, arg3, 0) - -#define LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(probe, lp, c, wt, f, l) do { \ - uint32_t id; \ - \ - lock_profile_obtain_lock_success(&(lp)->lock_object, c, wt, f, l); \ - if ((id = lockstat_probemap[(probe)])) \ - (*lockstat_probe_func)(id, (uintptr_t)(lp), 0, 0, 0, 0); \ +#define LOCKSTAT_PROFILE_RELEASE_LOCK(probe, lp) do { \ + lock_profile_release_lock(&(lp)->lock_object); \ + LOCKSTAT_RECORD0(probe, lp); \ } while (0) -#define LOCKSTAT_PROFILE_RELEASE_LOCK(probe, lp) do { \ - uint32_t id; \ - \ - lock_profile_release_lock(&(lp)->lock_object); \ - if ((id = lockstat_probemap[(probe)])) \ - (*lockstat_probe_func)(id, (uintptr_t)(lp), 0, 0, 0, 0); \ +#define LOCKSTAT_PROFILE_RELEASE_RWLOCK(probe, lp, a) do { \ + lock_profile_release_lock(&(lp)->lock_object); \ + LOCKSTAT_RECORD1(probe, lp, a); \ } while (0) -#define LOCKSTAT_WRITER 0 -#define LOCKSTAT_READER 1 +#define LOCKSTAT_PROFILE_ENABLED(probe) __predict_false(lockstat_enabled) -#else /* !KDTRACE_HOOKS */ +struct lock_object; +uint64_t lockstat_nsecs(struct lock_object *); -#define LOCKSTAT_RECORD(probe, lp, arg1) +#else /* !KDTRACE_HOOKS */ + #define LOCKSTAT_RECORD0(probe, lp) #define LOCKSTAT_RECORD1(probe, lp, arg1) #define LOCKSTAT_RECORD2(probe, lp, arg1, arg2) @@ -216,11 +124,18 @@ #define LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(probe, lp, c, wt, f, l) \ lock_profile_obtain_lock_success(&(lp)->lock_object, c, wt, f, l) +#define LOCKSTAT_PROFILE_OBTAIN_RWLOCK_SUCCESS(probe, lp, c, wt, f, l, a) \ + LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(probe, lp, c, wt, f, l) + #define LOCKSTAT_PROFILE_RELEASE_LOCK(probe, lp) \ lock_profile_release_lock(&(lp)->lock_object) -#endif /* !KDTRACE_HOOKS */ +#define LOCKSTAT_PROFILE_RELEASE_RWLOCK(probe, lp, a) \ + LOCKSTAT_PROFILE_RELEASE_LOCK(probe, lp) -#endif /* _KERNEL */ +#define LOCKSTAT_PROFILE_ENABLED(probe) 0 -#endif /* _SYS_LOCKSTAT_H */ +#endif /* !KDTRACE_HOOKS */ + +#endif /* _KERNEL */ +#endif /* _SYS_LOCKSTAT_H */ From laffer1 at midnightbsd.org Sun Feb 16 17:39:47 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 17:39:47 -0500 (EST) Subject: [Midnightbsd-cvs] src [12382] trunk/sys/sys/lockmgr.h: Sync with FreeBSD 11-stable Message-ID: <202002162239.01GMdl3S036254@stargazer.midnightbsd.org> Revision: 12382 http://svnweb.midnightbsd.org/src/?rev=12382 Author: laffer1 Date: 2020-02-16 17:39:47 -0500 (Sun, 16 Feb 2020) Log Message: ----------- Sync with FreeBSD 11-stable Modified Paths: -------------- trunk/sys/sys/lockmgr.h Modified: trunk/sys/sys/lockmgr.h =================================================================== --- trunk/sys/sys/lockmgr.h 2020-02-16 22:39:31 UTC (rev 12381) +++ trunk/sys/sys/lockmgr.h 2020-02-16 22:39:47 UTC (rev 12382) @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * - * $FreeBSD: stable/10/sys/sys/lockmgr.h 274606 2014-11-16 23:02:32Z kib $ + * $FreeBSD: stable/11/sys/sys/lockmgr.h 331722 2018-03-29 02:50:57Z eadler $ */ #ifndef _SYS_LOCKMGR_H_ @@ -69,6 +69,10 @@ */ int __lockmgr_args(struct lock *lk, u_int flags, struct lock_object *ilk, const char *wmesg, int prio, int timo, const char *file, int line); +int lockmgr_lock_fast_path(struct lock *lk, u_int flags, + struct lock_object *ilk, const char *file, int line); +int lockmgr_unlock_fast_path(struct lock *lk, u_int flags, + struct lock_object *ilk); #if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) void _lockmgr_assert(const struct lock *lk, int what, const char *file, int line); #endif @@ -160,6 +164,7 @@ #define LK_SLEEPFAIL 0x000800 #define LK_TIMELOCK 0x001000 #define LK_NODDLKTREAT 0x002000 +#define LK_VNHELD 0x004000 /* * Operations for lockmgr(). From laffer1 at midnightbsd.org Sun Feb 16 17:40:03 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 17:40:03 -0500 (EST) Subject: [Midnightbsd-cvs] src [12383] trunk/sys/sys/loginclass.h: Sync with FreeBSD 11-stable Message-ID: <202002162240.01GMe3pQ036618@stargazer.midnightbsd.org> Revision: 12383 http://svnweb.midnightbsd.org/src/?rev=12383 Author: laffer1 Date: 2020-02-16 17:40:02 -0500 (Sun, 16 Feb 2020) Log Message: ----------- Sync with FreeBSD 11-stable Modified Paths: -------------- trunk/sys/sys/loginclass.h Modified: trunk/sys/sys/loginclass.h =================================================================== --- trunk/sys/sys/loginclass.h 2020-02-16 22:39:47 UTC (rev 12382) +++ trunk/sys/sys/loginclass.h 2020-02-16 22:40:02 UTC (rev 12383) @@ -1,3 +1,4 @@ +/* $MidnightBSD$ */ /*- * Copyright (c) 2011 The FreeBSD Foundation * All rights reserved. @@ -26,7 +27,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $MidnightBSD$ + * $FreeBSD: stable/11/sys/sys/loginclass.h 331722 2018-03-29 02:50:57Z eadler $ */ #ifndef _SYS_LOGINCLASS_H_ @@ -48,6 +49,7 @@ void loginclass_free(struct loginclass *lc); struct loginclass *loginclass_find(const char *name); void loginclass_racct_foreach(void (*callback)(struct racct *racct, - void *arg2, void *arg3), void *arg2, void *arg3); + void *arg2, void *arg3), void (*pre)(void), void (*post)(void), + void *arg2, void *arg3); #endif /* !_SYS_LOGINCLASS_H_ */ From laffer1 at midnightbsd.org Sun Feb 16 17:40:36 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 17:40:36 -0500 (EST) Subject: [Midnightbsd-cvs] src [12384] trunk/sys/sys/lock.h: Sync with FreeBSD 11-stable Message-ID: <202002162240.01GMeaJe037002@stargazer.midnightbsd.org> Revision: 12384 http://svnweb.midnightbsd.org/src/?rev=12384 Author: laffer1 Date: 2020-02-16 17:40:35 -0500 (Sun, 16 Feb 2020) Log Message: ----------- Sync with FreeBSD 11-stable Modified Paths: -------------- trunk/sys/sys/lock.h Modified: trunk/sys/sys/lock.h =================================================================== --- trunk/sys/sys/lock.h 2020-02-16 22:40:02 UTC (rev 12383) +++ trunk/sys/sys/lock.h 2020-02-16 22:40:35 UTC (rev 12384) @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * from BSDI Id: mutex.h,v 2.7.2.35 2000/04/27 03:10:26 cp - * $FreeBSD: stable/10/sys/sys/lock.h 323870 2017-09-21 19:24:11Z marius $ + * $FreeBSD: stable/11/sys/sys/lock.h 331722 2018-03-29 02:50:57Z eadler $ */ #ifndef _SYS_LOCK_H_ @@ -35,6 +35,7 @@ #include #include +#include struct lock_list_entry; struct thread; @@ -125,7 +126,8 @@ * calling conventions for this debugging code in modules so that modules can * work with both debug and non-debug kernels. */ -#if defined(KLD_MODULE) || defined(WITNESS) || defined(INVARIANTS) || defined(INVARIANT_SUPPORT) || defined(KTR) || defined(LOCK_PROFILING) +#if defined(KLD_MODULE) || defined(WITNESS) || defined(INVARIANTS) || \ + defined(INVARIANT_SUPPORT) || defined(LOCK_PROFILING) || defined(KTR) #define LOCK_DEBUG 1 #else #define LOCK_DEBUG 0 @@ -136,9 +138,13 @@ * operations. Otherwise, use default values to avoid the unneeded bloat. */ #if LOCK_DEBUG > 0 +#define LOCK_FILE_LINE_ARG_DEF , const char *file, int line +#define LOCK_FILE_LINE_ARG , file, line #define LOCK_FILE __FILE__ #define LOCK_LINE __LINE__ #else +#define LOCK_FILE_LINE_ARG_DEF +#define LOCK_FILE_LINE_ARG #define LOCK_FILE NULL #define LOCK_LINE 0 #endif @@ -154,9 +160,14 @@ * file - file name * line - line number */ +#if LOCK_DEBUG > 0 #define LOCK_LOG_TEST(lo, flags) \ (((flags) & LOP_QUIET) == 0 && ((lo)->lo_flags & LO_QUIET) == 0) +#else +#define LOCK_LOG_TEST(lo, flags) 0 +#endif + #define LOCK_LOG_LOCK(opname, lo, flags, recurse, file, line) do { \ if (LOCK_LOG_TEST((lo), (flags))) \ CTR6(KTR_LOCK, opname " (%s) %s %p r = %d at %s:%d", \ @@ -179,7 +190,7 @@ #define LOCK_LOG_DESTROY(lo, flags) LOCK_LOG_INIT(lo, flags) -#define lock_initalized(lo) ((lo)->lo_flags & LO_INITIALIZED) +#define lock_initialized(lo) ((lo)->lo_flags & LO_INITIALIZED) /* * Helpful macros for quickly coming up with assertions with informative @@ -202,9 +213,7 @@ extern struct lock_class *lock_classes[]; struct lock_delay_config { - u_int initial; - u_int step; - u_int min; + u_int base; u_int max; }; @@ -215,19 +224,32 @@ }; static inline void -lock_delay_arg_init(struct lock_delay_arg *la, struct lock_delay_config *lc) { +lock_delay_arg_init(struct lock_delay_arg *la, struct lock_delay_config *lc) +{ la->config = lc; - la->delay = 0; + la->delay = lc->base; la->spin_cnt = 0; } +#define lock_delay_spin(n) do { \ + u_int _i; \ + \ + for (_i = (n); _i > 0; _i--) \ + cpu_spinwait(); \ +} while (0) + #define LOCK_DELAY_SYSINIT(func) \ SYSINIT(func##_ld, SI_SUB_LOCK, SI_ORDER_ANY, func, NULL) +#define LOCK_DELAY_SYSINIT_DEFAULT(lc) \ + SYSINIT(lock_delay_##lc##_ld, SI_SUB_LOCK, SI_ORDER_ANY, \ + lock_delay_default_init, &lc) + void lock_init(struct lock_object *, struct lock_class *, const char *, const char *, int); void lock_destroy(struct lock_object *); void lock_delay(struct lock_delay_arg *); +void lock_delay_default_init(struct lock_delay_config *); void spinlock_enter(void); void spinlock_exit(void); void witness_init(struct lock_object *, const char *); From laffer1 at midnightbsd.org Sun Feb 16 17:42:27 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 17:42:27 -0500 (EST) Subject: [Midnightbsd-cvs] src [12385] trunk/sys/sys/iov.h: Sync with FreeBSD 11-stable Message-ID: <202002162242.01GMgR39037105@stargazer.midnightbsd.org> Revision: 12385 http://svnweb.midnightbsd.org/src/?rev=12385 Author: laffer1 Date: 2020-02-16 17:42:27 -0500 (Sun, 16 Feb 2020) Log Message: ----------- Sync with FreeBSD 11-stable Added Paths: ----------- trunk/sys/sys/iov.h Added: trunk/sys/sys/iov.h =================================================================== --- trunk/sys/sys/iov.h (rev 0) +++ trunk/sys/sys/iov.h 2020-02-16 22:42:27 UTC (rev 12385) @@ -0,0 +1,258 @@ +/* $MidnightBSD$ */ +/*- + * Copyright (c) 2013-2015 Sandvine Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: stable/11/sys/sys/iov.h 296865 2016-03-14 17:41:17Z rstone $ + */ + +#ifndef _SYS_IOV_H_ +#define _SYS_IOV_H_ + +#include + +#define PF_CONFIG_NAME "PF" +#define VF_SCHEMA_NAME "VF" + +#define VF_PREFIX "VF-" +#define VF_PREFIX_LEN 3 +#define VF_NUM_LEN 5 /* The maximum VF num is 65535. */ +#define VF_MAX_NAME (VF_PREFIX_LEN + VF_NUM_LEN + 1) + +#define DRIVER_CONFIG_NAME "DRIVER" +#define IOV_CONFIG_NAME "IOV" + +#define TYPE_SCHEMA_NAME "TYPE" +#define DEFAULT_SCHEMA_NAME "DEFAULT" +#define REQUIRED_SCHEMA_NAME "REQUIRED" + +/* + * Because each PF device is expected to expose a unique set of possible + * configurations, the SR-IOV infrastructure dynamically queries the PF + * driver for its capabilities. These capabilities are exposed to userland + * with a configuration schema. The schema is exported from the kernel as a + * packed nvlist. See nv(3) for the details of the nvlist API. The expected + * format of the nvlist is: + * + * BASIC RULES + * 1) All keys are case-insensitive. + * 2) No keys that are not specified below may exist at any level of the + * schema. + * 3) All keys are mandatory unless explicitly documented as optional. If a + * key is mandatory then the associated value is also mandatory. + * 4) Order of keys is irrelevant. + * + * TOP LEVEL + * 1) There must be a top-level key with the name PF_CONFIG_NAME. The value + * associated with this key is a nvlist that follows the device schema + * node format. The parameters in this node specify the configuration + * parameters that may be applied to a PF. + * 2) There must be a top-level key with the name VF_SCHEMA_NAME. The value + * associated with this key is a nvlist that follows the device schema + * node format. The parameters in this node specify the configuration + * parameters that may be applied to a VF. + * + * DEVICE SCHEMA NODE + * 1) There must be a key with the name DRIVER_CONFIG_NAME. The value + * associated with this key is a nvlist that follows the device/subsystem + * schema node format. The parameters in this node specify the + * configuration parameters that are specific to a particular device + * driver. + * 2) There must be a key with the name IOV_CONFIG_NAME. The value associated + * with this key is an nvlist that follows the device/subsystem schema node + * format. The parameters in this node specify the configuration + * parameters that are applied by the SR-IOV infrastructure. + * + * DEVICE/SUBSYSTEM SCHEMA NODE + * 1) All keys in the device/subsystem schema node are optional. + * 2) Each key specifies the name of a valid configuration parameter that may + * be applied to the device/subsystem combination specified by this node. + * The value associated with the key specifies the format of valid + * configuration values, and must be a nvlist in parameter schema node + * format. + * + * PARAMETER SCHEMA NODE + * 1) The parameter schema node must contain a key with the name + * TYPE_SCHEMA_NAME. The value associated with this key must be a string. + * This string specifies the type of value that the parameter specified by + * this node must take. The string must have one of the following values: + * - "bool" - The configuration value must be a boolean. + * - "mac-addr" - The configuration value must be a binary value. In + * addition, the value must be exactly 6 bytes long and + * the value must not be a multicast or broadcast mac. + * - "uint8_t" - The configuration value must be a integer value in + * the range [0, UINT8_MAX]. + * - "uint16_t" - The configuration value must be a integer value in + * the range [0, UINT16_MAX]. + * - "uint32_t" - The configuration value must be a integer value in + * the range [0, UINT32_MAX]. + * - "uint64_t" - The configuration value must be a integer value in + * the range [0, UINT64_MAX]. + * 2) The parameter schema may contain a key with the name + * REQUIRED_SCHEMA_NAME. This key is optional. If this key is present, the + * value associated with it must have a boolean type. If the value is true, + * then the parameter specified by this schema is a required parameter. All + * valid configurations must include all required parameters. + * 3) The parameter schema may contain a key with the name DEFAULT_SCHEMA_NAME. + * This key is optional. This key must not be present if the parameter + * specified by this schema is required. If this key is present, the value + * associated with the parent key must follow all restrictions specified by + * the type specified by this schema. If a configuration does not supply a + * value for the parameter specified by this schema, then the kernel will + * apply the value associated with this key in its place. + * + * The following is an example of a valid schema, as printed by nvlist_dump. + * Keys are printed followed by the type of the value in parantheses. The + * value is displayed following a colon. The indentation level reflects the + * level of nesting of nvlists. String values are displayed between [] + * brackets. Binary values are shown with the length of the binary value (in + * bytes) followed by the actual binary values. + * + * PF (NVLIST): + * IOV (NVLIST): + * num_vfs (NVLIST): + * type (STRING): [uint16_t] + * required (BOOL): TRUE + * device (NVLIST): + * type (STRING): [string] + * required (BOOL): TRUE + * DRIVER (NVLIST): + * VF (NVLIST): + * IOV (NVLIST): + * passthrough (NVLIST): + * type (STRING): [bool] + * default (BOOL): FALSE + * DRIVER (NVLIST): + * mac-addr (NVLIST): + * type (STRING): [mac-addr] + * default (BINARY): 6 000000000000 + * vlan (NVLIST): + * type (STRING): [uint16_t] + * spoof-check (NVLIST): + * type (STRING): [bool] + * default (BOOL): TRUE + * allow-set-mac (NVLIST): + * type (STRING): [bool] + * default (BOOL): FALSE + */ +struct pci_iov_schema +{ + void *schema; + size_t len; + int error; +}; + +/* + * SR-IOV configuration is passed to the kernel as a packed nvlist. See nv(3) + * for the details of the nvlist API. The expected format of the nvlist is: + * + * BASIC RULES + * 1) All keys are case-insensitive. + * 2) No keys that are not specified below may exist at any level of the + * config nvlist. + * 3) Unless otherwise specified, all keys are optional. It should go without + * saying a key being mandatory is transitive: that is, if a key is + * specified to contain a sub-nodes that contains a mandatory key, then + * the outer key is implicitly mandatory. If a key is mandatory then the + * associated value is also mandatory. + * 4) Order of keys is irrelevant. + * + * TOP LEVEL OF CONFIG NVLIST + * 1) All keys specified in this section are mandatory. + * 2) There must be a top-level key with the name PF_CONFIG_NAME. The value + * associated is an nvlist that follows the "device node" format. The + * parameters in this node specify parameters that apply to the PF. + * 3) For every VF being configured (this is set via the "num_vfs" parameter + * in the PF section), there must be a top-level key whose name is VF_PREFIX + * immediately followed by the index of the VF as a decimal integer. For + * example, this would be VF-0 for the first VF. VFs are numbered starting + * from 0. The value associated with this key follows the "device node" + * format. The parameters in this node specify configuration that applies + * to the VF specified in the key. Leading zeros are not permitted in VF + * index. Configuration for the second VF must be specified in a node with + * the key VF-1. VF-01 is not a valid key. + * + * DEVICE NODES + * 1) All keys specified in this section are mandatory. + * 2) The device node must contain a key with the name DRIVER_CONFIG_NAME. The + * value associated with this key is an nvlist following the subsystem node + * format. The parameters in this key specify configuration that is specific + * to a particular device driver. + * 3) The device node must contain a key with the name IOV_CONFIG_NAME. The + * value associated with this key is an nvlist following the subsystem node + * format. The parameters in this key specify configuration that is consumed + * by the SR-IOV infrastructure. + * + * SUBSYSTEM NODES + * 1) A subsystem node specifies configuration parameters that apply to a + * particular subsystem (driver or infrastructure) of a particular device + * (PF or individual VF). + * Note: We will refer to the section of the configuration schema that + * specifies the parameters for this subsystem and device + * configuration as the device/subystem schema. + * 2) The subsystem node must contain only keys that correspond to parameters + * that are specified in the device/subsystem schema. + * 3) Every parameter specified as required in the device/subsystem schema is + * a mandatory key in the subsystem node. + * Note: All parameters that are not required in device/subsystem schema are + * optional keys. In particular, any parameter specified to have a + * default value in the device/subsystem schema is optional. The + * kernel is responsible for applying default values. + * 4) The value of every parameter in the device node must conform to the + * restrictions of the type specified for that parameter in the device/ + * subsystem schema. + * + * The following is an example of a valid configuration, when validated against + * the schema example given above. + * + * PF (NVLIST): + * driver (NVLIST): + * iov (NVLIST): + * num_vfs (NUMBER): 3 (3) (0x3) + * device (STRING): [ix0] + * VF-0 (NVLIST): + * driver (NVLIST): + * vlan (NUMBER): 1000 (1000) (0x3e8) + * iov (NVLIST): + * passthrough (BOOL): TRUE + * VF-1 (NVLIST): + * driver (NVLIST): + * iov (NVLIST): + * VF-2 (NVLIST): + * driver (NVLIST): + * mac-addr (BINARY): 6 020102030405 + * iov (NVLIST): + */ +struct pci_iov_arg +{ + void *config; + size_t len; +}; + +#define IOV_CONFIG _IOW('p', 10, struct pci_iov_arg) +#define IOV_DELETE _IO('p', 11) +#define IOV_GET_SCHEMA _IOWR('p', 12, struct pci_iov_schema) + +#endif + Property changes on: trunk/sys/sys/iov.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +MidnightBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property From laffer1 at midnightbsd.org Sun Feb 16 17:43:24 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 17:43:24 -0500 (EST) Subject: [Midnightbsd-cvs] src [12386] trunk/sys/sys/linker.h: Sync with FreeBSD 11-stable Message-ID: <202002162243.01GMhOdk037187@stargazer.midnightbsd.org> Revision: 12386 http://svnweb.midnightbsd.org/src/?rev=12386 Author: laffer1 Date: 2020-02-16 17:43:24 -0500 (Sun, 16 Feb 2020) Log Message: ----------- Sync with FreeBSD 11-stable Modified Paths: -------------- trunk/sys/sys/linker.h Modified: trunk/sys/sys/linker.h =================================================================== --- trunk/sys/sys/linker.h 2020-02-16 22:42:27 UTC (rev 12385) +++ trunk/sys/sys/linker.h 2020-02-16 22:43:24 UTC (rev 12386) @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/sys/linker.h 300060 2016-05-17 15:18:01Z pfg $ + * $FreeBSD: stable/11/sys/sys/linker.h 338867 2018-09-21 20:40:37Z markj $ */ #ifndef _SYS_LINKER_H_ @@ -80,6 +80,8 @@ int id; /* unique id */ caddr_t address; /* load address */ size_t size; /* size of file */ + caddr_t ctors_addr; /* address of .ctors */ + size_t ctors_size; /* size of .ctors */ int ndeps; /* number of dependencies */ linker_file_t* deps; /* list of dependencies */ STAILQ_HEAD(, common_symbol) common; /* list of common symbols */ @@ -141,7 +143,7 @@ * Lookup a symbol in a file. If deps is TRUE, look in dependencies * if not found in file. */ -caddr_t linker_file_lookup_symbol(linker_file_t _file, const char* _name, +caddr_t linker_file_lookup_symbol(linker_file_t _file, const char* _name, int _deps); /* @@ -155,7 +157,7 @@ /* * List all functions in a file. */ -int linker_file_function_listall(linker_file_t, +int linker_file_function_listall(linker_file_t, linker_function_nameval_callback_t, void *); /* @@ -212,6 +214,10 @@ #define MODINFOMD_KERNEND 0x0008 /* kernend */ #endif #define MODINFOMD_SHDR 0x0009 /* section header table */ +#define MODINFOMD_CTORS_ADDR 0x000a /* address of .ctors */ +#define MODINFOMD_CTORS_SIZE 0x000b /* size of .ctors */ +#define MODINFOMD_FW_HANDLE 0x000c /* Firmware dependent handle */ +#define MODINFOMD_KEYBUF 0x000d /* Crypto key intake buffer */ #define MODINFOMD_NOCOPY 0x8000 /* don't copy this metadata to the kernel */ #define MODINFOMD_DEPLIST (0x4001 | MODINFOMD_NOCOPY) /* depends on */ @@ -225,6 +231,7 @@ #endif #define LINKER_HINTS_VERSION 1 /* linker.hints file version */ +#define LINKER_HINTS_MAX (1 << 20) /* Allow at most 1MB for linker.hints */ #ifdef _KERNEL @@ -263,11 +270,15 @@ typedef int elf_lookup_fn(linker_file_t, Elf_Size, int, Elf_Addr *); /* Support functions */ -int elf_reloc(linker_file_t _lf, Elf_Addr base, const void *_rel, int _type, elf_lookup_fn _lu); -int elf_reloc_local(linker_file_t _lf, Elf_Addr base, const void *_rel, int _type, elf_lookup_fn _lu); +bool elf_is_ifunc_reloc(Elf_Size r_info); +int elf_reloc(linker_file_t _lf, Elf_Addr base, const void *_rel, + int _type, elf_lookup_fn _lu); +int elf_reloc_local(linker_file_t _lf, Elf_Addr base, const void *_rel, + int _type, elf_lookup_fn _lu); Elf_Addr elf_relocaddr(linker_file_t _lf, Elf_Addr addr); const Elf_Sym *elf_get_sym(linker_file_t _lf, Elf_Size _symidx); const char *elf_get_symname(linker_file_t _lf, Elf_Size _symidx); +void link_elf_ireloc(caddr_t kmdp); typedef struct linker_ctf { const uint8_t *ctftab; /* Decompressed CTF data. */ From laffer1 at midnightbsd.org Sun Feb 16 17:44:32 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 17:44:32 -0500 (EST) Subject: [Midnightbsd-cvs] src [12387] trunk/sys/sys/ktr.h: Sync with FreeBSD 11-stable Message-ID: <202002162244.01GMiW7h037287@stargazer.midnightbsd.org> Revision: 12387 http://svnweb.midnightbsd.org/src/?rev=12387 Author: laffer1 Date: 2020-02-16 17:44:32 -0500 (Sun, 16 Feb 2020) Log Message: ----------- Sync with FreeBSD 11-stable Modified Paths: -------------- trunk/sys/sys/ktr.h Modified: trunk/sys/sys/ktr.h =================================================================== --- trunk/sys/sys/ktr.h 2020-02-16 22:43:24 UTC (rev 12386) +++ trunk/sys/sys/ktr.h 2020-02-16 22:44:32 UTC (rev 12387) @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * from BSDI $Id: ktr.h,v 1.10.2.7 2000/03/16 21:44:42 cp Exp $ - * $FreeBSD: stable/10/sys/sys/ktr.h 284343 2015-06-13 16:15:43Z jhb $ + * $FreeBSD: stable/11/sys/sys/ktr.h 331722 2018-03-29 02:50:57Z eadler $ */ /* @@ -37,58 +37,8 @@ #ifndef _SYS_KTR_H_ #define _SYS_KTR_H_ -/* - * Trace classes - * - * Two of the trace classes (KTR_DEV and KTR_SUBSYS) are special in that - * they are really placeholders so that indvidual drivers and subsystems - * can map their internal tracing to the general class when they wish to - * have tracing enabled and map it to 0 when they don't. - */ -#define KTR_GEN 0x00000001 /* General (TR) */ -#define KTR_NET 0x00000002 /* Network */ -#define KTR_DEV 0x00000004 /* Device driver */ -#define KTR_LOCK 0x00000008 /* MP locking */ -#define KTR_SMP 0x00000010 /* MP general */ -#define KTR_SUBSYS 0x00000020 /* Subsystem. */ -#define KTR_PMAP 0x00000040 /* Pmap tracing */ -#define KTR_MALLOC 0x00000080 /* Malloc tracing */ -#define KTR_TRAP 0x00000100 /* Trap processing */ -#define KTR_INTR 0x00000200 /* Interrupt tracing */ -#define KTR_SIG 0x00000400 /* Signal processing */ -#define KTR_SPARE2 0x00000800 /* XXX Used by cxgb */ -#define KTR_PROC 0x00001000 /* Process scheduling */ -#define KTR_SYSC 0x00002000 /* System call */ -#define KTR_INIT 0x00004000 /* System initialization */ -#define KTR_SPARE3 0x00008000 /* XXX Used by cxgb */ -#define KTR_SPARE4 0x00010000 /* XXX Used by cxgb */ -#define KTR_EVH 0x00020000 /* Eventhandler */ -#define KTR_VFS 0x00040000 /* VFS events */ -#define KTR_VOP 0x00080000 /* Auto-generated vop events */ -#define KTR_VM 0x00100000 /* The virtual memory system */ -#define KTR_INET 0x00200000 /* IPv4 stack */ -#define KTR_RUNQ 0x00400000 /* Run queue */ -#define KTR_CONTENTION 0x00800000 /* Lock contention */ -#define KTR_UMA 0x01000000 /* UMA slab allocator */ -#define KTR_CALLOUT 0x02000000 /* Callouts and timeouts */ -#define KTR_GEOM 0x04000000 /* GEOM I/O events */ -#define KTR_BUSDMA 0x08000000 /* busdma(9) events */ -#define KTR_INET6 0x10000000 /* IPv6 stack */ -#define KTR_SCHED 0x20000000 /* Machine parsed sched info. */ -#define KTR_BUF 0x40000000 /* Buffer cache */ -#define KTR_PTRACE 0x80000000 /* Process debugging. */ -#define KTR_ALL 0xffffffff +#include -/* Trace classes to compile in */ -#ifdef KTR -#ifndef KTR_COMPILE -#define KTR_COMPILE (KTR_ALL) -#endif -#else /* !KTR */ -#undef KTR_COMPILE -#define KTR_COMPILE 0 -#endif /* KTR */ - /* * Version number for ktr_entry struct. Increment this when you break binary * compatibility. @@ -113,7 +63,7 @@ }; extern cpuset_t ktr_cpumask; -extern int ktr_mask; +extern uint64_t ktr_mask; extern int ktr_entries; extern int ktr_verbose; @@ -122,7 +72,7 @@ #ifdef KTR -void ktr_tracepoint(u_int mask, const char *file, int line, +void ktr_tracepoint(uint64_t mask, const char *file, int line, const char *format, u_long arg1, u_long arg2, u_long arg3, u_long arg4, u_long arg5, u_long arg6); From laffer1 at midnightbsd.org Sun Feb 16 17:44:55 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 17:44:55 -0500 (EST) Subject: [Midnightbsd-cvs] src [12388] trunk/sys/sys/hash.h: Sync with FreeBSD 11-stable Message-ID: <202002162244.01GMitjF037341@stargazer.midnightbsd.org> Revision: 12388 http://svnweb.midnightbsd.org/src/?rev=12388 Author: laffer1 Date: 2020-02-16 17:44:54 -0500 (Sun, 16 Feb 2020) Log Message: ----------- Sync with FreeBSD 11-stable Modified Paths: -------------- trunk/sys/sys/hash.h Modified: trunk/sys/sys/hash.h =================================================================== --- trunk/sys/sys/hash.h 2020-02-16 22:44:32 UTC (rev 12387) +++ trunk/sys/sys/hash.h 2020-02-16 22:44:54 UTC (rev 12388) @@ -24,7 +24,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $OpenBSD: hash.h,v 1.4 2004/05/25 18:37:23 jmc Exp $ - * $FreeBSD: stable/10/sys/sys/hash.h 274486 2014-11-13 21:58:42Z gnn $ + * $FreeBSD: stable/11/sys/sys/hash.h 331722 2018-03-29 02:50:57Z eadler $ */ #ifndef _SYS_HASH_H_ @@ -127,7 +127,8 @@ uint32_t jenkins_hash(const void *, size_t, uint32_t); uint32_t jenkins_hash32(const uint32_t *, size_t, uint32_t); -uint32_t murmur3_aligned_32(const void *data, size_t len, uint32_t seed); +uint32_t murmur3_32_hash(const void *, size_t, uint32_t); +uint32_t murmur3_32_hash32(const uint32_t *, size_t, uint32_t); #endif /* _KERNEL */ From laffer1 at midnightbsd.org Sun Feb 16 17:45:27 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 17:45:27 -0500 (EST) Subject: [Midnightbsd-cvs] src [12389] trunk/sys/sys/kobj.h: Sync with FreeBSD 11-stable Message-ID: <202002162245.01GMjRYG038025@stargazer.midnightbsd.org> Revision: 12389 http://svnweb.midnightbsd.org/src/?rev=12389 Author: laffer1 Date: 2020-02-16 17:45:26 -0500 (Sun, 16 Feb 2020) Log Message: ----------- Sync with FreeBSD 11-stable Modified Paths: -------------- trunk/sys/sys/kobj.h Modified: trunk/sys/sys/kobj.h =================================================================== --- trunk/sys/sys/kobj.h 2020-02-16 22:44:54 UTC (rev 12388) +++ trunk/sys/sys/kobj.h 2020-02-16 22:45:26 UTC (rev 12389) @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/sys/kobj.h 318275 2017-05-14 14:21:11Z marius $ + * $FreeBSD: stable/11/sys/sys/kobj.h 331722 2018-03-29 02:50:57Z eadler $ */ #ifndef _SYS_KOBJ_H_ @@ -147,13 +147,13 @@ * DEFINE_CLASS_2(foo, foo_class, foo_methods, sizeof(foo_softc), * bar, baz); */ -#define DEFINE_CLASS_2(name, methods, size, \ +#define DEFINE_CLASS_2(name, classvar, methods, size, \ base1, base2) \ \ static kobj_class_t name ## _baseclasses[] = \ { &base1, \ &base2, NULL }; \ -struct kobj_class name ## _class = { \ +struct kobj_class classvar = { \ #name, methods, size, name ## _baseclasses \ } @@ -163,7 +163,7 @@ * DEFINE_CLASS_3(foo, foo_class, foo_methods, sizeof(foo_softc), * bar, baz, foobar); */ -#define DEFINE_CLASS_3(name, methods, size, \ +#define DEFINE_CLASS_3(name, classvar, methods, size, \ base1, base2, base3) \ \ static kobj_class_t name ## _baseclasses[] = \ @@ -170,7 +170,7 @@ { &base1, \ &base2, \ &base3, NULL }; \ -struct kobj_class name ## _class = { \ +struct kobj_class classvar = { \ #name, methods, size, name ## _baseclasses \ } From laffer1 at midnightbsd.org Sun Feb 16 17:45:40 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 17:45:40 -0500 (EST) Subject: [Midnightbsd-cvs] src [12390] trunk/sys/sys/ksem.h: Sync with FreeBSD 11-stable Message-ID: <202002162245.01GMjebE038077@stargazer.midnightbsd.org> Revision: 12390 http://svnweb.midnightbsd.org/src/?rev=12390 Author: laffer1 Date: 2020-02-16 17:45:40 -0500 (Sun, 16 Feb 2020) Log Message: ----------- Sync with FreeBSD 11-stable Modified Paths: -------------- trunk/sys/sys/ksem.h Modified: trunk/sys/sys/ksem.h =================================================================== --- trunk/sys/sys/ksem.h 2020-02-16 22:45:26 UTC (rev 12389) +++ trunk/sys/sys/ksem.h 2020-02-16 22:45:40 UTC (rev 12390) @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/sys/ksem.h 250223 2013-05-03 21:11:57Z jhb $ + * $FreeBSD: stable/11/sys/sys/ksem.h 331722 2018-03-29 02:50:57Z eadler $ */ #ifndef _POSIX4_KSEM_H_ @@ -64,9 +64,4 @@ #define KS_ANONYMOUS 0x0001 /* Anonymous (unnamed) semaphore. */ #define KS_DEAD 0x0002 /* No new waiters allowed. */ -#ifdef _KERNEL -extern void (*ksem_info)(struct ksem *ks, char *path, size_t size, - uint32_t *value); -#endif - #endif /* !_POSIX4_KSEM_H_ */ From laffer1 at midnightbsd.org Sun Feb 16 17:46:24 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 17:46:24 -0500 (EST) Subject: [Midnightbsd-cvs] src [12391] trunk/sys/sys/intr.h: Sync with FreeBSD 11-stable Message-ID: <202002162246.01GMkO3O038143@stargazer.midnightbsd.org> Revision: 12391 http://svnweb.midnightbsd.org/src/?rev=12391 Author: laffer1 Date: 2020-02-16 17:46:23 -0500 (Sun, 16 Feb 2020) Log Message: ----------- Sync with FreeBSD 11-stable Added Paths: ----------- trunk/sys/sys/intr.h Added: trunk/sys/sys/intr.h =================================================================== --- trunk/sys/sys/intr.h (rev 0) +++ trunk/sys/sys/intr.h 2020-02-16 22:46:23 UTC (rev 12391) @@ -0,0 +1,163 @@ +/* $MidnightBSD$ */ +/*- + * Copyright (c) 2015-2016 Svatopluk Kraus + * Copyright (c) 2015-2016 Michal Meloun + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: stable/11/sys/sys/intr.h 308333 2016-11-05 10:23:02Z mmel $ + */ + +#ifndef _SYS_INTR_H_ +#define _SYS_INTR_H_ +#ifndef INTRNG +#error Need INTRNG for this file +#endif + +#include + +#define INTR_IRQ_INVALID 0xFFFFFFFF + +enum intr_map_data_type { + INTR_MAP_DATA_ACPI = 0, + INTR_MAP_DATA_FDT, + INTR_MAP_DATA_GPIO, + INTR_MAP_DATA_MSI, + + /* Placeholders for platform specific types */ + INTR_MAP_DATA_PLAT_1 = 1000, + INTR_MAP_DATA_PLAT_2, + INTR_MAP_DATA_PLAT_3, + INTR_MAP_DATA_PLAT_4, + INTR_MAP_DATA_PLAT_5, +}; + +struct intr_map_data { + size_t len; + enum intr_map_data_type type; +}; + +struct intr_map_data_msi { + struct intr_map_data hdr; + struct intr_irqsrc *isrc; +}; + +#ifdef notyet +#define INTR_SOLO INTR_MD1 +typedef int intr_irq_filter_t(void *arg, struct trapframe *tf); +#else +typedef int intr_irq_filter_t(void *arg); +#endif +typedef int intr_child_irq_filter_t(void *arg, uintptr_t irq); + +#define INTR_ISRC_NAMELEN (MAXCOMLEN + 1) + +#define INTR_ISRCF_IPI 0x01 /* IPI interrupt */ +#define INTR_ISRCF_PPI 0x02 /* PPI interrupt */ +#define INTR_ISRCF_BOUND 0x04 /* bound to a CPU */ + +struct intr_pic; + +/* Interrupt source definition. */ +struct intr_irqsrc { + device_t isrc_dev; /* where isrc is mapped */ + u_int isrc_irq; /* unique identificator */ + u_int isrc_flags; + char isrc_name[INTR_ISRC_NAMELEN]; + cpuset_t isrc_cpu; /* on which CPUs is enabled */ + u_int isrc_index; + u_long * isrc_count; + u_int isrc_handlers; + struct intr_event * isrc_event; +#ifdef INTR_SOLO + intr_irq_filter_t * isrc_filter; + void * isrc_arg; +#endif +}; + +/* Intr interface for PIC. */ +int intr_isrc_deregister(struct intr_irqsrc *); +int intr_isrc_register(struct intr_irqsrc *, device_t, u_int, const char *, ...) + __printflike(4, 5); + +#ifdef SMP +bool intr_isrc_init_on_cpu(struct intr_irqsrc *isrc, u_int cpu); +#endif + +int intr_isrc_dispatch(struct intr_irqsrc *, struct trapframe *); +u_int intr_irq_next_cpu(u_int current_cpu, cpuset_t *cpumask); + +struct intr_pic *intr_pic_register(device_t, intptr_t); +int intr_pic_deregister(device_t, intptr_t); +int intr_pic_claim_root(device_t, intptr_t, intr_irq_filter_t *, void *, u_int); +struct intr_pic *intr_pic_add_handler(device_t, struct intr_pic *, + intr_child_irq_filter_t *, void *, uintptr_t, uintptr_t); + +extern device_t intr_irq_root_dev; + +/* Intr interface for BUS. */ + +int intr_activate_irq(device_t, struct resource *); +int intr_deactivate_irq(device_t, struct resource *); + +int intr_setup_irq(device_t, struct resource *, driver_filter_t, driver_intr_t, + void *, int, void **); +int intr_teardown_irq(device_t, struct resource *, void *); + +int intr_describe_irq(device_t, struct resource *, void *, const char *); +int intr_child_irq_handler(struct intr_pic *, uintptr_t); + +/* Intr resources mapping. */ +struct intr_map_data *intr_alloc_map_data(enum intr_map_data_type, size_t, int); +void intr_free_intr_map_data(struct intr_map_data *); +u_int intr_map_irq(device_t, intptr_t, struct intr_map_data *); +void intr_unmap_irq(u_int ); +u_int intr_map_clone_irq(u_int ); + +/* MSI/MSI-X handling */ +int intr_msi_register(device_t, intptr_t); +int intr_alloc_msi(device_t, device_t, intptr_t, int, int, int *); +int intr_release_msi(device_t, device_t, intptr_t, int, int *); +int intr_map_msi(device_t, device_t, intptr_t, int, uint64_t *, uint32_t *); +int intr_alloc_msix(device_t, device_t, intptr_t, int *); +int intr_release_msix(device_t, device_t, intptr_t, int); + +#ifdef SMP +int intr_bind_irq(device_t, struct resource *, int); + +void intr_pic_init_secondary(void); + +/* Virtualization for interrupt source IPI counter increment. */ +static inline void +intr_ipi_increment_count(u_long *counter, u_int cpu) +{ + + KASSERT(cpu < MAXCPU, ("%s: too big cpu %u", __func__, cpu)); + counter[cpu]++; +} + +/* Virtualization for interrupt source IPI counters setup. */ +u_long * intr_ipi_setup_counters(const char *name); + +#endif +#endif /* _SYS_INTR_H */ Property changes on: trunk/sys/sys/intr.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +MidnightBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property From laffer1 at midnightbsd.org Sun Feb 16 17:47:19 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 17:47:19 -0500 (EST) Subject: [Midnightbsd-cvs] src [12392] trunk/sys/sys/kernel.h: Sync with FreeBSD 11-stable Message-ID: <202002162247.01GMlJX9038231@stargazer.midnightbsd.org> Revision: 12392 http://svnweb.midnightbsd.org/src/?rev=12392 Author: laffer1 Date: 2020-02-16 17:47:19 -0500 (Sun, 16 Feb 2020) Log Message: ----------- Sync with FreeBSD 11-stable Modified Paths: -------------- trunk/sys/sys/kernel.h Modified: trunk/sys/sys/kernel.h =================================================================== --- trunk/sys/sys/kernel.h 2020-02-16 22:46:23 UTC (rev 12391) +++ trunk/sys/sys/kernel.h 2020-02-16 22:47:19 UTC (rev 12392) @@ -40,7 +40,7 @@ * SUCH DAMAGE. * * @(#)kernel.h 8.3 (Berkeley) 1/21/94 - * $FreeBSD: stable/10/sys/sys/kernel.h 255040 2013-08-29 19:52:18Z gibbs $ + * $FreeBSD: stable/11/sys/sys/kernel.h 331722 2018-03-29 02:50:57Z eadler $ */ #ifndef _SYS_KERNEL_H_ @@ -81,10 +81,6 @@ * for binary compatibility with inserted elements. * * The SI_SUB_LAST value must have the highest lexical value. - * - * The SI_SUB_SWAP values represent a value used by - * the BSD 4.4Lite but not by FreeBSD; it is maintained in dependent - * order to support porting. */ enum sysinit_sub_id { SI_SUB_DUMMY = 0x0000000, /* not executed; for linker*/ @@ -91,12 +87,8 @@ SI_SUB_DONE = 0x0000001, /* processed*/ SI_SUB_TUNABLES = 0x0700000, /* establish tunable values */ SI_SUB_COPYRIGHT = 0x0800001, /* first use of console*/ - SI_SUB_SETTINGS = 0x0880000, /* check and recheck settings */ - SI_SUB_MTX_POOL_STATIC = 0x0900000, /* static mutex pool */ - SI_SUB_LOCKMGR = 0x0980000, /* lockmgr locks */ SI_SUB_VM = 0x1000000, /* virtual memory system init*/ SI_SUB_KMEM = 0x1800000, /* kernel memory*/ - SI_SUB_KVM_RSRC = 0x1A00000, /* kvm operational limits*/ SI_SUB_HYPERVISOR = 0x1A40000, /* * Hypervisor detection and * virtualization support @@ -110,8 +102,8 @@ SI_SUB_KLD = 0x2000000, /* KLD and module setup */ SI_SUB_CPU = 0x2100000, /* CPU resource(s)*/ SI_SUB_RACCT = 0x2110000, /* resource accounting */ - SI_SUB_RANDOM = 0x2120000, /* random number generator */ SI_SUB_KDTRACE = 0x2140000, /* Kernel dtrace hooks */ + SI_SUB_RANDOM = 0x2160000, /* random number generator */ SI_SUB_MAC = 0x2180000, /* TrustedBSD MAC subsystem */ SI_SUB_MAC_POLICY = 0x21C0000, /* TrustedBSD MAC policies */ SI_SUB_MAC_LATE = 0x21D0000, /* TrustedBSD MAC subsystem */ @@ -122,14 +114,16 @@ SI_SUB_RUN_QUEUE = 0x2400000, /* set up run queue*/ SI_SUB_KTRACE = 0x2480000, /* ktrace */ SI_SUB_OPENSOLARIS = 0x2490000, /* OpenSolaris compatibility */ - SI_SUB_CYCLIC = 0x24A0000, /* Cyclic timers */ SI_SUB_AUDIT = 0x24C0000, /* audit */ SI_SUB_CREATE_INIT = 0x2500000, /* create init process*/ SI_SUB_SCHED_IDLE = 0x2600000, /* required idle procs */ SI_SUB_MBUF = 0x2700000, /* mbuf subsystem */ SI_SUB_INTR = 0x2800000, /* interrupt threads */ - SI_SUB_SOFTINTR = 0x2800001, /* start soft interrupt thread */ - SI_SUB_ACL = 0x2900000, /* start for filesystem ACLs */ + SI_SUB_TASKQ = 0x2880000, /* task queues */ +#ifdef EARLY_AP_STARTUP + SI_SUB_SMP = 0x2900000, /* start the APs*/ +#endif + SI_SUB_SOFTINTR = 0x2A00000, /* start soft interrupt thread */ SI_SUB_DEVFS = 0x2F00000, /* devfs ready for devices */ SI_SUB_INIT_IF = 0x3000000, /* prep for net interfaces */ SI_SUB_NETGRAPH = 0x3010000, /* Let Netgraph initialize */ @@ -140,7 +134,6 @@ SI_SUB_CONFIGURE = 0x3800000, /* Configure devices */ SI_SUB_VFS = 0x4000000, /* virtual filesystem*/ SI_SUB_CLOCKS = 0x4800000, /* real time and stat clocks*/ - SI_SUB_CLIST = 0x5800000, /* clists*/ SI_SUB_SYSV_SHM = 0x6400000, /* System V shared memory*/ SI_SUB_SYSV_SEM = 0x6800000, /* System V semaphores*/ SI_SUB_SYSV_MSG = 0x6C00000, /* System V message queues*/ @@ -148,18 +141,18 @@ SI_SUB_PSEUDO = 0x7000000, /* pseudo devices*/ SI_SUB_EXEC = 0x7400000, /* execve() handlers */ SI_SUB_PROTO_BEGIN = 0x8000000, /* VNET initialization */ + SI_SUB_PROTO_PFIL = 0x8100000, /* Initialize pfil before FWs */ SI_SUB_PROTO_IF = 0x8400000, /* interfaces*/ SI_SUB_PROTO_DOMAININIT = 0x8600000, /* domain registration system */ + SI_SUB_PROTO_MC = 0x8700000, /* Multicast */ SI_SUB_PROTO_DOMAIN = 0x8800000, /* domains (address families?)*/ - SI_SUB_PROTO_IFATTACHDOMAIN = 0x8800001, /* domain dependent data init*/ + SI_SUB_PROTO_FIREWALL = 0x8806000, /* Firewalls */ + SI_SUB_PROTO_IFATTACHDOMAIN = 0x8808000,/* domain dependent data init */ SI_SUB_PROTO_END = 0x8ffffff, /* VNET helper functions */ SI_SUB_KPROF = 0x9000000, /* kernel profiling*/ SI_SUB_KICK_SCHEDULER = 0xa000000, /* start the timeout events*/ SI_SUB_INT_CONFIG_HOOKS = 0xa800000, /* Interrupts enabled config */ SI_SUB_ROOT_CONF = 0xb000000, /* Find root devices */ - SI_SUB_DUMP_CONF = 0xb200000, /* Find dump devices */ - SI_SUB_RAID = 0xb380000, /* Configure GEOM classes */ - SI_SUB_SWAP = 0xc000000, /* swap */ SI_SUB_INTRINSIC_POST = 0xd000000, /* proc 0 cleanup*/ SI_SUB_SYSCALLS = 0xd800000, /* register system calls */ SI_SUB_VNET_DONE = 0xdc00000, /* vnet registration complete */ @@ -169,8 +162,10 @@ SI_SUB_KTHREAD_BUF = 0xea00000, /* buffer daemon*/ SI_SUB_KTHREAD_UPDATE = 0xec00000, /* update daemon*/ SI_SUB_KTHREAD_IDLE = 0xee00000, /* idle procs*/ +#ifndef EARLY_AP_STARTUP SI_SUB_SMP = 0xf000000, /* start the APs*/ - SI_SUB_RACCTD = 0xf100000, /* start raccd*/ +#endif + SI_SUB_RACCTD = 0xf100000, /* start racctd*/ SI_SUB_LAST = 0xfffffff /* final initialization */ }; @@ -332,6 +327,44 @@ #define TUNABLE_ULONG_FETCH(path, var) getenv_ulong((path), (var)) /* + * int64_t + */ +extern void tunable_int64_init(void *); +struct tunable_int64 { + const char *path; + int64_t *var; +}; +#define TUNABLE_INT64(path, var) \ + static struct tunable_int64 __CONCAT(__tunable_int64_, __LINE__) = { \ + (path), \ + (var), \ + }; \ + SYSINIT(__CONCAT(__Tunable_init_, __LINE__), \ + SI_SUB_TUNABLES, SI_ORDER_MIDDLE, tunable_int64_init, \ + &__CONCAT(__tunable_int64_, __LINE__)) + +#define TUNABLE_INT64_FETCH(path, var) getenv_int64((path), (var)) + +/* + * uint64_t + */ +extern void tunable_uint64_init(void *); +struct tunable_uint64 { + const char *path; + uint64_t *var; +}; +#define TUNABLE_UINT64(path, var) \ + static struct tunable_uint64 __CONCAT(__tunable_uint64_, __LINE__) = { \ + (path), \ + (var), \ + }; \ + SYSINIT(__CONCAT(__Tunable_init_, __LINE__), \ + SI_SUB_TUNABLES, SI_ORDER_MIDDLE, tunable_uint64_init, \ + &__CONCAT(__tunable_uint64_, __LINE__)) + +#define TUNABLE_UINT64_FETCH(path, var) getenv_uint64((path), (var)) + +/* * quad */ extern void tunable_quad_init(void *); @@ -369,13 +402,16 @@ #define TUNABLE_STR_FETCH(path, var, size) \ getenv_string((path), (var), (size)) +typedef void (*ich_func_t)(void *_arg); + struct intr_config_hook { TAILQ_ENTRY(intr_config_hook) ich_links; - void (*ich_func)(void *arg); - void *ich_arg; + ich_func_t ich_func; + void *ich_arg; }; int config_intrhook_establish(struct intr_config_hook *hook); void config_intrhook_disestablish(struct intr_config_hook *hook); +void config_intrhook_oneshot(ich_func_t _func, void *_arg); #endif /* !_SYS_KERNEL_H_*/ From laffer1 at midnightbsd.org Sun Feb 16 17:48:42 2020 From: laffer1 at midnightbsd.org (laffer1 at midnightbsd.org) Date: Sun, 16 Feb 2020 17:48:42 -0500 (EST) Subject: [Midnightbsd-cvs] src [12393] trunk/sys/sys/gpio.h: Sync with FreeBSD 11-stable Message-ID: <202002162248.01GMmg1e038324@stargazer.midnightbsd.org> Revision: 12393 http://svnweb.midnightbsd.org/src/?rev=12393 Author: laffer1 Date: 2020-02-16 17:48:41 -0500 (Sun, 16 Feb 2020) Log Message: ----------- Sync with FreeBSD 11-stable Modified Paths: -------------- trunk/sys/sys/gpio.h Modified: trunk/sys/sys/gpio.h =================================================================== --- trunk/sys/sys/gpio.h 2020-02-16 22:47:19 UTC (rev 12392) +++ trunk/sys/sys/gpio.h 2020-02-16 22:48:41 UTC (rev 12393) @@ -27,7 +27,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: stable/10/sys/sys/gpio.h 213237 2010-09-28 03:24:53Z gonzo $ + * $FreeBSD: stable/11/sys/sys/gpio.h 331722 2018-03-29 02:50:57Z eadler $ * */ @@ -61,16 +61,28 @@ #define GPIOMAXNAME 64 /* GPIO pin configuration flags */ -#define GPIO_PIN_INPUT 0x0001 /* input direction */ -#define GPIO_PIN_OUTPUT 0x0002 /* output direction */ -#define GPIO_PIN_OPENDRAIN 0x0004 /* open-drain output */ -#define GPIO_PIN_PUSHPULL 0x0008 /* push-pull output */ -#define GPIO_PIN_TRISTATE 0x0010 /* output disabled */ -#define GPIO_PIN_PULLUP 0x0020 /* internal pull-up enabled */ -#define GPIO_PIN_PULLDOWN 0x0040 /* internal pull-down enabled */ -#define GPIO_PIN_INVIN 0x0080 /* invert input */ -#define GPIO_PIN_INVOUT 0x0100 /* invert output */ -#define GPIO_PIN_PULSATE 0x0200 /* pulsate in hardware */ +#define GPIO_PIN_INPUT 0x00000001 /* input direction */ +#define GPIO_PIN_OUTPUT 0x00000002 /* output direction */ +#define GPIO_PIN_OPENDRAIN 0x00000004 /* open-drain output */ +#define GPIO_PIN_PUSHPULL 0x00000008 /* push-pull output */ +#define GPIO_PIN_TRISTATE 0x00000010 /* output disabled */ +#define GPIO_PIN_PULLUP 0x00000020 /* internal pull-up enabled */ +#define GPIO_PIN_PULLDOWN 0x00000040 /* internal pull-down enabled */ +#define GPIO_PIN_INVIN 0x00000080 /* invert input */ +#define GPIO_PIN_INVOUT 0x00000100 /* invert output */ +#define GPIO_PIN_PULSATE 0x00000200 /* pulsate in hardware */ +#define GPIO_PIN_PRESET_LOW 0x00000400 /* preset pin to high or */ +#define GPIO_PIN_PRESET_HIGH 0x00000800 /* low before enabling output */ +/* GPIO interrupt capabilities */ +#define GPIO_INTR_NONE 0x00000000 /* no interrupt support */ +#define GPIO_INTR_LEVEL_LOW 0x00010000 /* level trigger, low */ +#define GPIO_INTR_LEVEL_HIGH 0x00020000 /* level trigger, high */ +#define GPIO_INTR_EDGE_RISING 0x00040000 /* edge trigger, rising */ +#define GPIO_INTR_EDGE_FALLING 0x00080000 /* edge trigger, falling */ +#define GPIO_INTR_EDGE_BOTH 0x00100000 /* edge trigger, both */ +#define GPIO_INTR_MASK (GPIO_INTR_LEVEL_LOW | GPIO_INTR_LEVEL_HIGH | \ + GPIO_INTR_EDGE_RISING | \ + GPIO_INTR_EDGE_FALLING | GPIO_INTR_EDGE_BOTH) struct gpio_pin { uint32_t gp_pin; /* pin number */ @@ -86,6 +98,71 @@ }; /* + * gpio_access_32 / GPIOACCESS32 + * + * Simultaneously read and/or change up to 32 adjacent pins. + * If the device cannot change the pins simultaneously, returns EOPNOTSUPP. + * + * This accesses an adjacent set of up to 32 pins starting at first_pin within + * the device's collection of pins. How the hardware pins are mapped to the 32 + * bits in the arguments is device-specific. It is expected that lower-numbered + * pins in the device's number space map linearly to lower-ordered bits within + * the 32-bit words (i.e., bit 0 is first_pin, bit 1 is first_pin+1, etc). + * Other mappings are possible; know your device. + * + * Some devices may limit the value of first_pin to 0, or to multiples of 16 or + * 32 or some other hardware-specific number; to access pin 2 would require + * first_pin to be zero and then manipulate bit (1 << 2) in the 32-bit word. + * Invalid values in first_pin result in an EINVAL error return. + * + * The starting state of the pins is captured and stored in orig_pins, then the + * pins are set to ((starting_state & ~clear_pins) ^ change_pins). + * + * Clear Change Hardware pin after call + * 0 0 No change + * 0 1 Opposite of current value + * 1 0 Cleared + * 1 1 Set + */ +struct gpio_access_32 { + uint32_t first_pin; /* First pin in group of 32 adjacent */ + uint32_t clear_pins; /* Pins are changed using: */ + uint32_t change_pins; /* ((hwstate & ~clear_pins) ^ change_pins) */ + uint32_t orig_pins; /* Returned hwstate of pins before change. */ +}; + +/* + * gpio_config_32 / GPIOCONFIG32 + * + * Simultaneously configure up to 32 adjacent pins. This is intended to change + * the configuration of all the pins simultaneously, such that pins configured + * for output all begin to drive the configured values simultaneously, but not + * all hardware can do that, so the driver "does the best it can" in this + * regard. Notably unlike pin_access_32(), this does NOT fail if the pins + * cannot be atomically configured; it is expected that callers understand the + * hardware and have decided to live with any such limitations it may have. + * + * The pin_flags argument is an array of GPIO_PIN_xxxx flags. If the array + * contains any GPIO_PIN_OUTPUT flags, the driver will manipulate the hardware + * such that all output pins become driven with the proper initial values + * simultaneously if it can. The elements in the array map to pins in the same + * way that bits are mapped by pin_acces_32(), and the same restrictions may + * apply. For example, to configure pins 2 and 3 it may be necessary to set + * first_pin to zero and only populate pin_flags[2] and pin_flags[3]. If a + * given array entry doesn't contain GPIO_PIN_INPUT or GPIO_PIN_OUTPUT then no + * configuration is done for that pin. + * + * Some devices may limit the value of first_pin to 0, or to multiples of 16 or + * 32 or some other hardware-specific number. Invalid values in first_pin or + * num_pins result in an error return with errno set to EINVAL. + */ +struct gpio_config_32 { + uint32_t first_pin; + uint32_t num_pins; + uint32_t pin_flags[32]; +}; + +/* * ioctls */ #define GPIOMAXPIN _IOR('G', 0, int) @@ -94,5 +171,8 @@ #define GPIOGET _IOWR('G', 3, struct gpio_req) #define GPIOSET _IOW('G', 4, struct gpio_req) #define GPIOTOGGLE _IOWR('G', 5, struct gpio_req) +#define GPIOSETNAME _IOW('G', 6, struct gpio_pin) +#define GPIOACCESS32 _IOWR('G', 7, struct gpio_access_32) +#define GPIOCONFIG32 _IOW('G', 8, struct gpio_config_32) #endif /* __GPIO_H__ */