diff options
Diffstat (limited to 'sys/sys')
358 files changed, 3297 insertions, 2238 deletions
diff --git a/sys/sys/_atomic64e.h b/sys/sys/_atomic64e.h index d0abdc2e5a89..f7245dafb98a 100644 --- a/sys/sys/_atomic64e.h +++ b/sys/sys/_atomic64e.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2019 Justin Hibbits * @@ -23,8 +23,6 @@ * 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$ */ #ifndef _SYS_ATOMIC64E_H_ diff --git a/sys/sys/_atomic_subword.h b/sys/sys/_atomic_subword.h index 2c0c70a18cbd..dc1b2f23e731 100644 --- a/sys/sys/_atomic_subword.h +++ b/sys/sys/_atomic_subword.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2019 Kyle Evans <kevans@FreeBSD.org> * @@ -23,8 +23,6 @@ * 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$ */ #ifndef _SYS__ATOMIC_SUBWORD_H_ #define _SYS__ATOMIC_SUBWORD_H_ diff --git a/sys/sys/_bitset.h b/sys/sys/_bitset.h index 70b9713ffada..87bc722fe5f8 100644 --- a/sys/sys/_bitset.h +++ b/sys/sys/_bitset.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2008, Jeffrey Roberson <jeff@freebsd.org> * All rights reserved. @@ -27,8 +27,6 @@ * 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$ */ #ifndef _SYS__BITSET_H_ diff --git a/sys/sys/_blockcount.h b/sys/sys/_blockcount.h index e4cb7921f8b5..4a0766fd9aa4 100644 --- a/sys/sys/_blockcount.h +++ b/sys/sys/_blockcount.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2020 The FreeBSD Foundation * @@ -26,8 +26,6 @@ * 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$ */ #ifndef __SYS__BLOCKCOUNT_H__ diff --git a/sys/sys/_bus_dma.h b/sys/sys/_bus_dma.h index c2a1730186c9..04df55d8c372 100644 --- a/sys/sys/_bus_dma.h +++ b/sys/sys/_bus_dma.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright 2006 John-Mark Gurney. * All rights reserved. @@ -25,8 +25,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ - * */ #ifndef _SYS__BUS_DMA_H_ diff --git a/sys/sys/_callout.h b/sys/sys/_callout.h index 468286ff9fec..7c1c397ff38a 100644 --- a/sys/sys/_callout.h +++ b/sys/sys/_callout.h @@ -34,7 +34,6 @@ * SUCH DAMAGE. * * @(#)callout.h 8.2 (Berkeley) 1/21/94 - * $FreeBSD$ */ #ifndef _SYS__CALLOUT_H diff --git a/sys/sys/_cpuset.h b/sys/sys/_cpuset.h index b75ee595da3c..8b77721f4b3c 100644 --- a/sys/sys/_cpuset.h +++ b/sys/sys/_cpuset.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2008, Jeffrey Roberson <jeff@freebsd.org> * All rights reserved. @@ -27,8 +27,6 @@ * 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$ */ #ifndef _SYS__CPUSET_H_ @@ -40,7 +38,7 @@ #define CPU_SETSIZE MAXCPU #endif -#define CPU_MAXSIZE 256 +#define CPU_MAXSIZE 1024 #ifndef CPU_SETSIZE #define CPU_SETSIZE CPU_MAXSIZE diff --git a/sys/sys/_domainset.h b/sys/sys/_domainset.h index 443c68fd331b..11ddef0e1909 100644 --- a/sys/sys/_domainset.h +++ b/sys/sys/_domainset.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2017, Jeffrey Roberson <jeff@freebsd.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS__DOMAINSET_H_ diff --git a/sys/sys/_endian.h b/sys/sys/_endian.h index 936962cc729f..8d1eb3f3f3df 100644 --- a/sys/sys/_endian.h +++ b/sys/sys/_endian.h @@ -32,18 +32,24 @@ #ifndef _SYS__ENDIAN_H_ #define _SYS__ENDIAN_H_ -#ifndef _MACHINE_ENDIAN_H_ +#if !defined(_MACHINE_ENDIAN_H_) && !defined(_BYTESWAP_H_) && !defined(_ENDIAN_H_) #error "sys/_endian.h should not be included directly" #endif -/* BSD Compatiblity */ +#include <sys/cdefs.h> /* visibility macros */ + +/* BSD Compatibility */ #define _BYTE_ORDER __BYTE_ORDER__ /* * Definitions for byte order, according to byte significance from low - * address to high. + * address to high. We undefine any prior definition of them because + * powerpc compilers define _LITTLE_ENDIAN and _BIG_ENDIAN to mean + * something else. */ +#undef _LITTLE_ENDIAN #define _LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__ /* LSB first: 1234 */ +#undef _BIG_ENDIAN #define _BIG_ENDIAN __ORDER_BIG_ENDIAN__ /* MSB first: 4321 */ #define _PDP_ENDIAN __ORDER_PDP_ENDIAN__ /* LSB first in word, * MSW first in long: 3412 */ @@ -62,10 +68,11 @@ #endif /* - * Deprecated variants that don't have enough underscores to be useful in more - * strict namespaces. + * POSIX Issue 8 will require these for endian.h. Define them there and in the + * traditional BSD compilation environment. Since issue 8 doesn't yet have an + * assigned date, use strictly greater than issue 7's date. */ -#if __BSD_VISIBLE +#if __BSD_VISIBLE || _POSIX_C_SOURCE > 200809 #define LITTLE_ENDIAN _LITTLE_ENDIAN #define BIG_ENDIAN _BIG_ENDIAN #define PDP_ENDIAN _PDP_ENDIAN @@ -89,4 +96,38 @@ #define __ntohs(x) ((__uint16_t)(x)) #endif +/* + * Host to big endian, host to little endian, big endian to host, and little + * endian to host byte order functions as detailed in byteorder(9). + */ +#if _BYTE_ORDER == _LITTLE_ENDIAN +#define htobe16(x) __bswap16((x)) +#define htobe32(x) __bswap32((x)) +#define htobe64(x) __bswap64((x)) +#define htole16(x) ((uint16_t)(x)) +#define htole32(x) ((uint32_t)(x)) +#define htole64(x) ((uint64_t)(x)) + +#define be16toh(x) __bswap16((x)) +#define be32toh(x) __bswap32((x)) +#define be64toh(x) __bswap64((x)) +#define le16toh(x) ((uint16_t)(x)) +#define le32toh(x) ((uint32_t)(x)) +#define le64toh(x) ((uint64_t)(x)) +#else /* _BYTE_ORDER != _LITTLE_ENDIAN */ +#define htobe16(x) ((uint16_t)(x)) +#define htobe32(x) ((uint32_t)(x)) +#define htobe64(x) ((uint64_t)(x)) +#define htole16(x) __bswap16((x)) +#define htole32(x) __bswap32((x)) +#define htole64(x) __bswap64((x)) + +#define be16toh(x) ((uint16_t)(x)) +#define be32toh(x) ((uint32_t)(x)) +#define be64toh(x) ((uint64_t)(x)) +#define le16toh(x) __bswap16((x)) +#define le32toh(x) __bswap32((x)) +#define le64toh(x) __bswap64((x)) +#endif /* _BYTE_ORDER == _LITTLE_ENDIAN */ + #endif /* _SYS__ENDIAN_H_ */ diff --git a/sys/sys/_eventhandler.h b/sys/sys/_eventhandler.h index 2973bfb3b189..38d51cd409eb 100644 --- a/sys/sys/_eventhandler.h +++ b/sys/sys/_eventhandler.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1999 Michael Smith <msmith@freebsd.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS__EVENTHANDLER_H_ diff --git a/sys/sys/_ffcounter.h b/sys/sys/_ffcounter.h index 511b0a598eb7..2aef0ffb8ddc 100644 --- a/sys/sys/_ffcounter.h +++ b/sys/sys/_ffcounter.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2011 The University of Melbourne * All rights reserved. @@ -27,8 +27,6 @@ * 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$ */ #ifndef _SYS__FFCOUNTER_H_ diff --git a/sys/sys/_iovec.h b/sys/sys/_iovec.h index da9a16a6351e..1b51169f5427 100644 --- a/sys/sys/_iovec.h +++ b/sys/sys/_iovec.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)uio.h 8.5 (Berkeley) 2/22/94 - * $FreeBSD$ */ #ifndef _SYS__IOVEC_H_ diff --git a/sys/sys/_lock.h b/sys/sys/_lock.h index ea7210f9c71a..ef167b9ab5ec 100644 --- a/sys/sys/_lock.h +++ b/sys/sys/_lock.h @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS__LOCK_H_ diff --git a/sys/sys/_lockmgr.h b/sys/sys/_lockmgr.h index b0d164bdb4dc..5023056fab98 100644 --- a/sys/sys/_lockmgr.h +++ b/sys/sys/_lockmgr.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2008 Attilio Rao <attilio@FreeBSD.org> * All rights reserved. @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS__LOCKMGR_H_ diff --git a/sys/sys/_mutex.h b/sys/sys/_mutex.h index e37226cc8e5d..0fcd5a2c2809 100644 --- a/sys/sys/_mutex.h +++ b/sys/sys/_mutex.h @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS__MUTEX_H_ diff --git a/sys/sys/_null.h b/sys/sys/_null.h index 8fa5e4246bf8..28a7bd7f6708 100644 --- a/sys/sys/_null.h +++ b/sys/sys/_null.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2003 Marcel Moolenaar * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef NULL diff --git a/sys/sys/_pctrie.h b/sys/sys/_pctrie.h index d9a98a78bfb2..5a5e56399703 100644 --- a/sys/sys/_pctrie.h +++ b/sys/sys/_pctrie.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2013 EMC Corp. * Copyright (c) 2011 Jeffrey Roberson <jeff@freebsd.org> @@ -26,18 +26,21 @@ * 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$ */ #ifndef __SYS_PCTRIE_H_ #define __SYS_PCTRIE_H_ /* + * Radix tree node. + */ +struct pctrie_node; + +/* * Radix tree root. */ struct pctrie { - uintptr_t pt_root; + struct pctrie_node *pt_root; }; #endif /* !__SYS_PCTRIE_H_ */ diff --git a/sys/sys/_pthreadtypes.h b/sys/sys/_pthreadtypes.h index fdd0878ff94c..eda8a02b6f92 100644 --- a/sys/sys/_pthreadtypes.h +++ b/sys/sys/_pthreadtypes.h @@ -31,8 +31,6 @@ * 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$ */ #ifndef _SYS__PTHREADTYPES_H_ diff --git a/sys/sys/_pv_entry.h b/sys/sys/_pv_entry.h new file mode 100644 index 000000000000..ec3ea24a21a5 --- /dev/null +++ b/sys/sys/_pv_entry.h @@ -0,0 +1,140 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 2003 Peter Wemm. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * the Systems Programming Group of the University of Utah Computer + * Science Department and William Jolitz of UUNET Technologies Inc. + * + * 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. + * 3. 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 REGENTS 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 REGENTS 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. + */ + +#ifndef __SYS__PV_ENTRY_H__ +#define __SYS__PV_ENTRY_H__ + +#include <sys/param.h> + +struct pmap; + +/* + * For each vm_page_t, there is a list of all currently valid virtual + * mappings of that page. An entry is a pv_entry_t, the list is pv_list. + */ +typedef struct pv_entry { + vm_offset_t pv_va; /* virtual address for mapping */ + TAILQ_ENTRY(pv_entry) pv_next; +} *pv_entry_t; + +/* + * pv_entries are allocated in chunks per-process. This avoids the + * need to track per-pmap assignments. Each chunk is the size of a + * single page. + * + * Chunks store a bitmap in pc_map[] to track which entries in the + * bitmap are free (1) or used (0). PC_FREEL is the value of the last + * entry in the pc_map[] array when a chunk is completely free. PC_FREEN + * is the value of all the other entries in the pc_map[] array when a + * chunk is completely free. + */ +#if PAGE_SIZE == 4 * 1024 +#ifdef __LP64__ +#define _NPCPV 168 +#define _NPAD 0 +#else +#define _NPCPV 336 +#define _NPAD 0 +#endif +#elif PAGE_SIZE == 16 * 1024 +#ifdef __LP64__ +#define _NPCPV 677 +#define _NPAD 1 +#endif +#endif + +#ifndef _NPCPV +#error Unsupported page size +#endif + +/* Support clang < 14 */ +#ifndef __LONG_WIDTH__ +#define __LONG_WIDTH__ (__CHAR_BIT__ * __SIZEOF_LONG__) +#endif + +#define _NPCM howmany(_NPCPV, __LONG_WIDTH__) +#define PC_FREEN ~0ul +#define PC_FREEL ((1ul << (_NPCPV % __LONG_WIDTH__)) - 1) + +#define PV_CHUNK_HEADER \ + struct pmap *pc_pmap; \ + TAILQ_ENTRY(pv_chunk) pc_list; \ + unsigned long pc_map[_NPCM]; /* bitmap; 1 = free */ \ + TAILQ_ENTRY(pv_chunk) pc_lru; + +struct pv_chunk_header { + PV_CHUNK_HEADER +}; + +struct pv_chunk { + PV_CHUNK_HEADER + struct pv_entry pc_pventry[_NPCPV]; + unsigned long pc_pad[_NPAD]; +}; + +_Static_assert(sizeof(struct pv_chunk) == PAGE_SIZE, + "PV entry chunk size mismatch"); + +#ifdef _KERNEL +static __inline bool +pc_is_full(struct pv_chunk *pc) +{ + for (u_int i = 0; i < _NPCM; i++) { + if (pc->pc_map[i] != 0) + return (false); + } + return (true); +} + +static __inline bool +pc_is_free(struct pv_chunk *pc) +{ + for (u_int i = 0; i < _NPCM - 1; i++) { + if (pc->pc_map[i] != PC_FREEN) + return (false); + } + return (pc->pc_map[_NPCM - 1] == PC_FREEL); +} + +static __inline struct pv_chunk * +pv_to_chunk(pv_entry_t pv) +{ + return ((struct pv_chunk *)((uintptr_t)pv & ~(uintptr_t)PAGE_MASK)); +} + +#define PV_PMAP(pv) (pv_to_chunk(pv)->pc_pmap) +#endif + +#endif /* !__SYS__PV_ENTRY_H__ */ diff --git a/sys/sys/_rangeset.h b/sys/sys/_rangeset.h index 17f5e374c91f..45945c6606b4 100644 --- a/sys/sys/_rangeset.h +++ b/sys/sys/_rangeset.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2019 The FreeBSD Foundation * @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS__RANGESET_H diff --git a/sys/sys/_rmlock.h b/sys/sys/_rmlock.h index 8bf5be57343c..38375b623a65 100644 --- a/sys/sys/_rmlock.h +++ b/sys/sys/_rmlock.h @@ -27,8 +27,6 @@ * 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$ */ #ifndef _SYS__RMLOCK_H_ diff --git a/sys/sys/_rwlock.h b/sys/sys/_rwlock.h index abd0034a4b20..d360cfe2a4e9 100644 --- a/sys/sys/_rwlock.h +++ b/sys/sys/_rwlock.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2006 John Baldwin <jhb@FreeBSD.org> * @@ -23,8 +23,6 @@ * 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$ */ #ifndef _SYS__RWLOCK_H_ diff --git a/sys/sys/_semaphore.h b/sys/sys/_semaphore.h index e9991439340c..96b0e02c1bb7 100644 --- a/sys/sys/_semaphore.h +++ b/sys/sys/_semaphore.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002 Alfred Perlstein <alfred@FreeBSD.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef __SEMAPHORE_H_ #define __SEMAPHORE_H_ diff --git a/sys/sys/_seqc.h b/sys/sys/_seqc.h index 718559e8b893..c0278b98da61 100644 --- a/sys/sys/_seqc.h +++ b/sys/sys/_seqc.h @@ -1,7 +1,6 @@ /*- * This file is in the public domain. */ -/* $FreeBSD$ */ #ifndef _SYS__SEQC_H_ #define _SYS__SEQC_H_ diff --git a/sys/sys/_sigset.h b/sys/sys/_sigset.h index 662fcc1e216c..f0566b9994c8 100644 --- a/sys/sys/_sigset.h +++ b/sys/sys/_sigset.h @@ -34,7 +34,6 @@ * SUCH DAMAGE. * * @(#)signal.h 8.4 (Berkeley) 5/4/95 - * $FreeBSD$ */ #ifndef _SYS__SIGSET_H_ diff --git a/sys/sys/_smr.h b/sys/sys/_smr.h index 272bf8c07077..f7917eadf51e 100644 --- a/sys/sys/_smr.h +++ b/sys/sys/_smr.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2019, 2020 Jeffrey Roberson <jeff@FreeBSD.org> * @@ -24,8 +24,6 @@ * (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$ - * */ #ifndef _SYS__SMR_H_ diff --git a/sys/sys/_sockaddr_storage.h b/sys/sys/_sockaddr_storage.h index 9584b4c76788..d8a5b089e442 100644 --- a/sys/sys/_sockaddr_storage.h +++ b/sys/sys/_sockaddr_storage.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)socket.h 8.4 (Berkeley) 2/21/94 - * $FreeBSD$ */ #ifndef _SYS__SOCKADDR_STORAGE_H_ diff --git a/sys/sys/_stack.h b/sys/sys/_stack.h index bab8dabd2080..205504dd4133 100644 --- a/sys/sys/_stack.h +++ b/sys/sys/_stack.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2005 Antoine Brodin * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS__STACK_H_ diff --git a/sys/sys/_stdarg.h b/sys/sys/_stdarg.h index f3a7d6a457b2..063e59dc83f6 100644 --- a/sys/sys/_stdarg.h +++ b/sys/sys/_stdarg.h @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS__STDARG_H_ diff --git a/sys/sys/_stdint.h b/sys/sys/_stdint.h index 248651535f35..5bb089adfba3 100644 --- a/sys/sys/_stdint.h +++ b/sys/sys/_stdint.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2011 David E. O'Brien <obrien@FreeBSD.org> * Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org> @@ -25,8 +25,6 @@ * 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$ */ #ifndef _SYS__STDINT_H_ diff --git a/sys/sys/_sx.h b/sys/sys/_sx.h index 7e53200393b3..f70462c9a008 100644 --- a/sys/sys/_sx.h +++ b/sys/sys/_sx.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2007 Attilio Rao <attilio@freebsd.org> * All rights reserved. @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS__SX_H_ diff --git a/sys/sys/_task.h b/sys/sys/_task.h index 043707d3b5f0..0e6f212990ec 100644 --- a/sys/sys/_task.h +++ b/sys/sys/_task.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2000 Doug Rabson * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS__TASK_H_ diff --git a/sys/sys/_termios.h b/sys/sys/_termios.h index b9fe17881b3a..327ffcb2f98b 100644 --- a/sys/sys/_termios.h +++ b/sys/sys/_termios.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)termios.h 8.3 (Berkeley) 3/28/94 - * $FreeBSD$ */ #ifndef _SYS__TERMIOS_H_ diff --git a/sys/sys/_timespec.h b/sys/sys/_timespec.h index d12d1f740e61..f94dcd424ef2 100644 --- a/sys/sys/_timespec.h +++ b/sys/sys/_timespec.h @@ -30,7 +30,6 @@ * * @(#)time.h 8.5 (Berkeley) 5/4/95 * from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp - * $FreeBSD$ */ #ifndef _SYS__TIMESPEC_H_ diff --git a/sys/sys/_timeval.h b/sys/sys/_timeval.h index 3da7a711eb19..eb834616e82a 100644 --- a/sys/sys/_timeval.h +++ b/sys/sys/_timeval.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS__TIMEVAL_H_ diff --git a/sys/sys/_tls_variant_i.h b/sys/sys/_tls_variant_i.h index 0f83f121cc41..0207585871b9 100644 --- a/sys/sys/_tls_variant_i.h +++ b/sys/sys/_tls_variant_i.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2005 David Xu <davidxu@freebsd.org>. * All rights reserved. diff --git a/sys/sys/_types.h b/sys/sys/_types.h index 9c6e6858b181..769451299b19 100644 --- a/sys/sys/_types.h +++ b/sys/sys/_types.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS__TYPES_H_ diff --git a/sys/sys/_ucontext.h b/sys/sys/_ucontext.h index 2cdec1bf0a53..b1ddd35dfe50 100644 --- a/sys/sys/_ucontext.h +++ b/sys/sys/_ucontext.h @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS__UCONTEXT_H_ diff --git a/sys/sys/_uio.h b/sys/sys/_uio.h index 18612ed7367b..c46ade914c25 100644 --- a/sys/sys/_uio.h +++ b/sys/sys/_uio.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)uio.h 8.5 (Berkeley) 2/22/94 - * $FreeBSD$ */ #ifndef _SYS__UIO_H_ diff --git a/sys/sys/_umtx.h b/sys/sys/_umtx.h index d280c7d3db19..b08fab82cd1f 100644 --- a/sys/sys/_umtx.h +++ b/sys/sys/_umtx.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2010, David Xu <davidxu@freebsd.org> * All rights reserved. @@ -25,8 +25,6 @@ * (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$ - * */ #ifndef _SYS__UMTX_H_ diff --git a/sys/sys/_unrhdr.h b/sys/sys/_unrhdr.h index 65abe5789710..13edf40fcbe3 100644 --- a/sys/sys/_unrhdr.h +++ b/sys/sys/_unrhdr.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Poul-Henning Kamp * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_UNRHDR_H diff --git a/sys/sys/_winsize.h b/sys/sys/_winsize.h index 78d0b8a6ec38..5030dc401fa9 100644 --- a/sys/sys/_winsize.h +++ b/sys/sys/_winsize.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)ttycom.h 8.1 (Berkeley) 3/28/94 - * $FreeBSD$ */ #ifndef _SYS__WINSIZE_H_ diff --git a/sys/sys/aac_ioctl.h b/sys/sys/aac_ioctl.h index 6b6e2dee756e..7b4c9e5645db 100644 --- a/sys/sys/aac_ioctl.h +++ b/sys/sys/aac_ioctl.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2000 Michael Smith * Copyright (c) 2000 Scott Long @@ -26,8 +26,6 @@ * 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$ */ /* diff --git a/sys/sys/abi_compat.h b/sys/sys/abi_compat.h index 0df31dbfbdce..c2233f2eac2c 100644 --- a/sys/sys/abi_compat.h +++ b/sys/sys/abi_compat.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001 Doug Rabson * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _COMPAT_H_ diff --git a/sys/sys/acct.h b/sys/sys/acct.h index 7f61f3f4fc10..58a68725fd7a 100644 --- a/sys/sys/acct.h +++ b/sys/sys/acct.h @@ -34,7 +34,6 @@ * SUCH DAMAGE. * * @(#)acct.h 8.4 (Berkeley) 1/9/95 - * $FreeBSD$ */ #ifndef _SYS_ACCT_H_ diff --git a/sys/sys/acl.h b/sys/sys/acl.h index b6958e73c881..f679808dceca 100644 --- a/sys/sys/acl.h +++ b/sys/sys/acl.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1999-2001 Robert N. M. Watson * Copyright (c) 2008 Edward Tomasz Napierała <trasz@FreeBSD.org> @@ -27,8 +27,6 @@ * 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$ */ /* * Developed by the TrustedBSD Project. diff --git a/sys/sys/agpio.h b/sys/sys/agpio.h index 69b91462f39b..46a436e46768 100644 --- a/sys/sys/agpio.h +++ b/sys/sys/agpio.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2000 Doug Rabson * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_AGPIO_H_ diff --git a/sys/sys/aio.h b/sys/sys/aio.h index 7b931d04febc..a1aa96efed09 100644 --- a/sys/sys/aio.h +++ b/sys/sys/aio.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1997 John S. Dyson. All rights reserved. * @@ -14,8 +14,6 @@ * DISCLAIMER: This code isn't warranted to do anything useful. Anything * bad that happens because of using this software isn't the responsibility * of the author. This software is distributed AS-IS. - * - * $FreeBSD$ */ #ifndef _SYS_AIO_H_ @@ -151,7 +149,7 @@ struct kaiocb { aio_handle_fn_t *handle_fn; /* (c) backend handle function */ union { /* Backend-specific data fields */ struct { /* BIO backend */ - int nbio; /* Number of remaining bios */ + volatile u_int nbio; /* Number of remaining bios */ int error; /* Worst error of all bios */ long nbytes; /* Bytes completed so far */ }; diff --git a/sys/sys/alq.h b/sys/sys/alq.h index fc8962c13cdb..d230240321fd 100644 --- a/sys/sys/alq.h +++ b/sys/sys/alq.h @@ -31,8 +31,6 @@ * (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$ - * */ #ifndef _SYS_ALQ_H_ #define _SYS_ALQ_H_ diff --git a/sys/sys/apm.h b/sys/sys/apm.h index ef076ea594b4..307f6ac529d9 100644 --- a/sys/sys/apm.h +++ b/sys/sys/apm.h @@ -1,5 +1,4 @@ /*- * This file is in the public domain. */ -/* $FreeBSD$ */ #include <sys/disk/apm.h> diff --git a/sys/sys/arb.h b/sys/sys/arb.h index aa076e4681b9..850b0c7f2591 100644 --- a/sys/sys/arb.h +++ b/sys/sys/arb.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright 2002 Niels Provos <provos@citi.umich.edu> * Copyright 2018-2019 Netflix, Inc. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_ARB_H_ diff --git a/sys/sys/asan.h b/sys/sys/asan.h index caa6643bda68..a3becdef5f57 100644 --- a/sys/sys/asan.h +++ b/sys/sys/asan.h @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS_ASAN_H_ @@ -56,11 +54,10 @@ #define KASAN_EXEC_ARGS_FREED 0xFF void kasan_init(void); +void kasan_init_early(vm_offset_t, size_t); void kasan_shadow_map(vm_offset_t, size_t); - void kasan_mark(const void *, size_t, size_t, uint8_t); #else /* KASAN */ -#define kasan_early_init(u) #define kasan_init() #define kasan_shadow_map(a, s) #define kasan_mark(p, s, l, c) diff --git a/sys/sys/assym.h b/sys/sys/assym.h index 3cb4afd5803c..dab3febe9f1d 100644 --- a/sys/sys/assym.h +++ b/sys/sys/assym.h @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS_ASSYM_H_ diff --git a/sys/sys/ata.h b/sys/sys/ata.h index 2cebba0e4864..5e9c2bcb9aa0 100644 --- a/sys/sys/ata.h +++ b/sys/sys/ata.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2000 - 2008 Søren Schmidt <sos@FreeBSD.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_ATA_H_ diff --git a/sys/sys/atomic_common.h b/sys/sys/atomic_common.h index e3969b241a8c..83e0d5af583d 100644 --- a/sys/sys/atomic_common.h +++ b/sys/sys/atomic_common.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2017 The FreeBSD Foundation * @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS_ATOMIC_COMMON_H_ #define _SYS_ATOMIC_COMMON_H_ @@ -36,39 +34,99 @@ #error do not include this header, use machine/atomic.h #endif -#define atomic_load_char(p) (*(volatile u_char *)(p)) -#define atomic_load_short(p) (*(volatile u_short *)(p)) -#define atomic_load_int(p) (*(volatile u_int *)(p)) -#define atomic_load_long(p) (*(volatile u_long *)(p)) -#define atomic_load_ptr(p) (*(volatile __typeof(*p) *)(p)) -#define atomic_load_8(p) (*(volatile uint8_t *)(p)) -#define atomic_load_16(p) (*(volatile uint16_t *)(p)) -#define atomic_load_32(p) (*(volatile uint32_t *)(p)) -#ifdef _LP64 -#define atomic_load_64(p) (*(volatile uint64_t *)(p)) -#endif +#include <sys/types.h> + +#define __atomic_load_bool_relaxed(p) (*(volatile _Bool *)(p)) +#define __atomic_store_bool_relaxed(p, v) \ + (*(volatile _Bool *)(p) = (_Bool)(v)) + +#define __atomic_load_char_relaxed(p) (*(volatile u_char *)(p)) +#define __atomic_load_short_relaxed(p) (*(volatile u_short *)(p)) +#define __atomic_load_int_relaxed(p) (*(volatile u_int *)(p)) +#define __atomic_load_long_relaxed(p) (*(volatile u_long *)(p)) +#define __atomic_load_8_relaxed(p) (*(volatile uint8_t *)(p)) +#define __atomic_load_16_relaxed(p) (*(volatile uint16_t *)(p)) +#define __atomic_load_32_relaxed(p) (*(volatile uint32_t *)(p)) +#define __atomic_load_64_relaxed(p) (*(volatile uint64_t *)(p)) -#define atomic_store_char(p, v) \ +#define __atomic_store_char_relaxed(p, v) \ (*(volatile u_char *)(p) = (u_char)(v)) -#define atomic_store_short(p, v) \ +#define __atomic_store_short_relaxed(p, v) \ (*(volatile u_short *)(p) = (u_short)(v)) -#define atomic_store_int(p, v) \ +#define __atomic_store_int_relaxed(p, v) \ (*(volatile u_int *)(p) = (u_int)(v)) -#define atomic_store_long(p, v) \ +#define __atomic_store_long_relaxed(p, v) \ (*(volatile u_long *)(p) = (u_long)(v)) -#define atomic_store_ptr(p, v) \ - (*(volatile __typeof(*p) *)(p) = (v)) -#define atomic_store_8(p, v) \ +#define __atomic_store_8_relaxed(p, v) \ (*(volatile uint8_t *)(p) = (uint8_t)(v)) -#define atomic_store_16(p, v) \ +#define __atomic_store_16_relaxed(p, v) \ (*(volatile uint16_t *)(p) = (uint16_t)(v)) -#define atomic_store_32(p, v) \ +#define __atomic_store_32_relaxed(p, v) \ (*(volatile uint32_t *)(p) = (uint32_t)(v)) -#ifdef _LP64 -#define atomic_store_64(p, v) \ +#define __atomic_store_64_relaxed(p, v) \ (*(volatile uint64_t *)(p) = (uint64_t)(v)) + +/* + * When _Generic is available, try to provide some type checking. + */ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ + __has_extension(c_generic_selections) +#define atomic_load_bool(p) \ + _Generic(*(p), _Bool: __atomic_load_bool_relaxed(p)) +#define atomic_store_bool(p, v) \ + _Generic(*(p), _Bool: __atomic_store_bool_relaxed(p, v)) + +#define __atomic_load_generic(p, t, ut, n) \ + _Generic(*(p), \ + t: __atomic_load_ ## n ## _relaxed(p), \ + ut: __atomic_load_ ## n ## _relaxed(p)) +#define __atomic_store_generic(p, v, t, ut, n) \ + _Generic(*(p), \ + t: __atomic_store_ ## n ## _relaxed(p, v), \ + ut: __atomic_store_ ## n ## _relaxed(p, v)) +#else +#define atomic_load_bool(p) \ + __atomic_load_bool_relaxed(p) +#define atomic_store_bool(p, v) \ + __atomic_store_bool_relaxed(p, v) +#define __atomic_load_generic(p, t, ut, n) \ + __atomic_load_ ## n ## _relaxed(p) +#define __atomic_store_generic(p, v, t, ut, n) \ + __atomic_store_ ## n ## _relaxed(p, v) +#endif + +#define atomic_load_char(p) __atomic_load_generic(p, char, u_char, char) +#define atomic_load_short(p) __atomic_load_generic(p, short, u_short, short) +#define atomic_load_int(p) __atomic_load_generic(p, int, u_int, int) +#define atomic_load_long(p) __atomic_load_generic(p, long, u_long, long) +#define atomic_load_8(p) __atomic_load_generic(p, int8_t, uint8_t, 8) +#define atomic_load_16(p) __atomic_load_generic(p, int16_t, uint16_t, 16) +#define atomic_load_32(p) __atomic_load_generic(p, int32_t, uint32_t, 32) +#ifdef __LP64__ +#define atomic_load_64(p) __atomic_load_generic(p, int64_t, uint64_t, 64) +#endif +#define atomic_store_char(p, v) \ + __atomic_store_generic(p, v, char, u_char, char) +#define atomic_store_short(p, v) \ + __atomic_store_generic(p, v, short, u_short, short) +#define atomic_store_int(p, v) \ + __atomic_store_generic(p, v, int, u_int, int) +#define atomic_store_long(p, v) \ + __atomic_store_generic(p, v, long, u_long, long) +#define atomic_store_8(p, v) \ + __atomic_store_generic(p, v, int8_t, uint8_t, 8) +#define atomic_store_16(p, v) \ + __atomic_store_generic(p, v, int16_t, uint16_t, 16) +#define atomic_store_32(p, v) \ + __atomic_store_generic(p, v, int32_t, uint32_t, 32) +#ifdef __LP64__ +#define atomic_store_64(p, v) \ + __atomic_store_generic(p, v, int64_t, uint64_t, 64) #endif +#define atomic_load_ptr(p) (*(volatile __typeof(*p) *)(p)) +#define atomic_store_ptr(p, v) (*(volatile __typeof(*p) *)(p) = (v)) + /* * Currently all architectures provide acquire and release fences on their own, * but they don't provide consume. Kludge below allows relevant code to stop @@ -79,4 +137,4 @@ #define atomic_interrupt_fence() __compiler_membar() -#endif +#endif /* !_SYS_ATOMIC_COMMON_H_ */ diff --git a/sys/sys/atomic_san.h b/sys/sys/atomic_san.h index b0790962d8bd..eb6913296a45 100644 --- a/sys/sys/atomic_san.h +++ b/sys/sys/atomic_san.h @@ -32,8 +32,6 @@ * 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$ */ #ifndef _SYS_ATOMIC_SAN_H_ @@ -43,6 +41,8 @@ #error do not include this header, use machine/atomic.h #endif +#include <sys/types.h> + #define ATOMIC_SAN_FUNC_1(sp, op, name, type) \ void sp##_atomic_##op##_##name(volatile type *, type); \ void sp##_atomic_##op##_acq_##name(volatile type *, type); \ @@ -65,11 +65,15 @@ type sp##_atomic_readandclear_##name(volatile type *) #define ATOMIC_SAN_LOAD(sp, name, type) \ - type sp##_atomic_load_##name(volatile type *); \ + type sp##_atomic_load_##name(volatile type *) + +#define ATOMIC_SAN_LOAD_ACQ(sp, name, type) \ type sp##_atomic_load_acq_##name(volatile type *) #define ATOMIC_SAN_STORE(sp, name, type) \ - void sp##_atomic_store_##name(volatile type *, type); \ + void sp##_atomic_store_##name(volatile type *, type) + +#define ATOMIC_SAN_STORE_REL(sp, name, type) \ void sp##_atomic_store_rel_##name(volatile type *, type) #define ATOMIC_SAN_TEST(sp, op, name, type) \ @@ -86,6 +90,10 @@ #define ATOMIC_SAN_THREAD_FENCE(sp) \ _ATOMIC_SAN_THREAD_FENCE(sp) +#define ATOMIC_SAN_LOAD_STORE(sp, name, type) \ + ATOMIC_SAN_LOAD(sp, name, type); \ + ATOMIC_SAN_STORE(sp, name, type) + #define _ATOMIC_SAN_FUNCS(sp, name, type) \ ATOMIC_SAN_FUNC_1(sp, add, name, type); \ ATOMIC_SAN_FUNC_1(sp, clear, name, type); \ @@ -93,10 +101,12 @@ ATOMIC_SAN_FCMPSET(sp, name, type); \ ATOMIC_SAN_READ(sp, fetchadd, name, type); \ ATOMIC_SAN_LOAD(sp, name, type); \ + ATOMIC_SAN_LOAD_ACQ(sp, name, type); \ ATOMIC_SAN_READANDCLEAR(sp, name, type); \ ATOMIC_SAN_FUNC_1(sp, set, name, type); \ ATOMIC_SAN_FUNC_1(sp, subtract, name, type); \ ATOMIC_SAN_STORE(sp, name, type); \ + ATOMIC_SAN_STORE_REL(sp, name, type); \ ATOMIC_SAN_READ(sp, swap, name, type); \ ATOMIC_SAN_TEST(sp, testandclear, name, type); \ ATOMIC_SAN_TEST(sp, testandset, name, type) @@ -113,6 +123,7 @@ ATOMIC_SAN_FUNCS(8, uint8_t); ATOMIC_SAN_FUNCS(16, uint16_t); ATOMIC_SAN_FUNCS(32, uint32_t); ATOMIC_SAN_FUNCS(64, uint64_t); +ATOMIC_SAN_LOAD_STORE(SAN_INTERCEPTOR_PREFIX, bool, bool); ATOMIC_SAN_THREAD_FENCE(SAN_INTERCEPTOR_PREFIX); #ifndef SAN_RUNTIME @@ -125,6 +136,9 @@ ATOMIC_SAN_THREAD_FENCE(SAN_INTERCEPTOR_PREFIX); #define ATOMIC_SAN(func) \ __CONCAT(SAN_INTERCEPTOR_PREFIX, __CONCAT(_atomic_, func)) +#define atomic_load_bool ATOMIC_SAN(load_bool) +#define atomic_store_bool ATOMIC_SAN(store_bool) + #define atomic_add_char ATOMIC_SAN(add_char) #define atomic_add_acq_char ATOMIC_SAN(add_acq_char) #define atomic_add_rel_char ATOMIC_SAN(add_rel_char) @@ -251,17 +265,11 @@ ATOMIC_SAN_THREAD_FENCE(SAN_INTERCEPTOR_PREFIX); #define atomic_fcmpset_acq_ptr ATOMIC_SAN(fcmpset_acq_ptr) #define atomic_fcmpset_rel_ptr ATOMIC_SAN(fcmpset_rel_ptr) #define atomic_fetchadd_ptr ATOMIC_SAN(fetchadd_ptr) -#define atomic_load_ptr(x) ({ \ - __typeof(*x) __retptr; \ - __retptr = (void *)ATOMIC_SAN(load_ptr)((volatile uintptr_t *)(x)); \ - __retptr; \ -}) +#define atomic_load_ptr(x) \ + ((void *)ATOMIC_SAN(load_ptr)(__DECONST(volatile uintptr_t *, (x)))) #define atomic_load_acq_ptr ATOMIC_SAN(load_acq_ptr) -#define atomic_load_consume_ptr(x) ({ \ - __typeof(*x) __retptr; \ - __retptr = (void *)atomic_load_acq_ptr((volatile uintptr_t *)(x));\ - __retptr; \ -}) +#define atomic_load_consume_ptr(x) \ + ((void *)atomic_load_acq_ptr((volatile uintptr_t *)(x))) #define atomic_readandclear_ptr ATOMIC_SAN(readandclear_ptr) #define atomic_set_ptr ATOMIC_SAN(set_ptr) #define atomic_set_acq_ptr ATOMIC_SAN(set_acq_ptr) diff --git a/sys/sys/auxv.h b/sys/sys/auxv.h index 97616055ecc6..675deee26378 100644 --- a/sys/sys/auxv.h +++ b/sys/sys/auxv.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2017 Michal Meloun * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_AUXV_H_ diff --git a/sys/sys/backlight.h b/sys/sys/backlight.h index 697e0b6b6349..9e669c81d62c 100644 --- a/sys/sys/backlight.h +++ b/sys/sys/backlight.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2020 Emmanuel Vadot <manu@FreeBSD.org> * @@ -23,8 +23,6 @@ * 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$ */ #ifndef __BACKLIGHT_H__ diff --git a/sys/sys/bio.h b/sys/sys/bio.h index be4f4cd6c073..45a1ae724d73 100644 --- a/sys/sys/bio.h +++ b/sys/sys/bio.h @@ -34,7 +34,6 @@ * SUCH DAMAGE. * * @(#)buf.h 8.9 (Berkeley) 3/30/95 - * $FreeBSD$ */ #ifndef _SYS_BIO_H_ diff --git a/sys/sys/bitcount.h b/sys/sys/bitcount.h new file mode 100644 index 000000000000..aaa85c38d2e3 --- /dev/null +++ b/sys/sys/bitcount.h @@ -0,0 +1,106 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 1982, 1986, 1991, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * 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. + * 3. 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 REGENTS 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 REGENTS 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. + * + * @(#)types.h 8.6 (Berkeley) 2/19/95 + */ + +#ifndef _SYS_BITCOUNT_H_ +#define _SYS_BITCOUNT_H_ + +#include <sys/_types.h> + +#ifdef __POPCNT__ +#define __bitcount64(x) __builtin_popcountll((__uint64_t)(x)) +#define __bitcount32(x) __builtin_popcount((__uint32_t)(x)) +#define __bitcount16(x) __builtin_popcount((__uint16_t)(x)) +#define __bitcountl(x) __builtin_popcountl((unsigned long)(x)) +#define __bitcount(x) __builtin_popcount((unsigned int)(x)) +#else +/* + * Population count algorithm using SWAR approach + * - "SIMD Within A Register". + */ +static __inline __uint16_t +__bitcount16(__uint16_t _x) +{ + + _x = (_x & 0x5555) + ((_x & 0xaaaa) >> 1); + _x = (_x & 0x3333) + ((_x & 0xcccc) >> 2); + _x = (_x + (_x >> 4)) & 0x0f0f; + _x = (_x + (_x >> 8)) & 0x00ff; + return (_x); +} + +static __inline __uint32_t +__bitcount32(__uint32_t _x) +{ + + _x = (_x & 0x55555555) + ((_x & 0xaaaaaaaa) >> 1); + _x = (_x & 0x33333333) + ((_x & 0xcccccccc) >> 2); + _x = (_x + (_x >> 4)) & 0x0f0f0f0f; + _x = (_x + (_x >> 8)); + _x = (_x + (_x >> 16)) & 0x000000ff; + return (_x); +} + +#ifdef __LP64__ +static __inline __uint64_t +__bitcount64(__uint64_t _x) +{ + + _x = (_x & 0x5555555555555555) + ((_x & 0xaaaaaaaaaaaaaaaa) >> 1); + _x = (_x & 0x3333333333333333) + ((_x & 0xcccccccccccccccc) >> 2); + _x = (_x + (_x >> 4)) & 0x0f0f0f0f0f0f0f0f; + _x = (_x + (_x >> 8)); + _x = (_x + (_x >> 16)); + _x = (_x + (_x >> 32)) & 0x000000ff; + return (_x); +} + +#define __bitcountl(x) __bitcount64((unsigned long)(x)) +#else +static __inline __uint64_t +__bitcount64(__uint64_t _x) +{ + + return (__bitcount32(_x >> 32) + __bitcount32(_x)); +} + +#define __bitcountl(x) __bitcount32((unsigned long)(x)) +#endif +#define __bitcount(x) __bitcount32((unsigned int)(x)) +#endif + +#endif /* !_SYS_BITCOUNT_H_ */ diff --git a/sys/sys/bitset.h b/sys/sys/bitset.h index 4952d48b1b3c..5ff2bb76a4ab 100644 --- a/sys/sys/bitset.h +++ b/sys/sys/bitset.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2008, Jeffrey Roberson <jeff@freebsd.org> * All rights reserved. @@ -27,8 +27,6 @@ * 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$ */ #ifndef _SYS_BITSET_H_ @@ -309,9 +307,6 @@ #define __BITSET_SIZE(_s) (__bitset_words((_s)) * sizeof(long)) #if defined(_KERNEL) || defined(_WANT_FREEBSD_BITSET) -/* - * Dynamically allocate a bitset. - */ #define BIT_AND(_s, d, s) __BIT_AND(_s, d, s) #define BIT_AND2(_s, d, s1, s2) __BIT_AND2(_s, d, s1, s2) #define BIT_ANDNOT(_s, d, s) __BIT_ANDNOT(_s, d, s) @@ -328,8 +323,7 @@ #define BIT_FFS_AT(_s, p, start) __BIT_FFS_AT(_s, p, start) #define BIT_FILL(_s, p) __BIT_FILL(_s, p) #define BIT_FLS(_s, p) __BIT_FLS(_s, p) -#define BIT_FOREACH(_s, i, p, op) __BIT_FOREACH(_s, i, p, op) -#define BIT_FOREACH_ADVANCE(_s, i, p, op) __BIT_FOREACH_ADVANCE(_s, i, p, op) +#define BIT_FOREACH(_s, i, p, op) __BIT_FOREACH(_s, i, p, op) #define BIT_FOREACH_ISCLR(_s, i, p) __BIT_FOREACH_ISCLR(_s, i, p) #define BIT_FOREACH_ISSET(_s, i, p) __BIT_FOREACH_ISSET(_s, i, p) #define BIT_ISFULLSET(_s, p) __BIT_ISFULLSET(_s, p) @@ -350,6 +344,9 @@ #define BIT_ZERO(_s, p) __BIT_ZERO(_s, p) #if defined(_KERNEL) +/* + * Dynamically allocate a bitset. + */ #define BITSET_ALLOC(_s, mt, mf) malloc(__BITSET_SIZE((_s)), mt, (mf)) #define BITSET_FREE(p, mt) free(p, mt) #endif /* _KERNEL */ diff --git a/sys/sys/bitstring.h b/sys/sys/bitstring.h index 3d239c531e47..127de2ebc419 100644 --- a/sys/sys/bitstring.h +++ b/sys/sys/bitstring.h @@ -58,8 +58,6 @@ * 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 DAMAGES. - * - * $FreeBSD$ */ #ifndef _SYS_BITSTRING_H_ #define _SYS_BITSTRING_H_ diff --git a/sys/sys/blist.h b/sys/sys/blist.h index 654708b2ae5f..1d12b8ce98f9 100644 --- a/sys/sys/blist.h +++ b/sys/sys/blist.h @@ -50,8 +50,6 @@ * the memory utilization would be insane if you actually did * that. Managing something like 512MB worth of 4K blocks * eats around 32 KBytes of memory. - * - * $FreeBSD$ */ diff --git a/sys/sys/blockcount.h b/sys/sys/blockcount.h index de1358b7da48..719c28d6863b 100644 --- a/sys/sys/blockcount.h +++ b/sys/sys/blockcount.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2005 John Baldwin <jhb@FreeBSD.org> * Copyright (c) 2020 The FreeBSD Foundation @@ -27,8 +27,6 @@ * 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$ */ #ifndef __SYS_BLOCKCOUNT_H__ diff --git a/sys/sys/boot.h b/sys/sys/boot.h index 7874d9663736..277fbbc0889f 100644 --- a/sys/sys/boot.h +++ b/sys/sys/boot.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2014 Roger Pau Monné <roger.pau@citrix.com> * All rights reserved. @@ -25,8 +25,6 @@ * 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$ */ #ifndef _SYS_BOOT_H_ @@ -36,7 +34,7 @@ int boot_env_to_howto(void); void boot_howto_to_env(int howto); -int boot_parse_arg(char *v); +int boot_parse_arg(const char *v); int boot_parse_cmdline_delim(char *cmdline, const char *delim); int boot_parse_cmdline(char *cmdline); int boot_parse_args(int argc, char *argv[]); diff --git a/sys/sys/boottrace.h b/sys/sys/boottrace.h index 2cb17c15ff0f..3a873d96c826 100644 --- a/sys/sys/boottrace.h +++ b/sys/sys/boottrace.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2008-2022 NetApp, Inc. * diff --git a/sys/sys/buf.h b/sys/sys/buf.h index fa930487235f..7fffb52f84f2 100644 --- a/sys/sys/buf.h +++ b/sys/sys/buf.h @@ -34,7 +34,6 @@ * SUCH DAMAGE. * * @(#)buf.h 8.9 (Berkeley) 3/30/95 - * $FreeBSD$ */ #ifndef _SYS_BUF_H_ @@ -522,7 +521,8 @@ extern int bdwriteskip; extern int dirtybufferflushes; extern int altbufferflushes; extern int nswbuf; /* Number of swap I/O buffer headers. */ -extern caddr_t unmapped_buf; /* Data address for unmapped buffers. */ +extern caddr_t __read_mostly unmapped_buf; /* Data address for unmapped + buffers. */ static inline int buf_mapped(struct buf *bp) diff --git a/sys/sys/buf_ring.h b/sys/sys/buf_ring.h index 9622503e1f96..32c9f5b15f22 100644 --- a/sys/sys/buf_ring.h +++ b/sys/sys/buf_ring.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2007-2009 Kip Macy <kmacy@freebsd.org> * All rights reserved. @@ -25,8 +25,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ - * */ #ifndef _SYS_BUF_RING_H_ diff --git a/sys/sys/bufobj.h b/sys/sys/bufobj.h index 0945097077b4..d70327e31a37 100644 --- a/sys/sys/bufobj.h +++ b/sys/sys/bufobj.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Poul-Henning Kamp * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ /* diff --git a/sys/sys/bus.h b/sys/sys/bus.h index a1d11138a1cc..fc07cf70f78a 100644 --- a/sys/sys/bus.h +++ b/sys/sys/bus.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1997,1998,2003 Doug Rabson * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_BUS_H_ @@ -72,6 +70,7 @@ typedef enum device_property_type { DEVICE_PROP_BUFFER = 1, DEVICE_PROP_UINT32 = 2, DEVICE_PROP_UINT64 = 3, + DEVICE_PROP_HANDLE = 4, } device_property_type_t; /** @@ -252,17 +251,19 @@ typedef void driver_intr_t(void*); /** * @brief Interrupt type bits. - * - * These flags are used both by newbus interrupt - * registration (nexus.c) and also in struct intrec, which defines - * interrupt properties. * - * XXX We should probably revisit this and remove the vestiges of the - * spls implicit in names like INTR_TYPE_TTY. In the meantime, don't - * confuse things by renaming them (Grog, 18 July 2000). + * These flags may be passed by drivers to bus_setup_intr(9) when + * registering a new interrupt handler. The field is overloaded to + * specify both the interrupt's type and any special properties. + * + * The INTR_TYPE* bits will be passed to intr_priority(9) to determine + * the scheduling priority of the handler's ithread. Historically, each + * type was assigned a unique scheduling preference, but now only + * INTR_TYPE_CLK receives a default priority higher than other + * interrupts. See sys/priority.h. * - * Buses which do interrupt remapping will want to change their type - * to reflect what sort of devices are underneath. + * Buses may choose to modify or augment these flags as appropriate, + * e.g. nexus may apply INTR_EXCL. */ enum intr_type { INTR_TYPE_TTY = 1, @@ -758,6 +759,7 @@ void bus_data_generation_update(void); #define BUS_LOCATOR_ACPI "ACPI" #define BUS_LOCATOR_FREEBSD "FreeBSD" #define BUS_LOCATOR_UEFI "UEFI" +#define BUS_LOCATOR_OFW "OFW" extern int bus_current_pass; @@ -800,17 +802,14 @@ struct driver_module_data { int dmd_pass; }; -#define _DRIVER_MODULE_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, NAME, ...) \ - NAME - -#define _EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, devclass, \ - evh, arg, order, pass) \ - \ +#define EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, evh, arg, \ + order, pass) \ + \ static struct driver_module_data name##_##busname##_driver_mod = { \ evh, arg, \ #busname, \ (kobj_class_t) &driver, \ - devclass, \ + NULL, \ pass \ }; \ \ @@ -822,57 +821,18 @@ static moduledata_t name##_##busname##_mod = { \ DECLARE_MODULE(name##_##busname, name##_##busname##_mod, \ SI_SUB_DRIVERS, order) -#define EARLY_DRIVER_MODULE_ORDERED7(name, busname, driver, evh, arg, \ - order, pass) \ - _EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, NULL, evh, \ - arg, order, pass) - -#define EARLY_DRIVER_MODULE_ORDERED8(name, busname, driver, devclass, \ - evh, arg, order, pass) \ - _EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, &devclass, \ - evh, arg, order, pass) - -#define EARLY_DRIVER_MODULE_ORDERED(...) \ - _DRIVER_MODULE_MACRO(__VA_ARGS__, EARLY_DRIVER_MODULE_ORDERED8, \ - EARLY_DRIVER_MODULE_ORDERED7)(__VA_ARGS__) - -#define EARLY_DRIVER_MODULE7(name, busname, driver, devclass, evh, arg, pass) \ - EARLY_DRIVER_MODULE_ORDERED8(name, busname, driver, devclass, \ - evh, arg, SI_ORDER_MIDDLE, pass) - -#define EARLY_DRIVER_MODULE6(name, busname, driver, evh, arg, pass) \ - EARLY_DRIVER_MODULE_ORDERED7(name, busname, driver, evh, arg, \ +#define EARLY_DRIVER_MODULE(name, busname, driver, evh, arg, pass) \ + EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, evh, arg, \ SI_ORDER_MIDDLE, pass) -#define EARLY_DRIVER_MODULE(...) \ - _DRIVER_MODULE_MACRO(__VA_ARGS__, INVALID, \ - EARLY_DRIVER_MODULE7, EARLY_DRIVER_MODULE6)(__VA_ARGS__) - -#define DRIVER_MODULE_ORDERED7(name, busname, driver, devclass, evh, arg,\ - order) \ - EARLY_DRIVER_MODULE_ORDERED8(name, busname, driver, devclass, \ - evh, arg, order, BUS_PASS_DEFAULT) - -#define DRIVER_MODULE_ORDERED6(name, busname, driver, evh, arg, order) \ - EARLY_DRIVER_MODULE_ORDERED7(name, busname, driver, evh, arg, \ +#define DRIVER_MODULE_ORDERED(name, busname, driver, evh, arg, order) \ + EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, evh, arg, \ order, BUS_PASS_DEFAULT) -#define DRIVER_MODULE_ORDERED(...) \ - _DRIVER_MODULE_MACRO(__VA_ARGS__, INVALID, \ - DRIVER_MODULE_ORDERED7, DRIVER_MODULE_ORDERED6)(__VA_ARGS__) - -#define DRIVER_MODULE6(name, busname, driver, devclass, evh, arg) \ - EARLY_DRIVER_MODULE7(name, busname, driver, devclass, evh, arg, \ - BUS_PASS_DEFAULT) - -#define DRIVER_MODULE5(name, busname, driver, evh, arg) \ - EARLY_DRIVER_MODULE6(name, busname, driver, evh, arg, \ +#define DRIVER_MODULE(name, busname, driver, evh, arg) \ + EARLY_DRIVER_MODULE(name, busname, driver, evh, arg, \ BUS_PASS_DEFAULT) -#define DRIVER_MODULE(...) \ - _DRIVER_MODULE_MACRO(__VA_ARGS__, INVALID, INVALID, \ - DRIVER_MODULE6, DRIVER_MODULE5)(__VA_ARGS__) - /** * Generic ivar accessor generation macros for bus drivers */ diff --git a/sys/sys/bus_dma.h b/sys/sys/bus_dma.h index 212d8e3af09d..530816f0532c 100644 --- a/sys/sys/bus_dma.h +++ b/sys/sys/bus_dma.h @@ -1,7 +1,7 @@ /* $NetBSD: bus.h,v 1.12 1997/10/01 08:25:15 fvdl Exp $ */ /*- - * SPDX-License-Identifier: (BSD-2-Clause-NetBSD AND BSD-4-Clause) + * SPDX-License-Identifier: (BSD-2-Clause AND BSD-4-Clause) * * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. * All rights reserved. @@ -62,7 +62,6 @@ * (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$ */ #ifndef _BUS_DMA_H_ #define _BUS_DMA_H_ diff --git a/sys/sys/bus_dma_internal.h b/sys/sys/bus_dma_internal.h index 0f5353974080..313c7c7e284b 100644 --- a/sys/sys/bus_dma_internal.h +++ b/sys/sys/bus_dma_internal.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2017 Jason A. Harmening. * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _BUS_DMA_INTERNAL_H_ diff --git a/sys/sys/bus_san.h b/sys/sys/bus_san.h index 09feb0660525..155d7fc0695c 100644 --- a/sys/sys/bus_san.h +++ b/sys/sys/bus_san.h @@ -32,8 +32,6 @@ * 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$ */ #ifndef _SYS_BUS_SAN_H_ diff --git a/sys/sys/busdma_bufalloc.h b/sys/sys/busdma_bufalloc.h index fe281212d20a..f06ba51c0d97 100644 --- a/sys/sys/busdma_bufalloc.h +++ b/sys/sys/busdma_bufalloc.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2012 Ian Lepore * All rights reserved. @@ -27,7 +27,6 @@ */ /* - * $FreeBSD$ */ /* diff --git a/sys/sys/callout.h b/sys/sys/callout.h index 9aa28e29d35c..93034f81c052 100644 --- a/sys/sys/callout.h +++ b/sys/sys/callout.h @@ -34,7 +34,6 @@ * SUCH DAMAGE. * * @(#)callout.h 8.2 (Berkeley) 1/21/94 - * $FreeBSD$ */ #ifndef _SYS_CALLOUT_H_ diff --git a/sys/sys/caprights.h b/sys/sys/caprights.h index f4325ea0ba57..32ae05172e24 100644 --- a/sys/sys/caprights.h +++ b/sys/sys/caprights.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2013 FreeBSD Foundation * @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS_CAPRIGHTS_H_ diff --git a/sys/sys/capsicum.h b/sys/sys/capsicum.h index af596cd179f4..93c5f0c9c390 100644 --- a/sys/sys/capsicum.h +++ b/sys/sys/capsicum.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2008-2010, 2015 Robert N. M. Watson * Copyright (c) 2012 FreeBSD Foundation @@ -31,8 +31,6 @@ * 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$ */ /* diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h index 2295dd39f5ad..4893ae1662b8 100644 --- a/sys/sys/cdefs.h +++ b/sys/sys/cdefs.h @@ -32,7 +32,6 @@ * SUCH DAMAGE. * * @(#)cdefs.h 8.8 (Berkeley) 1/9/95 - * $FreeBSD$ */ #ifndef _SYS_CDEFS_H_ @@ -312,6 +311,9 @@ * __generic(). Unlike _Generic(), this macro can only distinguish * between a single type, so it requires nested invocations to * distinguish multiple cases. + * + * Note that the comma operator is used to force expr to decay in + * order to match _Generic(). */ #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ @@ -321,7 +323,7 @@ #elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus) #define __generic(expr, t, yes, no) \ __builtin_choose_expr( \ - __builtin_types_compatible_p(__typeof(expr), t), yes, no) + __builtin_types_compatible_p(__typeof((0, (expr))), t), yes, no) #endif /* @@ -400,17 +402,15 @@ #endif /* - * GCC 2.95 provides `__restrict' as an extension to C90 to support the - * C99-specific `restrict' type qualifier. We happen to use `__restrict' as - * a way to define the `restrict' type qualifier without disturbing older - * software that is unaware of C99 keywords. + * We use `__restrict' as a way to define the `restrict' type qualifier + * without disturbing older software that is unaware of C99 keywords. + * GCC also provides `__restrict' as an extension to support C99-style + * restricted pointers in other language modes. */ -#if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95) -#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 -#define __restrict -#else +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901 #define __restrict restrict -#endif +#elif !__GNUC_PREREQ__(2, 95) +#define __restrict #endif /* @@ -577,7 +577,6 @@ * Embed the rcs id of a source file in the resulting library. Note that in * more recent ELF binutils, we use .ident allowing the ID to be stripped. * Usage: - * __FBSDID("$FreeBSD$"); */ #ifndef __FBSDID #if !defined(STRIP_FBSDID) @@ -637,15 +636,23 @@ * POSIX.1 requires that the macros we test be defined before any standard * header file is included. * - * Here's a quick run-down of the versions: + * Here's a quick run-down of the versions (and some informal names) * defined(_POSIX_SOURCE) 1003.1-1988 + * encoded as 198808 below * _POSIX_C_SOURCE == 1 1003.1-1990 + * encoded as 199009 below * _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option + * encoded as 199209 below * _POSIX_C_SOURCE == 199309 1003.1b-1993 + * (1003.1 Issue 4, Single Unix Spec v1, Unix 93) * _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995, * and the omnibus ISO/IEC 9945-1: 1996 - * _POSIX_C_SOURCE == 200112 1003.1-2001 - * _POSIX_C_SOURCE == 200809 1003.1-2008 + * (1003.1 Issue 5, Single Unix Spec v2, Unix 95) + * _POSIX_C_SOURCE == 200112 1003.1-2001 (1003.1 Issue 6, Unix 03) + * _POSIX_C_SOURCE == 200809 1003.1-2008 (1003.1 Issue 7) + * IEEE Std 1003.1-2017 (Rev of 1003.1-2008) is + * 1003.1-2008 with two TCs applied with + * _POSIX_C_SOURCE=200809 and _XOPEN_SOURCE=700 * * In addition, the X/Open Portability Guide, which is now the Single UNIX * Specification, defines a feature-test macro which indicates the version of @@ -888,6 +895,16 @@ #define __nosanitizethread #endif +/* + * Make it possible to opt out of stack smashing protection. + */ +#if __has_attribute(no_stack_protector) +#define __nostackprotector __attribute__((no_stack_protector)) +#else +#define __nostackprotector \ + __attribute__((__optimize__("-fno-stack-protector"))) +#endif + /* Guard variables and structure members by lock. */ #define __guarded_by(x) __lock_annotate(guarded_by(x)) #define __pt_guarded_by(x) __lock_annotate(pt_guarded_by(x)) diff --git a/sys/sys/cdio.h b/sys/sys/cdio.h index d8c700024e22..ad7ecd3a9262 100644 --- a/sys/sys/cdio.h +++ b/sys/sys/cdio.h @@ -1,7 +1,5 @@ /* * 16 Feb 93 Julian Elischer (julian@dialix.oz.au) - * - * $FreeBSD$ */ /* diff --git a/sys/sys/cdrio.h b/sys/sys/cdrio.h index f8af2fde5cb5..eb9913a8ba25 100644 --- a/sys/sys/cdrio.h +++ b/sys/sys/cdrio.h @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS_CDRIO_H_ diff --git a/sys/sys/cfictl.h b/sys/sys/cfictl.h index db5ecfe6a7c9..7d8bf5cb10d9 100644 --- a/sys/sys/cfictl.h +++ b/sys/sys/cfictl.h @@ -27,8 +27,6 @@ * 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$ */ #ifndef _SYS_CFICTL_H_ diff --git a/sys/sys/chio.h b/sys/sys/chio.h index 99cfd4528fb0..4bb004626c56 100644 --- a/sys/sys/chio.h +++ b/sys/sys/chio.h @@ -32,8 +32,6 @@ * 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$ */ #ifndef _SYS_CHIO_H_ diff --git a/sys/sys/ck.h b/sys/sys/ck.h index b04fe67b476d..1bb5e6f5be17 100644 --- a/sys/sys/ck.h +++ b/sys/sys/ck.h @@ -1,5 +1,4 @@ /* - * $FreeBSD$ */ #ifndef _SYS_CK_H_ #define _SYS_CK_H_ @@ -13,6 +12,8 @@ #define CK_STAILQ_ENTRY STAILQ_ENTRY #define CK_LIST_HEAD LIST_HEAD #define CK_LIST_ENTRY LIST_ENTRY +#define CK_SLIST_HEAD SLIST_HEAD +#define CK_SLIST_ENTRY SLIST_ENTRY #endif #endif /* !_SYS_CK_H_ */ diff --git a/sys/sys/clock.h b/sys/sys/clock.h index 790efdfee19f..38c999c8ebe2 100644 --- a/sys/sys/clock.h +++ b/sys/sys/clock.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1996 The NetBSD Foundation, Inc. * All rights reserved. @@ -42,8 +42,6 @@ * timezone instead of UTC and so on. * * All that code should go here for service. - * - * $FreeBSD$ */ #ifndef _SYS_CLOCK_H_ diff --git a/sys/sys/cnv.h b/sys/sys/cnv.h index babc913c5637..7741a64b9037 100644 --- a/sys/sys/cnv.h +++ b/sys/sys/cnv.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2016 Adam Starak <starak.adam@gmail.com> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _CNV_H_ @@ -38,6 +36,7 @@ #include <stdbool.h> #include <stdint.h> #include <stdio.h> +#include <sys/nv_namespace.h> #endif #ifndef _NVLIST_T_DECLARED diff --git a/sys/sys/compressor.h b/sys/sys/compressor.h index 5406ef3c3298..cad9080b46ff 100644 --- a/sys/sys/compressor.h +++ b/sys/sys/compressor.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2014, 2017 Mark Johnston <markj@FreeBSD.org> * @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS__COMPRESSOR_H_ diff --git a/sys/sys/condvar.h b/sys/sys/condvar.h index e1a890334afa..23558879452c 100644 --- a/sys/sys/condvar.h +++ b/sys/sys/condvar.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2000 Jake Burkholder <jake@freebsd.org>. * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_CONDVAR_H_ diff --git a/sys/sys/conf.h b/sys/sys/conf.h index 9f60dcaf62fa..f2dfaad5aa1b 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -36,7 +36,6 @@ * SUCH DAMAGE. * * @(#)conf.h 8.5 (Berkeley) 1/9/95 - * $FreeBSD$ */ #ifndef _SYS_CONF_H_ @@ -279,7 +278,6 @@ void destroy_dev(struct cdev *_dev); int destroy_dev_sched(struct cdev *dev); int destroy_dev_sched_cb(struct cdev *dev, void (*cb)(void *), void *arg); void destroy_dev_drain(struct cdevsw *csw); -void drain_dev_clone_events(void); struct cdevsw *dev_refthread(struct cdev *_dev, int *_ref); struct cdevsw *devvn_refthread(struct vnode *vp, struct cdev **devp, int *_ref); void dev_relthread(struct cdev *_dev, int _ref); @@ -361,7 +359,21 @@ struct dumperinfo { extern int dumping; /* system is dumping */ -void dump_savectx(void); +/* + * Save registers for later extraction from a kernel dump. + * + * This must be inlined into the caller, which in turn must be the function that + * calls (mini)dumpsys(). Otherwise, the saved frame pointer will reference a + * stack frame that may be clobbered by subsequent function calls. + */ +#define dump_savectx() do { \ + extern struct pcb dumppcb; \ + extern lwpid_t dumptid; \ + \ + savectx(&dumppcb); \ + dumptid = curthread->td_tid; \ +} while (0) + int doadump(boolean_t); struct diocskerneldump_arg; int dumper_create(const struct dumperinfo *di_template, const char *devname, diff --git a/sys/sys/cons.h b/sys/sys/cons.h index ad73b258df6d..5ad85a516dc5 100644 --- a/sys/sys/cons.h +++ b/sys/sys/cons.h @@ -34,7 +34,6 @@ * SUCH DAMAGE. * * from: @(#)cons.h 7.2 (Berkeley) 5/9/91 - * $FreeBSD$ */ #ifndef _MACHINE_CONS_H_ diff --git a/sys/sys/consio.h b/sys/sys/consio.h index f73f5b474d9e..8904cea66e09 100644 --- a/sys/sys/consio.h +++ b/sys/sys/consio.h @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS_CONSIO_H_ diff --git a/sys/sys/copyright.h b/sys/sys/copyright.h index b749b3babe1e..ee6f5b805164 100644 --- a/sys/sys/copyright.h +++ b/sys/sys/copyright.h @@ -1,7 +1,7 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (C) 1992-2022 The FreeBSD Project. All rights reserved. + * Copyright (C) 1992-2023 The FreeBSD Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,13 +27,15 @@ /* Copyrights macros */ -/* Add a FreeBSD vendor copyright here */ +/* Add a FreeBSD vendor copyright here - or via CFLAGS */ +#ifndef COPYRIGHT_Vendor #define COPYRIGHT_Vendor \ "" +#endif /* FreeBSD */ #define COPYRIGHT_FreeBSD \ - "Copyright (c) 1992-2022 The FreeBSD Project.\n" + "Copyright (c) 1992-2023 The FreeBSD Project.\n" /* Foundation */ #define TRADEMARK_Foundation \ diff --git a/sys/sys/counter.h b/sys/sys/counter.h index 3e1b7828d5d4..65d6a54b47a6 100644 --- a/sys/sys/counter.h +++ b/sys/sys/counter.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2012 Gleb Smirnoff <glebius@FreeBSD.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef __SYS_COUNTER_H__ diff --git a/sys/sys/coverage.h b/sys/sys/coverage.h index f00d6b992cf4..0925a975deeb 100644 --- a/sys/sys/coverage.h +++ b/sys/sys/coverage.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (C) 2018 The FreeBSD Foundation. All rights reserved. * Copyright (C) 2018, 2019 Andrew Turner. @@ -31,8 +31,6 @@ * 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$ */ #ifndef _SYS_COVERAGE_H_ diff --git a/sys/sys/cpu.h b/sys/sys/cpu.h index 60e2c05af693..b6a0094f0c51 100644 --- a/sys/sys/cpu.h +++ b/sys/sys/cpu.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2005-2007 Nate Lawson (SDG) * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_CPU_H_ diff --git a/sys/sys/cpuctl.h b/sys/sys/cpuctl.h index 8c7fb65632f5..6bcc57bf1717 100644 --- a/sys/sys/cpuctl.h +++ b/sys/sys/cpuctl.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2006-2008 Stanislav Sedov <stas@FreeBSD.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _CPUCTL_H_ diff --git a/sys/sys/cpuset.h b/sys/sys/cpuset.h index 5df5cff6497b..219e190f0b37 100644 --- a/sys/sys/cpuset.h +++ b/sys/sys/cpuset.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2008, Jeffrey Roberson <jeff@freebsd.org> * All rights reserved. @@ -27,8 +27,6 @@ * 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$ */ #ifndef _SYS_CPUSET_H_ @@ -75,23 +73,21 @@ #define CPUSET_FSET __BITSET_FSET(_NCPUWORDS) #define CPUSET_T_INITIALIZER(x) __BITSET_T_INITIALIZER(x) -#if !defined(_KERNEL) #define CPU_ALLOC_SIZE(_s) __BITSET_SIZE(_s) #define CPU_ALLOC(_s) __cpuset_alloc(_s) #define CPU_FREE(p) __cpuset_free(p) -#define CPU_ISSET_S(n, _s, p) __BIT_ISSET(_s, n, p) -#define CPU_SET_S(n, _s, p) __BIT_SET(_s, n, p) -#define CPU_CLR_S(n, _s, p) __BIT_CLR(_s, n, p) -#define CPU_ZERO_S(_s, p) __BIT_ZERO(_s, p) +#define CPU_ISSET_S(n, _s, p) __BIT_ISSET((_s) * 8, n, p) +#define CPU_SET_S(n, _s, p) __BIT_SET((_s) * 8, n, p) +#define CPU_CLR_S(n, _s, p) __BIT_CLR((_s) * 8, n, p) +#define CPU_ZERO_S(_s, p) __BIT_ZERO((_s) * 8, p) -#define CPU_OR_S(_s, d, s1, s2) __BIT_OR2(_s, d, s1, s2) -#define CPU_AND_S(_s, d, s1, s2) __BIT_AND2(_s, d, s1, s2) -#define CPU_XOR_S(_s, d, s1, s2) __BIT_XOR2(_s, d, s1, s2) +#define CPU_OR_S(_s, d, s1, s2) __BIT_OR2((_s) * 8, d, s1, s2) +#define CPU_AND_S(_s, d, s1, s2) __BIT_AND2((_s) * 8, d, s1, s2) +#define CPU_XOR_S(_s, d, s1, s2) __BIT_XOR2((_s) * 8, d, s1, s2) -#define CPU_COUNT_S(_s, p) ((int)__BIT_COUNT(_s, p)) -#define CPU_EQUAL_S(_s, p, c) (__BIT_CMP(_s, p, c) == 0) -#endif +#define CPU_COUNT_S(_s, p) ((int)__BIT_COUNT((_s) * 8, p)) +#define CPU_EQUAL_S(_s, p, c) (__BIT_CMP((_s) * 8, p, c) == 0) /* * Valid cpulevel_t values. @@ -111,6 +107,7 @@ #define CPU_WHICH_DOMAIN 6 /* Specifies a NUMA domain id. */ #define CPU_WHICH_INTRHANDLER 7 /* Specifies an irq # (not ithread). */ #define CPU_WHICH_ITHREAD 8 /* Specifies an irq's ithread. */ +#define CPU_WHICH_TIDPID 9 /* Specifies a process or thread id. */ /* * Reserved cpuset identifiers. @@ -122,6 +119,7 @@ #include <sys/queue.h> LIST_HEAD(setlist, cpuset); +extern u_int cpusetsizemin; /* * cpusets encapsulate cpu binding information for one or more threads. diff --git a/sys/sys/crc16.h b/sys/sys/crc16.h new file mode 100644 index 000000000000..38f1e8220c41 --- /dev/null +++ b/sys/sys/crc16.h @@ -0,0 +1,46 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2017, Fedor Uporov + * 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 REGENTS 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 REGENTS 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. + */ + +#include <sys/types.h> + +#ifndef _SYS_CRC16_H_ +#define _SYS_CRC16_H_ + +extern uint16_t const crc16_table[256]; + +static inline uint16_t +crc16(uint16_t crc, const void *buffer, unsigned int len) +{ + const unsigned char *cp = buffer; + while (len--) + crc = (((crc >> 8) & 0xffU) ^ + crc16_table[(crc ^ *cp++) & 0xffU]) & 0x0000ffffU; + return crc; +} + +#endif /* !_SYS_CRC16_H_ */ diff --git a/sys/sys/csan.h b/sys/sys/csan.h index 3b5f9ee74304..4ef681e6a1ff 100644 --- a/sys/sys/csan.h +++ b/sys/sys/csan.h @@ -27,8 +27,6 @@ * 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$ */ #ifndef _SYS_CSAN_H_ diff --git a/sys/sys/ctype.h b/sys/sys/ctype.h index d542e45a9473..effb549b40f8 100644 --- a/sys/sys/ctype.h +++ b/sys/sys/ctype.h @@ -32,8 +32,6 @@ * 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$ */ #ifndef _SYS_CTYPE_H_ diff --git a/sys/sys/devctl.h b/sys/sys/devctl.h index b72cd28dfce8..da26eaabc26c 100644 --- a/sys/sys/devctl.h +++ b/sys/sys/devctl.h @@ -12,11 +12,16 @@ * devctl hooks. Typically one should use the devctl_notify * hook to send the message. */ + bool devctl_process_running(void); void devctl_notify(const char *__system, const char *__subsystem, const char *__type, const char *__data); struct sbuf; void devctl_safe_quote_sb(struct sbuf *__sb, const char *__src); +typedef void send_event_f(const char *system, const char *subsystem, + const char *type, const char *data); +void devctl_set_notify_hook(send_event_f *hook); +void devctl_unset_notify_hook(void); #endif #endif /* _SYS_DEVCTL_H_ */ diff --git a/sys/sys/devicestat.h b/sys/sys/devicestat.h index af3f536e8296..1b8db6f100c9 100644 --- a/sys/sys/devicestat.h +++ b/sys/sys/devicestat.h @@ -26,8 +26,6 @@ * 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$ */ #ifndef _DEVICESTAT_H diff --git a/sys/sys/devmap.h b/sys/sys/devmap.h index af84e5602c67..786608e0ce30 100644 --- a/sys/sys/devmap.h +++ b/sys/sys/devmap.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2013 Ian Lepore <ian@freebsd.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_DEVMAP_H_ diff --git a/sys/sys/dirent.h b/sys/sys/dirent.h index 5bc6cf49afe7..fd36e3bb941b 100644 --- a/sys/sys/dirent.h +++ b/sys/sys/dirent.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)dirent.h 8.3 (Berkeley) 8/10/94 - * $FreeBSD$ */ #ifndef _SYS_DIRENT_H_ @@ -65,7 +64,7 @@ typedef __off_t off_t; struct dirent { ino_t d_fileno; /* file number of entry */ - off_t d_off; /* directory offset of entry */ + off_t d_off; /* directory offset of next entry */ __uint16_t d_reclen; /* length of this record */ __uint8_t d_type; /* file type, see below */ __uint8_t d_pad0; @@ -122,11 +121,14 @@ struct freebsd11_dirent { #define _GENERIC_DIRLEN(namlen) \ ((__offsetof(struct dirent, d_name) + (namlen) + 1 + 7) & ~7) #define _GENERIC_DIRSIZ(dp) _GENERIC_DIRLEN((dp)->d_namlen) +#define _GENERIC_MINDIRSIZ _GENERIC_DIRLEN(1) /* Name must not be empty */ +#define _GENERIC_MAXDIRSIZ _GENERIC_DIRLEN(MAXNAMLEN) #endif /* __BSD_VISIBLE */ #ifdef _KERNEL #define GENERIC_DIRSIZ(dp) _GENERIC_DIRSIZ(dp) - +#define GENERIC_MINDIRSIZ _GENERIC_MINDIRSIZ +#define GENERIC_MAXDIRSIZ _GENERIC_MAXDIRSIZ /* * Ensure that padding bytes are zeroed and that the name is NUL-terminated. */ diff --git a/sys/sys/disk.h b/sys/sys/disk.h index 8edcbe97a8f0..73ae5ce5756e 100644 --- a/sys/sys/disk.h +++ b/sys/sys/disk.h @@ -8,8 +8,6 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $FreeBSD$ - * */ #ifndef _SYS_DISK_H_ @@ -23,10 +21,6 @@ #ifdef _KERNEL -#ifndef _SYS_CONF_H_ -#include <sys/conf.h> /* XXX: temporary to avoid breakage */ -#endif - void disk_err(struct bio *bp, const char *what, int blkdone, int nl); #endif diff --git a/sys/sys/disk/apm.h b/sys/sys/disk/apm.h index 1cf64a53b81a..d8e0eb69a823 100644 --- a/sys/sys/disk/apm.h +++ b/sys/sys/disk/apm.h @@ -22,8 +22,6 @@ * 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$ */ #ifndef _SYS_DISK_APM_H_ diff --git a/sys/sys/disk/bsd.h b/sys/sys/disk/bsd.h index 3e627db09099..02284c5d052b 100644 --- a/sys/sys/disk/bsd.h +++ b/sys/sys/disk/bsd.h @@ -27,7 +27,6 @@ * SUCH DAMAGE. * * @(#)disklabel.h 8.2 (Berkeley) 7/10/94 - * $FreeBSD$ */ #ifndef _SYS_DISK_BSD_H_ diff --git a/sys/sys/disk/gpt.h b/sys/sys/disk/gpt.h index e4faef2c37fb..e48b13684814 100644 --- a/sys/sys/disk/gpt.h +++ b/sys/sys/disk/gpt.h @@ -22,8 +22,6 @@ * 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$ */ #ifndef _SYS_DISK_GPT_H_ diff --git a/sys/sys/disk/mbr.h b/sys/sys/disk/mbr.h index 1241059b02ea..6dc5e92b542d 100644 --- a/sys/sys/disk/mbr.h +++ b/sys/sys/disk/mbr.h @@ -27,7 +27,6 @@ * SUCH DAMAGE. * * @(#)disklabel.h 8.2 (Berkeley) 7/10/94 - * $FreeBSD$ */ #ifndef _SYS_DISK_MBR_H_ diff --git a/sys/sys/disk/vtoc.h b/sys/sys/disk/vtoc.h deleted file mode 100644 index c8e6e86268e4..000000000000 --- a/sys/sys/disk/vtoc.h +++ /dev/null @@ -1,110 +0,0 @@ -/*- - * Copyright (c) 2008 Marcel Moolenaar - * 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 ``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 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$ - */ - -#ifndef _SYS_DISK_VTOC_H_ -#define _SYS_DISK_VTOC_H_ - -#include <sys/types.h> - -#define VTOC_TAG_UNASSIGNED 0x00 -#define VTOC_TAG_BOOT 0x01 -#define VTOC_TAG_ROOT 0x02 -#define VTOC_TAG_SWAP 0x03 -#define VTOC_TAG_USR 0x04 -#define VTOC_TAG_BACKUP 0x05 /* "c" partition */ -#define VTOC_TAG_STAND 0x06 -#define VTOC_TAG_VAR 0x07 -#define VTOC_TAG_HOME 0x08 -#define VTOC_TAG_ALTSCTR 0x09 /* alternate sector partition */ -#define VTOC_TAG_CACHE 0x0a /* Solaris cachefs partition */ -#define VTOC_TAG_VXVM_PUB 0x0e /* VxVM public region */ -#define VTOC_TAG_VXVM_PRIV 0x0f /* VxVM private region */ - -/* NetBSD/mips defines this */ -#define VTOC_TAG_NETBSD_FFS 0xff - -/* FreeBSD tags: the high byte equals ELFOSABI_FREEBSD */ -#define VTOC_TAG_FREEBSD_SWAP 0x0901 -#define VTOC_TAG_FREEBSD_UFS 0x0902 -#define VTOC_TAG_FREEBSD_VINUM 0x0903 -#define VTOC_TAG_FREEBSD_ZFS 0x0904 -#define VTOC_TAG_FREEBSD_NANDFS 0x0905 - -#define VTOC_FLAG_UNMNT 0x01 /* unmountable partition */ -#define VTOC_FLAG_RDONLY 0x10 /* partition is read/only */ - -#define VTOC_ASCII_LEN 128 -#define VTOC_BOOTSIZE 8192 /* 16 sectors */ -#define VTOC_MAGIC 0xdabe -#define VTOC_RAW_PART 2 -#define VTOC_SANITY 0x600ddeee -#define VTOC_VERSION 1 -#define VTOC_VOLUME_LEN 8 - -#define VTOC8_NPARTS 8 - -struct vtoc8 { - char ascii[VTOC_ASCII_LEN]; - uint32_t version; - char volume[VTOC_VOLUME_LEN]; - uint16_t nparts; - struct { - uint16_t tag; - uint16_t flag; - } part[VTOC8_NPARTS]; - uint16_t __alignment; - uint32_t bootinfo[3]; - uint32_t sanity; - uint32_t reserved[10]; - uint32_t timestamp[VTOC8_NPARTS]; - uint16_t wskip; - uint16_t rskip; - char padding[152]; - uint16_t rpm; - uint16_t physcyls; - uint16_t sparesecs; - uint16_t spare1[2]; - uint16_t interleave; - uint16_t ncyls; - uint16_t altcyls; - uint16_t nheads; - uint16_t nsecs; - uint16_t spare2[2]; - struct { - uint32_t cyl; - uint32_t nblks; - } map[VTOC8_NPARTS]; - uint16_t magic; - uint16_t cksum; -}; - -#ifdef CTASSERT -CTASSERT(sizeof(struct vtoc8) == 512); -#endif - -#endif /* _SYS_DISK_VTOC_H_ */ diff --git a/sys/sys/disk_zone.h b/sys/sys/disk_zone.h index 89fc3be716bf..731fc04ecc29 100644 --- a/sys/sys/disk_zone.h +++ b/sys/sys/disk_zone.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2015 Spectra Logic Corporation * All rights reserved. @@ -30,8 +30,6 @@ * POSSIBILITY OF SUCH DAMAGES. * * Authors: Ken Merry (Spectra Logic Corporation) - * - * $FreeBSD$ */ #ifndef _SYS_DISK_ZONE_H_ diff --git a/sys/sys/disklabel.h b/sys/sys/disklabel.h index 6e24f82793fe..da12009ab0eb 100644 --- a/sys/sys/disklabel.h +++ b/sys/sys/disklabel.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)disklabel.h 8.2 (Berkeley) 7/10/94 - * $FreeBSD$ */ #ifndef _SYS_DISKLABEL_H_ diff --git a/sys/sys/diskmbr.h b/sys/sys/diskmbr.h index daa54d409e73..a04bea1c4bba 100644 --- a/sys/sys/diskmbr.h +++ b/sys/sys/diskmbr.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)disklabel.h 8.2 (Berkeley) 7/10/94 - * $FreeBSD$ */ #ifndef _SYS_DISKMBR_H_ diff --git a/sys/sys/dkstat.h b/sys/sys/dkstat.h index 5e2fb39557d5..25ddbe53b00a 100644 --- a/sys/sys/dkstat.h +++ b/sys/sys/dkstat.h @@ -34,7 +34,6 @@ * SUCH DAMAGE. * * @(#)dkstat.h 8.2 (Berkeley) 1/21/94 - * $FreeBSD$ */ #ifndef _SYS_DKSTAT_H_ diff --git a/sys/sys/dnv.h b/sys/sys/dnv.h index 9ddd8720c923..93ba9429bfc6 100644 --- a/sys/sys/dnv.h +++ b/sys/sys/dnv.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2013 The FreeBSD Foundation * @@ -26,8 +26,6 @@ * 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$ */ #ifndef _DNV_H_ @@ -40,6 +38,7 @@ #include <stdbool.h> #include <stddef.h> #include <stdint.h> +#include <sys/nv_namespace.h> #endif #ifndef _NVLIST_T_DECLARED diff --git a/sys/sys/domain.h b/sys/sys/domain.h index 409372e91915..5a06c41eca2d 100644 --- a/sys/sys/domain.h +++ b/sys/sys/domain.h @@ -29,11 +29,11 @@ * SUCH DAMAGE. * * @(#)domain.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD$ */ #ifndef _SYS_DOMAIN_H_ #define _SYS_DOMAIN_H_ +#include <sys/queue.h> /* * Structure per communications domain. @@ -48,7 +48,9 @@ struct socket; struct rib_head; struct domain { + SLIST_ENTRY(domain) dom_next; int dom_family; /* AF_xxx */ + u_int dom_nprotosw; /* length of dom_protosw[] */ char *dom_name; int dom_flags; int (*dom_probe)(void); /* check for support (optional) */ @@ -56,8 +58,6 @@ struct domain { (struct mbuf *, struct mbuf **, int); void (*dom_dispose) /* dispose of internalized rights */ (struct socket *); - struct protosw *dom_protosw, *dom_protoswNPROTOSW; - struct domain *dom_next; struct rib_head *(*dom_rtattach) /* initialize routing table */ (uint32_t); void (*dom_rtdetach) /* clean up routing table */ @@ -66,17 +66,17 @@ struct domain { void (*dom_ifdetach)(struct ifnet *, void *); int (*dom_ifmtu)(struct ifnet *); /* af-dependent data on ifnet */ + struct protosw *dom_protosw[]; }; /* dom_flags */ -#define DOMF_SUPPORTED 0x0001 /* System supports this domain. */ -#define DOMF_INITED 0x0002 /* Initialized in the default vnet. */ +#define DOMF_UNLOADABLE 0x0004 /* Can be unloaded */ #ifdef _KERNEL extern int domain_init_status; -extern struct domain *domains; -void domain_add(void *); -void domain_init(void *); +extern SLIST_HEAD(domainhead, domain) domains; +void domain_add(struct domain *); +void domain_remove(struct domain *); #ifdef VIMAGE void vnet_domain_init(void *); void vnet_domain_uninit(void *); @@ -85,8 +85,8 @@ void vnet_domain_uninit(void *); #define DOMAIN_SET(name) \ SYSINIT(domain_add_ ## name, SI_SUB_PROTO_DOMAIN, \ SI_ORDER_FIRST, domain_add, & name ## domain); \ - SYSINIT(domain_init_ ## name, SI_SUB_PROTO_DOMAIN, \ - SI_ORDER_SECOND, domain_init, & name ## domain); + SYSUNINIT(domain_remove_ ## name, SI_SUB_PROTO_DOMAIN, \ + SI_ORDER_FIRST, domain_remove, & name ## domain); #endif /* _KERNEL */ #endif /* !_SYS_DOMAIN_H_ */ diff --git a/sys/sys/domainset.h b/sys/sys/domainset.h index 51b5011fcb4e..42891263b81b 100644 --- a/sys/sys/domainset.h +++ b/sys/sys/domainset.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2017, Jeffrey Roberson <jeff@freebsd.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_DOMAINSET_H_ diff --git a/sys/sys/dtrace_bsd.h b/sys/sys/dtrace_bsd.h index 10d67cf699c4..4d5f9d827728 100644 --- a/sys/sys/dtrace_bsd.h +++ b/sys/sys/dtrace_bsd.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2007-2008 John Birrell (jb@freebsd.org) * All rights reserved. @@ -25,8 +25,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ - * * This file contains BSD shims for Sun's DTrace code. */ diff --git a/sys/sys/dvdio.h b/sys/sys/dvdio.h index 6d6f2f53bc1f..75dc69292349 100644 --- a/sys/sys/dvdio.h +++ b/sys/sys/dvdio.h @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS_DVDIO_H_ diff --git a/sys/sys/efi.h b/sys/sys/efi.h index 6ace7dd6e523..4345b1636c2b 100644 --- a/sys/sys/efi.h +++ b/sys/sys/efi.h @@ -22,8 +22,6 @@ * 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$ */ #ifndef _SYS_EFI_H_ @@ -44,6 +42,8 @@ {0xb122a263,0x3661,0x4f68,0x99,0x29,{0x78,0xf8,0xb0,0xd6,0x21,0x80}} #define EFI_PROPERTIES_TABLE \ {0x880aaca3,0x4adc,0x4a04,0x90,0x79,{0xb7,0x47,0x34,0x08,0x25,0xe5}} +#define LINUX_EFI_MEMRESERVE_TABLE \ + {0x888eb0c6,0x8ede,0x4ff5,0xa8,0xf0,{0x9a,0xee,0x5c,0xb9,0x77,0xc2}} enum efi_reset { EFI_RESET_COLD = 0, @@ -59,6 +59,8 @@ struct efi_cfgtbl { void *ct_data; }; +#define EFI_MEMORY_DESCRIPTOR_VERSION 1 + struct efi_md { uint32_t md_type; #define EFI_MD_TYPE_NULL 0 @@ -199,6 +201,34 @@ struct efi_systbl { extern vm_paddr_t efi_systbl_phys; +/* + * When memory is reserved for some use, Linux will add a + * LINUX_EFI_MEMSERVE_TABLE to the cfgtbl array of tables to communicate + * this. At present, Linux only uses this as part of its workaround for a GICv3 + * issue where you can't stop the controller long enough to move it's config and + * pending vectors. When the LinuxBoot environment kexec's a new kernel, the new + * kernel needs to use this old memory (and not use it for any other purpose). + * + * Linux stores the PA of this table in the cfgtbl. And all the addresses are + * the physical address of 'reserved' memory. The mr_next field creates a linked + * list of these tables, and all must be walked. If mr_count is 0, that entry + * should be ignored. There is no checksum for these tables, nor do they have + * a efi_tblhdr. + * + * This table is only documented in the Linux code in drivers/firmware/efi/efi.c. + */ +struct linux_efi_memreserve_entry { + vm_offset_t mre_base; /* PA of reserved area */ + vm_offset_t mre_size; /* Size of area */ +}; + +struct linux_efi_memreserve { + uint32_t mr_size; /* Total size of table in bytes */ + uint32_t mr_count; /* Count of entries used */ + vm_offset_t mr_next; /* Next in chain (though unused?) */ + struct linux_efi_memreserve_entry mr_entry[]; +}; + struct efirt_callinfo; /* Internal MD EFI functions */ @@ -222,6 +252,9 @@ struct efi_ops { int (*get_time_capabilities)(struct efi_tmcap *); int (*reset_system)(enum efi_reset); int (*set_time)(struct efi_tm *); + int (*get_waketime)(uint8_t *enabled, uint8_t *pending, + struct efi_tm *tm); + int (*set_waketime)(uint8_t enable, struct efi_tm *tm); int (*var_get)(uint16_t *, struct uuid *, uint32_t *, size_t *, void *); int (*var_nextname)(size_t *, uint16_t *, struct uuid *); @@ -287,6 +320,21 @@ static inline int efi_set_time(struct efi_tm *tm) return (active_efi_ops->set_time(tm)); } +static inline int efi_get_waketime(uint8_t *enabled, uint8_t *pending, + struct efi_tm *tm) +{ + if (active_efi_ops->get_waketime == NULL) + return (ENXIO); + return (active_efi_ops->get_waketime(enabled, pending, tm)); +} + +static inline int efi_set_waketime(uint8_t enable, struct efi_tm *tm) +{ + if (active_efi_ops->set_waketime == NULL) + return (ENXIO); + return (active_efi_ops->set_waketime(enable, tm)); +} + static inline int efi_var_get(uint16_t *name, struct uuid *vendor, uint32_t *attrib, size_t *datasize, void *data) { diff --git a/sys/sys/efiio.h b/sys/sys/efiio.h index 803aed6a965e..3faec236f0ed 100644 --- a/sys/sys/efiio.h +++ b/sys/sys/efiio.h @@ -21,8 +21,6 @@ * 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$ */ #ifndef _SYS_EFIIO_H_ @@ -50,11 +48,20 @@ struct efi_var_ioc size_t datasize; /* Number of *bytes* in the data */ }; +struct efi_waketime_ioc +{ + struct efi_tm waketime; + uint8_t enabled; + uint8_t pending; +}; + #define EFIIOC_GET_TABLE _IOWR('E', 1, struct efi_get_table_ioc) #define EFIIOC_GET_TIME _IOR('E', 2, struct efi_tm) #define EFIIOC_SET_TIME _IOW('E', 3, struct efi_tm) #define EFIIOC_VAR_GET _IOWR('E', 4, struct efi_var_ioc) #define EFIIOC_VAR_NEXT _IOWR('E', 5, struct efi_var_ioc) #define EFIIOC_VAR_SET _IOWR('E', 6, struct efi_var_ioc) +#define EFIIOC_GET_WAKETIME _IOR('E', 7, struct efi_waketime_ioc) +#define EFIIOC_SET_WAKETIME _IOW('E', 8, struct efi_waketime_ioc) #endif /* _SYS_EFIIO_H_ */ diff --git a/sys/sys/elf.h b/sys/sys/elf.h index f9bc91b30640..c353aec27d40 100644 --- a/sys/sys/elf.h +++ b/sys/sys/elf.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001 David E. O'Brien. * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ /* diff --git a/sys/sys/elf32.h b/sys/sys/elf32.h index c328ce3b2f80..cc80e2f57061 100644 --- a/sys/sys/elf32.h +++ b/sys/sys/elf32.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1996-1998 John D. Polstra. * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_ELF32_H_ diff --git a/sys/sys/elf64.h b/sys/sys/elf64.h index cc5c682e07da..c3951032d3ee 100644 --- a/sys/sys/elf64.h +++ b/sys/sys/elf64.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1996-1998 John D. Polstra. * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_ELF64_H_ diff --git a/sys/sys/elf_common.h b/sys/sys/elf_common.h index 4eae060895ab..ce82734833cf 100644 --- a/sys/sys/elf_common.h +++ b/sys/sys/elf_common.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2017, 2018 Dell EMC * Copyright (c) 2000, 2001, 2008, 2011, David E. O'Brien @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS_ELF_COMMON_H_ @@ -332,6 +330,7 @@ typedef struct { #define EF_ARM_EABI_VER3 0x03000000 #define EF_ARM_EABI_VER4 0x04000000 #define EF_ARM_EABI_VER5 0x05000000 +#define EF_ARM_EABI_VERSION(x) ((x) & EF_ARM_EABIMASK) #define EF_ARM_INTERWORK 0x00000004 #define EF_ARM_APCS_26 0x00000008 #define EF_ARM_APCS_FLOAT 0x00000010 @@ -944,6 +943,7 @@ typedef struct { /* Values for ch_type (compressed section headers). */ #define ELFCOMPRESS_ZLIB 1 /* ZLIB/DEFLATE */ +#define ELFCOMPRESS_ZSTD 2 /* Zstandard */ #define ELFCOMPRESS_LOOS 0x60000000 /* OS-specific */ #define ELFCOMPRESS_HIOS 0x6fffffff #define ELFCOMPRESS_LOPROC 0x70000000 /* Processor-specific */ @@ -985,8 +985,10 @@ typedef struct { #define AT_PS_STRINGS 32 /* struct ps_strings */ #define AT_FXRNG 33 /* Pointer to root RNG seed version. */ #define AT_KPRELOAD 34 /* Base of vdso, preloaded by rtld */ +#define AT_USRSTACKBASE 35 /* Top of user stack */ +#define AT_USRSTACKLIM 36 /* Grow limit of user stack */ -#define AT_COUNT 35 /* Count of defined aux entry types. */ +#define AT_COUNT 37 /* Count of defined aux entry types. */ /* * Relocation types. @@ -1157,7 +1159,7 @@ typedef struct { #define R_IA_64_PCREL22 0x7a /* immediate22 S + A - P */ #define R_IA_64_PCREL64I 0x7b /* immediate64 S + A - P */ #define R_IA_64_IPLTMSB 0x80 /* function descriptor MSB special */ -#define R_IA_64_IPLTLSB 0x81 /* function descriptor LSB speciaal */ +#define R_IA_64_IPLTLSB 0x81 /* function descriptor LSB special */ #define R_IA_64_SUB 0x85 /* immediate64 A - S */ #define R_IA_64_LTOFF22X 0x86 /* immediate22 special */ #define R_IA_64_LDXMOV 0x87 /* immediate22 special */ @@ -1360,8 +1362,6 @@ typedef struct { #define R_RISCV_SUB16 38 #define R_RISCV_SUB32 39 #define R_RISCV_SUB64 40 -#define R_RISCV_GNU_VTINHERIT 41 -#define R_RISCV_GNU_VTENTRY 42 #define R_RISCV_ALIGN 43 #define R_RISCV_RVC_BRANCH 44 #define R_RISCV_RVC_JUMP 45 @@ -1500,5 +1500,6 @@ typedef struct { #define R_X86_64_REX_GOTPCRELX 42 #define ELF_BSDF_SIGFASTBLK 0x0001 /* Kernel supports fast sigblock */ +#define ELF_BSDF_VMNOOVERCOMMIT 0x0002 #endif /* !_SYS_ELF_COMMON_H_ */ diff --git a/sys/sys/elf_generic.h b/sys/sys/elf_generic.h index 177de7339d3f..c18210e64405 100644 --- a/sys/sys/elf_generic.h +++ b/sys/sys/elf_generic.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1998 John D. Polstra. * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_ELF_GENERIC_H_ diff --git a/sys/sys/endian.h b/sys/sys/endian.h index faac0458ae2c..e8af78513e4a 100644 --- a/sys/sys/endian.h +++ b/sys/sys/endian.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002 Thomas Moestl <tmm@FreeBSD.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_ENDIAN_H_ @@ -56,48 +54,19 @@ typedef __uint64_t uint64_t; #endif /* + * Note: While tempting to try to avoid namespace pollution from this file, + * several software packages assume these marcos are defined, even when it + * defines _POSIX_C_SOURCE to request an unpolluted namespace. + */ + +/* * General byte order swapping functions. */ #define bswap16(x) __bswap16(x) #define bswap32(x) __bswap32(x) #define bswap64(x) __bswap64(x) -/* - * Host to big endian, host to little endian, big endian to host, and little - * endian to host byte order functions as detailed in byteorder(9). - */ -#if _BYTE_ORDER == _LITTLE_ENDIAN -#define htobe16(x) __bswap16((x)) -#define htobe32(x) __bswap32((x)) -#define htobe64(x) __bswap64((x)) -#define htole16(x) ((uint16_t)(x)) -#define htole32(x) ((uint32_t)(x)) -#define htole64(x) ((uint64_t)(x)) - -#define be16toh(x) __bswap16((x)) -#define be32toh(x) __bswap32((x)) -#define be64toh(x) __bswap64((x)) -#define le16toh(x) ((uint16_t)(x)) -#define le32toh(x) ((uint32_t)(x)) -#define le64toh(x) ((uint64_t)(x)) -#else /* _BYTE_ORDER != _LITTLE_ENDIAN */ -#define htobe16(x) ((uint16_t)(x)) -#define htobe32(x) ((uint32_t)(x)) -#define htobe64(x) ((uint64_t)(x)) -#define htole16(x) __bswap16((x)) -#define htole32(x) __bswap32((x)) -#define htole64(x) __bswap64((x)) - -#define be16toh(x) ((uint16_t)(x)) -#define be32toh(x) ((uint32_t)(x)) -#define be64toh(x) ((uint64_t)(x)) -#define le16toh(x) __bswap16((x)) -#define le32toh(x) __bswap32((x)) -#define le64toh(x) __bswap64((x)) -#endif /* _BYTE_ORDER == _LITTLE_ENDIAN */ - /* Alignment-agnostic encode/decode bytestream to/from little/big endian. */ - static __inline uint16_t be16dec(const void *pp) { @@ -203,5 +172,4 @@ le64enc(void *pp, uint64_t u) le32enc(p, (uint32_t)(u & 0xffffffffU)); le32enc(p + 4, (uint32_t)(u >> 32)); } - #endif /* _SYS_ENDIAN_H_ */ diff --git a/sys/sys/epoch.h b/sys/sys/epoch.h index 7b06ee19c2f3..918500aa60b9 100644 --- a/sys/sys/epoch.h +++ b/sys/sys/epoch.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2018, Matthew Macy <mmacy@freebsd.org> * @@ -23,8 +23,6 @@ * 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$ */ #ifndef _SYS_EPOCH_H_ @@ -109,6 +107,7 @@ extern epoch_t net_epoch_preempt; #define NET_EPOCH_EXIT(et) epoch_exit_preempt(net_epoch_preempt, &(et)) #define NET_EPOCH_WAIT() epoch_wait_preempt(net_epoch_preempt) #define NET_EPOCH_CALL(f, c) epoch_call(net_epoch_preempt, (f), (c)) +#define NET_EPOCH_DRAIN_CALLBACKS() epoch_drain_callbacks(net_epoch_preempt) #define NET_EPOCH_ASSERT() MPASS(in_epoch(net_epoch_preempt)) #define NET_TASK_INIT(t, p, f, c) TASK_INIT_FLAGS(t, p, f, c, TASK_NETWORK) #define NET_GROUPTASK_INIT(gtask, prio, func, ctx) \ diff --git a/sys/sys/errno.h b/sys/sys/errno.h index e53a8d4c6c7f..927ddd338cac 100644 --- a/sys/sys/errno.h +++ b/sys/sys/errno.h @@ -34,7 +34,6 @@ * SUCH DAMAGE. * * @(#)errno.h 8.5 (Berkeley) 1/21/94 - * $FreeBSD$ */ #ifndef _SYS_ERRNO_H_ diff --git a/sys/sys/eui64.h b/sys/sys/eui64.h index 163a5bdd5198..fdec865a60cb 100644 --- a/sys/sys/eui64.h +++ b/sys/sys/eui64.h @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS_EUI64_H #define _SYS_EUI64_H diff --git a/sys/sys/event.h b/sys/sys/event.h index 05eddfd681b1..1c640c86703d 100644 --- a/sys/sys/event.h +++ b/sys/sys/event.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_EVENT_H_ @@ -218,6 +216,9 @@ struct freebsd11_kevent32 { #define NOTE_NSECONDS 0x00000008 /* data is nanoseconds */ #define NOTE_ABSTIME 0x00000010 /* timeout is absolute */ +/* Flags for kqueuex(2) */ +#define KQUEUE_CLOEXEC 0x00000001 /* close on exec */ + struct knote; SLIST_HEAD(klist, knote); struct kqueue; @@ -305,7 +306,7 @@ struct knote { struct aioliojob *p_lio; /* LIO job pointer */ void *p_v; /* generic other pointer */ } kn_ptr; - struct filterops *kn_fop; + const struct filterops *kn_fop; #define kn_id kn_kevent.ident #define kn_filter kn_kevent.filter @@ -337,7 +338,6 @@ int knlist_empty(struct knlist *knl); void knlist_init(struct knlist *knl, void *lock, void (*kl_lock)(void *), void (*kl_unlock)(void *), void (*kl_assert_lock)(void *, int)); void knlist_init_mtx(struct knlist *knl, struct mtx *lock); -void knlist_init_rw_reader(struct knlist *knl, struct rwlock *lock); void knlist_destroy(struct knlist *knl); void knlist_cleardel(struct knlist *knl, struct thread *td, int islocked, int killkn); @@ -348,7 +348,7 @@ void knlist_cleardel(struct knlist *knl, struct thread *td, void knote_fdclose(struct thread *p, int fd); int kqfd_register(int fd, struct kevent *kev, struct thread *p, int mflag); -int kqueue_add_filteropts(int filt, struct filterops *filtops); +int kqueue_add_filteropts(int filt, const struct filterops *filtops); int kqueue_del_filteropts(int filt); void kqueue_drain_schedtask(void); @@ -359,6 +359,8 @@ struct timespec; __BEGIN_DECLS int kqueue(void); +int kqueuex(unsigned flags); +int kqueue1(int flags); int kevent(int kq, const struct kevent *changelist, int nchanges, struct kevent *eventlist, int nevents, const struct timespec *timeout); diff --git a/sys/sys/eventfd.h b/sys/sys/eventfd.h index 1bdec8ebc269..0f64483753e5 100644 --- a/sys/sys/eventfd.h +++ b/sys/sys/eventfd.h @@ -1,7 +1,7 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2020 Greg V + * Copyright (c) 2020 Val Packett * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/sys/sys/eventhandler.h b/sys/sys/eventhandler.h index 9e307ecc327c..c0d9811dd1b9 100644 --- a/sys/sys/eventhandler.h +++ b/sys/sys/eventhandler.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1999 Michael Smith <msmith@freebsd.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_EVENTHANDLER_H_ @@ -184,7 +182,14 @@ eventhandler_tag vimage_eventhandler_register(struct eventhandler_list *list, #define EVENTHANDLER_PRI_ANY 10000 #define EVENTHANDLER_PRI_LAST 20000 -/* Shutdown events */ +/* + * Successive shutdown events invoked by kern_reboot(9). + * + * Handlers will receive the 'howto' value as their second argument. + * + * All handlers must be prepared to be executed from a panic/debugger context; + * see the man page for details. + */ typedef void (*shutdown_fn)(void *, int); #define SHUTDOWN_PRI_FIRST EVENTHANDLER_PRI_FIRST @@ -205,6 +210,8 @@ EVENTHANDLER_DECLARE(power_suspend_early, power_change_fn); typedef void (*vm_lowmem_handler_t)(void *, int); #define LOWMEM_PRI_DEFAULT EVENTHANDLER_PRI_FIRST EVENTHANDLER_DECLARE(vm_lowmem, vm_lowmem_handler_t); +/* Some of mbuf(9) zones reached maximum */ +EVENTHANDLER_DECLARE(mbuf_lowmem, vm_lowmem_handler_t); /* Root mounted event */ typedef void (*mountroot_handler_t)(void *); @@ -309,12 +316,19 @@ enum evhdev_detach { }; typedef void (*device_attach_fn)(void *, device_t); typedef void (*device_detach_fn)(void *, device_t, enum evhdev_detach); +typedef void (*device_nomatch_fn)(void *, device_t); EVENTHANDLER_DECLARE(device_attach, device_attach_fn); EVENTHANDLER_DECLARE(device_detach, device_detach_fn); +EVENTHANDLER_DECLARE(device_nomatch, device_nomatch_fn); /* Interface address addition and removal event */ struct ifaddr; typedef void (*rt_addrmsg_fn)(void *, struct ifaddr *, int); EVENTHANDLER_DECLARE(rt_addrmsg, rt_addrmsg_fn); +/* Kernel environment variable change event */ +typedef void (*env_change_fn)(void *, const char *); +EVENTHANDLER_DECLARE(setenv, env_change_fn); +EVENTHANDLER_DECLARE(unsetenv, env_change_fn); + #endif /* _SYS_EVENTHANDLER_H_ */ diff --git a/sys/sys/eventvar.h b/sys/sys/eventvar.h index 1ed6e9fc4b6b..7fec444447f9 100644 --- a/sys/sys/eventvar.h +++ b/sys/sys/eventvar.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1999,2000 Jonathan Lemon <jlemon@FreeBSD.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_EVENTVAR_H_ diff --git a/sys/sys/exec.h b/sys/sys/exec.h index 82ee16befe28..c5daf03f472d 100644 --- a/sys/sys/exec.h +++ b/sys/sys/exec.h @@ -34,7 +34,6 @@ * SUCH DAMAGE. * * @(#)exec.h 8.3 (Berkeley) 1/21/94 - * $FreeBSD$ */ #ifndef _SYS_EXEC_H_ @@ -90,6 +89,16 @@ struct execsw { #define PROC_PS_STRINGS(p) \ ((p)->p_vmspace->vm_stacktop - (p)->p_sysent->sv_psstringssz) +/* + * Address of signal trampoline (in user space). + * This assumes that the sigcode resides in the shared page. + */ +#define PROC_SIGCODE(p) \ + ((p)->p_vmspace->vm_shp_base + (p)->p_sysent->sv_sigcode_offset) + +#define PROC_HAS_SHP(p) \ + ((p)->p_sysent->sv_shared_page_obj != NULL) + int exec_map_first_page(struct image_params *); void exec_unmap_first_page(struct image_params *); diff --git a/sys/sys/extattr.h b/sys/sys/extattr.h index f24995b80c54..a16ef238656f 100644 --- a/sys/sys/extattr.h +++ b/sys/sys/extattr.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1999-2001 Robert N. M. Watson * All rights reserved. @@ -26,8 +26,6 @@ * 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$ */ /* * Developed by the TrustedBSD Project. diff --git a/sys/sys/fail.h b/sys/sys/fail.h index dbd2c3e51414..b5fe9a9863ea 100644 --- a/sys/sys/fail.h +++ b/sys/sys/fail.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2009-2019 Dell EMC Isilon http://www.isilon.com/ * @@ -23,8 +23,6 @@ * 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$ */ /** * @file diff --git a/sys/sys/fbio.h b/sys/sys/fbio.h index 194e08bbfb95..58203a925364 100644 --- a/sys/sys/fbio.h +++ b/sys/sys/fbio.h @@ -33,8 +33,6 @@ * SUCH DAMAGE. * * @(#)fbio.h 8.2 (Berkeley) 10/30/93 - * - * $FreeBSD$ */ #ifndef _SYS_FBIO_H_ diff --git a/sys/sys/fcntl.h b/sys/sys/fcntl.h index 491b0172a1e6..9cb6fbe2f2a3 100644 --- a/sys/sys/fcntl.h +++ b/sys/sys/fcntl.h @@ -34,7 +34,6 @@ * SUCH DAMAGE. * * @(#)fcntl.h 8.3 (Berkeley) 1/21/94 - * $FreeBSD$ */ #ifndef _SYS_FCNTL_H_ diff --git a/sys/sys/fdcio.h b/sys/sys/fdcio.h index bceffaed2a37..fe93b4860599 100644 --- a/sys/sys/fdcio.h +++ b/sys/sys/fdcio.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (C) 1992-1994,2001 by Joerg Wunsch, Dresden * All rights reserved. @@ -25,8 +25,6 @@ * (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$ */ #ifndef _MACHINE_IOCTL_FD_H_ diff --git a/sys/sys/file.h b/sys/sys/file.h index 7d2a4885e415..214e8a31c969 100644 --- a/sys/sys/file.h +++ b/sys/sys/file.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)file.h 8.3 (Berkeley) 1/9/95 - * $FreeBSD$ */ #ifndef _SYS_FILE_H_ @@ -70,7 +69,7 @@ struct nameidata; #define DTYPE_DEV 11 /* Device specific fd type */ #define DTYPE_PROCDESC 12 /* process descriptor */ #define DTYPE_EVENTFD 13 /* eventfd */ -#define DTYPE_LINUXTFD 14 /* emulation timerfd type */ +#define DTYPE_TIMERFD 14 /* timerfd */ #ifdef _KERNEL @@ -132,6 +131,7 @@ typedef int fo_fallocate_t(struct file *fp, off_t offset, off_t len, typedef int fo_fspacectl_t(struct file *fp, int cmd, off_t *offset, off_t *length, int flags, struct ucred *active_cred, struct thread *td); +typedef int fo_spare_t(struct file *fp); typedef int fo_flags_t; struct fileops { @@ -154,6 +154,7 @@ struct fileops { fo_get_seals_t *fo_get_seals; fo_fallocate_t *fo_fallocate; fo_fspacectl_t *fo_fspacectl; + fo_spare_t *fo_spares[8]; /* Spare slots */ fo_flags_t fo_flags; /* DFLAG_* below */ }; diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h index 8ecf7d8cb45e..06e086fba152 100644 --- a/sys/sys/filedesc.h +++ b/sys/sys/filedesc.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)filedesc.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD$ */ #ifndef _SYS_FILEDESC_H_ @@ -89,6 +88,8 @@ struct fdescenttbl { /* * This struct is copy-on-write and allocated from an SMR zone. * All fields are constant after initialization apart from the reference count. + * The ABI root directory is initialized as the root directory and changed + * during process transiting to or from non-native ABI. * * Check pwd_* routines for usage. */ @@ -97,6 +98,7 @@ struct pwd { struct vnode *pwd_cdir; /* current directory */ struct vnode *pwd_rdir; /* root directory */ struct vnode *pwd_jdir; /* jail root directory */ + struct vnode *pwd_adir; /* abi root directory */ }; typedef SMR_POINTER(struct pwd *) smrpwd_t; @@ -225,6 +227,7 @@ enum { #define falloc(td, resultfp, resultfd, flags) \ falloc_caps(td, resultfp, resultfd, flags, NULL) +struct mount; struct thread; static __inline void @@ -241,6 +244,7 @@ void filecaps_free(struct filecaps *fcaps); int closef(struct file *fp, struct thread *td); void closef_nothread(struct file *fp); +int descrip_check_write_mp(struct filedesc *fdp, struct mount *mp); int dupfdopen(struct thread *td, struct filedesc *fdp, int dfd, int mode, int openerror, int *indxp); int falloc_caps(struct thread *td, struct file **resultfp, int *resultfd, @@ -270,6 +274,9 @@ struct filedesc *fdshare(struct filedesc *fdp); struct filedesc_to_leader * filedesc_to_leader_alloc(struct filedesc_to_leader *old, struct filedesc *fdp, struct proc *leader); +struct filedesc_to_leader * + filedesc_to_leader_share(struct filedesc_to_leader *fdtol, + struct filedesc *fdp); int getvnode(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp); int getvnode_path(struct thread *td, int fd, cap_rights_t *rightsp, @@ -298,7 +305,7 @@ fget_noref(struct filedesc *fdp, int fd) FILEDESC_LOCK_ASSERT(fdp); - if (__predict_false((u_int)fd >= fdp->fd_nfiles)) + if (__predict_false((u_int)fd >= (u_int)fdp->fd_nfiles)) return (NULL); return (fdp->fd_ofiles[fd].fde_file); @@ -311,7 +318,7 @@ fdeget_noref(struct filedesc *fdp, int fd) FILEDESC_LOCK_ASSERT(fdp); - if (__predict_false((u_int)fd >= fdp->fd_nfiles)) + if (__predict_false((u_int)fd >= (u_int)fdp->fd_nfiles)) return (NULL); fde = &fdp->fd_ofiles[fd]; @@ -337,6 +344,7 @@ struct pwddesc *pdinit(struct pwddesc *pdp, bool keeplock); struct pwddesc *pdshare(struct pwddesc *pdp); void pdunshare(struct thread *td); +void pwd_altroot(struct thread *td, struct vnode *altroot_vp); void pwd_chdir(struct thread *td, struct vnode *vp); int pwd_chroot(struct thread *td, struct vnode *vp); int pwd_chroot_chdir(struct thread *td, struct vnode *vp); diff --git a/sys/sys/filio.h b/sys/sys/filio.h index 3eea7a7acd60..152f2e63ec21 100644 --- a/sys/sys/filio.h +++ b/sys/sys/filio.h @@ -34,7 +34,6 @@ * SUCH DAMAGE. * * @(#)filio.h 8.1 (Berkeley) 3/28/94 - * $FreeBSD$ */ #ifndef _SYS_FILIO_H_ diff --git a/sys/sys/firmware.h b/sys/sys/firmware.h index 0d74a749f4fc..9a33f83cca02 100644 --- a/sys/sys/firmware.h +++ b/sys/sys/firmware.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2005, Sam Leffler <sam@errno.com> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_FIRMWARE_H_ #define _SYS_FIRMWARE_H_ diff --git a/sys/sys/fnv_hash.h b/sys/sys/fnv_hash.h index 901603eac18a..ba1a5f7cf89e 100644 --- a/sys/sys/fnv_hash.h +++ b/sys/sys/fnv_hash.h @@ -4,8 +4,6 @@ * * This is an implementation of the algorithms posted above. * This file is placed in the public domain by Peter Wemm. - * - * $FreeBSD$ */ #ifndef _SYS_FNV_HASH_H_ #define _SYS_FNV_HASH_H_ diff --git a/sys/sys/font.h b/sys/sys/font.h index 04cab126e906..fb5fbbc9e557 100644 --- a/sys/sys/font.h +++ b/sys/sys/font.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2009, 2013 The FreeBSD Foundation * @@ -29,8 +29,6 @@ * 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$ */ #ifndef _SYS_FONT_H_ diff --git a/sys/sys/gmon.h b/sys/sys/gmon.h index 47b5c5c17573..96eafe513e04 100644 --- a/sys/sys/gmon.h +++ b/sys/sys/gmon.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)gmon.h 8.2 (Berkeley) 1/4/94 - * $FreeBSD$ */ #ifndef _SYS_GMON_H_ diff --git a/sys/sys/gpio.h b/sys/sys/gpio.h index 9ea1d6636c20..ba5b362125f8 100644 --- a/sys/sys/gpio.h +++ b/sys/sys/gpio.h @@ -1,7 +1,7 @@ /* $NetBSD: gpio.h,v 1.7 2009/09/25 20:27:50 mbalmer Exp $ */ /* $OpenBSD: gpio.h,v 1.7 2008/11/26 14:51:20 mbalmer Exp $ */ /*- - * SPDX-License-Identifier: (BSD-2-Clause-FreeBSD AND ISC) + * SPDX-License-Identifier: (BSD-2-Clause AND ISC) * * Copyright (c) 2009, Oleksandr Tymoshenko <gonzo@FreeBSD.org> * All rights reserved. @@ -28,8 +28,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ - * */ /* diff --git a/sys/sys/gpt.h b/sys/sys/gpt.h index 4e543063754c..b93d0b07982e 100644 --- a/sys/sys/gpt.h +++ b/sys/sys/gpt.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002 Marcel Moolenaar * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_GPT_H_ diff --git a/sys/sys/gsb_crc32.h b/sys/sys/gsb_crc32.h index dc126a5258fb..9a5e59bd3cf2 100644 --- a/sys/sys/gsb_crc32.h +++ b/sys/sys/gsb_crc32.h @@ -1,8 +1,6 @@ /*- * COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or * code or tables extracted from it, as desired without restriction. - * - * $FreeBSD$ */ #ifndef _SYS_GSB_CRC32_H_ diff --git a/sys/sys/gtaskqueue.h b/sys/sys/gtaskqueue.h index f662aa39f00e..a005c431a1e4 100644 --- a/sys/sys/gtaskqueue.h +++ b/sys/sys/gtaskqueue.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2014 Jeffrey Roberson <jeff@freebsd.org> * Copyright (c) 2016 Matthew Macy <mmacy@mattmacy.io> @@ -25,8 +25,6 @@ * 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$ */ #ifndef _SYS_GTASKQUEUE_H_ diff --git a/sys/sys/hash.h b/sys/sys/hash.h index 35e76ec758cb..ac4bb35d70e9 100644 --- a/sys/sys/hash.h +++ b/sys/sys/hash.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001 Tobias Weingartner * All rights reserved. @@ -25,7 +25,6 @@ * 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$ */ #ifndef _SYS_HASH_H_ diff --git a/sys/sys/hhook.h b/sys/sys/hhook.h index 76c827e66939..084023ccb546 100644 --- a/sys/sys/hhook.h +++ b/sys/sys/hhook.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2010,2013 Lawrence Stewart <lstewart@freebsd.org> * Copyright (c) 2010 The FreeBSD Foundation @@ -34,8 +34,6 @@ * 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$ */ /* diff --git a/sys/sys/iconv.h b/sys/sys/iconv.h index ba9b0e9dd9c8..b8be3f099d6f 100644 --- a/sys/sys/iconv.h +++ b/sys/sys/iconv.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2000-2001 Boris Popov * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_ICONV_H_ #define _SYS_ICONV_H_ diff --git a/sys/sys/imgact.h b/sys/sys/imgact.h index bc1ab77a491e..4f0c8aff9f42 100644 --- a/sys/sys/imgact.h +++ b/sys/sys/imgact.h @@ -27,8 +27,6 @@ * 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$ */ #ifndef _SYS_IMGACT_H_ @@ -66,6 +64,7 @@ struct image_params { const char *image_header; /* header of file to exec */ unsigned long entry_addr; /* entry address of target executable */ unsigned long reloc_base; /* load address of image */ + unsigned long et_dyn_addr; /* PIE load base */ char *interpreter_name; /* name of the interpreter */ void *auxargs; /* ELF Auxinfo structure pointer */ struct sf_buf *firstpage; /* first page that we mapped */ @@ -92,6 +91,9 @@ struct image_params { bool opened; /* we have opened executable vnode */ bool textset; u_int map_flags; +#define IMGP_ASLR_SHARED_PAGE 0x1 + uint32_t imgp_flags; + struct vnode *interpreter_vp; /* vnode of the interpreter */ }; #ifdef _KERNEL diff --git a/sys/sys/imgact_aout.h b/sys/sys/imgact_aout.h index d1af92afd281..6f0f4c63b2a2 100644 --- a/sys/sys/imgact_aout.h +++ b/sys/sys/imgact_aout.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * from: @(#)exec.h 8.1 (Berkeley) 6/11/93 - * $FreeBSD$ */ #ifndef _IMGACT_AOUT_H_ diff --git a/sys/sys/imgact_binmisc.h b/sys/sys/imgact_binmisc.h index 74ff68622075..d33a809140da 100644 --- a/sys/sys/imgact_binmisc.h +++ b/sys/sys/imgact_binmisc.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2013 Stacey D. Son * @@ -23,8 +23,6 @@ * 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$ */ #ifndef _IMGACT_BINMISC_H_ @@ -57,8 +55,9 @@ _Static_assert(IBE_MAGIC_MAX <= IBE_MATCH_MAX, */ #define IBF_ENABLED 0x0001 /* Entry is active. */ #define IBF_USE_MASK 0x0002 /* Use mask on header magic field. */ +#define IBF_PRE_OPEN 0x0004 /* Cache the vnode for interpreter */ -#define IBF_VALID_UFLAGS 0x0003 /* Bits allowed from userland. */ +#define IBF_VALID_UFLAGS 0x0007 /* Bits allowed from userland. */ /* * Used with sysctlbyname() to pass imgact bin misc entries in and out of the diff --git a/sys/sys/imgact_elf.h b/sys/sys/imgact_elf.h index 6890df5c1500..f3d9be027079 100644 --- a/sys/sys/imgact_elf.h +++ b/sys/sys/imgact_elf.h @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS_IMGACT_ELF_H_ @@ -83,13 +81,12 @@ typedef struct { int brand; int machine; const char *compat_3_brand; /* pre Binutils 2.10 method (FBSD 3) */ - const char *emul_path; const char *interp_path; struct sysentvec *sysvec; const char *interp_newpath; int flags; Elf_Brandnote *brand_note; - boolean_t (*header_supported)(struct image_params *, + bool (*header_supported)(struct image_params *, int32_t *, uint32_t *); /* High 8 bits of flags is private to the ABI */ #define BI_CAN_EXEC_DYN 0x0001 diff --git a/sys/sys/interrupt.h b/sys/sys/interrupt.h index 09162469daed..9fa0adf9139f 100644 --- a/sys/sys/interrupt.h +++ b/sys/sys/interrupt.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1997, Stefan Esser <se@freebsd.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_INTERRUPT_H_ @@ -138,8 +136,8 @@ struct intr_event { #define SWI_DELAY 0x2 /* - * Software interrupt numbers in priority order. The priority determines - * the priority of the corresponding interrupt thread. + * Software interrupt numbers. Historically this was used to determine + * the relative priority of SWI ithreads. */ #define SWI_TTY 0 #define SWI_NET 1 @@ -150,11 +148,12 @@ struct intr_event { #define SWI_TQ 6 #define SWI_TQ_GIANT 6 +/* Maximum number of stray interrupts to log */ +#define INTR_STRAY_LOG_MAX 5 + struct proc; extern struct intr_event *clk_intr_event; -extern struct intr_event *tty_intr_event; -extern void *vm_ih; /* Counts and names for statistics (defined in MD code). */ extern u_long *intrcnt; /* counts for each device and stray */ diff --git a/sys/sys/intr.h b/sys/sys/intr.h index 8c51fe7cb504..e91a661673d0 100644 --- a/sys/sys/intr.h +++ b/sys/sys/intr.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2015-2016 Svatopluk Kraus * Copyright (c) 2015-2016 Michal Meloun @@ -25,8 +25,6 @@ * 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$ */ #ifndef _SYS_INTR_H_ diff --git a/sys/sys/ioccom.h b/sys/sys/ioccom.h index 13faba046719..c8283ead2e3d 100644 --- a/sys/sys/ioccom.h +++ b/sys/sys/ioccom.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)ioccom.h 8.3 (Berkeley) 1/9/95 - * $FreeBSD$ */ #ifndef _SYS_IOCCOM_H_ @@ -82,7 +81,7 @@ #define _IOC_INVALID (_IOC_VOID|_IOC_INOUT) /* Never valid cmd value, use as filler */ -#else +#elif !defined(_STANDALONE) #include <sys/cdefs.h> diff --git a/sys/sys/ioctl.h b/sys/sys/ioctl.h index e63a64d25ed0..413fb8a0cd33 100644 --- a/sys/sys/ioctl.h +++ b/sys/sys/ioctl.h @@ -34,7 +34,6 @@ * SUCH DAMAGE. * * @(#)ioctl.h 8.6 (Berkeley) 3/28/94 - * $FreeBSD$ */ #ifndef _SYS_IOCTL_H_ diff --git a/sys/sys/ioctl_compat.h b/sys/sys/ioctl_compat.h index 8ec21990345e..5fec544b7df0 100644 --- a/sys/sys/ioctl_compat.h +++ b/sys/sys/ioctl_compat.h @@ -34,7 +34,6 @@ * SUCH DAMAGE. * * @(#)ioctl_compat.h 8.4 (Berkeley) 1/21/94 - * $FreeBSD$ */ #ifndef _SYS_IOCTL_COMPAT_H_ diff --git a/sys/sys/iov.h b/sys/sys/iov.h index ee60d6d4320b..cc9074489559 100644 --- a/sys/sys/iov.h +++ b/sys/sys/iov.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2013-2015 Sandvine Inc. * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_IOV_H_ diff --git a/sys/sys/iov_schema.h b/sys/sys/iov_schema.h index 12e120795bef..cb50f7796d30 100644 --- a/sys/sys/iov_schema.h +++ b/sys/sys/iov_schema.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2014-2015 Sandvine Inc. * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_IOV_SCHEMA_H_ diff --git a/sys/sys/ipc.h b/sys/sys/ipc.h index a0bd61f7f07d..95a01be20eec 100644 --- a/sys/sys/ipc.h +++ b/sys/sys/ipc.h @@ -39,7 +39,6 @@ * SUCH DAMAGE. * * @(#)ipc.h 8.4 (Berkeley) 2/19/95 - * $FreeBSD$ */ /* diff --git a/sys/sys/ipmi.h b/sys/sys/ipmi.h index 3c805bac099d..6770309465c4 100644 --- a/sys/sys/ipmi.h +++ b/sys/sys/ipmi.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2006 IronPort Systems Inc. <ambrisko@ironport.com> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef __SYS_IPMI_H__ @@ -33,9 +31,11 @@ #define IPMI_MAX_ADDR_SIZE 0x20 #define IPMI_MAX_RX 1024 -#define IPMI_BMC_SLAVE_ADDR 0x20 /* Linux Default slave address */ + #define IPMI_BMC_CHANNEL 0x0f /* Linux BMC channel */ +#define IPMI_IPMB_CHANNEL 0x00 +#define IPMI_BMC_SLAVE_ADDR 0x20 /* Linux Default slave address */ #define IPMI_BMC_SMS_LUN 0x02 #define IPMI_SYSTEM_INTERFACE_ADDR_TYPE 0x0c diff --git a/sys/sys/jail.h b/sys/sys/jail.h index b7ecfc198b4c..fb8858f73453 100644 --- a/sys/sys/jail.h +++ b/sys/sys/jail.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1999 Poul-Henning Kamp. * Copyright (c) 2009 James Gritton. @@ -25,8 +25,6 @@ * 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$ */ #ifndef _SYS_JAIL_H_ @@ -159,6 +157,7 @@ typedef enum { * * Lock key: * (a) allprison_lock + * (A) allproc_lock * (c) set only during creation before the structure is shared, no mutex * required to read * (m) locked by pr_mtx @@ -176,6 +175,7 @@ struct prison { volatile u_int pr_uref; /* (r) user (alive) refcount */ unsigned pr_flags; /* (p) PR_* flags */ LIST_HEAD(, prison) pr_children; /* (a) list of child jails */ + LIST_HEAD(, proc) pr_proclist; /* (A) list of jailed processes */ LIST_ENTRY(prison) pr_sibling; /* (a) next in parent's list */ struct prison *pr_parent; /* (c) containing jail */ struct mtx pr_mtx; @@ -194,7 +194,8 @@ struct prison { int pr_enforce_statfs; /* (p) statfs permission */ int pr_devfs_rsnum; /* (p) devfs ruleset */ enum prison_state pr_state; /* (q) state in life cycle */ - int pr_spare[2]; + volatile int pr_exportcnt; /* (r) count of mount exports */ + int pr_spare; int pr_osreldate; /* (c) kern.osreldate value */ unsigned long pr_hostid; /* (p) jail hostid */ char pr_name[MAXHOSTNAMELEN]; /* (p) admin jail name */ @@ -251,7 +252,9 @@ struct prison_racct { #define PR_ALLOW_SUSER 0x00000400 #define PR_ALLOW_RESERVED_PORTS 0x00008000 #define PR_ALLOW_KMEM_ACCESS 0x00010000 /* reserved, not used yet */ -#define PR_ALLOW_ALL_STATIC 0x000187ff +#define PR_ALLOW_NFSD 0x00020000 +#define PR_ALLOW_EXTATTR 0x00040000 +#define PR_ALLOW_ALL_STATIC 0x000787ff /* * PR_ALLOW_DIFFERENCES determines which flags are able to be @@ -409,31 +412,35 @@ struct vfsconf; */ #define jailed(cred) (cred->cr_prison != &prison0) -int jailed_without_vnet(struct ucred *); +bool jailed_without_vnet(struct ucred *); void getcredhostname(struct ucred *, char *, size_t); void getcreddomainname(struct ucred *, char *, size_t); void getcredhostuuid(struct ucred *, char *, size_t); void getcredhostid(struct ucred *, unsigned long *); void getjailname(struct ucred *cred, char *name, size_t len); void prison0_init(void); -int prison_allow(struct ucred *, unsigned); +bool prison_allow(struct ucred *, unsigned); int prison_check(struct ucred *cred1, struct ucred *cred2); -int prison_owns_vnet(struct ucred *); +bool prison_check_nfsd(struct ucred *cred); +bool prison_owns_vnet(struct ucred *); int prison_canseemount(struct ucred *cred, struct mount *mp); void prison_enforce_statfs(struct ucred *cred, struct mount *mp, struct statfs *sp); struct prison *prison_find(int prid); struct prison *prison_find_child(struct prison *, int); struct prison *prison_find_name(struct prison *, const char *); -int prison_flag(struct ucred *, unsigned); +bool prison_flag(struct ucred *, unsigned); void prison_free(struct prison *pr); void prison_free_locked(struct prison *pr); void prison_hold(struct prison *pr); void prison_hold_locked(struct prison *pr); void prison_proc_hold(struct prison *); void prison_proc_free(struct prison *); +void prison_proc_link(struct prison *, struct proc *); +void prison_proc_unlink(struct prison *, struct proc *); +void prison_proc_iterate(struct prison *, void (*)(struct proc *, void *), void *); void prison_set_allow(struct ucred *cred, unsigned flag, int enable); -int prison_ischild(struct prison *, struct prison *); +bool prison_ischild(struct prison *, struct prison *); bool prison_isalive(const struct prison *); bool prison_isvalid(struct prison *); #if defined(INET) || defined(INET6) @@ -442,24 +449,24 @@ const void *prison_ip_get0(const struct prison *, const pr_family_t); u_int prison_ip_cnt(const struct prison *, const pr_family_t); #endif #ifdef INET -int prison_equal_ip4(struct prison *, struct prison *); +bool prison_equal_ip4(struct prison *, struct prison *); 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(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 *); +bool prison_saddrsel_ip4(struct ucred *, struct in_addr *); int prison_qcmp_v4(const void *, const void *); bool prison_valid_v4(const void *); #endif #ifdef INET6 -int prison_equal_ip6(struct prison *, struct prison *); +bool 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(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 *); +bool prison_saddrsel_ip6(struct ucred *, struct in6_addr *); int prison_qcmp_v6(const void *, const void *); bool prison_valid_v6(const void *); #endif diff --git a/sys/sys/joystick.h b/sys/sys/joystick.h index 60a89dce38c3..531957ef9b1e 100644 --- a/sys/sys/joystick.h +++ b/sys/sys/joystick.h @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS_JOYSTICK_H_ diff --git a/sys/sys/kassert.h b/sys/sys/kassert.h index bb6847dc404f..d7c1a21385f9 100644 --- a/sys/sys/kassert.h +++ b/sys/sys/kassert.h @@ -46,19 +46,35 @@ extern bool panicked; kassert_panic msg; \ } \ } while (0) +#define MPASSERT(exp, mp, msg) do { \ + if (__predict_false(!(exp))) { \ + printf("MPASSERT mp %p failed: %s not true at %s:%d (%s)\n",\ + (mp), #exp, __FILE__, __LINE__, __func__); \ + kassert_panic msg; \ + } \ +} while (0) #define VNPASS(exp, vp) do { \ const char *_exp = #exp; \ VNASSERT(exp, vp, ("condition %s not met at %s:%d (%s)", \ _exp, __FILE__, __LINE__, __func__)); \ } while (0) +#define MPPASS(exp, mp) do { \ + const char *_exp = #exp; \ + MPASSERT(exp, mp, ("condition %s not met at %s:%d (%s)", \ + _exp, __FILE__, __LINE__, __func__)); \ +} while (0) #define __assert_unreachable() \ panic("executing segment marked as unreachable at %s:%d (%s)\n", \ __FILE__, __LINE__, __func__) #else /* INVARIANTS */ #define VNASSERT(exp, vp, msg) do { \ } while (0) +#define MPASSERT(exp, mp, msg) do { \ +} while (0) #define VNPASS(exp, vp) do { \ } while (0) +#define MPPASS(exp, mp) do { \ +} while (0) #define __assert_unreachable() __unreachable() #endif /* INVARIANTS */ diff --git a/sys/sys/kbio.h b/sys/sys/kbio.h index 7f17bda76c51..9fb63eb1b2bb 100644 --- a/sys/sys/kbio.h +++ b/sys/sys/kbio.h @@ -1,5 +1,4 @@ /*- - * $FreeBSD$ */ #ifndef _SYS_KBIO_H_ @@ -70,6 +69,13 @@ struct keyboard_info { }; typedef struct keyboard_info keyboard_info_t; +/* keyboard repeat rate mapping table */ +static const int kbdelays[] = { 250, 500, 750, 1000 }; +static const int kbrates[] = { 34, 38, 42, 46, 50, + 55, 59, 63, 68, 76, 84, 92, 100, 110, 118, 126, + 136, 152, 168, 184, 200, 220, 236, 252, 272, 304, 336, + 368, 400, 440, 472, 504 }; + /* add/remove keyboard to/from mux */ #define KBADDKBD _IOW('K', 68, keyboard_info_t) /* add keyboard */ #define KBRELKBD _IOW('K', 69, keyboard_info_t) /* release keyboard */ @@ -120,7 +126,7 @@ struct keymap { }; typedef struct keymap keymap_t; -#ifdef _KERNEL +#ifdef COMPAT_FREEBSD13 struct okeyent_t { u_char map[NUM_STATES]; u_char spcl; @@ -132,7 +138,7 @@ struct okeymap { struct okeyent_t key[NUM_KEYS]; }; typedef struct okeymap okeymap_t; -#endif /* _KERNEL */ +#endif /* COMPAT_FREEBSD13 */ #endif /* !_KEYMAP_DECLARED */ @@ -199,8 +205,8 @@ typedef struct okeymap okeymap_t; #define ACC(x) ((x)+F_ACC) struct acc_t { - u_char accchar; - u_char map[NUM_ACCENTCHARS][2]; + u_int accchar; + u_int map[NUM_ACCENTCHARS][2]; }; struct accentmap { @@ -209,6 +215,19 @@ struct accentmap { }; typedef struct accentmap accentmap_t; +#ifdef COMPAT_FREEBSD13 +struct oacc_t { + u_char accchar; + u_char map[NUM_ACCENTCHARS][2]; +}; + +struct oaccentmap { + u_short n_accs; + struct oacc_t acc[NUM_DEADKEYS]; +}; +typedef struct oaccentmap oaccentmap_t; +#endif /* COMPAT_FREEBSD13 */ + struct keyarg { u_short keynum; struct keyent_t key; @@ -237,12 +256,17 @@ typedef struct fkeyarg fkeyarg_t; /* XXX: Should have keymap_t as an argument, but that's too big for ioctl()! */ #define GIO_KEYMAP _IO('k', 6) #define PIO_KEYMAP _IO('k', 7) -#ifdef _KERNEL +#ifdef COMPAT_FREEBSD13 #define OGIO_KEYMAP _IOR('k', 6, okeymap_t) #define OPIO_KEYMAP _IOW('k', 7, okeymap_t) -#endif /* _KERNEL */ -#define GIO_DEADKEYMAP _IOR('k', 8, accentmap_t) -#define PIO_DEADKEYMAP _IOW('k', 9, accentmap_t) +#endif /* COMPAT_FREEBSD13 */ +/* XXX: Should have accentmap_t as an argument, but that's too big for ioctl()! */ +#define GIO_DEADKEYMAP _IO('k', 8) +#define PIO_DEADKEYMAP _IO('k', 9) +#ifdef COMPAT_FREEBSD13 +#define OGIO_DEADKEYMAP _IOR('k', 8, oaccentmap_t) +#define OPIO_DEADKEYMAP _IOW('k', 9, oaccentmap_t) +#endif /* COMPAT_FREEBSD13 */ #define GIO_KEYMAPENT _IOWR('k', 10, keyarg_t) #define PIO_KEYMAPENT _IOW('k', 11, keyarg_t) diff --git a/sys/sys/kcov.h b/sys/sys/kcov.h index 89be2c3df5de..b29fced3aa08 100644 --- a/sys/sys/kcov.h +++ b/sys/sys/kcov.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (C) 2018 The FreeBSD Foundation. All rights reserved. * Copyright (C) 2018, 2019 Andrew Turner. @@ -31,8 +31,6 @@ * 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$ */ #ifndef _SYS_KCOV_H_ diff --git a/sys/sys/kdb.h b/sys/sys/kdb.h index 4669a3f9f551..24b4389773f9 100644 --- a/sys/sys/kdb.h +++ b/sys/sys/kdb.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Marcel Moolenaar * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_KDB_H_ diff --git a/sys/sys/kenv.h b/sys/sys/kenv.h index eccdc027adcc..27e8e02e9a74 100644 --- a/sys/sys/kenv.h +++ b/sys/sys/kenv.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002 Maxime Henrion <mux@FreeBSD.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_KENV_H_ diff --git a/sys/sys/kern_prefetch.h b/sys/sys/kern_prefetch.h index 6945132f12e0..aaca521a1077 100644 --- a/sys/sys/kern_prefetch.h +++ b/sys/sys/kern_prefetch.h @@ -21,8 +21,6 @@ * 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$ */ #ifndef __kern_prefetch_h__ #define __kern_prefetch_h__ diff --git a/sys/sys/kernel.h b/sys/sys/kernel.h index 765484df351c..62b9e6a02b3c 100644 --- a/sys/sys/kernel.h +++ b/sys/sys/kernel.h @@ -41,7 +41,6 @@ * SUCH DAMAGE. * * @(#)kernel.h 8.3 (Berkeley) 1/21/94 - * $FreeBSD$ */ #ifndef _SYS_KERNEL_H_ @@ -51,7 +50,7 @@ #ifdef _KERNEL -/* for intrhook below */ +/* for intrhook and sysinit linked list below */ #include <sys/queue.h> /* for timestamping SYSINITs; other files may assume this is included here */ @@ -221,6 +220,7 @@ typedef void (*sysinit_cfunc_t)(const void *); struct sysinit { enum sysinit_sub_id subsystem; /* subsystem identifier*/ enum sysinit_elem_order order; /* init order within subsystem*/ + STAILQ_ENTRY(sysinit) next; /* singly-linked list */ sysinit_cfunc_t func; /* function */ const void *udata; /* multiplexer/argument */ }; @@ -261,6 +261,7 @@ sysinit_tslog_shim(const void * data) static struct sysinit uniquifier ## _sys_init = { \ subsystem, \ order, \ + { NULL }, \ sysinit_tslog_shim, \ &uniquifier ## _sys_init_tslog \ }; \ @@ -270,6 +271,7 @@ sysinit_tslog_shim(const void * data) static struct sysinit uniquifier ## _sys_init = { \ subsystem, \ order, \ + { NULL }, \ func, \ (ident) \ }; \ @@ -287,6 +289,7 @@ sysinit_tslog_shim(const void * data) static struct sysinit uniquifier ## _sys_uninit = { \ subsystem, \ order, \ + { NULL }, \ func, \ (ident) \ }; \ diff --git a/sys/sys/kerneldump.h b/sys/sys/kerneldump.h index 637eab5c39e5..46f05b3c130d 100644 --- a/sys/sys/kerneldump.h +++ b/sys/sys/kerneldump.h @@ -33,8 +33,6 @@ * 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$ */ #ifndef _SYS_KERNELDUMP_H diff --git a/sys/sys/khelp.h b/sys/sys/khelp.h index 54c4791d3be9..2ef45806c35a 100644 --- a/sys/sys/khelp.h +++ b/sys/sys/khelp.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2010 Lawrence Stewart <lstewart@freebsd.org> * Copyright (c) 2010 The FreeBSD Foundation @@ -34,8 +34,6 @@ * 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$ */ /* diff --git a/sys/sys/kobj.h b/sys/sys/kobj.h index 75d8caed7b3f..7adc01c1f1f3 100644 --- a/sys/sys/kobj.h +++ b/sys/sys/kobj.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2000,2003 Doug Rabson * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_KOBJ_H_ diff --git a/sys/sys/kpilite.h b/sys/sys/kpilite.h index 2a7e9743f799..b48b062bd7ea 100644 --- a/sys/sys/kpilite.h +++ b/sys/sys/kpilite.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2018, Matthew Macy <mmacy@freebsd.org> * @@ -23,8 +23,6 @@ * 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$ */ #ifndef _SYS_KPILITE_H_ diff --git a/sys/sys/ksem.h b/sys/sys/ksem.h index 4776901fd7b1..55a82dd40a58 100644 --- a/sys/sys/ksem.h +++ b/sys/sys/ksem.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002 Alfred Perlstein <alfred@FreeBSD.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _POSIX4_KSEM_H_ diff --git a/sys/sys/kthread.h b/sys/sys/kthread.h index 826472f4bb38..52d9c0621866 100644 --- a/sys/sys/kthread.h +++ b/sys/sys/kthread.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1999 Peter Wemm <peter@FreeBSD.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_KTHREAD_H_ @@ -60,7 +58,7 @@ void kproc_start(const void *); int kproc_suspend(struct proc *, int); void kproc_suspend_check(struct proc *); -/* create a thread inthe given process. create the process if needed */ +/* create a thread in the given process. create the process if needed */ int kproc_kthread_add(void (*)(void *), void *, struct proc **, struct thread **, diff --git a/sys/sys/ktls.h b/sys/sys/ktls.h index 885e4dc38ef9..693864394ffe 100644 --- a/sys/sys/ktls.h +++ b/sys/sys/ktls.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2014-2019 Netflix Inc. * @@ -23,8 +23,6 @@ * 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$ */ #ifndef _SYS_KTLS_H_ #define _SYS_KTLS_H_ @@ -187,20 +185,35 @@ struct ktls_session { struct task reset_tag_task; struct task disable_ifnet_task; - struct inpcb *inp; + union { + struct inpcb *inp; /* Used by transmit tasks. */ + struct socket *so; /* Used by receive task. */ + }; + struct ifnet *rx_ifp; + u_short rx_vlan_id; bool reset_pending; - bool disable_ifnet_pending; + bool tx; bool sync_dispatch; bool sequential_records; /* Only used for TLS 1.0. */ uint64_t next_seqno; STAILQ_HEAD(, mbuf) pending_records; + + /* Used to destroy any kTLS session */ + struct task destroy_task; } __aligned(CACHE_LINE_SIZE); extern unsigned int ktls_ifnet_max_rexmit_pct; +typedef enum { + KTLS_MBUF_CRYPTO_ST_MIXED = 0, + KTLS_MBUF_CRYPTO_ST_ENCRYPTED = 1, + KTLS_MBUF_CRYPTO_ST_DECRYPTED = -1, +} ktls_mbuf_crypto_st_t; + void ktls_check_rx(struct sockbuf *sb); +ktls_mbuf_crypto_st_t ktls_mbuf_crypto_state(struct mbuf *mb, int offset, int len); void ktls_disable_ifnet(void *arg); int ktls_enable_rx(struct socket *so, struct tls_enable *en); int ktls_enable_tx(struct socket *so, struct tls_enable *en); @@ -215,6 +228,7 @@ int ktls_get_rx_mode(struct socket *so, int *modep); int ktls_set_tx_mode(struct socket *so, int mode); int ktls_get_tx_mode(struct socket *so, int *modep); int ktls_get_rx_sequence(struct inpcb *inp, uint32_t *tcpseq, uint64_t *tlsseq); +void ktls_input_ifp_mismatch(struct sockbuf *sb, struct ifnet *ifp); int ktls_output_eagain(struct inpcb *inp, struct ktls_session *tls); #ifdef RATELIMIT int ktls_modify_txrtlmt(struct ktls_session *tls, uint64_t max_pacing_rate); diff --git a/sys/sys/ktr.h b/sys/sys/ktr.h index 396ad21cffc7..288e4d48e0e1 100644 --- a/sys/sys/ktr.h +++ b/sys/sys/ktr.h @@ -28,7 +28,6 @@ * SUCH DAMAGE. * * from BSDI $Id: ktr.h,v 1.10.2.7 2000/03/16 21:44:42 cp Exp $ - * $FreeBSD$ */ /* diff --git a/sys/sys/ktr_class.h b/sys/sys/ktr_class.h index f2c76c73505b..b4861bdef54d 100644 --- a/sys/sys/ktr_class.h +++ b/sys/sys/ktr_class.h @@ -28,7 +28,6 @@ * SUCH DAMAGE. * * from BSDI $Id: ktr.h,v 1.10.2.7 2000/03/16 21:44:42 cp Exp $ - * $FreeBSD$ */ #ifndef _SYS_KTR_CLASS_H_ diff --git a/sys/sys/ktrace.h b/sys/sys/ktrace.h index f417fdf8a22a..110e14698570 100644 --- a/sys/sys/ktrace.h +++ b/sys/sys/ktrace.h @@ -29,13 +29,14 @@ * SUCH DAMAGE. * * @(#)ktrace.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD$ */ #ifndef _SYS_KTRACE_H_ #define _SYS_KTRACE_H_ #include <sys/caprights.h> +#include <sys/signal.h> +#include <sys/_uio.h> /* * operations to ktrace system call (KTROP(op)) @@ -52,15 +53,31 @@ /* * ktrace record header */ -struct ktr_header { +struct ktr_header_v0 { int ktr_len; /* length of buf */ short ktr_type; /* trace record type */ pid_t ktr_pid; /* process id */ char ktr_comm[MAXCOMLEN + 1];/* command name */ struct timeval ktr_time; /* timestamp */ - intptr_t ktr_tid; /* was ktr_buffer */ + long ktr_tid; /* thread id */ +}; + +struct ktr_header { + int ktr_len; /* length of buf */ + short ktr_type; /* trace record type */ + short ktr_version; /* ktr_header version */ + pid_t ktr_pid; /* process id */ + char ktr_comm[MAXCOMLEN + 1];/* command name */ + struct timespec ktr_time; /* timestamp */ + /* XXX: make ktr_tid an lwpid_t on next ABI break */ + long ktr_tid; /* thread id */ + int ktr_cpu; /* cpu id */ }; +#define KTR_VERSION0 0 +#define KTR_VERSION1 1 +#define KTR_OFFSET_V0 sizeof(struct ktr_header_v0) - \ + sizeof(struct ktr_header) /* * Test for kernel trace point (MP SAFE). * @@ -236,6 +253,13 @@ struct ktr_struct_array { * between the previous record and this record was dropped. */ #define KTR_DROP 0x8000 +/* + * KTR_VERSIONED - If this bit is set in ktr_type, then the kernel + * exposes the new struct ktr_header (versioned), otherwise the old + * struct ktr_header_v0 is exposed. + */ +#define KTR_VERSIONED 0x4000 +#define KTR_TYPE (KTR_DROP | KTR_VERSIONED) /* * kernel trace points (in p_traceflag) diff --git a/sys/sys/libkern.h b/sys/sys/libkern.h index 41844fa7490e..92698a3f9b23 100644 --- a/sys/sys/libkern.h +++ b/sys/sys/libkern.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)libkern.h 8.1 (Berkeley) 6/10/93 - * $FreeBSD$ */ #ifndef _SYS_LIBKERN_H_ @@ -114,6 +113,7 @@ static __inline off_t omax(off_t a, off_t b) { return (a > b ? a : b); } static __inline off_t omin(off_t a, off_t b) { return (a < b ? a : b); } static __inline int abs(int a) { return (a < 0 ? -a : a); } static __inline long labs(long a) { return (a < 0 ? -a : a); } +static __inline int64_t abs64(int64_t a) { return (a < 0 ? -a : a); } static __inline quad_t qabs(quad_t a) { return (a < 0 ? -a : a); } #ifndef RANDOM_FENESTRASX @@ -132,24 +132,63 @@ void arc4rand(void *, u_int, int); int timingsafe_bcmp(const void *, const void *, size_t); void *bsearch(const void *, const void *, size_t, size_t, int (*)(const void *, const void *)); -#ifndef HAVE_INLINE_FFS -int ffs(int); -#endif -#ifndef HAVE_INLINE_FFSL -int ffsl(long); -#endif -#ifndef HAVE_INLINE_FFSLL -int ffsll(long long); -#endif -#ifndef HAVE_INLINE_FLS -int fls(int); -#endif -#ifndef HAVE_INLINE_FLSL -int flsl(long); -#endif -#ifndef HAVE_INLINE_FLSLL -int flsll(long long); -#endif + +/* + * MHTODO: remove the 'HAVE_INLINE_FOO' defines once use of these flags has + * been purged everywhere. For now we provide them unconditionally. + */ +#define HAVE_INLINE_FFS +#define HAVE_INLINE_FFSL +#define HAVE_INLINE_FFSLL +#define HAVE_INLINE_FLS +#define HAVE_INLINE_FLSL +#define HAVE_INLINE_FLSLL + +static __inline __pure2 int +ffs(int mask) +{ + + return (__builtin_ffs((u_int)mask)); +} + +static __inline __pure2 int +ffsl(long mask) +{ + + return (__builtin_ffsl((u_long)mask)); +} + +static __inline __pure2 int +ffsll(long long mask) +{ + + return (__builtin_ffsll((unsigned long long)mask)); +} + +static __inline __pure2 int +fls(int mask) +{ + + return (mask == 0 ? 0 : + 8 * sizeof(mask) - __builtin_clz((u_int)mask)); +} + +static __inline __pure2 int +flsl(long mask) +{ + + return (mask == 0 ? 0 : + 8 * sizeof(mask) - __builtin_clzl((u_long)mask)); +} + +static __inline __pure2 int +flsll(long long mask) +{ + + return (mask == 0 ? 0 : + 8 * sizeof(mask) - __builtin_clzll((unsigned long long)mask)); +} + #define bitcount64(x) __bitcount64((uint64_t)(x)) #define bitcount32(x) __bitcount32((uint32_t)(x)) #define bitcount16(x) __bitcount16((uint16_t)(x)) @@ -163,8 +202,8 @@ void *memcchr(const void *s, int c, size_t n); void *memmem(const void *l, size_t l_len, const void *s, size_t s_len); void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)); -void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, - int (*compar)(void *, const void *, const void *)); +void qsort_r(void *base, size_t nmemb, size_t size, + int (*compar)(const void *, const void *, void *), void *thunk); u_long random(void); int scanc(u_int, const u_char *, const u_char *, int); int strcasecmp(const char *, const char *); diff --git a/sys/sys/limits.h b/sys/sys/limits.h index d4fb8b7e04e3..2cb0051fe86c 100644 --- a/sys/sys/limits.h +++ b/sys/sys/limits.h @@ -27,8 +27,6 @@ * 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$ */ #ifndef _SYS_LIMITS_H_ diff --git a/sys/sys/link_aout.h b/sys/sys/link_aout.h index 2e4f3862c747..5d18097ff909 100644 --- a/sys/sys/link_aout.h +++ b/sys/sys/link_aout.h @@ -28,8 +28,6 @@ * 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$ */ /* diff --git a/sys/sys/link_elf.h b/sys/sys/link_elf.h index 9a9bb6899e40..2ef044032f58 100644 --- a/sys/sys/link_elf.h +++ b/sys/sys/link_elf.h @@ -28,8 +28,6 @@ * 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$ */ /* diff --git a/sys/sys/linker.h b/sys/sys/linker.h index 2d65630cd66b..b94cd9f27405 100644 --- a/sys/sys/linker.h +++ b/sys/sys/linker.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1997-2000 Doug Rabson * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_LINKER_H_ diff --git a/sys/sys/linker_set.h b/sys/sys/linker_set.h index 04e031500aac..22d5075cd912 100644 --- a/sys/sys/linker_set.h +++ b/sys/sys/linker_set.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1999 John D. Polstra * Copyright (c) 1999,2001 Peter Wemm <peter@FreeBSD.org> @@ -25,8 +25,6 @@ * 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$ */ #ifndef _SYS_LINKER_SET_H_ diff --git a/sys/sys/lock.h b/sys/sys/lock.h index 2db38f9df89a..65064aad5aa8 100644 --- a/sys/sys/lock.h +++ b/sys/sys/lock.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved. * @@ -28,7 +28,6 @@ * SUCH DAMAGE. * * from BSDI Id: mutex.h,v 2.7.2.35 2000/04/27 03:10:26 cp - * $FreeBSD$ */ #ifndef _SYS_LOCK_H_ @@ -182,7 +181,7 @@ extern u_short locks_delay_loops; struct lock_delay_arg { struct lock_delay_config *config; - u_short delay; + u_int delay; u_int spin_cnt; }; @@ -237,6 +236,7 @@ int witness_list_locks(struct lock_list_entry **, int (*)(const char *, ...)); int witness_warn(int, struct lock_object *, const char *, ...); void witness_assert(const struct lock_object *, int, const char *, int); +int witness_is_owned(const struct lock_object *lock); void witness_display_spinlock(struct lock_object *, struct thread *, int (*)(const char *, ...)); int witness_line(struct lock_object *); diff --git a/sys/sys/lock_profile.h b/sys/sys/lock_profile.h index de1a95779254..e13f25b61504 100644 --- a/sys/sys/lock_profile.h +++ b/sys/sys/lock_profile.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2006 Kip Macy kmacy@FreeBSD.org * Copyright (c) 2006 Kris Kennaway kris@FreeBSD.org @@ -25,8 +25,6 @@ * 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$ */ #ifndef _SYS_LOCK_PROFILE_H_ diff --git a/sys/sys/lockf.h b/sys/sys/lockf.h index cca02501a462..ab3fe8ae6225 100644 --- a/sys/sys/lockf.h +++ b/sys/sys/lockf.h @@ -32,7 +32,6 @@ * SUCH DAMAGE. * * @(#)lockf.h 8.1 (Berkeley) 6/11/93 - * $FreeBSD$ */ #ifndef _SYS_LOCKF_H_ diff --git a/sys/sys/lockmgr.h b/sys/sys/lockmgr.h index fc3046f8c85a..ebe238cd0e25 100644 --- a/sys/sys/lockmgr.h +++ b/sys/sys/lockmgr.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2008 Attilio Rao <attilio@FreeBSD.org> * All rights reserved. @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS_LOCKMGR_H_ diff --git a/sys/sys/lockstat.h b/sys/sys/lockstat.h index 76bd97dbafa5..65ee851a9d90 100644 --- a/sys/sys/lockstat.h +++ b/sys/sys/lockstat.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2008-2009 Stacey Son <sson@FreeBSD.org> * @@ -23,8 +23,6 @@ * 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$ */ /* diff --git a/sys/sys/loginclass.h b/sys/sys/loginclass.h index c07a2d92dad6..8d8e6488d74d 100644 --- a/sys/sys/loginclass.h +++ b/sys/sys/loginclass.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2011 The FreeBSD Foundation * @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS_LOGINCLASS_H_ diff --git a/sys/sys/mac.h b/sys/sys/mac.h index bc12cb753083..facdc14c332d 100644 --- a/sys/sys/mac.h +++ b/sys/sys/mac.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1999-2002 Robert N. M. Watson * Copyright (c) 2001-2005 Networks Associates Technology, Inc. @@ -36,8 +36,6 @@ * 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$ */ /* * Userland interface for Mandatory Access Control. Loosely based on the diff --git a/sys/sys/malloc.h b/sys/sys/malloc.h index b83d78a18444..1661cd194a1f 100644 --- a/sys/sys/malloc.h +++ b/sys/sys/malloc.h @@ -31,7 +31,6 @@ * SUCH DAMAGE. * * @(#)malloc.h 8.5 (Berkeley) 5/3/95 - * $FreeBSD$ */ #ifndef _SYS_MALLOC_H_ diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 61da52c6e67c..2183d5b848f9 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -30,7 +30,6 @@ * SUCH DAMAGE. * * @(#)mbuf.h 8.5 (Berkeley) 2/19/95 - * $FreeBSD$ */ #ifndef _SYS_MBUF_H_ @@ -42,12 +41,7 @@ #include <sys/systm.h> #include <sys/refcount.h> #include <vm/uma.h> -#ifdef WITNESS -#include <sys/lock.h> -#endif -#endif -#ifdef _KERNEL #include <sys/sdt.h> #define MBUF_PROBE1(probe, arg0) \ @@ -150,8 +144,8 @@ struct m_snd_tag { /* * Record/packet header in first mbuf of chain; valid only if M_PKTHDR is set. - * Size ILP32: 48 - * LP64: 56 + * Size ILP32: 56 + * LP64: 64 * Compile-time assertions in uipc_mbuf.c test these values to ensure that * they are correct. */ @@ -164,6 +158,13 @@ struct pkthdr { uint16_t rcvgen; /* ... and generation count */ }; }; + union { + struct ifnet *leaf_rcvif; /* leaf rcv interface */ + struct { + uint16_t leaf_rcvidx; /* leaf rcv interface index ... */ + uint16_t leaf_rcvgen; /* ... and generation count */ + }; + }; SLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */ int32_t len; /* total packet length */ @@ -173,6 +174,9 @@ struct pkthdr { uint16_t fibnum; /* this packet should use this fib */ uint8_t numa_domain; /* NUMA domain of recvd pkt */ uint8_t rsstype; /* hash type */ +#if !defined(__LP64__) + uint32_t pad; /* pad for 64bit alignment */ +#endif union { uint64_t rcv_tstmp; /* timestamp in ns */ struct { @@ -197,13 +201,17 @@ struct pkthdr { /* Layer specific non-persistent local storage for reassembly, etc. */ union { - uint8_t eight[8]; - uint16_t sixteen[4]; - uint32_t thirtytwo[2]; - uint64_t sixtyfour[1]; - uintptr_t unintptr[1]; - void *ptr; - } PH_loc; + union { + uint8_t eight[8]; + uint16_t sixteen[4]; + uint32_t thirtytwo[2]; + uint64_t sixtyfour[1]; + uintptr_t unintptr[1]; + void *ptr; + } PH_loc; + /* Upon allocation: total packet memory consumption. */ + u_int memlen; + }; }; #define ether_vtag PH_per.sixteen[0] #define tcp_tun_port PH_per.sixteen[0] /* outbound */ @@ -238,7 +246,7 @@ struct pkthdr { #if defined(__LP64__) #define MBUF_PEXT_MAX_PGS (40 / sizeof(vm_paddr_t)) #else -#define MBUF_PEXT_MAX_PGS (72 / sizeof(vm_paddr_t)) +#define MBUF_PEXT_MAX_PGS (64 / sizeof(vm_paddr_t)) #endif #define MBUF_PEXT_MAX_BYTES \ @@ -777,15 +785,11 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgoff) #ifdef _KERNEL union if_snd_tag_alloc_params; -#ifdef WITNESS #define MBUF_CHECKSLEEP(how) do { \ if (how == M_WAITOK) \ WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, \ "Sleeping in \"%s\"", __func__); \ } while (0) -#else -#define MBUF_CHECKSLEEP(how) do {} while (0) -#endif /* * Network buffer allocation API @@ -880,11 +884,9 @@ m_gettype(int size) case MCLBYTES: type = EXT_CLUSTER; break; -#if MJUMPAGESIZE != MCLBYTES case MJUMPAGESIZE: type = EXT_JUMBOP; break; -#endif case MJUM9BYTES: type = EXT_JUMBO9; break; @@ -930,11 +932,9 @@ m_getzone(int size) case MCLBYTES: zone = zone_clust; break; -#if MJUMPAGESIZE != MCLBYTES case MJUMPAGESIZE: zone = zone_jumbop; break; -#endif case MJUM9BYTES: zone = zone_jumbo9; break; @@ -1054,11 +1054,9 @@ m_cljset(struct mbuf *m, void *cl, int type) case EXT_CLUSTER: size = MCLBYTES; break; -#if MJUMPAGESIZE != MCLBYTES case EXT_JUMBOP: size = MJUMPAGESIZE; break; -#endif case EXT_JUMBO9: size = MJUM9BYTES; break; @@ -1237,6 +1235,16 @@ m_align(struct mbuf *m, int len) (M_WRITABLE(m) ? ((m)->m_data - M_START(m)) : 0) /* + * So M_TRAILINGROOM() is for when you want to know how much space + * would be there if it was writable. This can be used to + * detect changes in mbufs by knowing the value at one point + * and then being able to compare it later to the current M_TRAILINGROOM(). + * The TRAILINGSPACE() macro is not suitable for this since an mbuf + * at one point might not be writable and then later it becomes writable + * even though the space at the back of it has not changed. + */ +#define M_TRAILINGROOM(m) ((M_START(m) + M_SIZE(m)) - ((m)->m_data + (m)->m_len)) +/* * Compute the amount of space available after the end of data in an mbuf. * * The M_WRITABLE() is a temporary, conservative safety measure: the burden @@ -1246,9 +1254,7 @@ m_align(struct mbuf *m, int len) * for mbufs with external storage. We now allow mbuf-embedded data to be * read-only as well. */ -#define M_TRAILINGSPACE(m) \ - (M_WRITABLE(m) ? \ - ((M_START(m) + M_SIZE(m)) - ((m)->m_data + (m)->m_len)) : 0) +#define M_TRAILINGSPACE(m) (M_WRITABLE(m) ? M_TRAILINGROOM(m) : 0) /* * Arrange to prepend space of size plen to mbuf m. If a new mbuf must be @@ -1292,10 +1298,12 @@ m_rcvif(struct mbuf *m) /* Length to m_copy to copy all. */ #define M_COPYALL 1000000000 -extern int max_datalen; /* MHLEN - max_hdr */ -extern int max_hdr; /* Largest link + protocol header */ -extern int max_linkhdr; /* Largest link-level header */ -extern int max_protohdr; /* Largest protocol header */ +extern u_int max_linkhdr; /* Largest link-level header */ +extern u_int max_hdr; /* Largest link + protocol header */ +extern u_int max_protohdr; /* Largest protocol header */ +void max_linkhdr_grow(u_int); +void max_protohdr_grow(u_int); + extern int nmbclusters; /* Maximum number of clusters */ extern bool mb_use_ext_pgs; /* Use ext_pgs for sendfile */ @@ -1371,11 +1379,12 @@ extern bool mb_use_ext_pgs; /* Use ext_pgs for sendfile */ #define PACKET_TAG_IPFORWARD 18 /* ipforward info */ #define PACKET_TAG_MACLABEL (19 | MTAG_PERSISTENT) /* MAC label */ #define PACKET_TAG_PF 21 /* PF/ALTQ information */ -#define PACKET_TAG_RTSOCKFAM 25 /* rtsock sa family */ +/* was PACKET_TAG_RTSOCKFAM 25 rtsock sa family */ #define PACKET_TAG_IPOPTIONS 27 /* Saved IP options */ #define PACKET_TAG_CARP 28 /* CARP info */ #define PACKET_TAG_IPSEC_NAT_T_PORTS 29 /* two uint16_t */ #define PACKET_TAG_ND_OUTGOING 30 /* ND outgoing */ +#define PACKET_TAG_PF_REASSEMBLED 31 /* Specific cookies and tags. */ @@ -1665,12 +1674,24 @@ mbuf_tstmp2timespec(struct mbuf *m, struct timespec *ts) { KASSERT((m->m_flags & M_PKTHDR) != 0, ("mbuf %p no M_PKTHDR", m)); - KASSERT((m->m_flags & (M_TSTMP|M_TSTMP_LRO)) != 0, ("mbuf %p no M_TSTMP or M_TSTMP_LRO", m)); + KASSERT((m->m_flags & (M_TSTMP|M_TSTMP_LRO)) != 0, + ("mbuf %p no M_TSTMP or M_TSTMP_LRO", m)); ts->tv_sec = m->m_pkthdr.rcv_tstmp / 1000000000; ts->tv_nsec = m->m_pkthdr.rcv_tstmp % 1000000000; } #endif +static inline void +mbuf_tstmp2timeval(struct mbuf *m, struct timeval *tv) +{ + + KASSERT((m->m_flags & M_PKTHDR) != 0, ("mbuf %p no M_PKTHDR", m)); + KASSERT((m->m_flags & (M_TSTMP|M_TSTMP_LRO)) != 0, + ("mbuf %p no M_TSTMP or M_TSTMP_LRO", m)); + tv->tv_sec = m->m_pkthdr.rcv_tstmp / 1000000000; + tv->tv_usec = (m->m_pkthdr.rcv_tstmp % 1000000000) / 1000; +} + #ifdef DEBUGNET /* Invoked from the debugnet client code. */ void debugnet_mbuf_drain(void); diff --git a/sys/sys/mchain.h b/sys/sys/mchain.h index 28391d749472..b119ce7b92a1 100644 --- a/sys/sys/mchain.h +++ b/sys/sys/mchain.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2000, 2001 Boris Popov * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_MCHAIN_H_ #define _SYS_MCHAIN_H_ diff --git a/sys/sys/md4.h b/sys/sys/md4.h index 78873d9f7e8e..0918d533659b 100644 --- a/sys/sys/md4.h +++ b/sys/sys/md4.h @@ -1,5 +1,4 @@ /* MD4.H - header file for MD4C.C - * $FreeBSD$ */ /*- diff --git a/sys/sys/md5.h b/sys/sys/md5.h index f5ddd9c48cd1..ac9a1dbfe4ae 100644 --- a/sys/sys/md5.h +++ b/sys/sys/md5.h @@ -1,5 +1,4 @@ /* MD5.H - header file for MD5C.C - * $FreeBSD$ */ /*- diff --git a/sys/sys/mdioctl.h b/sys/sys/mdioctl.h index 97464c11149b..dc8bb6c82b31 100644 --- a/sys/sys/mdioctl.h +++ b/sys/sys/mdioctl.h @@ -38,8 +38,6 @@ * @(#)vnioctl.h 8.1 (Berkeley) 6/10/93 * * From: src/sys/sys/vnioctl.h,v 1.4 - * - * $FreeBSD$ */ #ifndef _SYS_MDIOCTL_H_ diff --git a/sys/sys/membarrier.h b/sys/sys/membarrier.h new file mode 100644 index 000000000000..958b769da23e --- /dev/null +++ b/sys/sys/membarrier.h @@ -0,0 +1,70 @@ +/*- + * Copyright (c) 2021 The FreeBSD Foundation + * + * This software were developed by Konstantin Belousov <kib@FreeBSD.org> + * 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: + * 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. + */ + +#ifndef __SYS_MEMBARRIER_H__ +#define __SYS_MEMBARRIER_H__ + +#include <sys/cdefs.h> + +/* + * The enum membarrier_cmd values are bits. The MEMBARRIER_CMD_QUERY + * command returns a bitset indicating which commands are supported. + * Also the value of MEMBARRIER_CMD_QUERY is zero, so it is + * effectively not returned by the query. + */ +enum membarrier_cmd { + MEMBARRIER_CMD_QUERY = 0x00000000, + MEMBARRIER_CMD_GLOBAL = 0x00000001, + MEMBARRIER_CMD_SHARED = MEMBARRIER_CMD_GLOBAL, + MEMBARRIER_CMD_GLOBAL_EXPEDITED = 0x00000002, + MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED = 0x00000004, + MEMBARRIER_CMD_PRIVATE_EXPEDITED = 0x00000008, + MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED = 0x00000010, + MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE = 0x00000020, + MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE = 0x00000040, + + /* + * RSEQ constants are defined for source compatibility but are + * not yes supported, MEMBARRIER_CMD_QUERY does not return + * them in the mask. + */ + MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ = 0x00000080, + MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ = 0x00000100, +}; + +enum membarrier_cmd_flag { + MEMBARRIER_CMD_FLAG_CPU = 0x00000001, +}; + +#ifndef _KERNEL +__BEGIN_DECLS +int membarrier(int, unsigned, int); +__END_DECLS +#endif /* _KERNEL */ + +#endif /* __SYS_MEMBARRIER_H__ */ diff --git a/sys/sys/memdesc.h b/sys/sys/memdesc.h index 8a128fd7f519..24a2c2da6347 100644 --- a/sys/sys/memdesc.h +++ b/sys/sys/memdesc.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2012 EMC Corp. * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_MEMDESC_H_ @@ -35,6 +33,7 @@ struct bio; struct bus_dma_segment; struct uio; struct mbuf; +struct vm_page; union ccb; /* @@ -46,12 +45,17 @@ struct memdesc { void *md_vaddr; vm_paddr_t md_paddr; struct bus_dma_segment *md_list; - struct bio *md_bio; struct uio *md_uio; struct mbuf *md_mbuf; - union ccb *md_ccb; + struct vm_page **md_ma; } u; - size_t md_opaque; /* type specific data. */ + union { /* type specific data. */ + size_t md_len; /* VADDR, PADDR, VMPAGES */ + int md_nseg; /* VLIST, PLIST */ + }; + union { + uint32_t md_offset; /* VMPAGES */ + }; uint32_t md_type; /* Type of memory. */ }; @@ -59,10 +63,9 @@ struct memdesc { #define MEMDESC_PADDR 2 /* Contiguous physical address. */ #define MEMDESC_VLIST 3 /* scatter/gather list of kva addresses. */ #define MEMDESC_PLIST 4 /* scatter/gather list of physical addresses. */ -#define MEMDESC_BIO 5 /* Pointer to a bio (block io). */ #define MEMDESC_UIO 6 /* Pointer to a uio (any io). */ #define MEMDESC_MBUF 7 /* Pointer to a mbuf (network io). */ -#define MEMDESC_CCB 8 /* Cam control block. (scsi/ata io). */ +#define MEMDESC_VMPAGES 8 /* Pointer to array of VM pages. */ static inline struct memdesc memdesc_vaddr(void *vaddr, size_t len) @@ -70,7 +73,7 @@ memdesc_vaddr(void *vaddr, size_t len) struct memdesc mem; mem.u.md_vaddr = vaddr; - mem.md_opaque = len; + mem.md_len = len; mem.md_type = MEMDESC_VADDR; return (mem); @@ -82,7 +85,7 @@ memdesc_paddr(vm_paddr_t paddr, size_t len) struct memdesc mem; mem.u.md_paddr = paddr; - mem.md_opaque = len; + mem.md_len = len; mem.md_type = MEMDESC_PADDR; return (mem); @@ -94,7 +97,7 @@ memdesc_vlist(struct bus_dma_segment *vlist, int sglist_cnt) struct memdesc mem; mem.u.md_list = vlist; - mem.md_opaque = sglist_cnt; + mem.md_nseg = sglist_cnt; mem.md_type = MEMDESC_VLIST; return (mem); @@ -106,24 +109,13 @@ memdesc_plist(struct bus_dma_segment *plist, int sglist_cnt) struct memdesc mem; mem.u.md_list = plist; - mem.md_opaque = sglist_cnt; + mem.md_nseg = sglist_cnt; mem.md_type = MEMDESC_PLIST; return (mem); } static inline struct memdesc -memdesc_bio(struct bio *bio) -{ - struct memdesc mem; - - mem.u.md_bio = bio; - mem.md_type = MEMDESC_BIO; - - return (mem); -} - -static inline struct memdesc memdesc_uio(struct uio *uio) { struct memdesc mem; @@ -146,13 +138,29 @@ memdesc_mbuf(struct mbuf *mbuf) } static inline struct memdesc -memdesc_ccb(union ccb *ccb) +memdesc_vmpages(struct vm_page **ma, size_t len, u_int ma_offset) { struct memdesc mem; - mem.u.md_ccb = ccb; - mem.md_type = MEMDESC_CCB; + mem.u.md_ma = ma; + mem.md_len = len; + mem.md_type = MEMDESC_VMPAGES; + mem.md_offset = ma_offset; return (mem); } + +struct memdesc memdesc_bio(struct bio *bio); +struct memdesc memdesc_ccb(union ccb *ccb); + +/* + * Similar to m_copyback/data, *_copyback copy data from the 'src' + * buffer into the memory descriptor's data buffer while *_copydata + * copy data from the memory descriptor's data buffer into the the + * 'dst' buffer. + */ +void memdesc_copyback(struct memdesc *mem, int off, int size, + const void *src); +void memdesc_copydata(struct memdesc *mem, int off, int size, void *dst); + #endif /* _SYS_MEMDESC_H_ */ diff --git a/sys/sys/memrange.h b/sys/sys/memrange.h index d3eeeb79b664..08321bdf9c44 100644 --- a/sys/sys/memrange.h +++ b/sys/sys/memrange.h @@ -1,12 +1,12 @@ /* * Memory range attribute operations, performed on /dev/mem - * - * $FreeBSD$ */ #ifndef _SYS_MEMRANGE_H_ #define _SYS_MEMRANGE_H_ +#include <sys/ioccom.h> + /* Memory range attributes */ #define MDF_UNCACHEABLE (1<<0) /* region not cached */ #define MDF_WRITECOMBINE (1<<1) /* region supports "write combine" action */ diff --git a/sys/sys/mman.h b/sys/sys/mman.h index a07b3550d51a..7eb38a5f59d0 100644 --- a/sys/sys/mman.h +++ b/sys/sys/mman.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)mman.h 8.2 (Berkeley) 1/9/95 - * $FreeBSD$ */ #ifndef _SYS_MMAN_H_ @@ -104,9 +103,7 @@ #define MAP_EXCL 0x00004000 /* for MAP_FIXED, fail if address is used */ #define MAP_NOCORE 0x00020000 /* dont include these pages in a coredump */ #define MAP_PREFAULT_READ 0x00040000 /* prefault mapping for reading */ -#ifdef __LP64__ #define MAP_32BIT 0x00080000 /* map in the low 2GB of address space */ -#endif /* * Request specific alignment (n == log2 of the desired alignment). @@ -268,6 +265,7 @@ struct file; struct shmfd { vm_ooffset_t shm_size; vm_object_t shm_object; + vm_pindex_t shm_pages; /* allocated pages */ int shm_refs; uid_t shm_uid; gid_t shm_gid; @@ -300,6 +298,8 @@ struct shmfd { #endif #ifdef _KERNEL +struct prison; + 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); @@ -309,6 +309,7 @@ struct shmfd *shm_hold(struct shmfd *shmfd); void shm_drop(struct shmfd *shmfd); int shm_dotruncate(struct shmfd *shmfd, off_t length); bool shm_largepage(struct shmfd *shmfd); +void shm_remove_prison(struct prison *pr); extern struct fileops shm_ops; diff --git a/sys/sys/module.h b/sys/sys/module.h index efefaf4cb513..f749455bdf63 100644 --- a/sys/sys/module.h +++ b/sys/sys/module.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1997 Doug Rabson * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_MODULE_H_ diff --git a/sys/sys/module_khelp.h b/sys/sys/module_khelp.h index bab33e487497..59533709a9e5 100644 --- a/sys/sys/module_khelp.h +++ b/sys/sys/module_khelp.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2010 Lawrence Stewart <lstewart@freebsd.org> * Copyright (c) 2010 The FreeBSD Foundation @@ -34,8 +34,6 @@ * 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$ */ #ifndef _SYS_MODULE_KHELP_H_ diff --git a/sys/sys/mount.h b/sys/sys/mount.h index 3383bfe8f431..c4e1f83e9683 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)mount.h 8.21 (Berkeley) 5/20/95 - * $FreeBSD$ */ #ifndef _SYS_MOUNT_H_ @@ -91,7 +90,9 @@ struct statfs { uint64_t f_asyncwrites; /* count of async writes since mount */ uint64_t f_syncreads; /* count of sync reads since mount */ uint64_t f_asyncreads; /* count of async reads since mount */ - uint64_t f_spare[10]; /* unused spare */ + uint32_t f_nvnodelistsize; /* # of vnodes */ + uint32_t f_spare0; /* unused spare */ + uint64_t f_spare[9]; /* unused spare */ uint32_t f_namemax; /* maximum filename length */ uid_t f_owner; /* user that mounted the filesystem */ fsid_t f_fsid; /* filesystem id */ @@ -214,6 +215,7 @@ struct mount_upper_node { * i - interlock * v - vnode freelist mutex * d - deferred unmount list mutex + * e - mnt_explock * * Unmarked fields are considered stable as long as a ref is held. * @@ -243,13 +245,14 @@ struct mount { void * mnt_data; /* private data */ time_t mnt_time; /* last time written*/ int mnt_iosize_max; /* max size for clusters, etc */ - struct netexport *mnt_export; /* export list */ + struct netexport *mnt_export; /* (e) export list */ struct label *mnt_label; /* MAC label for the fs */ u_int mnt_hashseed; /* Random seed for vfs_hash */ int mnt_lockref; /* (i) Lock reference count */ int mnt_secondary_writes; /* (i) # of secondary writes */ int mnt_secondary_accwrites;/* (i) secondary wr. starts */ struct thread *mnt_susp_owner; /* (i) thread owning suspension */ + struct ucred *mnt_exjail; /* (i) jail which did exports */ #define mnt_endzero mnt_gjprovider char *mnt_gjprovider; /* gjournal provider name */ struct mtx mnt_listmtx; @@ -676,6 +679,7 @@ struct ovfsconf { #define VFCF_DELEGADMIN 0x00800000 /* supports delegated administration */ #define VFCF_SBDRY 0x01000000 /* Stop at Boundary: defer stop requests to kernel->user (AST) transition */ +#define VFCF_FILEMOUNT 0x02000000 /* allow mounting files */ typedef uint32_t fsctlop_t; @@ -1012,8 +1016,10 @@ int vfs_setpublicfs /* set publicly exported fs */ (struct mount *, struct netexport *, struct export_args *); void vfs_periodic(struct mount *, int); int vfs_busy(struct mount *, int); +void vfs_exjail_delete(struct prison *); int vfs_export /* process mount export info */ - (struct mount *, struct export_args *); + (struct mount *, struct export_args *, bool); +void vfs_free_addrlist(struct netexport *); void vfs_allocate_syncvnode(struct mount *); void vfs_deallocate_syncvnode(struct mount *); int vfs_donmount(struct thread *td, uint64_t fsflags, diff --git a/sys/sys/mouse.h b/sys/sys/mouse.h index a23e09abb874..3c70c7b0843e 100644 --- a/sys/sys/mouse.h +++ b/sys/sys/mouse.h @@ -21,8 +21,6 @@ * 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$ */ #ifndef _SYS_MOUSE_H_ diff --git a/sys/sys/mpt_ioctl.h b/sys/sys/mpt_ioctl.h index 527334594faf..f3640fbc83bd 100644 --- a/sys/sys/mpt_ioctl.h +++ b/sys/sys/mpt_ioctl.h @@ -30,8 +30,6 @@ * SUCH DAMAGE. * * LSI MPT-Fusion Host Adapter FreeBSD userland interface - * - * $FreeBSD$ */ #ifndef _MPT_IOCTL_H_ diff --git a/sys/sys/mqueue.h b/sys/sys/mqueue.h index ca9fd13cca76..50f6681ce218 100644 --- a/sys/sys/mqueue.h +++ b/sys/sys/mqueue.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2005 David Xu <davidxu@freebsd.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_MQUEUE_H_ diff --git a/sys/sys/msg.h b/sys/sys/msg.h index c98e0749ad53..29fb8c2106b5 100644 --- a/sys/sys/msg.h +++ b/sys/sys/msg.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /* $NetBSD: msg.h,v 1.4 1994/06/29 06:44:43 cgd Exp $ */ /*- diff --git a/sys/sys/msgbuf.h b/sys/sys/msgbuf.h index 6768b862faf7..e5c482f329e7 100644 --- a/sys/sys/msgbuf.h +++ b/sys/sys/msgbuf.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)msgbuf.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD$ */ #ifndef _SYS_MSGBUF_H_ diff --git a/sys/sys/mtio.h b/sys/sys/mtio.h index 843b32909224..e52692eb33ab 100644 --- a/sys/sys/mtio.h +++ b/sys/sys/mtio.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)mtio.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD$ */ #ifndef _SYS_MTIO_H_ diff --git a/sys/sys/mutex.h b/sys/sys/mutex.h index 04e2c823541a..56c03a1b0be9 100644 --- a/sys/sys/mutex.h +++ b/sys/sys/mutex.h @@ -28,7 +28,6 @@ * SUCH DAMAGE. * * from BSDI $Id: mutex.h,v 2.7.2.35 2000/04/27 03:10:26 cp Exp $ - * $FreeBSD$ */ #ifndef _SYS_MUTEX_H_ @@ -509,16 +508,13 @@ do { \ } #define PICKUP_GIANT() \ - PARTIAL_PICKUP_GIANT(); \ -} while (0) - -#define PARTIAL_PICKUP_GIANT() \ mtx_assert(&Giant, MA_NOTOWNED); \ if (__predict_false(_giantcnt > 0)) { \ while (_giantcnt--) \ mtx_lock(&Giant); \ WITNESS_RESTORE(&Giant.lock_object, Giant); \ - } + } \ +} while (0) #endif struct mtx_args { diff --git a/sys/sys/namei.h b/sys/sys/namei.h index 0b293d1d1abf..8ffa87aa3d7e 100644 --- a/sys/sys/namei.h +++ b/sys/sys/namei.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)namei.h 8.5 (Berkeley) 1/9/95 - * $FreeBSD$ */ #ifndef _SYS_NAMEI_H_ @@ -47,7 +46,6 @@ struct componentname { /* * Arguments to lookup. */ - u_int64_t cn_origflags; /* flags to namei */ u_int64_t cn_flags; /* flags to namei */ struct ucred *cn_cred; /* credentials */ enum nameiop cn_nameiop; /* namei operation */ @@ -158,21 +156,10 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status, /* * Namei parameter descriptors. - * - * SAVENAME may be set by either the callers of namei or by VOP_LOOKUP. - * If the caller of namei sets the flag (for example execve wants to - * know the name of the program that is being executed), then it must - * free the buffer. If VOP_LOOKUP sets the flag, then the buffer must - * be freed by either the commit routine or the VOP_ABORT routine. - * SAVESTART is set only by the callers of namei. It implies SAVENAME - * plus the addition of saving the parent directory that contains the - * name in ni_startdir. It allows repeated calls to lookup for the - * name being sought. The caller is responsible for releasing the - * buffer and for vrele'ing ni_startdir. */ #define RDONLY 0x00000200 /* lookup with read-only semantics */ -#define SAVENAME 0x00000400 /* save pathname buffer */ -#define SAVESTART 0x00000800 /* save starting directory */ +#define ISRESTARTED 0x00000400 /* restarted namei */ +/* UNUSED 0x00000800 */ #define ISWHITEOUT 0x00001000 /* found whiteout */ #define DOWHITEOUT 0x00002000 /* do whiteouts */ #define WILLBEDIR 0x00004000 /* new files will be dirs; allow trailing / */ @@ -185,7 +172,7 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status, #define OPENREAD 0x00200000 /* open for reading */ #define OPENWRITE 0x00400000 /* open for writing */ #define WANTIOCTLCAPS 0x00800000 /* leave ioctl caps for the caller */ -#define HASBUF 0x01000000 /* has allocated pathname buffer */ +/* UNUSED 0x01000000 */ #define NOEXECCHECK 0x02000000 /* do not perform exec check on dir */ #define MAKEENTRY 0x04000000 /* entry is to be added to name cache */ #define ISSYMLINK 0x08000000 /* symlink needs interpretation */ @@ -198,8 +185,8 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status, * Flags which must not be passed in by callers. */ #define NAMEI_INTERNAL_FLAGS \ - (HASBUF | NOEXECCHECK | MAKEENTRY | ISSYMLINK | ISLASTCN | ISDOTDOT | \ - TRAILINGSLASH) + (NOEXECCHECK | MAKEENTRY | ISSYMLINK | ISLASTCN | ISDOTDOT | \ + TRAILINGSLASH | ISRESTARTED) /* * Namei results flags @@ -280,34 +267,29 @@ do { \ (ndp)->ni_vp_seqc = SEQC_MOD; \ } while (0) -#define NDF_NO_DVP_RELE 0x00000001 -#define NDF_NO_DVP_UNLOCK 0x00000002 -#define NDF_NO_DVP_PUT 0x00000003 -#define NDF_NO_VP_RELE 0x00000004 -#define NDF_NO_VP_UNLOCK 0x00000008 -#define NDF_NO_VP_PUT 0x0000000c -#define NDF_NO_STARTDIR_RELE 0x00000010 -#define NDF_NO_FREE_PNBUF 0x00000020 - #define NDFREE_IOCTLCAPS(ndp) do { \ struct nameidata *_ndp = (ndp); \ filecaps_free(&_ndp->ni_filecaps); \ } while (0) -void NDFREE_PNBUF(struct nameidata *); -void NDFREE(struct nameidata *, const u_int); -#ifdef INVARIANTS -void NDFREE_NOTHING(struct nameidata *); -void NDVALIDATE(struct nameidata *); -#else -#define NDFREE_NOTHING(ndp) do { } while (0) -#define NDVALIDATE(ndp) do { } while (0) -#endif +#define NDFREE_PNBUF(ndp) do { \ + struct nameidata *_ndp = (ndp); \ + MPASS(_ndp->ni_cnd.cn_pnbuf != NULL); \ + uma_zfree(namei_zone, _ndp->ni_cnd.cn_pnbuf); \ + _ndp->ni_cnd.cn_pnbuf = NULL; \ +} while (0) int namei(struct nameidata *ndp); int vfs_lookup(struct nameidata *ndp); int vfs_relookup(struct vnode *dvp, struct vnode **vpp, - struct componentname *cnp); + struct componentname *cnp, bool refstart); + +#define namei_setup_rootdir(ndp, cnp, pwd) do { \ + if (__predict_true((cnp->cn_flags & ISRESTARTED) == 0)) \ + ndp->ni_rootdir = pwd->pwd_adir; \ + else \ + ndp->ni_rootdir = pwd->pwd_rdir; \ +} while (0) #endif /* diff --git a/sys/sys/nlist_aout.h b/sys/sys/nlist_aout.h index 0e1fa284de1e..16e1f67c6b26 100644 --- a/sys/sys/nlist_aout.h +++ b/sys/sys/nlist_aout.h @@ -34,8 +34,6 @@ * SUCH DAMAGE. * * @(#)nlist.h 8.2 (Berkeley) 1/21/94 - * - * $FreeBSD$ */ #ifndef _SYS_NLIST_AOUT_H_ diff --git a/sys/sys/nv.h b/sys/sys/nv.h index 80fb877721f0..6219eac6a827 100644 --- a/sys/sys/nv.h +++ b/sys/sys/nv.h @@ -28,8 +28,6 @@ * 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$ */ #ifndef _NV_H_ @@ -42,6 +40,7 @@ #include <stdbool.h> #include <stdint.h> #include <stdio.h> +#include <sys/nv_namespace.h> #endif #ifndef _NVLIST_T_DECLARED diff --git a/sys/sys/nv_namespace.h b/sys/sys/nv_namespace.h new file mode 100644 index 000000000000..ccc55edcdb90 --- /dev/null +++ b/sys/sys/nv_namespace.h @@ -0,0 +1,280 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2022 Rubicon Communications, LLC (Netgate) + * 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 AUTHORS 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 AUTHORS 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. + */ + +#ifndef _NV_NAMESPACE_H_ +#define _NV_NAMESPACE_H_ + +#define cnvlist_free_binary FreeBSD_cnvlist_free_binary +#define cnvlist_free_bool FreeBSD_cnvlist_free_bool +#define cnvlist_free_bool_array FreeBSD_cnvlist_free_bool_array +#define cnvlist_free_descriptor FreeBSD_cnvlist_free_descriptor +#define cnvlist_free_descriptor_array FreeBSD_cnvlist_free_descriptor_array +#define cnvlist_free_number FreeBSD_cnvlist_free_number +#define cnvlist_free_number_array FreeBSD_cnvlist_free_number_array +#define cnvlist_free_nvlist FreeBSD_cnvlist_free_nvlist +#define cnvlist_free_nvlist_array FreeBSD_cnvlist_free_nvlist_array +#define cnvlist_free_string FreeBSD_cnvlist_free_string +#define cnvlist_free_string_array FreeBSD_cnvlist_free_string_array +#define cnvlist_get_binary FreeBSD_cnvlist_get_binary +#define cnvlist_get_bool FreeBSD_cnvlist_get_bool +#define cnvlist_get_bool_array FreeBSD_cnvlist_get_bool_array +#define cnvlist_get_descriptor FreeBSD_cnvlist_get_descriptor +#define cnvlist_get_descriptor_array FreeBSD_cnvlist_get_descriptor_array +#define cnvlist_get_number FreeBSD_cnvlist_get_number +#define cnvlist_get_number_array FreeBSD_cnvlist_get_number_array +#define cnvlist_get_nvlist FreeBSD_cnvlist_get_nvlist +#define cnvlist_get_nvlist_array FreeBSD_cnvlist_get_nvlist_array +#define cnvlist_get_string FreeBSD_cnvlist_get_string +#define cnvlist_get_string_array FreeBSD_cnvlist_get_string_array +#define cnvlist_name FreeBSD_cnvlist_name +#define cnvlist_take_binary FreeBSD_cnvlist_take_binary +#define cnvlist_take_bool FreeBSD_cnvlist_take_bool +#define cnvlist_take_bool_array FreeBSD_cnvlist_take_bool_array +#define cnvlist_take_descriptor FreeBSD_cnvlist_take_descriptor +#define cnvlist_take_descriptor_array FreeBSD_cnvlist_take_descriptor_array +#define cnvlist_take_number FreeBSD_cnvlist_take_number +#define cnvlist_take_number_array FreeBSD_cnvlist_take_number_array +#define cnvlist_take_nvlist FreeBSD_cnvlist_take_nvlist +#define cnvlist_take_nvlist_array FreeBSD_cnvlist_take_nvlist_array +#define cnvlist_take_string FreeBSD_cnvlist_take_string +#define cnvlist_take_string_array FreeBSD_cnvlist_take_string_array +#define cnvlist_type FreeBSD_cnvlist_type +#define dnvlist_get_binary FreeBSD_dnvlist_get_binary +#define dnvlist_get_bool FreeBSD_dnvlist_get_bool +#define dnvlist_get_descriptor FreeBSD_dnvlist_get_descriptor +#define dnvlist_get_number FreeBSD_dnvlist_get_number +#define dnvlist_get_nvlist FreeBSD_dnvlist_get_nvlist +#define dnvlist_get_string FreeBSD_dnvlist_get_string +#define dnvlist_take_binary FreeBSD_dnvlist_take_binary +#define dnvlist_take_bool FreeBSD_dnvlist_take_bool +#define dnvlist_take_descriptor FreeBSD_dnvlist_take_descriptor +#define dnvlist_take_number FreeBSD_dnvlist_take_number +#define dnvlist_take_nvlist FreeBSD_dnvlist_take_nvlist +#define dnvlist_take_string FreeBSD_dnvlist_take_string +#define nvlist FreeBSD_nvlist +#define nvlist_add_binary FreeBSD_nvlist_add_binary +#define nvlist_add_bool FreeBSD_nvlist_add_bool +#define nvlist_add_bool_array FreeBSD_nvlist_add_bool_array +#define nvlist_add_descriptor FreeBSD_nvlist_add_descriptor +#define nvlist_add_descriptor_array FreeBSD_nvlist_add_descriptor_array +#define nvlist_add_null FreeBSD_nvlist_add_null +#define nvlist_add_number FreeBSD_nvlist_add_number +#define nvlist_add_number_array FreeBSD_nvlist_add_number_array +#define nvlist_add_nvlist FreeBSD_nvlist_add_nvlist +#define nvlist_add_nvlist_array FreeBSD_nvlist_add_nvlist_array +#define nvlist_add_nvpair FreeBSD_nvlist_add_nvpair +#define nvlist_add_string FreeBSD_nvlist_add_string +#define nvlist_add_string_array FreeBSD_nvlist_add_string_array +#define nvlist_add_stringf FreeBSD_nvlist_add_stringf +#define nvlist_add_stringv FreeBSD_nvlist_add_stringv +#define nvlist_append_bool_array FreeBSD_nvlist_append_bool_array +#define nvlist_append_descriptor_array FreeBSD_nvlist_append_descriptor_array +#define nvlist_append_number_array FreeBSD_nvlist_append_number_array +#define nvlist_append_nvlist_array FreeBSD_nvlist_append_nvlist_array +#define nvlist_append_string_array FreeBSD_nvlist_append_string_array +#define nvlist_clone FreeBSD_nvlist_clone +#define nvlist_create FreeBSD_nvlist_create +#define nvlist_descriptors FreeBSD_nvlist_descriptors +#define nvlist_destroy FreeBSD_nvlist_destroy +#define nvlist_dump FreeBSD_nvlist_dump +#define nvlist_empty FreeBSD_nvlist_empty +#define nvlist_error FreeBSD_nvlist_error +#define nvlist_exists FreeBSD_nvlist_exists +#define nvlist_exists_binary FreeBSD_nvlist_exists_binary +#define nvlist_exists_bool FreeBSD_nvlist_exists_bool +#define nvlist_exists_bool_array FreeBSD_nvlist_exists_bool_array +#define nvlist_exists_descriptor FreeBSD_nvlist_exists_descriptor +#define nvlist_exists_descriptor_array FreeBSD_nvlist_exists_descriptor_array +#define nvlist_exists_null FreeBSD_nvlist_exists_null +#define nvlist_exists_number FreeBSD_nvlist_exists_number +#define nvlist_exists_number_array FreeBSD_nvlist_exists_number_array +#define nvlist_exists_nvlist FreeBSD_nvlist_exists_nvlist +#define nvlist_exists_nvlist_array FreeBSD_nvlist_exists_nvlist_array +#define nvlist_exists_string FreeBSD_nvlist_exists_string +#define nvlist_exists_string_array FreeBSD_nvlist_exists_string_array +#define nvlist_exists_type FreeBSD_nvlist_exists_type +#define nvlist_fdump FreeBSD_nvlist_fdump +#define nvlist_first_nvpair FreeBSD_nvlist_first_nvpair +#define nvlist_flags FreeBSD_nvlist_flags +#define nvlist_free FreeBSD_nvlist_free +#define nvlist_free_binary FreeBSD_nvlist_free_binary +#define nvlist_free_binary_array FreeBSD_nvlist_free_binary_array +#define nvlist_free_bool FreeBSD_nvlist_free_bool +#define nvlist_free_bool_array FreeBSD_nvlist_free_bool_array +#define nvlist_free_descriptor FreeBSD_nvlist_free_descriptor +#define nvlist_free_descriptor_array FreeBSD_nvlist_free_descriptor_array +#define nvlist_free_null FreeBSD_nvlist_free_null +#define nvlist_free_number FreeBSD_nvlist_free_number +#define nvlist_free_number_array FreeBSD_nvlist_free_number_array +#define nvlist_free_nvlist FreeBSD_nvlist_free_nvlist +#define nvlist_free_nvlist_array FreeBSD_nvlist_free_nvlist_array +#define nvlist_free_nvpair FreeBSD_nvlist_free_nvpair +#define nvlist_free_string FreeBSD_nvlist_free_string +#define nvlist_free_string_array FreeBSD_nvlist_free_string_array +#define nvlist_free_type FreeBSD_nvlist_free_type +#define nvlist_get_array_next FreeBSD_nvlist_get_array_next +#define nvlist_get_array_next_nvpair FreeBSD_nvlist_get_array_next_nvpair +#define nvlist_get_binary FreeBSD_nvlist_get_binary +#define nvlist_get_bool FreeBSD_nvlist_get_bool +#define nvlist_get_bool_array FreeBSD_nvlist_get_bool_array +#define nvlist_get_descriptor FreeBSD_nvlist_get_descriptor +#define nvlist_get_descriptor_array FreeBSD_nvlist_get_descriptor_array +#define nvlist_get_number FreeBSD_nvlist_get_number +#define nvlist_get_number_array FreeBSD_nvlist_get_number_array +#define nvlist_get_nvlist FreeBSD_nvlist_get_nvlist +#define nvlist_get_nvlist_array FreeBSD_nvlist_get_nvlist_array +#define nvlist_get_nvpair FreeBSD_nvlist_get_nvpair +#define nvlist_get_nvpair_parent FreeBSD_nvlist_get_nvpair_parent +#define nvlist_get_pararr FreeBSD_nvlist_get_pararr +#define nvlist_get_parent FreeBSD_nvlist_get_parent +#define nvlist_get_string FreeBSD_nvlist_get_string +#define nvlist_get_string_array FreeBSD_nvlist_get_string_array +#define nvlist_in_array FreeBSD_nvlist_in_array +#define nvlist_move_binary FreeBSD_nvlist_move_binary +#define nvlist_move_bool_array FreeBSD_nvlist_move_bool_array +#define nvlist_move_descriptor FreeBSD_nvlist_move_descriptor +#define nvlist_move_descriptor_array FreeBSD_nvlist_move_descriptor_array +#define nvlist_move_number_array FreeBSD_nvlist_move_number_array +#define nvlist_move_nvlist FreeBSD_nvlist_move_nvlist +#define nvlist_move_nvlist_array FreeBSD_nvlist_move_nvlist_array +#define nvlist_move_nvpair FreeBSD_nvlist_move_nvpair +#define nvlist_move_string FreeBSD_nvlist_move_string +#define nvlist_move_string_array FreeBSD_nvlist_move_string_array +#define nvlist_ndescriptors FreeBSD_nvlist_ndescriptors +#define nvlist_next FreeBSD_nvlist_next +#define nvlist_next_nvpair FreeBSD_nvlist_next_nvpair +#define nvlist_pack FreeBSD_nvlist_pack +#define nvlist_prev_nvpair FreeBSD_nvlist_prev_nvpair +#define nvlist_recv FreeBSD_nvlist_recv +#define nvlist_remove_nvpair FreeBSD_nvlist_remove_nvpair +#define nvlist_report_missing FreeBSD_nvlist_report_missing +#define nvlist_send FreeBSD_nvlist_send +#define nvlist_set_array_next FreeBSD_nvlist_set_array_next +#define nvlist_set_error FreeBSD_nvlist_set_error +#define nvlist_set_flags FreeBSD_nvlist_set_flags +#define nvlist_set_parent FreeBSD_nvlist_set_parent +#define nvlist_size FreeBSD_nvlist_size +#define nvlist_t FreeBSD_nvlist_t +#define nvlist_take_binary FreeBSD_nvlist_take_binary +#define nvlist_take_bool FreeBSD_nvlist_take_bool +#define nvlist_take_bool_array FreeBSD_nvlist_take_bool_array +#define nvlist_take_descriptor FreeBSD_nvlist_take_descriptor +#define nvlist_take_descriptor_array FreeBSD_nvlist_take_descriptor_array +#define nvlist_take_number FreeBSD_nvlist_take_number +#define nvlist_take_number_array FreeBSD_nvlist_take_number_array +#define nvlist_take_nvlist FreeBSD_nvlist_take_nvlist +#define nvlist_take_nvlist_array FreeBSD_nvlist_take_nvlist_array +#define nvlist_take_nvpair FreeBSD_nvlist_take_nvpair +#define nvlist_take_string FreeBSD_nvlist_take_string +#define nvlist_take_string_array FreeBSD_nvlist_take_string_array +#define nvlist_unpack FreeBSD_nvlist_unpack +#define nvlist_unpack_header FreeBSD_nvlist_unpack_header +#define nvlist_xfer FreeBSD_nvlist_xfer +#define nvpair_append_bool_array FreeBSD_nvpair_append_bool_array +#define nvpair_append_descriptor_array FreeBSD_nvpair_append_descriptor_array +#define nvpair_append_number_array FreeBSD_nvpair_append_number_array +#define nvpair_append_nvlist_array FreeBSD_nvpair_append_nvlist_array +#define nvpair_append_string_array FreeBSD_nvpair_append_string_array +#define nvpair_assert FreeBSD_nvpair_assert +#define nvpair_clone FreeBSD_nvpair_clone +#define nvpair_create_binary FreeBSD_nvpair_create_binary +#define nvpair_create_bool FreeBSD_nvpair_create_bool +#define nvpair_create_bool_array FreeBSD_nvpair_create_bool_array +#define nvpair_create_descriptor FreeBSD_nvpair_create_descriptor +#define nvpair_create_descriptor_array FreeBSD_nvpair_create_descriptor_array +#define nvpair_create_null FreeBSD_nvpair_create_null +#define nvpair_create_number FreeBSD_nvpair_create_number +#define nvpair_create_number_array FreeBSD_nvpair_create_number_array +#define nvpair_create_nvlist FreeBSD_nvpair_create_nvlist +#define nvpair_create_nvlist_array FreeBSD_nvpair_create_nvlist_array +#define nvpair_create_string FreeBSD_nvpair_create_string +#define nvpair_create_string_array FreeBSD_nvpair_create_string_array +#define nvpair_create_stringf FreeBSD_nvpair_create_stringf +#define nvpair_create_stringv FreeBSD_nvpair_create_stringv +#define nvpair_free FreeBSD_nvpair_free +#define nvpair_free_structure FreeBSD_nvpair_free_structure +#define nvpair_get_binary FreeBSD_nvpair_get_binary +#define nvpair_get_bool FreeBSD_nvpair_get_bool +#define nvpair_get_bool_array FreeBSD_nvpair_get_bool_array +#define nvpair_get_descriptor FreeBSD_nvpair_get_descriptor +#define nvpair_get_descriptor_array FreeBSD_nvpair_get_descriptor_array +#define nvpair_get_number FreeBSD_nvpair_get_number +#define nvpair_get_number_array FreeBSD_nvpair_get_number_array +#define nvpair_get_nvlist FreeBSD_nvpair_get_nvlist +#define nvpair_get_nvlist_array FreeBSD_nvpair_get_nvlist_array +#define nvpair_get_string FreeBSD_nvpair_get_string +#define nvpair_get_string_array FreeBSD_nvpair_get_string_array +#define nvpair_header_size FreeBSD_nvpair_header_size +#define nvpair_init_datasize FreeBSD_nvpair_init_datasize +#define nvpair_insert FreeBSD_nvpair_insert +#define nvpair_move_binary FreeBSD_nvpair_move_binary +#define nvpair_move_bool_array FreeBSD_nvpair_move_bool_array +#define nvpair_move_descriptor FreeBSD_nvpair_move_descriptor +#define nvpair_move_descriptor_array FreeBSD_nvpair_move_descriptor_array +#define nvpair_move_number_array FreeBSD_nvpair_move_number_array +#define nvpair_move_nvlist FreeBSD_nvpair_move_nvlist +#define nvpair_move_nvlist_array FreeBSD_nvpair_move_nvlist_array +#define nvpair_move_string FreeBSD_nvpair_move_string +#define nvpair_move_string_array FreeBSD_nvpair_move_string_array +#define nvpair_name FreeBSD_nvpair_name +#define nvpair_next FreeBSD_nvpair_next +#define nvpair_nvlist FreeBSD_nvpair_nvlist +#define nvpair_pack_binary FreeBSD_nvpair_pack_binary +#define nvpair_pack_bool FreeBSD_nvpair_pack_bool +#define nvpair_pack_bool_array FreeBSD_nvpair_pack_bool_array +#define nvpair_pack_descriptor FreeBSD_nvpair_pack_descriptor +#define nvpair_pack_descriptor_array FreeBSD_nvpair_pack_descriptor_array +#define nvpair_pack_header FreeBSD_nvpair_pack_header +#define nvpair_pack_null FreeBSD_nvpair_pack_null +#define nvpair_pack_number FreeBSD_nvpair_pack_number +#define nvpair_pack_number_array FreeBSD_nvpair_pack_number_array +#define nvpair_pack_nvlist_array_next FreeBSD_nvpair_pack_nvlist_array_next +#define nvpair_pack_nvlist_up FreeBSD_nvpair_pack_nvlist_up +#define nvpair_pack_string FreeBSD_nvpair_pack_string +#define nvpair_pack_string_array FreeBSD_nvpair_pack_string_array +#define nvpair_prev FreeBSD_nvpair_prev +#define nvpair_remove FreeBSD_nvpair_remove +#define nvpair_size FreeBSD_nvpair_size +#define nvpair_type FreeBSD_nvpair_type +#define nvpair_type_string FreeBSD_nvpair_type_string +#define nvpair_unpack FreeBSD_nvpair_unpack +#define nvpair_unpack_binary FreeBSD_nvpair_unpack_binary +#define nvpair_unpack_bool FreeBSD_nvpair_unpack_bool +#define nvpair_unpack_bool_array FreeBSD_nvpair_unpack_bool_array +#define nvpair_unpack_descriptor FreeBSD_nvpair_unpack_descriptor +#define nvpair_unpack_descriptor_array FreeBSD_nvpair_unpack_descriptor_array +#define nvpair_unpack_header FreeBSD_nvpair_unpack_header +#define nvpair_unpack_null FreeBSD_nvpair_unpack_null +#define nvpair_unpack_number FreeBSD_nvpair_unpack_number +#define nvpair_unpack_number_array FreeBSD_nvpair_unpack_number_array +#define nvpair_unpack_nvlist FreeBSD_nvpair_unpack_nvlist +#define nvpair_unpack_nvlist_array FreeBSD_nvpair_unpack_nvlist_array +#define nvpair_unpack_string FreeBSD_nvpair_unpack_string +#define nvpair_unpack_string_array FreeBSD_nvpair_unpack_string_array + +#endif diff --git a/sys/sys/osd.h b/sys/sys/osd.h index a9824184c579..1c58c4fff8de 100644 --- a/sys/sys/osd.h +++ b/sys/sys/osd.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_OSD_H_ diff --git a/sys/sys/param.h b/sys/sys/param.h index 1f720ed31142..2e4310dac111 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -34,7 +34,6 @@ * SUCH DAMAGE. * * @(#)param.h 8.3 (Berkeley) 4/4/95 - * $FreeBSD$ */ #ifndef _SYS_PARAM_H_ @@ -76,7 +75,7 @@ * cannot include sys/param.h and should only be updated here. */ #undef __FreeBSD_version -#define __FreeBSD_version 1400059 +#define __FreeBSD_version 1500001 /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, @@ -94,7 +93,7 @@ #undef __FreeBSD_kernel__ #define __FreeBSD_kernel__ -#if defined(_KERNEL) || defined(IN_RTLD) +#if defined(_KERNEL) || defined(_WANT_P_OSREL) #define P_OSREL_SIGWAIT 700000 #define P_OSREL_SIGSEGV 700004 #define P_OSREL_MAP_ANON 800104 @@ -107,6 +106,8 @@ #define P_OSREL_CK_SUPERBLOCK 1300000 #define P_OSREL_CK_INODE 1300005 #define P_OSREL_POWERPC_NEW_AUX_ARGS 1300070 +#define P_OSREL_TIDPID 1400079 +#define P_OSREL_ARM64_SPSR 1400084 #define P_OSREL_MAJOR(x) ((x) / 100000) #endif @@ -200,9 +201,7 @@ #define MCLBYTES (1 << MCLSHIFT) /* size of an mbuf cluster */ -#if PAGE_SIZE < 2048 -#define MJUMPAGESIZE MCLBYTES -#elif PAGE_SIZE <= 8192 +#if PAGE_SIZE <= 8192 #define MJUMPAGESIZE PAGE_SIZE #else #define MJUMPAGESIZE (8 * 1024) diff --git a/sys/sys/pciio.h b/sys/sys/pciio.h index 16635a884ca3..eead6989b5fa 100644 --- a/sys/sys/pciio.h +++ b/sys/sys/pciio.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1997, Stefan Esser <se@FreeBSD.ORG> * Copyright (c) 1997, 1998, 1999, Kenneth D. Merry <ken@FreeBSD.ORG> @@ -26,8 +26,6 @@ * (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$ - * */ #ifndef _SYS_PCIIO_H_ diff --git a/sys/sys/pcpu.h b/sys/sys/pcpu.h index 14bef5cf690e..d52a3b3a03a5 100644 --- a/sys/sys/pcpu.h +++ b/sys/sys/pcpu.h @@ -28,8 +28,6 @@ * 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$ */ #ifndef _SYS_PCPU_H_ @@ -86,7 +84,7 @@ extern uintptr_t dpcpu_off[]; #define DPCPU_DEFINE(t, n) \ struct _hack; t DPCPU_NAME(n) __section(DPCPU_SETNAME) __used #if defined(KLD_MODULE) && (defined(__aarch64__) || defined(__riscv) \ - || defined(__powerpc64__)) + || defined(__powerpc64__) || defined(__i386__)) /* * On some architectures the compiler will use PC-relative load to * find the address of DPCPU data with the static keyword. We then @@ -189,7 +187,8 @@ struct pcpu { long pc_cp_time[CPUSTATES]; /* statclock ticks */ struct _device *pc_device; /* CPU device handle */ void *pc_netisr; /* netisr SWI cookie */ - int pc_unused1; /* unused field */ + int8_t pc_vfs_freevnodes; /* freevnodes counter */ + char pc_unused1[3]; /* unused pad */ int pc_domain; /* Memory domain. */ struct rm_queue pc_rm_queue; /* rmlock list of trackers */ uintptr_t pc_dynamic; /* Dynamic per-cpu data area */ diff --git a/sys/sys/pctrie.h b/sys/sys/pctrie.h index 5cf740b25d7a..eec74610587a 100644 --- a/sys/sys/pctrie.h +++ b/sys/sys/pctrie.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2013 EMC Corp. * Copyright (c) 2011 Jeffrey Roberson <jeff@freebsd.org> @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS_PCTRIE_H_ @@ -78,19 +76,28 @@ name##_PCTRIE_PTR2VAL(struct type *ptr) \ static __inline int \ name##_PCTRIE_INSERT(struct pctrie *ptree, struct type *ptr) \ { \ - \ - return pctrie_insert(ptree, name##_PCTRIE_PTR2VAL(ptr), \ - allocfn); \ + struct pctrie_node *parent; \ + void *parentp; \ + uint64_t *val = name##_PCTRIE_PTR2VAL(ptr); \ + \ + parentp = pctrie_insert_lookup(ptree, val); \ + if (parentp == NULL) \ + return (0); \ + parent = allocfn(ptree); \ + if (parent == NULL) \ + return (ENOMEM); \ + pctrie_insert_node(parentp, parent, val); \ + return (0); \ } \ \ -static __inline struct type * \ +static __inline __unused struct type * \ name##_PCTRIE_LOOKUP(struct pctrie *ptree, uint64_t key) \ { \ \ return name##_PCTRIE_VAL2PTR(pctrie_lookup(ptree, key)); \ } \ \ -static __inline __unused struct type * \ +static __inline __unused struct type * \ name##_PCTRIE_LOOKUP_LE(struct pctrie *ptree, uint64_t key) \ { \ \ @@ -107,48 +114,89 @@ name##_PCTRIE_LOOKUP_GE(struct pctrie *ptree, uint64_t key) \ static __inline __unused void \ name##_PCTRIE_RECLAIM(struct pctrie *ptree) \ { \ + struct pctrie_node *freenode, *node; \ + \ + for (freenode = pctrie_reclaim_begin(&node, ptree); \ + freenode != NULL; \ + freenode = pctrie_reclaim_resume(&node)) \ + freefn(ptree, freenode); \ +} \ + \ +static __inline __unused struct type * \ +name##_PCTRIE_REPLACE(struct pctrie *ptree, struct type *ptr) \ +{ \ \ - pctrie_reclaim_allnodes(ptree, freefn); \ + return name##_PCTRIE_VAL2PTR( \ + pctrie_replace(ptree, name##_PCTRIE_PTR2VAL(ptr))); \ } \ \ -static __inline void \ +static __inline __unused void \ name##_PCTRIE_REMOVE(struct pctrie *ptree, uint64_t key) \ { \ + uint64_t *val; \ + struct pctrie_node *freenode; \ + \ + val = pctrie_remove_lookup(ptree, key, &freenode); \ + if (val == NULL) \ + panic("%s: key not found", __func__); \ + if (freenode != NULL) \ + freefn(ptree, freenode); \ +} \ + \ +static __inline __unused struct type * \ +name##_PCTRIE_REMOVE_LOOKUP(struct pctrie *ptree, uint64_t key) \ +{ \ + uint64_t *val; \ + struct pctrie_node *freenode; \ \ - pctrie_remove(ptree, key, freefn); \ + val = pctrie_remove_lookup(ptree, key, &freenode); \ + if (freenode != NULL) \ + freefn(ptree, freenode); \ + return name##_PCTRIE_VAL2PTR(val); \ } -typedef void *(*pctrie_alloc_t)(struct pctrie *ptree); -typedef void (*pctrie_free_t)(struct pctrie *ptree, void *node); - -int pctrie_insert(struct pctrie *ptree, uint64_t *val, - pctrie_alloc_t allocfn); +void *pctrie_insert_lookup(struct pctrie *ptree, uint64_t *val); +void pctrie_insert_node(void *parentp, + struct pctrie_node *parent, uint64_t *val); uint64_t *pctrie_lookup(struct pctrie *ptree, uint64_t key); uint64_t *pctrie_lookup_ge(struct pctrie *ptree, uint64_t key); uint64_t *pctrie_lookup_le(struct pctrie *ptree, uint64_t key); uint64_t *pctrie_lookup_unlocked(struct pctrie *ptree, uint64_t key, smr_t smr); -void pctrie_reclaim_allnodes(struct pctrie *ptree, - pctrie_free_t freefn); -void pctrie_remove(struct pctrie *ptree, uint64_t key, - pctrie_free_t freefn); +struct pctrie_node *pctrie_reclaim_begin(struct pctrie_node **pnode, + struct pctrie *ptree); +struct pctrie_node *pctrie_reclaim_resume(struct pctrie_node **pnode); +uint64_t *pctrie_remove_lookup(struct pctrie *ptree, uint64_t index, + struct pctrie_node **killnode); +uint64_t *pctrie_replace(struct pctrie *ptree, uint64_t *newval); size_t pctrie_node_size(void); int pctrie_zone_init(void *mem, int size, int flags); +/* + * Each search path in the trie terminates at a leaf, which is a pointer to a + * value marked with a set 1-bit. A leaf may be associated with a null pointer + * to indicate no value there. + */ +#define PCTRIE_ISLEAF 0x1 +#define PCTRIE_NULL (struct pctrie_node *)PCTRIE_ISLEAF + static __inline void pctrie_init(struct pctrie *ptree) { - - ptree->pt_root = 0; + ptree->pt_root = PCTRIE_NULL; } static __inline bool pctrie_is_empty(struct pctrie *ptree) { - - return (ptree->pt_root == 0); + return (ptree->pt_root == PCTRIE_NULL); } +/* Set of all flag bits stored in node pointers. */ +#define PCTRIE_FLAGS (PCTRIE_ISLEAF) +/* Minimum align parameter for uma_zcreate. */ +#define PCTRIE_PAD PCTRIE_FLAGS + /* * 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 diff --git a/sys/sys/physmem.h b/sys/sys/physmem.h index f9ba69228c95..1b75dc63dc40 100644 --- a/sys/sys/physmem.h +++ b/sys/sys/physmem.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2014 Ian Lepore <ian@freebsd.org> * All rights reserved. @@ -24,13 +24,15 @@ * 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$ */ #ifndef _SYS_PHYSMEM_H_ #define _SYS_PHYSMEM_H_ +#ifndef _KERNEL +#include <stdbool.h> +#endif + /* * Routines to help configure physical ram. * @@ -54,6 +56,7 @@ void physmem_exclude_region(vm_paddr_t pa, vm_size_t sz, uint32_t flags); size_t physmem_avail(vm_paddr_t *avail, size_t maxavail); void physmem_init_kernel_globals(void); void physmem_print_tables(void); +bool physmem_excluded(vm_paddr_t pa, vm_size_t sz); /* * Convenience routines for FDT. diff --git a/sys/sys/pidctrl.h b/sys/sys/pidctrl.h index e09202e871d7..8a1ae342aa11 100644 --- a/sys/sys/pidctrl.h +++ b/sys/sys/pidctrl.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2017, Jeffrey Roberson <jeff@freebsd.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_PIDCTRL_H_ diff --git a/sys/sys/pipe.h b/sys/sys/pipe.h index c9f222ffb01a..61fb57480605 100644 --- a/sys/sys/pipe.h +++ b/sys/sys/pipe.h @@ -17,8 +17,6 @@ * is allowed if this notation is included. * 5. Modifications may be freely made to this file if the above conditions * are met. - * - * $FreeBSD$ */ #ifndef _SYS_PIPE_H_ @@ -74,8 +72,8 @@ struct pipebuf { * Information to support direct transfers between processes for pipes. */ struct pipemapping { - vm_size_t cnt; /* number of chars in buffer */ - vm_size_t pos; /* current position of transfer */ + u_int cnt; /* number of chars in buffer */ + u_int pos; /* current position of transfer */ int npages; /* number of pages */ vm_page_t ms[PIPENPAGES]; /* pages in source process */ }; diff --git a/sys/sys/pmc.h b/sys/sys/pmc.h index b54bc8d8e9f0..714d8a7c65b7 100644 --- a/sys/sys/pmc.h +++ b/sys/sys/pmc.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2003-2008, Joseph Koshy * Copyright (c) 2007 The FreeBSD Foundation @@ -28,8 +28,6 @@ * 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$ */ #ifndef _SYS_PMC_H_ @@ -61,8 +59,8 @@ * * The patch version is incremented for every bug fix. */ -#define PMC_VERSION_MAJOR 0x09 -#define PMC_VERSION_MINOR 0x03 +#define PMC_VERSION_MAJOR 0x0A +#define PMC_VERSION_MINOR 0x00 #define PMC_VERSION_PATCH 0x0000 #define PMC_VERSION (PMC_VERSION_MAJOR << 24 | \ @@ -79,59 +77,52 @@ extern char pmc_cpuid[PMC_CPUID_LEN]; * some way for PMC operations. CPU names are grouped by manufacturer * and numbered sparsely in order to minimize changes to the ABI involved * when new CPUs are added. + * + * Please keep the pmc(3) manual page in sync with this list. */ - -#define __PMC_CPUS() \ - __PMC_CPU(AMD_K7, 0x00, "AMD K7") \ - __PMC_CPU(AMD_K8, 0x01, "AMD K8") \ - __PMC_CPU(INTEL_P5, 0x80, "Intel Pentium") \ - __PMC_CPU(INTEL_P6, 0x81, "Intel Pentium Pro") \ - __PMC_CPU(INTEL_CL, 0x82, "Intel Celeron") \ - __PMC_CPU(INTEL_PII, 0x83, "Intel Pentium II") \ - __PMC_CPU(INTEL_PIII, 0x84, "Intel Pentium III") \ - __PMC_CPU(INTEL_PM, 0x85, "Intel Pentium M") \ - __PMC_CPU(INTEL_PIV, 0x86, "Intel Pentium IV") \ - __PMC_CPU(INTEL_CORE, 0x87, "Intel Core Solo/Duo") \ - __PMC_CPU(INTEL_CORE2, 0x88, "Intel Core2") \ - __PMC_CPU(INTEL_CORE2EXTREME, 0x89, "Intel Core2 Extreme") \ - __PMC_CPU(INTEL_ATOM, 0x8A, "Intel Atom") \ - __PMC_CPU(INTEL_COREI7, 0x8B, "Intel Core i7") \ - __PMC_CPU(INTEL_WESTMERE, 0x8C, "Intel Westmere") \ - __PMC_CPU(INTEL_SANDYBRIDGE, 0x8D, "Intel Sandy Bridge") \ - __PMC_CPU(INTEL_IVYBRIDGE, 0x8E, "Intel Ivy Bridge") \ - __PMC_CPU(INTEL_SANDYBRIDGE_XEON, 0x8F, "Intel Sandy Bridge Xeon") \ - __PMC_CPU(INTEL_IVYBRIDGE_XEON, 0x90, "Intel Ivy Bridge Xeon") \ - __PMC_CPU(INTEL_HASWELL, 0x91, "Intel Haswell") \ - __PMC_CPU(INTEL_ATOM_SILVERMONT, 0x92, "Intel Atom Silvermont") \ - __PMC_CPU(INTEL_NEHALEM_EX, 0x93, "Intel Nehalem Xeon 7500") \ - __PMC_CPU(INTEL_WESTMERE_EX, 0x94, "Intel Westmere Xeon E7") \ - __PMC_CPU(INTEL_HASWELL_XEON, 0x95, "Intel Haswell Xeon E5 v3") \ - __PMC_CPU(INTEL_BROADWELL, 0x96, "Intel Broadwell") \ - __PMC_CPU(INTEL_BROADWELL_XEON, 0x97, "Intel Broadwell Xeon") \ - __PMC_CPU(INTEL_SKYLAKE, 0x98, "Intel Skylake") \ - __PMC_CPU(INTEL_SKYLAKE_XEON, 0x99, "Intel Skylake Xeon") \ - __PMC_CPU(INTEL_ATOM_GOLDMONT, 0x9A, "Intel Atom Goldmont") \ - __PMC_CPU(INTEL_ICELAKE, 0x9B, "Intel Icelake") \ - __PMC_CPU(INTEL_ICELAKE_XEON, 0x9C, "Intel Icelake Xeon") \ - __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(MIPS_BERI, 0x203, "BERI") \ - __PMC_CPU(PPC_7450, 0x300, "PowerPC MPC7450") \ - __PMC_CPU(PPC_E500, 0x340, "PowerPC e500 Core") \ - __PMC_CPU(PPC_970, 0x380, "IBM PowerPC 970") \ - __PMC_CPU(PPC_POWER8, 0x390, "IBM POWER8") \ - __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") \ - __PMC_CPU(ARMV8_CORTEX_A76, 0x602, "ARMv8 Cortex A76") +#define __PMC_CPUS() \ + __PMC_CPU(AMD_K7, 0x00, "AMD K7") \ + __PMC_CPU(AMD_K8, 0x01, "AMD K8") \ + __PMC_CPU(INTEL_CORE, 0x87, "Intel Core Solo/Duo") \ + __PMC_CPU(INTEL_CORE2, 0x88, "Intel Core2") \ + __PMC_CPU(INTEL_CORE2EXTREME, 0x89, "Intel Core2 Extreme") \ + __PMC_CPU(INTEL_ATOM, 0x8A, "Intel Atom") \ + __PMC_CPU(INTEL_COREI7, 0x8B, "Intel Core i7") \ + __PMC_CPU(INTEL_WESTMERE, 0x8C, "Intel Westmere") \ + __PMC_CPU(INTEL_SANDYBRIDGE, 0x8D, "Intel Sandy Bridge") \ + __PMC_CPU(INTEL_IVYBRIDGE, 0x8E, "Intel Ivy Bridge") \ + __PMC_CPU(INTEL_SANDYBRIDGE_XEON, 0x8F, "Intel Sandy Bridge Xeon") \ + __PMC_CPU(INTEL_IVYBRIDGE_XEON, 0x90, "Intel Ivy Bridge Xeon") \ + __PMC_CPU(INTEL_HASWELL, 0x91, "Intel Haswell") \ + __PMC_CPU(INTEL_ATOM_SILVERMONT, 0x92, "Intel Atom Silvermont") \ + __PMC_CPU(INTEL_NEHALEM_EX, 0x93, "Intel Nehalem Xeon 7500") \ + __PMC_CPU(INTEL_WESTMERE_EX, 0x94, "Intel Westmere Xeon E7") \ + __PMC_CPU(INTEL_HASWELL_XEON, 0x95, "Intel Haswell Xeon E5 v3") \ + __PMC_CPU(INTEL_BROADWELL, 0x96, "Intel Broadwell") \ + __PMC_CPU(INTEL_BROADWELL_XEON, 0x97, "Intel Broadwell Xeon") \ + __PMC_CPU(INTEL_SKYLAKE, 0x98, "Intel Skylake") \ + __PMC_CPU(INTEL_SKYLAKE_XEON, 0x99, "Intel Skylake Xeon") \ + __PMC_CPU(INTEL_ATOM_GOLDMONT, 0x9A, "Intel Atom Goldmont") \ + __PMC_CPU(INTEL_ICELAKE, 0x9B, "Intel Icelake") \ + __PMC_CPU(INTEL_ICELAKE_XEON, 0x9C, "Intel Icelake Xeon") \ + __PMC_CPU(INTEL_ALDERLAKE, 0x9D, "Intel Alderlake") \ + __PMC_CPU(INTEL_ATOM_GOLDMONT_P, 0x9E, "Intel Atom Goldmont Plus") \ + __PMC_CPU(INTEL_ATOM_TREMONT, 0x9F, "Intel Atom Tremont") \ + __PMC_CPU(INTEL_XSCALE, 0x100, "Intel XScale") \ + __PMC_CPU(PPC_7450, 0x300, "PowerPC MPC7450") \ + __PMC_CPU(PPC_E500, 0x340, "PowerPC e500 Core") \ + __PMC_CPU(PPC_970, 0x380, "IBM PowerPC 970") \ + __PMC_CPU(PPC_POWER8, 0x390, "IBM POWER8") \ + __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") \ + __PMC_CPU(ARMV8_CORTEX_A76, 0x602, "ARMv8 Cortex A76") enum pmc_cputype { #undef __PMC_CPU @@ -145,30 +136,25 @@ enum pmc_cputype { /* * Classes of PMCs */ - -#define __PMC_CLASSES() \ - __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(BERI, 0x14, "MIPS BERI") \ - __PMC_CLASS(POWER8, 0x15, "IBM POWER8 class") +#define __PMC_CLASSES() \ + __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(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(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(E500, 0x13, "Freescale e500 class") \ + __PMC_CLASS(POWER8, 0x15, "IBM POWER8 class") \ + __PMC_CLASS(DMC620_PMU_CD2, 0x16, "ARM DMC620 Memory Controller PMU CLKDIV2") \ + __PMC_CLASS(DMC620_PMU_C, 0x17, "ARM DMC620 Memory Controller PMU CLK") \ + __PMC_CLASS(CMN600_PMU, 0x18, "Arm CoreLink CMN600 Coherent Mesh Network PMU") enum pmc_class { #undef __PMC_CLASS @@ -177,7 +163,7 @@ enum pmc_class { }; #define PMC_CLASS_FIRST PMC_CLASS_TSC -#define PMC_CLASS_LAST PMC_CLASS_POWER8 +#define PMC_CLASS_LAST PMC_CLASS_CMN600_PMU /* * A PMC can be in the following states: @@ -305,7 +291,9 @@ enum pmc_disp { __PMC_CAP(QUALIFIER, 8, "further qualify monitored events") \ __PMC_CAP(PRECISE, 9, "perform precise sampling") \ __PMC_CAP(TAGGING, 10, "tag upstream events") \ - __PMC_CAP(CASCADE, 11, "cascade counters") + __PMC_CAP(CASCADE, 11, "cascade counters") \ + __PMC_CAP(SYSWIDE, 12, "system wide counter") \ + __PMC_CAP(DOMWIDE, 13, "NUMA domain wide counter") enum pmc_caps { @@ -315,7 +303,7 @@ enum pmc_caps }; #define PMC_CAP_FIRST PMC_CAP_INTERRUPT -#define PMC_CAP_LAST PMC_CAP_CASCADE +#define PMC_CAP_LAST PMC_CAP_DOMWIDE /* * PMC Event Numbers @@ -381,6 +369,14 @@ enum pmc_ops { #define PMC_F_CALLCHAIN 0x00000080 /*OP ALLOCATE capture callchains */ #define PMC_F_USERCALLCHAIN 0x00000100 /*OP ALLOCATE use userspace stack */ +/* V10 API */ +#define PMC_F_EV_PMU 0x00000200 /* + * OP ALLOCATE: pm_ev has special + * userspace meaning; counter + * configuration is communicated + * through class-dependent fields + */ + /* internal flags */ #define PMC_F_ATTACHED_TO_OWNER 0x00010000 /*attached to owner*/ #define PMC_F_NEEDS_LOGFILE 0x00020000 /*needs log file */ @@ -994,6 +990,7 @@ struct pmc_cpu { struct pmc_binding { int pb_bound; /* is bound? */ int pb_cpu; /* if so, to which CPU */ + u_char pb_priority; /* Thread active priority. */ }; struct pmc_mdep; @@ -1013,8 +1010,10 @@ struct pmc_classdep { /* configuring/reading/writing the hardware PMCs */ int (*pcd_config_pmc)(int _cpu, int _ri, struct pmc *_pm); int (*pcd_get_config)(int _cpu, int _ri, struct pmc **_ppm); - int (*pcd_read_pmc)(int _cpu, int _ri, pmc_value_t *_value); - int (*pcd_write_pmc)(int _cpu, int _ri, pmc_value_t _value); + int (*pcd_read_pmc)(int _cpu, int _ri, struct pmc *_pm, + pmc_value_t *_value); + int (*pcd_write_pmc)(int _cpu, int _ri, struct pmc *_pm, + pmc_value_t _value); /* pmc allocation/release */ int (*pcd_allocate_pmc)(int _cpu, int _ri, struct pmc *_t, @@ -1022,8 +1021,8 @@ struct pmc_classdep { int (*pcd_release_pmc)(int _cpu, int _ri, struct pmc *_pm); /* starting and stopping PMCs */ - int (*pcd_start_pmc)(int _cpu, int _ri); - int (*pcd_stop_pmc)(int _cpu, int _ri); + int (*pcd_start_pmc)(int _cpu, int _ri, struct pmc *_pm); + int (*pcd_stop_pmc)(int _cpu, int _ri, struct pmc *_pm); /* description */ int (*pcd_describe)(int _cpu, int _ri, struct pmc_info *_pi, @@ -1052,10 +1051,6 @@ struct pmc_mdep { * Machine dependent methods. */ - /* per-cpu initialization and finalization */ - int (*pmd_pcpu_init)(struct pmc_mdep *_md, int _cpu); - int (*pmd_pcpu_fini)(struct pmc_mdep *_md, int _cpu); - /* thread context switch in/out */ int (*pmd_switch_in)(struct pmc_cpu *_p, struct pmc_process *_pp); int (*pmd_switch_out)(struct pmc_cpu *_p, struct pmc_process *_pp); @@ -1080,9 +1075,21 @@ extern struct pmc_cpu **pmc_pcpu; extern struct pmc_driverstats pmc_stats; #if defined(HWPMC_DEBUG) + +/* HWPMC_DEBUG without KTR will compile but is a no-op. */ +#if !defined(KTR) || !defined(KTR_COMPILE) || ((KTR_COMPILE & KTR_SUBSYS) == 0) +#error "HWPMC_DEBUG requires KTR and KTR_COMPILE=KTR_SUBSYS -- see ktr(4)" +#endif + #include <sys/ktr.h> -/* debug flags, major flag groups */ +#define __pmcdbg_used /* unused variable annotation */ + +/* + * Debug flags, major flag groups. + * + * Please keep the DEBUGGING section of the hwpmc(4) man page in sync. + */ struct pmc_debugflags { int pdb_CPU; int pdb_CSW; @@ -1198,6 +1205,7 @@ extern struct pmc_debugflags pmc_debugflags; #define PMC_DEBUG_MIN_CLO 12 /* close */ #else +#define __pmcdbg_used __unused #define PMCDBG0(M, N, L, F) /* nothing */ #define PMCDBG1(M, N, L, F, p1) #define PMCDBG2(M, N, L, F, p1, p2) @@ -1222,6 +1230,9 @@ int pmc_save_kernel_callchain(uintptr_t *_cc, int _maxsamples, struct trapframe *_tf); int pmc_save_user_callchain(uintptr_t *_cc, int _maxsamples, struct trapframe *_tf); +void pmc_restore_cpu_binding(struct pmc_binding *pb); +void pmc_save_cpu_binding(struct pmc_binding *pb); +void pmc_select_cpu(int cpu); struct pmc_mdep *pmc_mdep_alloc(int nclasses); void pmc_mdep_free(struct pmc_mdep *md); uint64_t pmc_rdtsc(void); diff --git a/sys/sys/pmckern.h b/sys/sys/pmckern.h index 5b337f8d76df..047500d552e5 100644 --- a/sys/sys/pmckern.h +++ b/sys/sys/pmckern.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2003-2007, Joseph Koshy * Copyright (c) 2007 The FreeBSD Foundation @@ -28,8 +28,6 @@ * 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$ */ /* @@ -76,7 +74,8 @@ typedef enum ring_type { struct pmckern_procexec { int pm_credentialschanged; - uintfptr_t pm_entryaddr; + uintptr_t pm_baseaddr; + uintptr_t pm_dynaddr; }; struct pmckern_map_in { diff --git a/sys/sys/pmclog.h b/sys/sys/pmclog.h index 0ee9b7e2e853..3f79f17f306c 100644 --- a/sys/sys/pmclog.h +++ b/sys/sys/pmclog.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2005-2007, Joseph Koshy * Copyright (c) 2007 The FreeBSD Foundation @@ -28,8 +28,6 @@ * 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$ */ #ifndef _SYS_PMCLOG_H_ @@ -202,7 +200,10 @@ struct pmclog_procexec { PMCLOG_ENTRY_HEADER uint32_t pl_pid; uint32_t pl_pmcid; - uintfptr_t pl_start; /* keep 8 byte aligned */ + /* keep 8 byte aligned */ + uintptr_t pl_base; /* AT_BASE */ + /* keep 8 byte aligned */ + uintptr_t pl_dyn; /* PIE load base */ char pl_pathname[PATH_MAX]; } __packed; @@ -314,7 +315,7 @@ void pmclog_process_pmcdetach(struct pmc *_pm, pid_t _pid); void pmclog_process_proccsw(struct pmc *_pm, struct pmc_process *_pp, pmc_value_t _v, struct thread *); void pmclog_process_procexec(struct pmc_owner *_po, pmc_id_t _pmid, pid_t _pid, - uintfptr_t _startaddr, char *_path); + uintfptr_t _baseaddr, uintptr_t _dynaddr, char *_path); void pmclog_process_procexit(struct pmc *_pm, struct pmc_process *_pp); void pmclog_process_procfork(struct pmc_owner *_po, pid_t _oldpid, pid_t _newpid); void pmclog_process_sysexit(struct pmc_owner *_po, pid_t _pid); diff --git a/sys/sys/poll.h b/sys/sys/poll.h index 02347ed09a13..0ae4e0f4dd15 100644 --- a/sys/sys/poll.h +++ b/sys/sys/poll.h @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS_POLL_H_ diff --git a/sys/sys/posix4.h b/sys/sys/posix4.h index bb3195e8a1a5..c8fdedf24335 100644 --- a/sys/sys/posix4.h +++ b/sys/sys/posix4.h @@ -32,8 +32,6 @@ * 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$ */ #include <sys/param.h> diff --git a/sys/sys/power.h b/sys/sys/power.h index b0535312d1f7..9afa55dd403a 100644 --- a/sys/sys/power.h +++ b/sys/sys/power.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001 Mitsuru IWASAKI * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_POWER_H_ diff --git a/sys/sys/priority.h b/sys/sys/priority.h index 428be2d02c68..4428a85c0987 100644 --- a/sys/sys/priority.h +++ b/sys/sys/priority.h @@ -29,8 +29,6 @@ * 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$ */ #ifndef _SYS_PRIORITY_H_ @@ -69,10 +67,10 @@ * Priorities range from 0 to 255, but differences of less then 4 (RQ_PPQ) * are insignificant. Ranges are as follows: * - * Interrupt threads: 0 - 47 - * Realtime user threads: 48 - 79 - * Top half kernel threads: 80 - 119 - * Time sharing user threads: 120 - 223 + * Interrupt threads: 0 - 15 + * Realtime user threads: 16 - 47 + * Top half kernel threads: 48 - 87 + * Time sharing user threads: 88 - 223 * Idle user threads: 224 - 255 * * XXX If/When the specific interrupt thread and top half thread ranges @@ -85,20 +83,25 @@ #define PRI_MIN_ITHD (PRI_MIN) #define PRI_MAX_ITHD (PRI_MIN_REALTIME - 1) +/* + * Most hardware interrupt threads run at the same priority, but can + * decay to lower priorities if they run for full time slices. + */ #define PI_REALTIME (PRI_MIN_ITHD + 0) -#define PI_AV (PRI_MIN_ITHD + 4) -#define PI_SOFTCLOCK PI_AV -#define PI_NET (PRI_MIN_ITHD + 8) -#define PI_DISK (PRI_MIN_ITHD + 12) -#define PI_TTY (PRI_MIN_ITHD + 16) -#define PI_DULL (PRI_MIN_ITHD + 20) -#define PI_SOFT (PRI_MIN_ITHD + 24) -#define PI_SWI(x) (PI_SOFT + (x) * RQ_PPQ) - -#define PRI_MIN_REALTIME (48) +#define PI_INTR (PRI_MIN_ITHD + 4) +#define PI_AV PI_INTR +#define PI_NET PI_INTR +#define PI_DISK PI_INTR +#define PI_TTY PI_INTR +#define PI_DULL PI_INTR +#define PI_SOFT (PRI_MIN_ITHD + 8) +#define PI_SOFTCLOCK PI_SOFT +#define PI_SWI(x) PI_SOFT + +#define PRI_MIN_REALTIME (16) #define PRI_MAX_REALTIME (PRI_MIN_KERN - 1) -#define PRI_MIN_KERN (80) +#define PRI_MIN_KERN (48) #define PRI_MAX_KERN (PRI_MIN_TIMESHARE - 1) #define PSWP (PRI_MIN_KERN + 0) @@ -112,7 +115,7 @@ #define PLOCK (PRI_MIN_KERN + 32) #define PPAUSE (PRI_MIN_KERN + 36) -#define PRI_MIN_TIMESHARE (120) +#define PRI_MIN_TIMESHARE (88) #define PRI_MAX_TIMESHARE (PRI_MIN_IDLE - 1) #define PUSER (PRI_MIN_TIMESHARE) diff --git a/sys/sys/priv.h b/sys/sys/priv.h index 8757db879a5c..45cb5bab4275 100644 --- a/sys/sys/priv.h +++ b/sys/sys/priv.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2006 nCircle Network Security, Inc. * All rights reserved. @@ -27,8 +27,6 @@ * 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$ */ /* @@ -348,6 +346,9 @@ #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 */ +#define PRIV_NET_OVPN 422 /* Administer OpenVPN DCO. */ +#define PRIV_NET_ME 423 /* Administer ME interface. */ +#define PRIV_NET_WG 424 /* Administer WireGuard interface. */ /* * 802.11-related privileges. @@ -513,9 +514,21 @@ #define PRIV_KMEM_WRITE 681 /* Open mem/kmem for writing. */ /* + * Kernel debugger privileges. + */ +#define PRIV_KDB_SET_BACKEND 690 /* Allow setting KDB backend. */ + +/* + * veriexec override privileges - very rare! + */ +#define PRIV_VERIEXEC_DIRECT 700 /* Can override 'indirect' */ +#define PRIV_VERIEXEC_NOVERIFY 701 /* Can override O_VERIFY */ +#define PRIV_VERIEXEC_CONTROL 702 /* Can configure veriexec */ + +/* * Track end of privilege list. */ -#define _PRIV_HIGHEST 682 +#define _PRIV_HIGHEST 703 /* * Validate that a named privilege is known by the privilege system. Invalid diff --git a/sys/sys/prng.h b/sys/sys/prng.h index a1abe6ad1a11..7b7170c03935 100644 --- a/sys/sys/prng.h +++ b/sys/sys/prng.h @@ -1,7 +1,5 @@ /*- * This file is in the public domain. - * - * $FreeBSD$ */ #ifndef _SYS_PRNG_H_ diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 223714724aca..3102cae7add0 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -34,7 +34,6 @@ * SUCH DAMAGE. * * @(#)proc.h 8.15 (Berkeley) 5/19/95 - * $FreeBSD$ */ #ifndef _SYS_PROC_H_ @@ -113,6 +112,8 @@ struct pgrp { pid_t pg_id; /* (c) Process group id. */ struct mtx pg_mtx; /* Mutex to protect members */ int pg_flags; /* (m) PGRP_ flags */ + struct sx pg_killsx; /* Mutual exclusion between group member + * fork() and killpg() */ }; #define PGRP_ORPHANED 0x00000001 /* Group is orphaned */ @@ -157,7 +158,6 @@ struct pargs { * 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 * o - ktrace lock * q - td_contested lock @@ -169,7 +169,6 @@ struct pargs { * 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 - * z - zombie threads lock * * If the locking key specifies two identifiers (for example, p_pptr) then * either lock is sufficient for read access, but both locks must be held @@ -257,11 +256,13 @@ struct thread { #define td_siglist td_sigqueue.sq_signals u_char td_lend_user_pri; /* (t) Lend user pri. */ u_char td_allocdomain; /* (b) NUMA domain backing this struct thread. */ + u_char td_base_ithread_pri; /* (t) Base ithread pri */ struct kmsan_td *td_kmsan; /* (k) KMSAN state */ -/* Cleared during fork1() */ +/* Cleared during fork1(), thread_create(), or kthread_add(). */ #define td_startzero td_flags int td_flags; /* (t) TDF_* flags. */ + int td_ast; /* (t) TDA_* indicators */ int td_inhibitors; /* (t) Why can not run. */ int td_pflags; /* (k) Private thread (TDP_*) flags. */ int td_pflags2; /* (k) Private thread (TDP2_*) flags. */ @@ -271,11 +272,11 @@ struct thread { const char *td_wmesg; /* (t) Reason for sleep. */ volatile u_char td_owepreempt; /* (k*) Preempt on last critical_exit */ u_char td_tsqueue; /* (t) Turnstile queue blocked on. */ - short td_locks; /* (k) Debug: count of non-spin locks */ - short td_rw_rlocks; /* (k) Count of rwlock read locks. */ - short td_sx_slocks; /* (k) Count of sx shared locks. */ - short td_lk_slocks; /* (k) Count of lockmgr shared locks. */ - short td_stopsched; /* (k) Scheduler stopped. */ + u_char td_stopsched; /* (k) Scheduler stopped. */ + int td_locks; /* (k) Debug: count of non-spin locks */ + int td_rw_rlocks; /* (k) Count of rwlock read locks. */ + int td_sx_slocks; /* (k) Count of sx shared locks. */ + int td_lk_slocks; /* (k) Count of lockmgr shared locks. */ struct turnstile *td_blocked; /* (t) Lock thread is blocked on. */ const char *td_lockname; /* (t) Name of lock blocked on. */ LIST_HEAD(, turnstile) td_contested; /* (q) Contested locks. */ @@ -321,10 +322,10 @@ struct thread { int td_errno; /* (k) Error from last syscall. */ size_t td_vslock_sz; /* (k) amount of vslock-ed space */ struct kcov_info *td_kcov_info; /* (*) Kernel code coverage data */ - u_int td_ucredref; /* (k) references on td_realucred */ + long td_ucredref; /* (k) references on td_realucred */ #define td_endzero td_sigmask -/* Copied during fork1() or create_thread(). */ +/* Copied during fork1(), thread_create(), or kthread_add(). */ #define td_startcopy td_endzero sigset_t td_sigmask; /* (c) Current signal mask. */ u_char td_rqindex; /* (t) Run queue index. */ @@ -344,7 +345,7 @@ struct thread { #define td_endcopy td_pcb /* - * Fields that must be manually set in fork1() or create_thread() + * Fields that must be manually set in fork1(), thread_create(), kthread_add(), * or already have been set in the allocator, constructor, etc. */ struct pcb *td_pcb; /* (k) Kernel VA of pcb and kstack. */ @@ -384,7 +385,7 @@ struct thread { int td_oncpu; /* (t) Which cpu we are on. */ void *td_lkpi_task; /* LinuxKPI task struct pointer */ int td_pmcpend; - void *td_coredump; /* (c) coredump request. */ + void *td_remotereq; /* (c) dbg remote request. */ off_t td_ktr_io_lim; /* (k) limit for ktrace file size */ #ifdef EPOCH_TRACE SLIST_HEAD(, epoch_tracker) td_epochs; @@ -430,7 +431,7 @@ do { \ #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))); \ + ("Thread %p owns no locks", (td))); \ (td)->td_locks--; \ } while (0) #else @@ -456,26 +457,53 @@ do { \ #define TDF_KTH_SUSP 0x00000100 /* kthread is suspended */ #define TDF_ALLPROCSUSP 0x00000200 /* suspended by SINGLE_ALLPROC */ #define TDF_BOUNDARY 0x00000400 /* Thread suspended at user boundary */ -#define TDF_ASTPENDING 0x00000800 /* Thread has some asynchronous events. */ -#define TDF_KQTICKLED 0x00001000 /* AST drain kqueue taskqueue */ +#define TDF_UNUSED1 0x00000800 /* Available */ +#define TDF_UNUSED2 0x00001000 /* Available */ #define TDF_SBDRY 0x00002000 /* Stop only on usermode boundary. */ #define TDF_UPIBLOCKED 0x00004000 /* Thread blocked on user PI mutex. */ -#define TDF_NEEDSUSPCHK 0x00008000 /* Thread may need to suspend. */ -#define TDF_NEEDRESCHED 0x00010000 /* Thread needs to yield. */ -#define TDF_NEEDSIGCHK 0x00020000 /* Thread may need signal delivery. */ +#define TDF_UNUSED3 0x00008000 /* Available */ +#define TDF_UNUSED4 0x00010000 /* Available */ +#define TDF_UNUSED5 0x00020000 /* Available */ #define TDF_NOLOAD 0x00040000 /* Ignore during load avg calculations. */ #define TDF_SERESTART 0x00080000 /* ERESTART on stop attempts. */ #define TDF_THRWAKEUP 0x00100000 /* Libthr thread must not suspend itself. */ #define TDF_SEINTR 0x00200000 /* EINTR on stop attempts. */ #define TDF_SWAPINREQ 0x00400000 /* Swapin request due to wakeup. */ -#define TDF_UNUSED23 0x00800000 /* --available-- */ +#define TDF_UNUSED6 0x00800000 /* Available */ #define TDF_SCHED0 0x01000000 /* Reserved for scheduler private use */ #define TDF_SCHED1 0x02000000 /* Reserved for scheduler private use */ #define TDF_SCHED2 0x04000000 /* Reserved for scheduler private use */ #define TDF_SCHED3 0x08000000 /* Reserved for scheduler private use */ -#define TDF_ALRMPEND 0x10000000 /* Pending SIGVTALRM needs to be posted. */ -#define TDF_PROFPEND 0x20000000 /* Pending SIGPROF needs to be posted. */ -#define TDF_MACPEND 0x40000000 /* AST-based MAC event pending. */ +#define TDF_UNUSED7 0x10000000 /* Available */ +#define TDF_UNUSED8 0x20000000 /* Available */ +#define TDF_UNUSED9 0x40000000 /* Available */ +#define TDF_UNUSED10 0x80000000 /* Available */ + +enum { + TDA_AST = 0, /* Special: call all non-flagged AST handlers */ + TDA_OWEUPC, + TDA_HWPMC, + TDA_VFORK, + TDA_ALRM, + TDA_PROF, + TDA_MAC, + TDA_SCHED, + TDA_UFS, + TDA_GEOM, + TDA_KQUEUE, + TDA_RACCT, + TDA_MOD1, /* For third party use, before signals are */ + TAD_MOD2, /* processed .. */ + TDA_SIG, + TDA_KTRACE, + TDA_SUSPEND, + TDA_SIGSUSPEND, + TDA_MOD3, /* .. and after */ + TAD_MOD4, + TDA_MAX, +}; +#define TDAI(tda) (1U << (tda)) +#define td_ast_pending(td, tda) ((td->td_ast & TDAI(tda)) != 0) /* Userland debug flags */ #define TDB_SUSPEND 0x00000001 /* Thread is suspended by debugger */ @@ -495,7 +523,9 @@ do { \ #define TDB_FSTP 0x00001000 /* The thread is PT_ATTACH leader */ #define TDB_STEP 0x00002000 /* (x86) PSL_T set for PT_STEP */ #define TDB_SSWITCH 0x00004000 /* Suspended in ptracestop */ -#define TDB_COREDUMPRQ 0x00008000 /* Coredump request */ +#define TDB_BOUNDARY 0x00008000 /* ptracestop() at boundary */ +#define TDB_COREDUMPREQ 0x00010000 /* Coredump request */ +#define TDB_SCREMOTEREQ 0x00020000 /* Remote syscall request */ /* * "Private" flags kept in td_pflags: @@ -530,7 +560,7 @@ do { \ #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_UNUSED0 0x20000000 /* UNUSED */ +#define TDP_INTCPCALLOUT 0x20000000 /* used by netinet/tcp_timer.c */ #define TDP_EXECVMSPC 0x40000000 /* Execve destroyed old vmspace */ #define TDP_SIGFASTPENDING 0x80000000 /* Pending signal due to sigfastblock */ @@ -712,6 +742,7 @@ struct proc { uint64_t p_elf_flags; /* (x) ELF flags */ void *p_elf_brandinfo; /* (x) Elf_Brandinfo, NULL for non ELF binaries. */ + sbintime_t p_umtx_min_timeout; /* End area that is copied on creation. */ #define p_endcopy p_xexit @@ -744,6 +775,7 @@ struct proc { LIST_HEAD(, proc) p_orphans; /* (e) Pointer to list of orphans. */ TAILQ_HEAD(, kq_timer_cb_data) p_kqtim_stop; /* (c) */ + LIST_ENTRY(proc) p_jaillist; /* (d) Jail process linkage. */ }; #define p_session p_pgrp->pg_session @@ -847,6 +879,16 @@ struct proc { #define P2_NO_NEW_PRIVS 0x00008000 /* Ignore setuid */ #define P2_WXORX_DISABLE 0x00010000 /* WX mappings enabled */ #define P2_WXORX_ENABLE_EXEC 0x00020000 /* WXORX enabled after exec */ +#define P2_WEXIT 0x00040000 /* exit just started, no + external thread_single() is + permitted */ +#define P2_REAPKILLED 0x00080000 +#define P2_MEMBAR_PRIVE 0x00100000 /* membar private expedited + registered */ +#define P2_MEMBAR_PRIVE_SYNCORE 0x00200000 /* membar private expedited + sync core registered */ +#define P2_MEMBAR_GLOBE 0x00400000 /* membar global expedited + registered */ /* Flags protected by proctree_lock, kept in p_treeflags. */ #define P_TREE_ORPHANED 0x00000001 /* Reparented, on orphan list */ @@ -871,22 +913,20 @@ struct proc { #ifdef _KERNEL -/* Types and flags for mi_switch(). */ +/* Types and flags for mi_switch(9). */ #define SW_TYPE_MASK 0xff /* First 8 bits are switch type */ -#define SWT_NONE 0 /* Unspecified switch. */ -#define SWT_PREEMPT 1 /* Switching due to preemption. */ -#define SWT_OWEPREEMPT 2 /* Switching due to owepreempt. */ -#define SWT_TURNSTILE 3 /* Turnstile contention. */ -#define SWT_SLEEPQ 4 /* Sleepq wait. */ -#define SWT_SLEEPQTIMO 5 /* Sleepq timeout wait. */ -#define SWT_RELINQUISH 6 /* yield call. */ -#define SWT_NEEDRESCHED 7 /* NEEDRESCHED was set. */ -#define SWT_IDLE 8 /* Switching from the idle thread. */ -#define SWT_IWAIT 9 /* Waiting for interrupts. */ -#define SWT_SUSPEND 10 /* Thread suspended. */ -#define SWT_REMOTEPREEMPT 11 /* Remote processor preempted. */ -#define SWT_REMOTEWAKEIDLE 12 /* Remote processor preempted idle. */ -#define SWT_COUNT 13 /* Number of switch types. */ +#define SWT_OWEPREEMPT 1 /* Switching due to owepreempt. */ +#define SWT_TURNSTILE 2 /* Turnstile contention. */ +#define SWT_SLEEPQ 3 /* Sleepq wait. */ +#define SWT_RELINQUISH 4 /* yield call. */ +#define SWT_NEEDRESCHED 5 /* NEEDRESCHED was set. */ +#define SWT_IDLE 6 /* Switching from the idle thread. */ +#define SWT_IWAIT 7 /* Waiting for interrupts. */ +#define SWT_SUSPEND 8 /* Thread suspended. */ +#define SWT_REMOTEPREEMPT 9 /* Remote processor preempted. */ +#define SWT_REMOTEWAKEIDLE 10 /* Remote processor preempted idle. */ +#define SWT_BIND 11 /* Thread bound to a new CPU. */ +#define SWT_COUNT 12 /* Number of switch types. */ /* Flags */ #define SW_VOL 0x0100 /* Voluntary switch. */ #define SW_INVOL 0x0200 /* Involuntary switch. */ @@ -1105,7 +1145,23 @@ struct fork_req { int pget(pid_t pid, int flags, struct proc **pp); +/* ast_register() flags */ +#define ASTR_ASTF_REQUIRED 0x0001 /* td_ast TDAI(TDA_X) flag set is + required for call */ +#define ASTR_TDP 0x0002 /* td_pflags flag set is required */ +#define ASTR_KCLEAR 0x0004 /* call me on ast_kclear() */ +#define ASTR_UNCOND 0x0008 /* call me always */ + void ast(struct trapframe *framep); +void ast_kclear(struct thread *td); +void ast_register(int ast, int ast_flags, int tdp, + void (*f)(struct thread *td, int asts)); +void ast_deregister(int tda); +void ast_sched_locked(struct thread *td, int tda); +void ast_sched_mask(struct thread *td, int ast); +void ast_sched(struct thread *td, int tda); +void ast_unsched_locked(struct thread *td, int tda); + struct thread *choosethread(void); int cr_cansee(struct ucred *u1, struct ucred *u2); int cr_canseesocket(struct ucred *cred, struct socket *so); @@ -1118,7 +1174,6 @@ int enterpgrp(struct proc *p, pid_t pgid, struct pgrp *pgrp, int enterthispgrp(struct proc *p, struct pgrp *pgrp); void faultin(struct proc *p); int fork1(struct thread *, struct fork_req *); -void fork_rfppwait(struct thread *); void fork_exit(void (*)(void *, struct trapframe *), void *, struct trapframe *); void fork_return(struct thread *, struct trapframe *); @@ -1155,6 +1210,7 @@ void proc_linkup(struct proc *p, struct thread *td); struct proc *proc_realparent(struct proc *child); void proc_reap(struct thread *td, struct proc *p, int *status, int options); void proc_reparent(struct proc *child, struct proc *newparent, bool set_oppid); +void proc_set_p2_wexit(struct proc *p); void proc_set_traced(struct proc *p, bool stop); void proc_wkilled(struct proc *p); struct pstats *pstats_alloc(void); @@ -1168,7 +1224,7 @@ void sess_hold(struct session *); void sess_release(struct session *); int setrunnable(struct thread *, int); void setsugid(struct proc *p); -int should_yield(void); +bool should_yield(void); int sigonstack(size_t sp); void stopevent(struct proc *, u_int, u_int); struct thread *tdfind(lwpid_t, pid_t); @@ -1179,6 +1235,7 @@ void cpu_idle(int); int cpu_idle_wakeup(int); extern void (*cpu_idle_hook)(sbintime_t); /* Hook to machdep CPU idler. */ void cpu_switch(struct thread *, struct thread *, struct mtx *); +void cpu_sync_core(void); void cpu_throw(struct thread *, struct thread *) __dead2; bool curproc_sigkilled(void); void userret(struct thread *, struct trapframe *); @@ -1232,7 +1289,7 @@ void thread_unlink(struct thread *td); void thread_unsuspend(struct proc *p); void thread_wait(struct proc *p); -void stop_all_proc_block(void); +bool stop_all_proc_block(void); void stop_all_proc_unblock(void); void stop_all_proc(void); void resume_all_proc(void); @@ -1275,13 +1332,6 @@ curthread_pflags2_restore(int save) curthread->td_pflags2 &= save; } -static __inline bool -kstack_contains(struct thread *td, vm_offset_t va, size_t len) -{ - return (va >= td->td_kstack && va + len >= va && - va + len <= td->td_kstack + td->td_kstack_pages * PAGE_SIZE); -} - static __inline __pure2 struct td_sched * td_get_sched(struct thread *td) { @@ -1289,15 +1339,6 @@ 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); -} - #define PROC_ID_PID 0 #define PROC_ID_GROUP 1 #define PROC_ID_SESSION 2 diff --git a/sys/sys/procctl.h b/sys/sys/procctl.h index 0fcb62e94bb9..851ca821d72d 100644 --- a/sys/sys/procctl.h +++ b/sys/sys/procctl.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2013 Hudson River Trading LLC * Copyright (c) 2014, 2016 The FreeBSD Foundation @@ -29,8 +29,6 @@ * 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$ */ #ifndef _SYS_PROCCTL_H_ @@ -102,6 +100,9 @@ struct procctl_reaper_pidinfo { #define REAPER_PIDINFO_VALID 0x00000001 #define REAPER_PIDINFO_CHILD 0x00000002 #define REAPER_PIDINFO_REAPER 0x00000004 +#define REAPER_PIDINFO_ZOMBIE 0x00000008 +#define REAPER_PIDINFO_STOPPED 0x00000010 +#define REAPER_PIDINFO_EXITING 0x00000020 struct procctl_reaper_pids { u_int rp_count; diff --git a/sys/sys/procdesc.h b/sys/sys/procdesc.h index b307917c5479..ca26d65d5417 100644 --- a/sys/sys/procdesc.h +++ b/sys/sys/procdesc.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2009 Robert N. M. Watson * All rights reserved. @@ -27,8 +27,6 @@ * 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$ */ #ifndef _SYS_PROCDESC_H_ diff --git a/sys/sys/procfs.h b/sys/sys/procfs.h index 85e718b20c35..4623d6596815 100644 --- a/sys/sys/procfs.h +++ b/sys/sys/procfs.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1998 John D. Polstra. * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_PROCFS_H_ diff --git a/sys/sys/protosw.h b/sys/sys/protosw.h index dc550d42f1fd..66b194ff1b9a 100644 --- a/sys/sys/protosw.h +++ b/sys/sys/protosw.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)protosw.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD$ */ #ifndef _SYS_PROTOSW_H_ @@ -52,60 +51,102 @@ struct sockopt; * Each protocol has a handle initializing one of these structures, * which is used for protocol-protocol and system-protocol communication. * - * Thereafter it is called every 200ms through the pr_fasttimo entry and - * every 500ms through the pr_slowtimo for timer based actions. - * The system will call the pr_drain entry if it is low on space and - * this should throw away any non-critical data. - * - * Protocols pass data between themselves as chains of mbufs using - * the pr_input and pr_output hooks. Pr_input passes data up (towards - * the users) and pr_output passes it down (towards the interfaces); control - * information passes up and down on pr_ctlinput and pr_ctloutput. - * The protocol is responsible for the space occupied by any the - * arguments to these entries and must dispose it. - * * In retrospect, it would be a lot nicer to use an interface * similar to the vnode VOP interface. */ +struct ifnet; +struct stat; +struct ucred; +struct uio; + /* USE THESE FOR YOUR PROTOTYPES ! */ -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_fasttimo_t (void); -typedef void pr_slowtimo_t (void); -typedef void pr_drain_t (void); +typedef int pr_ctloutput_t(struct socket *, struct sockopt *); +typedef int pr_setsbopt_t(struct socket *, struct sockopt *); +typedef void pr_abort_t(struct socket *); +typedef int pr_accept_t(struct socket *, struct sockaddr **); +typedef int pr_attach_t(struct socket *, int, struct thread *); +typedef int pr_bind_t(struct socket *, struct sockaddr *, struct thread *); +typedef int pr_connect_t(struct socket *, struct sockaddr *, + struct thread *); +typedef int pr_connect2_t(struct socket *, struct socket *); +typedef int pr_control_t(struct socket *, unsigned long, void *, + struct ifnet *, struct thread *); +typedef void pr_detach_t(struct socket *); +typedef int pr_disconnect_t(struct socket *); +typedef int pr_listen_t(struct socket *, int, struct thread *); +typedef int pr_peeraddr_t(struct socket *, struct sockaddr **); +typedef int pr_rcvd_t(struct socket *, int); +typedef int pr_rcvoob_t(struct socket *, struct mbuf *, int); +typedef enum { + PRUS_OOB = 0x1, + PRUS_EOF = 0x2, + PRUS_MORETOCOME = 0x4, + PRUS_NOTREADY = 0x8, + PRUS_IPV6 = 0x10, +} pr_send_flags_t; +typedef int pr_send_t(struct socket *, int, struct mbuf *, + struct sockaddr *, struct mbuf *, struct thread *); +typedef int pr_ready_t(struct socket *, struct mbuf *, int); +typedef int pr_sense_t(struct socket *, struct stat *); +typedef int pr_shutdown_t(struct socket *); +typedef int pr_flush_t(struct socket *, int); +typedef int pr_sockaddr_t(struct socket *, struct sockaddr **); +typedef int pr_sosend_t(struct socket *, struct sockaddr *, struct uio *, + struct mbuf *, struct mbuf *, int, struct thread *); +typedef int pr_soreceive_t(struct socket *, struct sockaddr **, + struct uio *, struct mbuf **, struct mbuf **, int *); +typedef int pr_sopoll_t(struct socket *, int, struct ucred *, + struct thread *); +typedef void pr_sosetlabel_t(struct socket *); +typedef void pr_close_t(struct socket *); +typedef int pr_bindat_t(int, struct socket *, struct sockaddr *, + struct thread *); +typedef int pr_connectat_t(int, struct socket *, struct sockaddr *, + struct thread *); +typedef int pr_aio_queue_t(struct socket *, struct kaiocb *); struct protosw { short pr_type; /* socket type used for */ - struct domain *pr_domain; /* domain protocol a member of */ short pr_protocol; /* protocol number */ short pr_flags; /* see below */ -/* protocol-protocol hooks */ - pr_input_t *pr_input; /* input to protocol (from below) */ - pr_output_t *pr_output; /* output to protocol (from above) */ - pr_ctlinput_t *pr_ctlinput; /* control input (from below) */ - pr_ctloutput_t *pr_ctloutput; /* control output (from above) */ -/* utility hooks */ - 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 */ - - struct pr_usrreqs *pr_usrreqs; /* user-protocol hook */ - LIST_ENTRY(protosw) pr_fasttimos; - LIST_ENTRY(protosw) pr_slowtimos; + short pr_unused; + struct domain *pr_domain; /* domain protocol a member of */ + + pr_soreceive_t *pr_soreceive; /* recv(2) */ + pr_rcvd_t *pr_rcvd; /* soreceive_generic() if PR_WANTRCVD */ + pr_sosend_t *pr_sosend; /* send(2) */ + pr_send_t *pr_send; /* send(2) via sosend_generic() */ + pr_ready_t *pr_ready; /* sendfile/ktls readyness */ + pr_sopoll_t *pr_sopoll; /* poll(2) */ +/* Cache line #2 */ + pr_attach_t *pr_attach; /* creation: socreate(), sonewconn() */ + pr_detach_t *pr_detach; /* destruction: sofree() */ + pr_connect_t *pr_connect; /* connect(2) */ + pr_disconnect_t *pr_disconnect; /* sodisconnect() */ + pr_close_t *pr_close; /* close(2) */ + pr_shutdown_t *pr_shutdown; /* shutdown(2) */ + pr_abort_t *pr_abort; /* abrupt tear down: soabort() */ + pr_aio_queue_t *pr_aio_queue; /* aio(9) */ +/* Cache line #3 */ + pr_bind_t *pr_bind; /* bind(2) */ + pr_bindat_t *pr_bindat; /* bindat(2) */ + pr_listen_t *pr_listen; /* listen(2) */ + pr_accept_t *pr_accept; /* accept(2) */ + pr_connectat_t *pr_connectat; /* connectat(2) */ + pr_connect2_t *pr_connect2; /* socketpair(2) */ + pr_control_t *pr_control; /* ioctl(2) */ + pr_rcvoob_t *pr_rcvoob; /* soreceive_rcvoob() */ +/* Cache line #4 */ + pr_ctloutput_t *pr_ctloutput; /* control output (from above) */ + pr_peeraddr_t *pr_peeraddr; /* getpeername(2) */ + pr_sockaddr_t *pr_sockaddr; /* getsockname(2) */ + pr_sense_t *pr_sense; /* stat(2) */ + pr_flush_t *pr_flush; /* XXXGL: merge with pr_shutdown_t! */ + pr_sosetlabel_t *pr_sosetlabel; /* MAC, XXXGL: remove */ + pr_setsbopt_t *pr_setsbopt; /* Socket buffer ioctls */ }; /*#endif*/ -#define PR_SLOWHZ 2 /* 2 slow timeouts per second */ -#define PR_FASTHZ 5 /* 5 fast timeouts per second */ - -/* - * This number should be defined again within each protocol family to avoid - * confusion. - */ -#define PROTO_SPACER 32767 /* spacer for loadable protocols */ - /* * Values for pr_flags. * PR_ADDR requires PR_ATOMIC; @@ -114,6 +155,8 @@ struct protosw { * and the protocol understands the MSG_EOF flag. The first property is * is only relevant if PR_CONNREQUIRED is set (otherwise sendto is allowed * anyhow). + * PR_SOCKBUF requires protocol to initialize and destroy its socket buffers + * in its pr_attach and pr_detach. */ #define PR_ATOMIC 0x01 /* exchange atomic messages only */ #define PR_ADDR 0x02 /* addresses given with messages */ @@ -121,202 +164,9 @@ struct protosw { #define PR_WANTRCVD 0x08 /* want PRU_RCVD calls */ #define PR_RIGHTS 0x10 /* passes capabilities */ #define PR_IMPLOPCL 0x20 /* implied open/close */ -#define PR_LASTHDR 0x40 /* enforce ipsec policy; last header */ +/* was PR_LASTHDR 0x40 enforce ipsec policy; last header */ #define PR_CAPATTACH 0x80 /* socket can attach in cap mode */ - -/* - * In earlier BSD network stacks, a single pr_usrreq() function pointer was - * invoked with an operation number indicating what operation was desired. - * We now provide individual function pointers which protocols can implement, - * which offers a number of benefits (such as type checking for arguments). - * These older constants are still present in order to support TCP debugging. - */ -#define PRU_ATTACH 0 /* attach protocol to up */ -#define PRU_DETACH 1 /* detach protocol from up */ -#define PRU_BIND 2 /* bind socket to address */ -#define PRU_LISTEN 3 /* listen for connection */ -#define PRU_CONNECT 4 /* establish connection to peer */ -#define PRU_ACCEPT 5 /* accept connection from peer */ -#define PRU_DISCONNECT 6 /* disconnect from peer */ -#define PRU_SHUTDOWN 7 /* won't send any more data */ -#define PRU_RCVD 8 /* have taken data; more room now */ -#define PRU_SEND 9 /* send this data */ -#define PRU_ABORT 10 /* abort (fast DISCONNECT, DETATCH) */ -#define PRU_CONTROL 11 /* control operations on protocol */ -#define PRU_SENSE 12 /* return status into m */ -#define PRU_RCVOOB 13 /* retrieve out of band data */ -#define PRU_SENDOOB 14 /* send out of band data */ -#define PRU_SOCKADDR 15 /* fetch socket's address */ -#define PRU_PEERADDR 16 /* fetch peer's address */ -#define PRU_CONNECT2 17 /* connect two sockets */ -/* begin for protocols internal use */ -#define PRU_FASTTIMO 18 /* 200ms timeout */ -#define PRU_SLOWTIMO 19 /* 500ms timeout */ -#define PRU_PROTORCV 20 /* receive from below */ -#define PRU_PROTOSEND 21 /* send to below */ -/* end for protocol's internal use */ -#define PRU_SEND_EOF 22 /* send and close */ -#define PRU_SOSETLABEL 23 /* MAC label change */ -#define PRU_CLOSE 24 /* socket close */ -#define PRU_FLUSH 25 /* flush the socket */ -#define PRU_NREQ 25 - -#ifdef PRUREQUESTS -const char *prurequests[] = { - "ATTACH", "DETACH", "BIND", "LISTEN", - "CONNECT", "ACCEPT", "DISCONNECT", "SHUTDOWN", - "RCVD", "SEND", "ABORT", "CONTROL", - "SENSE", "RCVOOB", "SENDOOB", "SOCKADDR", - "PEERADDR", "CONNECT2", "FASTTIMO", "SLOWTIMO", - "PROTORCV", "PROTOSEND", "SEND_EOF", "SOSETLABEL", - "CLOSE", "FLUSH", -}; -#endif - -#ifdef _KERNEL /* users shouldn't see this decl */ - -struct ifnet; -struct stat; -struct ucred; -struct uio; - -/* - * If the ordering here looks odd, that's because it's alphabetical. These - * should eventually be merged back into struct protosw. - * - * Some fields initialized to defaults if they are NULL. - */ -struct pr_usrreqs { - void (*pru_abort)(struct socket *so); - int (*pru_accept)(struct socket *so, struct sockaddr **nam); - int (*pru_attach)(struct socket *so, int proto, struct thread *td); - int (*pru_bind)(struct socket *so, struct sockaddr *nam, - struct thread *td); - int (*pru_connect)(struct socket *so, struct sockaddr *nam, - struct thread *td); - int (*pru_connect2)(struct socket *so1, struct socket *so2); - int (*pru_control)(struct socket *so, u_long cmd, caddr_t data, - struct ifnet *ifp, struct thread *td); - void (*pru_detach)(struct socket *so); - int (*pru_disconnect)(struct socket *so); - int (*pru_listen)(struct socket *so, int backlog, - struct thread *td); - int (*pru_peeraddr)(struct socket *so, struct sockaddr **nam); - int (*pru_rcvd)(struct socket *so, int flags); - int (*pru_rcvoob)(struct socket *so, struct mbuf *m, int flags); - int (*pru_send)(struct socket *so, int flags, struct mbuf *m, - struct sockaddr *addr, struct mbuf *control, - struct thread *td); -#define PRUS_OOB 0x1 -#define PRUS_EOF 0x2 -#define PRUS_MORETOCOME 0x4 -#define PRUS_NOTREADY 0x8 -#define PRUS_IPV6 0x10 - 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); - int (*pru_sockaddr)(struct socket *so, struct sockaddr **nam); - int (*pru_sosend)(struct socket *so, struct sockaddr *addr, - struct uio *uio, struct mbuf *top, struct mbuf *control, - int flags, struct thread *td); - int (*pru_soreceive)(struct socket *so, struct sockaddr **paddr, - struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, - int *flagsp); - int (*pru_sopoll)(struct socket *so, int events, - struct ucred *cred, struct thread *td); - void (*pru_sosetlabel)(struct socket *so); - void (*pru_close)(struct socket *so); - int (*pru_bindat)(int fd, struct socket *so, struct sockaddr *nam, - 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); -}; - -/* - * 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); -int pru_bindat_notsupp(int fd, struct socket *so, struct sockaddr *nam, - struct thread *td); -int pru_connect_notsupp(struct socket *so, struct sockaddr *nam, - struct thread *td); -int pru_connectat_notsupp(int fd, struct socket *so, struct sockaddr *nam, - struct thread *td); -int pru_connect2_notsupp(struct socket *so1, struct socket *so2); -int pru_control_notsupp(struct socket *so, u_long cmd, caddr_t data, - struct ifnet *ifp, struct thread *td); -int pru_disconnect_notsupp(struct socket *so); -int pru_listen_notsupp(struct socket *so, int backlog, struct thread *td); -int pru_peeraddr_notsupp(struct socket *so, struct sockaddr **nam); -int pru_rcvd_notsupp(struct socket *so, int flags); -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); -int pru_sosend_notsupp(struct socket *so, struct sockaddr *addr, - struct uio *uio, struct mbuf *top, struct mbuf *control, int flags, - struct thread *td); -int pru_soreceive_notsupp(struct socket *so, struct sockaddr **paddr, - struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, - int *flagsp); -int pru_sopoll_notsupp(struct socket *so, int events, struct ucred *cred, - struct thread *td); - -#endif /* _KERNEL */ - -/* - * The arguments to the ctlinput routine are - * (*protosw[].pr_ctlinput)(cmd, sa, arg); - * where cmd is one of the commands below, sa is a pointer to a sockaddr, - * and arg is a `void *' argument used within a protocol family. - */ -#define PRC_IFDOWN 0 /* interface transition */ -#define PRC_ROUTEDEAD 1 /* select new route if possible ??? */ -#define PRC_IFUP 2 /* interface has come back up */ -/* 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) */ -#define PRC_UNREACH_NET 8 /* no route to network */ -#define PRC_UNREACH_HOST 9 /* no route to host */ -#define PRC_UNREACH_PROTOCOL 10 /* dst says bad protocol */ -#define PRC_UNREACH_PORT 11 /* bad port # */ -/* was PRC_UNREACH_NEEDFRAG 12 (use PRC_MSGSIZE) */ -#define PRC_UNREACH_SRCFAIL 13 /* source route failed */ -#define PRC_REDIRECT_NET 14 /* net routing redirect */ -#define PRC_REDIRECT_HOST 15 /* host routing redirect */ -#define PRC_REDIRECT_TOSNET 16 /* redirect for type of service & net */ -#define PRC_REDIRECT_TOSHOST 17 /* redirect for tos & host */ -#define PRC_TIMXCEED_INTRANS 18 /* packet lifetime expired in transit */ -#define PRC_TIMXCEED_REASS 19 /* lifetime expired on reass q */ -#define PRC_PARAMPROB 20 /* header incorrect */ -#define PRC_UNREACH_ADMIN_PROHIB 21 /* packet administrativly prohibited */ - -#define PRC_NCMDS 22 - -#define PRC_IS_REDIRECT(cmd) \ - ((cmd) >= PRC_REDIRECT_NET && (cmd) <= PRC_REDIRECT_TOSHOST) - -#ifdef PRCREQUESTS -char *prcrequests[] = { - "IFDOWN", "ROUTEDEAD", "IFUP", "DEC-BIT-QUENCH2", - "QUENCH", "MSGSIZE", "HOSTDEAD", "#7", - "NET-UNREACH", "HOST-UNREACH", "PROTO-UNREACH", "PORT-UNREACH", - "#12", "SRCFAIL-UNREACH", "NET-REDIRECT", "HOST-REDIRECT", - "TOSNET-REDIRECT", "TOSHOST-REDIRECT", "TX-INTRANS", "TX-REASS", - "PARAMPROB", "ADMIN-UNREACH" -}; -#endif +#define PR_SOCKBUF 0x100 /* private implementation of buffers */ /* * The arguments to ctloutput are: @@ -343,12 +193,14 @@ char *prcorequests[] = { #endif #ifdef _KERNEL -void pfctlinput(int, struct sockaddr *); struct domain *pffinddomain(int family); -struct protosw *pffindproto(int family, int protocol, int type); -struct protosw *pffindtype(int family, int type); -int pf_proto_register(int family, struct protosw *npr); -int pf_proto_unregister(int family, int protocol, int type); +struct protosw *pffindproto(int family, int type, int proto); +int protosw_register(struct domain *, struct protosw *); +int protosw_unregister(struct protosw *); + +/* Domains that are known to be avaliable for protosw_register(). */ +extern struct domain inetdomain; +extern struct domain inet6domain; #endif #endif diff --git a/sys/sys/ptio.h b/sys/sys/ptio.h index 1c5aad22197b..f8233d93f060 100644 --- a/sys/sys/ptio.h +++ b/sys/sys/ptio.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1999 Kenneth D. Merry. * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_PTIO_H_ diff --git a/sys/sys/ptrace.h b/sys/sys/ptrace.h index 80797f290a41..3cce2c088f0b 100644 --- a/sys/sys/ptrace.h +++ b/sys/sys/ptrace.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)ptrace.h 8.2 (Berkeley) 1/4/94 - * $FreeBSD$ */ #ifndef _SYS_PTRACE_H_ @@ -87,6 +86,7 @@ #define PT_VM_ENTRY 41 /* Get VM map (entry) */ #define PT_GETREGSET 42 /* Get a target register set */ #define PT_SETREGSET 43 /* Set a target register set */ +#define PT_SC_REMOTE 44 /* Execute a syscall */ #define PT_FIRSTMACH 64 /* for machine-specific requests */ #include <machine/ptrace.h> /* machine-specific requests, if any */ @@ -192,8 +192,17 @@ struct ptrace_coredump { #define PC_COMPRESS 0x00000001 /* Allow compression */ #define PC_ALL 0x00000002 /* Include non-dumpable entries */ +struct ptrace_sc_remote { + struct ptrace_sc_ret pscr_ret; + u_int pscr_syscall; + u_int pscr_nargs; + syscallarg_t *pscr_args; +}; + #ifdef _KERNEL +#include <sys/proc.h> + struct thr_coredump_req { struct vnode *tc_vp; /* vnode to write coredump to. */ off_t tc_limit; /* max coredump file size. */ @@ -201,6 +210,12 @@ struct thr_coredump_req { int tc_error; /* request result */ }; +struct thr_syscall_req { + struct ptrace_sc_ret ts_ret; + u_int ts_nargs; + struct syscall_args ts_sa; +}; + int ptrace_set_pc(struct thread *_td, unsigned long _addr); int ptrace_single_step(struct thread *_td); int ptrace_clear_single_step(struct thread *_td); diff --git a/sys/sys/qmath.h b/sys/sys/qmath.h index 1b718f7edebf..fa5acdb985be 100644 --- a/sys/sys/qmath.h +++ b/sys/sys/qmath.h @@ -22,8 +22,6 @@ * 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$ */ /* diff --git a/sys/sys/queue.h b/sys/sys/queue.h index 6c7c37308b4d..47d85121e317 100644 --- a/sys/sys/queue.h +++ b/sys/sys/queue.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)queue.h 8.5 (Berkeley) 8/20/94 - * $FreeBSD$ */ #ifndef _SYS_QUEUE_H_ @@ -111,7 +110,7 @@ * _INSERT_TAIL - - + + * _CONCAT s s + + * _REMOVE_AFTER + - + - - * _REMOVE_HEAD + - + - + * _REMOVE_HEAD + + + + * _REMOVE s + s + * _SWAP + + + + * @@ -596,6 +595,9 @@ struct { \ __containerof((elm)->field.le_prev, \ QUEUE_TYPEOF(type), field.le_next)) +#define LIST_REMOVE_HEAD(head, field) \ + LIST_REMOVE(LIST_FIRST(head), field) + #define LIST_REMOVE(elm, field) do { \ QMD_SAVELINK(oldnext, (elm)->field.le_next); \ QMD_SAVELINK(oldprev, (elm)->field.le_prev); \ @@ -842,6 +844,9 @@ struct { \ ((elm)->field.tqe_prev == &(head)->tqh_first ? NULL : \ __containerof((elm)->field.tqe_prev, QUEUE_TYPEOF(type), field.tqe_next)) +#define TAILQ_REMOVE_HEAD(head, field) \ + TAILQ_REMOVE(head, TAILQ_FIRST(head), field) + #define TAILQ_REMOVE(head, elm, field) do { \ QMD_SAVELINK(oldnext, (elm)->field.tqe_next); \ QMD_SAVELINK(oldprev, (elm)->field.tqe_prev); \ diff --git a/sys/sys/queue_mergesort.h b/sys/sys/queue_mergesort.h new file mode 100644 index 000000000000..ea26b9aead46 --- /dev/null +++ b/sys/sys/queue_mergesort.h @@ -0,0 +1,217 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2023 Colin Percival + * + * 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. + */ + +#ifndef _SYS_QUEUE_MERGESORT_H_ +#define _SYS_QUEUE_MERGESORT_H_ + +/* + * This file defines macros for performing mergesorts on singly-linked lists, + * single-linked tail queues, lists, and tail queues as implemented in + * <sys/queue.h>. + */ + +/* + * Shims to work around _CONCAT and _INSERT_AFTER taking different numbers of + * arguments for different types of linked lists. + */ +#define STAILQ_CONCAT_4(head1, head2, type, field) \ + STAILQ_CONCAT(head1, head2) +#define TAILQ_CONCAT_4(head1, head2, type, field) \ + TAILQ_CONCAT(head1, head2, field) +#define SLIST_INSERT_AFTER_4(head, slistelm, elm, field) \ + SLIST_INSERT_AFTER(slistelm, elm, field) +#define LIST_INSERT_AFTER_4(head, slistelm, elm, field) \ + LIST_INSERT_AFTER(slistelm, elm, field) + +/* + * Generic macros which apply to all types of lists. + */ +#define SYSQUEUE_MERGE(sqms_list1, sqms_list2, thunk, sqms_cmp, TYPE, NAME, \ + M_FIRST, M_INSERT_AFTER, M_INSERT_HEAD, M_NEXT, M_REMOVE_HEAD) \ +do { \ + struct TYPE *sqms_elm1; \ + struct TYPE *sqms_elm1_prev; \ + struct TYPE *sqms_elm2; \ + \ + /* Start at the beginning of list1; _prev is the previous node. */ \ + sqms_elm1_prev = NULL; \ + sqms_elm1 = M_FIRST(sqms_list1); \ + \ + /* Pull entries from list2 and insert them into list1. */ \ + while ((sqms_elm2 = M_FIRST(sqms_list2)) != NULL) { \ + /* Remove from list2. */ \ + M_REMOVE_HEAD(sqms_list2, NAME); \ + \ + /* Advance until we find the right place to insert it. */ \ + while ((sqms_elm1 != NULL) && \ + (sqms_cmp)(sqms_elm2, sqms_elm1, thunk) >= 0) { \ + sqms_elm1_prev = sqms_elm1; \ + sqms_elm1 = M_NEXT(sqms_elm1, NAME); \ + } \ + \ + /* Insert into list1. */ \ + if (sqms_elm1_prev == NULL) \ + M_INSERT_HEAD(sqms_list1, sqms_elm2, NAME); \ + else \ + M_INSERT_AFTER(sqms_list1, sqms_elm1_prev, \ + sqms_elm2, NAME); \ + sqms_elm1_prev = sqms_elm2; \ + } \ +} while (0) + +#define SYSQUEUE_MERGE_SUBL(sqms_sorted, sqms_len1, sqms_len2, sqms_melm, \ + sqms_mpos, thunk, sqms_cmp, TYPE, NAME, \ + M_FIRST, M_NEXT, M_REMOVE_HEAD, M_INSERT_AFTER) \ +do { \ + struct TYPE *sqms_curelm; \ + size_t sqms_i; \ + \ + /* Find the element before the start of the second sorted region. */ \ + while ((sqms_mpos) < (sqms_len1)) { \ + (sqms_melm) = M_NEXT((sqms_melm), NAME); \ + (sqms_mpos)++; \ + } \ + \ + /* Pull len1 entries off the list and insert in the right place. */ \ + for (sqms_i = 0; sqms_i < (sqms_len1); sqms_i++) { \ + /* Grab the first element. */ \ + sqms_curelm = M_FIRST(&(sqms_sorted)); \ + \ + /* Advance until we find the right place to insert it. */ \ + while (((sqms_mpos) < (sqms_len1) + (sqms_len2)) && \ + ((sqms_cmp)(sqms_curelm, M_NEXT((sqms_melm), NAME), \ + thunk) >= 0)) { \ + (sqms_melm) = M_NEXT((sqms_melm), NAME); \ + (sqms_mpos)++; \ + } \ + \ + /* Move the element in the right place if not already there. */ \ + if (sqms_curelm != (sqms_melm)) { \ + M_REMOVE_HEAD(&(sqms_sorted), NAME); \ + M_INSERT_AFTER(&(sqms_sorted), (sqms_melm), \ + sqms_curelm, NAME); \ + (sqms_melm) = sqms_curelm; \ + } \ + } \ +} while (0) + +#define SYSQUEUE_MERGESORT(sqms_head, thunk, sqms_cmp, TYPE, NAME, M_HEAD, \ + M_HEAD_INITIALIZER, M_EMPTY, M_FIRST, M_NEXT, M_INSERT_HEAD, \ + M_INSERT_AFTER, M_CONCAT, M_REMOVE_HEAD) \ +do { \ + /* \ + * Invariant: If sqms_slen = 2^a + 2^b + ... + 2^z with a < b < ... < z \ + * then sqms_sorted is a sequence of 2^a sorted entries followed by a \ + * list of 2^b sorted entries ... followed by a list of 2^z sorted \ + * entries. \ + */ \ + M_HEAD(, TYPE) sqms_sorted = M_HEAD_INITIALIZER(sqms_sorted); \ + struct TYPE *sqms_elm; \ + size_t sqms_slen = 0; \ + size_t sqms_sortmask; \ + size_t sqms_mpos; \ + \ + /* Move everything from the input list to sqms_sorted. */ \ + while (!M_EMPTY(sqms_head)) { \ + /* Pull the head off the input list. */ \ + sqms_elm = M_FIRST(sqms_head); \ + M_REMOVE_HEAD(sqms_head, NAME); \ + \ + /* Push it onto sqms_sorted. */ \ + M_INSERT_HEAD(&sqms_sorted, sqms_elm, NAME); \ + sqms_slen++; \ + \ + /* Restore sorting invariant. */ \ + sqms_mpos = 1; \ + for (sqms_sortmask = 1; \ + sqms_sortmask & ~sqms_slen; \ + sqms_sortmask <<= 1) \ + SYSQUEUE_MERGE_SUBL(sqms_sorted, sqms_sortmask, \ + sqms_sortmask, sqms_elm, sqms_mpos, thunk, sqms_cmp,\ + TYPE, NAME, M_FIRST, M_NEXT, M_REMOVE_HEAD, \ + M_INSERT_AFTER); \ + } \ + \ + /* Merge the remaining sublists. */ \ + sqms_elm = M_FIRST(&sqms_sorted); \ + sqms_mpos = 1; \ + for (sqms_sortmask = 2; \ + sqms_sortmask < sqms_slen; \ + sqms_sortmask <<= 1) \ + if (sqms_slen & sqms_sortmask) \ + SYSQUEUE_MERGE_SUBL(sqms_sorted, \ + sqms_slen & (sqms_sortmask - 1), sqms_sortmask, \ + sqms_elm, sqms_mpos, thunk, sqms_cmp, \ + TYPE, NAME, M_FIRST, M_NEXT, M_REMOVE_HEAD, \ + M_INSERT_AFTER); \ + \ + /* Move the sorted list back to the input list. */ \ + M_CONCAT(sqms_head, &sqms_sorted, TYPE, NAME); \ +} while (0) + +/** + * Macros for each of the individual data types. They are all invoked as + * FOO_MERGESORT(head, thunk, compar, TYPE, NAME) + * and + * FOO_MERGE(list1, list2, thunk, compar, TYPE, NAME) + * where the compar function operates as in qsort_r, i.e. compar(a, b, thunk) + * returns an integer less than, equal to, or greater than zero if a is + * considered to be respectively less than, equal to, or greater than b. + */ +#define SLIST_MERGESORT(head, thunk, cmp, TYPE, NAME) \ + SYSQUEUE_MERGESORT((head), (thunk), (cmp), TYPE, NAME, SLIST_HEAD, \ + SLIST_HEAD_INITIALIZER, SLIST_EMPTY, SLIST_FIRST, SLIST_NEXT, \ + SLIST_INSERT_HEAD, SLIST_INSERT_AFTER_4, SLIST_CONCAT, SLIST_REMOVE_HEAD) +#define SLIST_MERGE(list1, list2, thunk, cmp, TYPE, NAME) \ + SYSQUEUE_MERGE((list1), (list2), (thunk), (cmp), TYPE, NAME, SLIST_FIRST, \ + SLIST_INSERT_AFTER_4, SLIST_INSERT_HEAD, SLIST_NEXT, SLIST_REMOVE_HEAD) + +#define LIST_MERGESORT(head, thunk, cmp, TYPE, NAME) \ + SYSQUEUE_MERGESORT((head), (thunk), (cmp), TYPE, NAME, LIST_HEAD, \ + LIST_HEAD_INITIALIZER, LIST_EMPTY, LIST_FIRST, LIST_NEXT, \ + LIST_INSERT_HEAD, LIST_INSERT_AFTER_4, LIST_CONCAT, LIST_REMOVE_HEAD) +#define LIST_MERGE(list1, list2, thunk, cmp, TYPE, NAME) \ + SYSQUEUE_MERGE((list1), (list2), (thunk), (cmp), TYPE, NAME, LIST_FIRST, \ + LIST_INSERT_AFTER_4, LIST_INSERT_HEAD, LIST_NEXT, LIST_REMOVE_HEAD) + +#define STAILQ_MERGESORT(head, thunk, cmp, TYPE, NAME) \ + SYSQUEUE_MERGESORT((head), (thunk), (cmp), TYPE, NAME, STAILQ_HEAD, \ + STAILQ_HEAD_INITIALIZER, STAILQ_EMPTY, STAILQ_FIRST, STAILQ_NEXT, \ + STAILQ_INSERT_HEAD, STAILQ_INSERT_AFTER, STAILQ_CONCAT_4, STAILQ_REMOVE_HEAD) +#define STAILQ_MERGE(list1, list2, thunk, cmp, TYPE, NAME) \ + SYSQUEUE_MERGE((list1), (list2), (thunk), (cmp), TYPE, NAME, STAILQ_FIRST, \ + STAILQ_INSERT_AFTER, STAILQ_INSERT_HEAD, STAILQ_NEXT, STAILQ_REMOVE_HEAD) + +#define TAILQ_MERGESORT(head, thunk, cmp, TYPE, NAME) \ + SYSQUEUE_MERGESORT((head), (thunk), (cmp), TYPE, NAME, TAILQ_HEAD, \ + TAILQ_HEAD_INITIALIZER, TAILQ_EMPTY, TAILQ_FIRST, TAILQ_NEXT, \ + TAILQ_INSERT_HEAD, TAILQ_INSERT_AFTER, TAILQ_CONCAT_4, TAILQ_REMOVE_HEAD) +#define TAILQ_MERGE(list1, list2, thunk, cmp, TYPE, NAME) \ + SYSQUEUE_MERGE((list1), (list2), (thunk), (cmp), TYPE, NAME, TAILQ_FIRST, \ + TAILQ_INSERT_AFTER, TAILQ_INSERT_HEAD, TAILQ_NEXT, TAILQ_REMOVE_HEAD) + +#endif /* !_SYS_QUEUE_MERGESORT_H_ */ diff --git a/sys/sys/racct.h b/sys/sys/racct.h index 49e0ce64069e..22b61bba537d 100644 --- a/sys/sys/racct.h +++ b/sys/sys/racct.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2010 The FreeBSD Foundation * @@ -26,8 +26,6 @@ * 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$ */ /* @@ -196,7 +194,6 @@ void racct_proc_exit(struct proc *p); 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_throttled(struct proc *p); void racct_proc_throttle(struct proc *p, int timeout); #else diff --git a/sys/sys/random.h b/sys/sys/random.h index 81d2a40c72dd..0e6ae02ac078 100644 --- a/sys/sys/random.h +++ b/sys/sys/random.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2000-2015, 2017 Mark R. V. Murray * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_RANDOM_H_ diff --git a/sys/sys/rangelock.h b/sys/sys/rangelock.h index 128a87918f4f..62ccf77c03bc 100644 --- a/sys/sys/rangelock.h +++ b/sys/sys/rangelock.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2009 Konstantin Belousov <kib@FreeBSD.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_RANGELOCK_H diff --git a/sys/sys/rangeset.h b/sys/sys/rangeset.h index 58dded5d37e2..a9fc0ad885c8 100644 --- a/sys/sys/rangeset.h +++ b/sys/sys/rangeset.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2019 The FreeBSD Foundation * @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS_RANGESET_H diff --git a/sys/sys/rctl.h b/sys/sys/rctl.h index 292bc3f9aa6b..39a859eeb47f 100644 --- a/sys/sys/rctl.h +++ b/sys/sys/rctl.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2010 The FreeBSD Foundation * @@ -26,8 +26,6 @@ * 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$ */ /* diff --git a/sys/sys/reboot.h b/sys/sys/reboot.h index 20b91f8ed91d..c41200022f4c 100644 --- a/sys/sys/reboot.h +++ b/sys/sys/reboot.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)reboot.h 8.3 (Berkeley) 12/13/94 - * $FreeBSD$ */ #ifndef _SYS_REBOOT_H_ diff --git a/sys/sys/refcount.h b/sys/sys/refcount.h index c320316a8e87..212e8e516271 100644 --- a/sys/sys/refcount.h +++ b/sys/sys/refcount.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2005 John Baldwin <jhb@FreeBSD.org> * @@ -23,8 +23,6 @@ * 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$ */ #ifndef __SYS_REFCOUNT_H__ diff --git a/sys/sys/reg.h b/sys/sys/reg.h index 97803498e2a0..03af4a2ee9c8 100644 --- a/sys/sys/reg.h +++ b/sys/sys/reg.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (C) 2014,2019 Andrew Turner * Copyright (c) 2014-2015 The FreeBSD Foundation @@ -31,8 +31,6 @@ * 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$ */ #ifndef _SYS_REG_H_ diff --git a/sys/sys/regression.h b/sys/sys/regression.h index 1ce711faa35f..a0058c53cb5e 100644 --- a/sys/sys/regression.h +++ b/sys/sys/regression.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001 Robert N. M. Watson * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_REGRESSION_H_ #define _SYS_REGRESSION_H_ diff --git a/sys/sys/resource.h b/sys/sys/resource.h index 08bb09b4a645..5100501fb2b8 100644 --- a/sys/sys/resource.h +++ b/sys/sys/resource.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)resource.h 8.4 (Berkeley) 1/9/95 - * $FreeBSD$ */ #ifndef _SYS_RESOURCE_H_ diff --git a/sys/sys/resourcevar.h b/sys/sys/resourcevar.h index bd57211c75f0..49119651665e 100644 --- a/sys/sys/resourcevar.h +++ b/sys/sys/resourcevar.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)resourcevar.h 8.4 (Berkeley) 1/9/95 - * $FreeBSD$ */ #ifndef _SYS_RESOURCEVAR_H_ @@ -82,6 +81,28 @@ struct plimit { int pl_refcnt; /* number of references */ }; +struct limbatch { + struct plimit *limp; + int count; +}; + +static inline void +limbatch_prep(struct limbatch *lb) +{ + lb->limp = NULL; + lb->count = 0; +} + +void limbatch_add(struct limbatch *lb, struct thread *td); + +static inline void +limbatch_process(struct limbatch *lb __unused) +{ + +} + +void limbatch_final(struct limbatch *lb); + struct racct; /*- diff --git a/sys/sys/rman.h b/sys/sys/rman.h index e955cd5834b9..bb63c4dfb100 100644 --- a/sys/sys/rman.h +++ b/sys/sys/rman.h @@ -27,8 +27,6 @@ * 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$ */ #ifndef _SYS_RMAN_H_ diff --git a/sys/sys/rmlock.h b/sys/sys/rmlock.h index 5aaf8f039026..664356998438 100644 --- a/sys/sys/rmlock.h +++ b/sys/sys/rmlock.h @@ -27,8 +27,6 @@ * 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$ */ #ifndef _SYS_RMLOCK_H_ @@ -151,6 +149,13 @@ rms_wowned(struct rmslock *rms) } #ifdef INVARIANTS +#define rms_assert_rlock_ok(x) \ + WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, __func__); +#else +#define rms_assert_rlock_ok(x) +#endif + +#ifdef INVARIANTS /* * For assertion purposes. * diff --git a/sys/sys/rtprio.h b/sys/sys/rtprio.h index a950e9a459c7..6e0d8c7b0fe7 100644 --- a/sys/sys/rtprio.h +++ b/sys/sys/rtprio.h @@ -29,8 +29,6 @@ * 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$ */ #ifndef _SYS_RTPRIO_H_ diff --git a/sys/sys/runq.h b/sys/sys/runq.h index 0e3113b1102f..1a54e83a7db3 100644 --- a/sys/sys/runq.h +++ b/sys/sys/runq.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001 Jake Burkholder <jake@FreeBSD.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _RUNQ_H_ diff --git a/sys/sys/rwlock.h b/sys/sys/rwlock.h index 99e885e07aaf..0ebe90e09bed 100644 --- a/sys/sys/rwlock.h +++ b/sys/sys/rwlock.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2006 John Baldwin <jhb@FreeBSD.org> * @@ -23,8 +23,6 @@ * 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$ */ #ifndef _SYS_RWLOCK_H_ diff --git a/sys/sys/sbuf.h b/sys/sys/sbuf.h index d87e3917b84c..60dcda53a461 100644 --- a/sys/sys/sbuf.h +++ b/sys/sys/sbuf.h @@ -1,8 +1,8 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2000-2008 Poul-Henning Kamp - * Copyright (c) 2000-2008 Dag-Erling Coïdan Smørgrav + * Copyright (c) 2000-2008 Dag-Erling Smørgrav * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS_SBUF_H_ diff --git a/sys/sys/sched.h b/sys/sys/sched.h index a9598767e4cb..9d37e8f0f999 100644 --- a/sys/sys/sched.h +++ b/sys/sys/sched.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: (BSD-4-Clause AND BSD-2-Clause-FreeBSD) + * SPDX-License-Identifier: (BSD-4-Clause AND BSD-2-Clause) * * Copyright (c) 1996, 1997 * HD Associates, Inc. All rights reserved. @@ -57,8 +57,6 @@ * 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$ */ #ifndef _SCHED_H_ @@ -95,6 +93,7 @@ void sched_ap_entry(void); void sched_exit_thread(struct thread *td, struct thread *child); u_int sched_estcpu(struct thread *td); void sched_fork_thread(struct thread *td, struct thread *child); +void sched_ithread_prio(struct thread *td, u_char prio); void sched_lend_prio(struct thread *td, u_char prio); void sched_lend_user_prio(struct thread *td, u_char pri); void sched_lend_user_prio_cond(struct thread *td, u_char pri); diff --git a/sys/sys/sdt.h b/sys/sys/sdt.h index fb5c3d671604..e059921b0e9e 100644 --- a/sys/sys/sdt.h +++ b/sys/sys/sdt.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright 2006-2008 John Birrell <jb@FreeBSD.org> * @@ -24,8 +24,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ - * * Statically Defined Tracing (SDT) definitions. * */ @@ -86,6 +84,8 @@ extern volatile bool sdt_probes_enabled; #ifndef KDTRACE_HOOKS +#define __sdt_used __unused + #define SDT_PROVIDER_DEFINE(prov) #define SDT_PROVIDER_DECLARE(prov) #define SDT_PROBE_DEFINE(prov, mod, func, name) @@ -141,6 +141,8 @@ extern volatile bool sdt_probes_enabled; #else +#define __sdt_used + SET_DECLARE(sdt_providers_set, struct sdt_provider); SET_DECLARE(sdt_probes_set, struct sdt_probe); SET_DECLARE(sdt_argtypes_set, struct sdt_argtype); diff --git a/sys/sys/select.h b/sys/sys/select.h index 15d59cbc68dd..1ded44197de9 100644 --- a/sys/sys/select.h +++ b/sys/sys/select.h @@ -27,8 +27,6 @@ * 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$ */ #ifndef _SYS_SELECT_H_ diff --git a/sys/sys/selinfo.h b/sys/sys/selinfo.h index c5f3ad6b80a4..f4af278a78e5 100644 --- a/sys/sys/selinfo.h +++ b/sys/sys/selinfo.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)select.h 8.2 (Berkeley) 1/4/94 - * $FreeBSD$ */ #ifndef _SYS_SELINFO_H_ diff --git a/sys/sys/sem.h b/sys/sys/sem.h index bf1e31e4aca1..05b69f64cd05 100644 --- a/sys/sys/sem.h +++ b/sys/sys/sem.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /* $NetBSD: sem.h,v 1.5 1994/06/29 06:45:15 cgd Exp $ */ /* diff --git a/sys/sys/sema.h b/sys/sys/sema.h index 3b91c921c46a..0d12da7fd5b7 100644 --- a/sys/sys/sema.h +++ b/sys/sys/sema.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (C) 2001 Jason Evans <jasone@freebsd.org>. All rights reserved. * @@ -25,8 +25,6 @@ * 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$ */ #ifndef _SYS_SEMA_H_ diff --git a/sys/sys/seqc.h b/sys/sys/seqc.h index c401ad28b47e..6472c2e3cfd7 100644 --- a/sys/sys/seqc.h +++ b/sys/sys/seqc.h @@ -21,8 +21,6 @@ * 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$ */ #ifndef _SYS_SEQC_H_ diff --git a/sys/sys/serial.h b/sys/sys/serial.h index 804687d31271..cb1527464397 100644 --- a/sys/sys/serial.h +++ b/sys/sys/serial.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Poul-Henning Kamp * All rights reserved. @@ -28,8 +28,6 @@ * This file contains definitions which pertain to serial ports as such, * (both async and sync), but which do not necessarily have anything to * do with tty processing. - * - * $FreeBSD$ */ #ifndef _SYS_SERIAL_H_ diff --git a/sys/sys/sf_buf.h b/sys/sys/sf_buf.h index b4ea671a2d23..173ec161ab60 100644 --- a/sys/sys/sf_buf.h +++ b/sys/sys/sf_buf.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2014 Gleb Smirnoff <glebius@FreeBSD.org> * Copyright (c) 2003-2004 Alan L. Cox <alc@cs.rice.edu> @@ -25,8 +25,6 @@ * 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$ */ #ifndef _SYS_SF_BUF_H_ diff --git a/sys/sys/sglist.h b/sys/sys/sglist.h index bf8aa482e3ce..96f3c1cd5ffb 100644 --- a/sys/sys/sglist.h +++ b/sys/sys/sglist.h @@ -28,8 +28,6 @@ * 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$ */ /* diff --git a/sys/sys/shm.h b/sys/sys/shm.h index 07eff28b7a50..0b5cba0120e5 100644 --- a/sys/sys/shm.h +++ b/sys/sys/shm.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /* $NetBSD: shm.h,v 1.15 1994/06/29 06:45:17 cgd Exp $ */ /*- diff --git a/sys/sys/sigio.h b/sys/sys/sigio.h index 0a4369e07056..eb84a7f676ac 100644 --- a/sys/sys/sigio.h +++ b/sys/sys/sigio.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)filedesc.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD$ */ #ifndef _SYS_SIGIO_H_ diff --git a/sys/sys/signal.h b/sys/sys/signal.h index 27014c20973a..4007c6968eae 100644 --- a/sys/sys/signal.h +++ b/sys/sys/signal.h @@ -34,7 +34,6 @@ * SUCH DAMAGE. * * @(#)signal.h 8.4 (Berkeley) 5/4/95 - * $FreeBSD$ */ #ifndef _SYS_SIGNAL_H_ diff --git a/sys/sys/signalvar.h b/sys/sys/signalvar.h index 4e86f54856f6..cf83af1db226 100644 --- a/sys/sys/signalvar.h +++ b/sys/sys/signalvar.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)signalvar.h 8.6 (Berkeley) 2/19/95 - * $FreeBSD$ */ #ifndef _SYS_SIGNALVAR_H_ @@ -272,7 +271,6 @@ int __sys_sigfastblock(int cmd, void *ptr); #endif #ifdef _KERNEL -extern sigset_t fastblock_mask; extern bool sigfastblock_fetch_always; /* Return nonzero if process p has an unmasked pending signal. */ @@ -383,9 +381,8 @@ sigallowstop(int prev) int cursig(struct thread *td); void execsigs(struct proc *p); -void gsignal(int pgid, int sig, ksiginfo_t *ksi); void killproc(struct proc *p, const char *why); -ksiginfo_t * ksiginfo_alloc(int wait); +ksiginfo_t *ksiginfo_alloc(int mwait); void ksiginfo_free(ksiginfo_t *ksi); int pksignal(struct proc *p, int sig, ksiginfo_t *ksi); void pgsigio(struct sigio **sigiop, int sig, int checkctty); @@ -406,7 +403,6 @@ void sigexit(struct thread *td, int sig) __dead2; int sigev_findtd(struct proc *p, struct sigevent *sigev, struct thread **); void sigfastblock_clear(struct thread *td); void sigfastblock_fetch(struct thread *td); -void sigfastblock_setpend(struct thread *td, bool resched); int sig_intr(void); void siginit(struct proc *p); void signotify(struct thread *td); diff --git a/sys/sys/sleepqueue.h b/sys/sys/sleepqueue.h index 6715894ed1f3..9e456141393b 100644 --- a/sys/sys/sleepqueue.h +++ b/sys/sys/sleepqueue.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 John Baldwin <jhb@FreeBSD.org> * @@ -23,8 +23,6 @@ * 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$ */ #ifndef _SYS_SLEEPQUEUE_H_ diff --git a/sys/sys/slicer.h b/sys/sys/slicer.h index 675b5acc2dd7..280e10ebb6fe 100644 --- a/sys/sys/slicer.h +++ b/sys/sys/slicer.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2012 Semihalf. * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _FLASH_SLICER_H_ diff --git a/sys/sys/smp.h b/sys/sys/smp.h index 4583dc4350c9..252dc9dc1cae 100644 --- a/sys/sys/smp.h +++ b/sys/sys/smp.h @@ -7,8 +7,6 @@ * can do whatever you want with this stuff. If we meet some day, and you think * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- - * - * $FreeBSD$ */ #ifndef _SYS_SMP_H_ @@ -178,6 +176,9 @@ extern int smp_threads_per_core; extern cpuset_t all_cpus; extern cpuset_t cpuset_domain[MAXMEMDOM]; /* CPUs in each NUMA domain. */ +struct pcb; +extern struct pcb *stoppcbs; + /* * Macro allowing us to determine whether a CPU is absent at any given * time, thus permitting us to configure sparse maps of cpuid-dependent diff --git a/sys/sys/smr.h b/sys/sys/smr.h index c110be9a66c2..3449bc65af88 100644 --- a/sys/sys/smr.h +++ b/sys/sys/smr.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2019, 2020 Jeffrey Roberson <jeff@FreeBSD.org> * @@ -24,8 +24,6 @@ * (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$ - * */ #ifndef _SYS_SMR_H_ @@ -122,8 +120,12 @@ smr_enter(smr_t smr) * Frees that are newer than this stored value will be * deferred until we call smr_exit(). * - * An acquire barrier is used to synchronize with smr_exit() - * and smr_poll(). + * Subsequent loads must not be re-ordered with the store. On + * x86 platforms, any locked instruction will provide this + * guarantee, so as an optimization we use a single operation to + * both store the cached write sequence number and provide the + * requisite barrier, taking advantage of the fact that + * SMR_SEQ_INVALID is zero. * * It is possible that a long delay between loading the wr_seq * and storing the c_seq could create a situation where the @@ -132,8 +134,12 @@ smr_enter(smr_t smr) * the load. See smr_poll() for details on how this condition * is detected and handled there. */ - /* This is an add because we do not have atomic_store_acq_int */ +#if defined(__amd64__) || defined(__i386__) atomic_add_acq_int(&smr->c_seq, smr_shared_current(smr->c_shared)); +#else + atomic_store_int(&smr->c_seq, smr_shared_current(smr->c_shared)); + atomic_thread_fence_seq_cst(); +#endif } /* @@ -233,11 +239,11 @@ void smr_destroy(smr_t smr); /* * Blocking wait for all readers to observe 'goal'. */ -static inline bool +static inline void smr_wait(smr_t smr, smr_seq_t goal) { - return (smr_poll(smr, goal, true)); + (void)smr_poll(smr, goal, true); } /* diff --git a/sys/sys/smr_types.h b/sys/sys/smr_types.h index 3497f21af846..9da4a73c568c 100644 --- a/sys/sys/smr_types.h +++ b/sys/sys/smr_types.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2019, 2020 Jeffrey Roberson <jeff@FreeBSD.org> * @@ -23,8 +23,6 @@ * 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$ */ #ifndef _SYS_SMR_TYPES_H_ diff --git a/sys/sys/sndstat.h b/sys/sys/sndstat.h index bd9b76e1652d..f0e4d352242f 100644 --- a/sys/sys/sndstat.h +++ b/sys/sys/sndstat.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2020 The FreeBSD Foundation * @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS_SNDSTAT_H_ diff --git a/sys/sys/snoop.h b/sys/sys/snoop.h index b25aa494ff8e..dd46892ea4b4 100644 --- a/sys/sys/snoop.h +++ b/sys/sys/snoop.h @@ -11,8 +11,6 @@ * This software is provided ``AS IS'' without any warranties of any kind. * * Snoop stuff. - * - * $FreeBSD$ */ #ifndef _SYS_SNOOP_H_ diff --git a/sys/sys/sockbuf.h b/sys/sys/sockbuf.h index 753ebd1fbf35..14107f5b2a10 100644 --- a/sys/sys/sockbuf.h +++ b/sys/sys/sockbuf.h @@ -29,8 +29,6 @@ * SUCH DAMAGE. * * @(#)socketvar.h 8.3 (Berkeley) 2/19/95 - * - * $FreeBSD$ */ #ifndef _SYS_SOCKBUF_H_ #define _SYS_SOCKBUF_H_ @@ -52,7 +50,8 @@ #define SB_AUTOSIZE 0x800 /* automatically size socket buffer */ #define SB_STOP 0x1000 /* backpressure indicator */ #define SB_AIO_RUNNING 0x2000 /* AIO operation running */ -#define SB_TLS_IFNET 0x4000 /* has used / is using ifnet KTLS */ +#define SB_UNUSED 0x4000 /* previously used for SB_TLS_IFNET */ +#define SB_TLS_RX_RESYNC 0x8000 /* KTLS RX lost HW sync */ #define SBS_CANTSENDMORE 0x0010 /* can't send more data to peer */ #define SBS_CANTRCVMORE 0x0020 /* can't receive more data from peer */ @@ -70,47 +69,103 @@ struct ktls_session; struct mbuf; struct sockaddr; struct socket; +struct sockopt; struct thread; struct selinfo; /* - * Variables for socket buffering. + * Socket buffer + * + * A buffer starts with the fields that are accessed by I/O multiplexing + * APIs like select(2), kevent(2) or AIO and thus are shared between different + * buffer implementations. They are protected by the SOCK_RECVBUF_LOCK() + * or SOCK_SENDBUF_LOCK() of the owning socket. + * + * XXX: sb_acc, sb_ccc and sb_mbcnt shall become implementation specific + * methods. * - * Locking key to struct sockbuf: - * (a) locked by SOCKBUF_LOCK(). + * Protocol specific implementations follow in a union. */ struct sockbuf { - struct mtx *sb_mtx; /* sockbuf lock */ struct selinfo *sb_sel; /* process selecting read/write */ - short sb_state; /* (a) socket state on sockbuf */ - short sb_flags; /* (a) flags, see above */ - struct mbuf *sb_mb; /* (a) the mbuf chain */ - struct mbuf *sb_mbtail; /* (a) the last mbuf in the chain */ - struct mbuf *sb_lastrecord; /* (a) first mbuf of last - * record in socket buffer */ - struct mbuf *sb_sndptr; /* (a) pointer into mbuf chain */ - struct mbuf *sb_fnrdy; /* (a) pointer to first not ready buffer */ - u_int sb_sndptroff; /* (a) byte offset of ptr into chain */ - u_int sb_acc; /* (a) available chars in buffer */ - u_int sb_ccc; /* (a) claimed chars in buffer */ - u_int sb_hiwat; /* (a) max actual char count */ - u_int sb_mbcnt; /* (a) chars of mbufs used */ - u_int sb_mcnt; /* (a) number of mbufs in buffer */ - u_int sb_ccnt; /* (a) number of clusters in buffer */ - u_int sb_mbmax; /* (a) max chars of mbufs to use */ - u_int sb_ctl; /* (a) non-data chars in buffer */ - u_int sb_tlscc; /* (a) TLS chain characters */ - u_int sb_tlsdcc; /* (a) TLS characters being decrypted */ - int sb_lowat; /* (a) low water mark */ - sbintime_t sb_timeo; /* (a) timeout for read/write */ - struct mbuf *sb_mtls; /* (a) TLS mbuf chain */ - struct mbuf *sb_mtlstail; /* (a) last mbuf in TLS chain */ - int (*sb_upcall)(struct socket *, void *, int); /* (a) */ - void *sb_upcallarg; /* (a) */ - uint64_t sb_tls_seqno; /* (a) TLS seqno */ - struct ktls_session *sb_tls_info; /* (a + b) TLS state */ - TAILQ_HEAD(, kaiocb) sb_aiojobq; /* (a) pending AIO ops */ - struct task sb_aiotask; /* AIO task */ + short sb_state; /* socket state on sockbuf */ + short sb_flags; /* flags, see above */ + u_int sb_acc; /* available chars in buffer */ + u_int sb_ccc; /* claimed chars in buffer */ + u_int sb_mbcnt; /* chars of mbufs used */ + u_int sb_ctl; /* non-data chars in buffer */ + u_int sb_hiwat; /* max actual char count */ + u_int sb_lowat; /* low water mark */ + u_int sb_mbmax; /* max chars of mbufs to use */ + sbintime_t sb_timeo; /* timeout for read/write */ + int (*sb_upcall)(struct socket *, void *, int); + void *sb_upcallarg; + TAILQ_HEAD(, kaiocb) sb_aiojobq; /* pending AIO ops */ + struct task sb_aiotask; /* AIO task */ + union { + /* + * Classic BSD one-size-fits-all socket buffer, capable of + * doing streams and datagrams. The stream part is able + * to perform special features: + * - not ready data (sendfile) + * - TLS + */ + struct { + /* compat: sockbuf lock pointer */ + struct mtx *sb_mtx; + /* first and last mbufs in the chain */ + struct mbuf *sb_mb; + struct mbuf *sb_mbtail; + /* first mbuf of last record in socket buffer */ + struct mbuf *sb_lastrecord; + /* pointer to data to send next (TCP */ + struct mbuf *sb_sndptr; + /* pointer to first not ready buffer */ + struct mbuf *sb_fnrdy; + /* byte offset of ptr into chain, used with sb_sndptr */ + u_int sb_sndptroff; + /* TLS */ + u_int sb_tlscc; /* TLS chain characters */ + u_int sb_tlsdcc; /* characters being decrypted */ + struct mbuf *sb_mtls; /* TLS mbuf chain */ + struct mbuf *sb_mtlstail; /* last mbuf in TLS chain */ + uint64_t sb_tls_seqno; /* TLS seqno */ + struct ktls_session *sb_tls_info; /* TLS state */ + }; + /* + * PF_UNIX/SOCK_DGRAM + * + * Local protocol, thus we should buffer on the receive side + * only. However, in one to many configuration we don't want + * a single receive buffer to be shared. So we would link + * send buffers onto receive buffer. All the fields are locked + * by the receive buffer lock. + */ + struct { + /* + * For receive buffer: own queue of this buffer for + * unconnected sends. For send buffer: queue lended + * to the peer receive buffer, to isolate ourselves + * from other senders. + */ + STAILQ_HEAD(, mbuf) uxdg_mb; + /* For receive buffer: datagram seen via MSG_PEEK. */ + struct mbuf *uxdg_peeked; + /* + * For receive buffer: queue of send buffers of + * connected peers. For send buffer: linkage on + * connected peer receive buffer queue. + */ + union { + TAILQ_HEAD(, sockbuf) uxdg_conns; + TAILQ_ENTRY(sockbuf) uxdg_clist; + }; + /* Counters for this buffer uxdg_mb chain + peeked. */ + u_int uxdg_cc; + u_int uxdg_ctl; + u_int uxdg_mbcnt; + }; + }; }; #endif /* defined(_KERNEL) || defined(_WANT_SOCKET) */ @@ -171,9 +226,11 @@ void sbflush(struct sockbuf *sb); void sbflush_locked(struct sockbuf *sb); void sbrelease(struct socket *, sb_which); void sbrelease_locked(struct socket *, sb_which); -int sbsetopt(struct socket *so, int cmd, u_long cc); +int sbsetopt(struct socket *so, struct sockopt *); bool sbreserve_locked(struct socket *so, sb_which which, u_long cc, struct thread *td); +bool sbreserve_locked_limit(struct socket *so, sb_which which, u_long cc, + u_long buf_max, struct thread *td); void sbsndptr_adv(struct sockbuf *sb, struct mbuf *mb, u_int len); struct mbuf * sbsndptr_noadv(struct sockbuf *sb, u_int off, u_int *moff); diff --git a/sys/sys/socket.h b/sys/sys/socket.h index de7a874b3079..fc97b4c0a0a8 100644 --- a/sys/sys/socket.h +++ b/sys/sys/socket.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)socket.h 8.4 (Berkeley) 2/21/94 - * $FreeBSD$ */ #ifndef _SYS_SOCKET_H_ @@ -264,10 +263,12 @@ struct accept_filter_arg { #define AF_ARP 35 #define AF_BLUETOOTH 36 /* Bluetooth sockets */ #define AF_IEEE80211 37 /* IEEE 802.11 protocol */ +#define AF_NETLINK 38 /* Netlink protocol */ #define AF_INET_SDP 40 /* OFED Socket Direct Protocol ipv4 */ #define AF_INET6_SDP 42 /* OFED Socket Direct Protocol ipv6 */ #define AF_HYPERV 43 /* HyperV sockets */ -#define AF_MAX 43 +#define AF_DIVERT 44 /* divert(4) */ +#define AF_MAX 44 /* * When allocating a new AF_ constant, please only allocate * even numbered constants for FreeBSD until 134 as odd numbered AF_ @@ -389,8 +390,10 @@ struct sockproto { #define PF_ARP AF_ARP #define PF_BLUETOOTH AF_BLUETOOTH #define PF_IEEE80211 AF_IEEE80211 +#define PF_NETLINK AF_NETLINK #define PF_INET_SDP AF_INET_SDP #define PF_INET6_SDP AF_INET6_SDP +#define PF_DIVERT AF_DIVERT #define PF_MAX AF_MAX @@ -718,7 +721,6 @@ __END_DECLS #ifdef _KERNEL struct socket; -struct tcpcb *so_sototcpcb(struct socket *so); struct inpcb *so_sotoinpcb(struct socket *so); struct sockbuf *so_sockbuf_snd(struct socket *); struct sockbuf *so_sockbuf_rcv(struct socket *); diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h index 05eefd7e4fd4..485494b605ec 100644 --- a/sys/sys/socketvar.h +++ b/sys/sys/socketvar.h @@ -29,8 +29,6 @@ * SUCH DAMAGE. * * @(#)socketvar.h 8.3 (Berkeley) 2/19/95 - * - * $FreeBSD$ */ #ifndef _SYS_SOCKETVAR_H_ @@ -210,7 +208,6 @@ struct socket { * Many fields will be read without locks to improve performance and avoid * lock order issues. However, this approach must be used with caution. */ -#define SS_NOFDREF 0x0001 /* no file table ref any more */ #define SS_ISCONNECTED 0x0002 /* socket connected to a peer */ #define SS_ISCONNECTING 0x0004 /* in process of connecting to peer */ #define SS_ISDISCONNECTING 0x0008 /* in process of disconnecting */ @@ -219,15 +216,6 @@ struct socket { #define SS_ISCONFIRMING 0x0400 /* deciding to accept connection req */ #define SS_ISDISCONNECTED 0x2000 /* socket disconnected from peer */ -/* - * Protocols can mark a socket as SS_PROTOREF to indicate that, following - * pru_detach, they still want the socket to persist, and will free it - * themselves when they are done. Protocols should only ever call sofree() - * following setting this flag in pru_detach(), and never otherwise, as - * sofree() bypasses socket reference counting. - */ -#define SS_PROTOREF 0x4000 /* strong protocol reference */ - #ifdef _KERNEL #define SOCK_MTX(so) (&(so)->so_lock) @@ -254,6 +242,11 @@ struct socket { KASSERT(SOLISTENING(sol), \ ("%s: %p not listening", __func__, (sol))); \ } while (0) +#define SOLISTEN_UNLOCK_ASSERT(sol) do { \ + mtx_assert(&(sol)->so_lock, MA_NOTOWNED); \ + KASSERT(SOLISTENING(sol), \ + ("%s: %p not listening", __func__, (sol))); \ +} while (0) /* * Socket buffer locks. These are strongly preferred over SOCKBUF_LOCK(sb) @@ -454,7 +447,9 @@ struct uio; int getsockaddr(struct sockaddr **namp, const struct sockaddr *uaddr, size_t len); int getsock_cap(struct thread *td, int fd, cap_rights_t *rightsp, - struct file **fpp, u_int *fflagp, struct filecaps *havecaps); + struct file **fpp, struct filecaps *havecaps); +int getsock(struct thread *td, int fd, cap_rights_t *rightsp, + struct file **fpp); void soabort(struct socket *so); int soaccept(struct socket *so, struct sockaddr **nam); void soaio_enqueue(struct task *task); @@ -474,14 +469,16 @@ int socreate(int dom, struct socket **aso, int type, int proto, int sodisconnect(struct socket *so); void sodtor_set(struct socket *, so_dtor_t *); struct sockaddr *sodupsockaddr(const struct sockaddr *sa, int mflags); -void sofree(struct socket *so); void sohasoutofband(struct socket *so); int solisten(struct socket *so, int backlog, struct thread *td); void solisten_proto(struct socket *so, int backlog); void solisten_proto_abort(struct socket *so); int solisten_proto_check(struct socket *so); +bool solisten_enqueue(struct socket *, int); int solisten_dequeue(struct socket *, struct socket **, int); struct socket * + solisten_clone(struct socket *); +struct socket * sonewconn(struct socket *head, int connstatus); struct socket * sopeeloff(struct socket *); @@ -501,11 +498,14 @@ int soreceive_generic(struct socket *so, struct sockaddr **paddr, struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, int *flagsp); void sorele_locked(struct socket *so); +void sodealloc(struct socket *); int soreserve(struct socket *so, u_long sndcc, u_long rcvcc); void sorflush(struct socket *so); int sosend(struct socket *so, struct sockaddr *addr, struct uio *uio, struct mbuf *top, struct mbuf *control, int flags, struct thread *td); +int sousrsend(struct socket *so, struct sockaddr *addr, struct uio *uio, + struct mbuf *control, int flags, struct proc *); int sosend_dgram(struct socket *so, struct sockaddr *addr, struct uio *uio, struct mbuf *top, struct mbuf *control, int flags, struct thread *td); @@ -577,8 +577,8 @@ struct xsocket { uint32_t sb_cc; uint32_t sb_hiwat; uint32_t sb_mbcnt; - uint32_t sb_mcnt; - uint32_t sb_ccnt; + uint32_t sb_spare0; /* was sb_mcnt */ + uint32_t sb_spare1; /* was sb_ccnt */ uint32_t sb_mbmax; int32_t sb_lowat; int32_t sb_timeo; diff --git a/sys/sys/sockio.h b/sys/sys/sockio.h index 93b8af28e171..e0f2ab697168 100644 --- a/sys/sys/sockio.h +++ b/sys/sys/sockio.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)sockio.h 8.1 (Berkeley) 3/28/94 - * $FreeBSD$ */ #ifndef _SYS_SOCKIO_H_ @@ -147,4 +146,7 @@ #define SIOCGIFDOWNREASON _IOWR('i', 154, struct ifdownreason) +#define SIOCSIFCAPNV _IOW('i', 155, struct ifreq) /* set IF features */ +#define SIOCGIFCAPNV _IOWR('i', 156, struct ifreq) /* get IF features */ + #endif /* !_SYS_SOCKIO_H_ */ diff --git a/sys/sys/sockopt.h b/sys/sys/sockopt.h index cb7fc3ffca27..11799dde4883 100644 --- a/sys/sys/sockopt.h +++ b/sys/sys/sockopt.h @@ -29,8 +29,6 @@ * SUCH DAMAGE. * * @(#)socketvar.h 8.3 (Berkeley) 2/19/95 - * - * $FreeBSD$ */ #ifndef _SYS_SOCKOPT_H_ #define _SYS_SOCKOPT_H_ diff --git a/sys/sys/soundcard.h b/sys/sys/soundcard.h index 285f26986434..ddd8a51d29a5 100644 --- a/sys/sys/soundcard.h +++ b/sys/sys/soundcard.h @@ -30,8 +30,6 @@ * 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$ */ /* @@ -1746,7 +1744,7 @@ typedef struct oss_sysinfo int openedaudio[8]; /* Bit mask telling which audio devices are busy */ - int numsynths; /* # of availavle synth devices */ + int numsynths; /* # of available synth devices */ int nummidis; /* # of available MIDI ports */ int numtimers; /* # of available timer devices */ int nummixers; /* # of mixer devices */ diff --git a/sys/sys/specialfd.h b/sys/sys/specialfd.h index c388bdcb7b6f..dc4d88ce689f 100644 --- a/sys/sys/specialfd.h +++ b/sys/sys/specialfd.h @@ -1,7 +1,7 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2020 Greg V + * Copyright (c) 2020 Val Packett * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,8 +23,6 @@ * 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$ */ #ifndef _SYS_SPECIALFD_H_ diff --git a/sys/sys/spigenio.h b/sys/sys/spigenio.h index 6ad9b01b634a..adfdceeb9b47 100644 --- a/sys/sys/spigenio.h +++ b/sys/sys/spigenio.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2000 Doug Rabson * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_SPIGENIO_H_ diff --git a/sys/sys/stack.h b/sys/sys/stack.h index 15ee178d63a6..1e2de017a082 100644 --- a/sys/sys/stack.h +++ b/sys/sys/stack.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2005 Antoine Brodin * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_STACK_H_ diff --git a/sys/sys/stat.h b/sys/sys/stat.h index 03040f74eba4..d083b877e6dd 100644 --- a/sys/sys/stat.h +++ b/sys/sys/stat.h @@ -34,7 +34,6 @@ * SUCH DAMAGE. * * @(#)stat.h 8.12 (Berkeley) 6/16/95 - * $FreeBSD$ */ #ifndef _SYS_STAT_H_ diff --git a/sys/sys/stats.h b/sys/sys/stats.h index c10bba856bfc..cd926cf1fcc5 100644 --- a/sys/sys/stats.h +++ b/sys/sys/stats.h @@ -22,8 +22,6 @@ * 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$ */ /* diff --git a/sys/sys/statvfs.h b/sys/sys/statvfs.h index 24fd8e02f6a6..9562643859f6 100644 --- a/sys/sys/statvfs.h +++ b/sys/sys/statvfs.h @@ -25,8 +25,6 @@ * 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$ */ #ifndef _SYS_STATVFS_H_ diff --git a/sys/sys/stdatomic.h b/sys/sys/stdatomic.h index f4fd1c6ae60e..e05606b1ead8 100644 --- a/sys/sys/stdatomic.h +++ b/sys/sys/stdatomic.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2011 Ed Schouten <ed@FreeBSD.org> * David Chisnall <theraven@FreeBSD.org> @@ -25,8 +25,6 @@ * 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$ */ #ifndef _STDATOMIC_H_ diff --git a/sys/sys/stddef.h b/sys/sys/stddef.h index fba87e4b4702..73636f5a2370 100644 --- a/sys/sys/stddef.h +++ b/sys/sys/stddef.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002 Maxime Henrion <mux@FreeBSD.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_STDDEF_H_ diff --git a/sys/sys/stdint.h b/sys/sys/stdint.h index e951ac3c5df8..f82e391c9e41 100644 --- a/sys/sys/stdint.h +++ b/sys/sys/stdint.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_STDINT_H_ diff --git a/sys/sys/sx.h b/sys/sys/sx.h index bd164a96558b..798e85ed67dc 100644 --- a/sys/sys/sx.h +++ b/sys/sys/sx.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2007 Attilio Rao <attilio@freebsd.org> * Copyright (c) 2001 Jason Evans <jasone@freebsd.org> @@ -27,8 +27,6 @@ * 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$ */ #ifndef _SYS_SX_H_ diff --git a/sys/sys/syscall.h b/sys/sys/syscall.h index 081437449b70..724ca454dbf7 100644 --- a/sys/sys/syscall.h +++ b/sys/sys/syscall.h @@ -2,7 +2,6 @@ * System call numbers. * * DO NOT EDIT-- this file is automatically @generated. - * $FreeBSD$ */ #define SYS_syscall 0 @@ -141,7 +140,7 @@ #define SYS_mkdir 136 #define SYS_rmdir 137 #define SYS_utimes 138 - /* 139 is obsolete 4.2 sigreturn */ + /* 139 is obsolete sigreturn */ #define SYS_adjtime 140 /* 141 is old getpeername */ /* 142 is old gethostid */ @@ -520,4 +519,9 @@ #define SYS_fspacectl 580 #define SYS_sched_getcpu 581 #define SYS_swapoff 582 -#define SYS_MAXSYSCALL 583 +#define SYS_kqueuex 583 +#define SYS_membarrier 584 +#define SYS_timerfd_create 585 +#define SYS_timerfd_gettime 586 +#define SYS_timerfd_settime 587 +#define SYS_MAXSYSCALL 588 diff --git a/sys/sys/syscall.mk b/sys/sys/syscall.mk index 56518e94d30d..ef58619ea6d4 100644 --- a/sys/sys/syscall.mk +++ b/sys/sys/syscall.mk @@ -1,6 +1,5 @@ # FreeBSD system call object files. # DO NOT EDIT-- this file is automatically @generated. -# $FreeBSD$ MIASM = \ syscall.o \ exit.o \ @@ -425,4 +424,9 @@ MIASM = \ aio_readv.o \ fspacectl.o \ sched_getcpu.o \ - swapoff.o + swapoff.o \ + kqueuex.o \ + membarrier.o \ + timerfd_create.o \ + timerfd_gettime.o \ + timerfd_settime.o diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h index 70e33e9244c4..0480eda2fca4 100644 --- a/sys/sys/syscallsubr.h +++ b/sys/sys/syscallsubr.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002 Ian Dowse. All rights reserved. * @@ -23,8 +23,6 @@ * 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$ */ #ifndef _SYS_SYSCALLSUBR_H_ @@ -81,6 +79,7 @@ struct mmap_req { mmap_check_fp_fn mr_check_fp_fn; }; +uint64_t at2cnpflags(u_int at_flags, u_int mask); int kern___getcwd(struct thread *td, char *buf, enum uio_seg bufseg, size_t buflen, size_t path_max); int kern_abort2(struct thread *td, const char *why, int nargs, @@ -93,8 +92,6 @@ int kern_accessat(struct thread *td, int fd, const char *path, enum uio_seg pathseg, int flags, int mode); int kern_adjtime(struct thread *td, struct timeval *delta, struct timeval *olddelta); -int kern_alternate_path(const char *prefix, const char *path, - enum uio_seg pathseg, char **pathbuf, int create, int dirfd); int kern_bindat(struct thread *td, int dirfd, int fd, struct sockaddr *sa); int kern_break(struct thread *td, uintptr_t *addr); int kern_cap_ioctls_limit(struct thread *td, int fd, u_long *cmds, @@ -119,9 +116,11 @@ int kern_connectat(struct thread *td, int dirfd, int fd, struct sockaddr *sa); int kern_copy_file_range(struct thread *td, int infd, off_t *inoffp, int outfd, off_t *outoffp, size_t len, unsigned int flags); -int kern_cpuset_getaffinity(struct thread *td, cpulevel_t level, +int user_cpuset_getaffinity(struct thread *td, cpulevel_t level, cpuwhich_t which, id_t id, size_t cpusetsize, cpuset_t *maskp, const struct cpuset_copy_cb *cb); +int kern_cpuset_getaffinity(struct thread *td, cpulevel_t level, + cpuwhich_t which, id_t id, size_t cpusetsize, cpuset_t *mask); int kern_cpuset_setaffinity(struct thread *td, cpulevel_t level, cpuwhich_t which, id_t id, cpuset_t *maskp); int user_cpuset_setaffinity(struct thread *td, cpulevel_t level, @@ -140,6 +139,26 @@ int kern_cpuset_setid(struct thread *td, cpuwhich_t which, int kern_dup(struct thread *td, u_int mode, int flags, int old, int new); int kern_execve(struct thread *td, struct image_args *args, struct mac *mac_p, struct vmspace *oldvmspace); +int kern_extattr_delete_fd(struct thread *td, int fd, int attrnamespace, + const char *attrname); +int kern_extattr_delete_path(struct thread *td, const char *path, + int attrnamespace, const char *attrname, int follow, + enum uio_seg pathseg); +int kern_extattr_get_fd(struct thread *td, int fd, int attrnamespace, + const char *attrname, void *data, size_t nbytes); +int kern_extattr_get_path(struct thread *td, const char *path, + int attrnamespace, const char *attrname, void *data, + size_t nbytes, int follow, enum uio_seg pathseg); +int kern_extattr_list_fd(struct thread *td, int fd, int attrnamespace, + struct uio *auiop); +int kern_extattr_list_path(struct thread *td, const char *path, + int attrnamespace, struct uio *auiop, int follow, + enum uio_seg pathseg); +int kern_extattr_set_fd(struct thread *td, int fd, int attrnamespace, + const char *attrname, void *data, size_t nbytes); +int kern_extattr_set_path(struct thread *td, const char *path, + int attrnamespace, const char *attrname, void *data, + size_t nbytes, int follow, enum uio_seg pathseg); int kern_fchmodat(struct thread *td, int fd, const char *path, enum uio_seg pathseg, mode_t mode, int flag); int kern_fchownat(struct thread *td, int fd, const char *path, @@ -205,6 +224,8 @@ int kern_minherit(struct thread *td, uintptr_t addr, size_t len, int inherit); int kern_mkdirat(struct thread *td, int fd, const char *path, enum uio_seg segflg, int mode); +int kern_membarrier(struct thread *td, int cmd, unsigned flags, + int cpu_id); int kern_mkfifoat(struct thread *td, int fd, const char *path, enum uio_seg pathseg, int mode); int kern_mknodat(struct thread *td, int fd, const char *path, @@ -215,7 +236,8 @@ int kern_mmap(struct thread *td, const struct mmap_req *mrp); int kern_mmap_racct_check(struct thread *td, struct vm_map *map, vm_size_t size); int kern_mmap_maxprot(struct proc *p, int prot); -int kern_mprotect(struct thread *td, uintptr_t addr, size_t size, int prot); +int kern_mprotect(struct thread *td, uintptr_t addr, size_t size, + int prot, int flags); int kern_msgctl(struct thread *, int, int, struct msqid_ds *); int kern_msgrcv(struct thread *, int, void *, size_t, long, int, long *); int kern_msgsnd(struct thread *, int, const void *, size_t, int, long); @@ -317,8 +339,7 @@ int kern_sigqueue(struct thread *td, pid_t pid, int signum, union sigval *value); int kern_socket(struct thread *td, int domain, int type, int protocol); int kern_statat(struct thread *td, int flag, int fd, const char *path, - enum uio_seg pathseg, struct stat *sbp, - void (*hook)(struct vnode *vp, struct stat *sbp)); + enum uio_seg pathseg, struct stat *sbp); int kern_specialfd(struct thread *td, int type, void *arg); int kern_statfs(struct thread *td, const char *path, enum uio_seg pathseg, struct statfs *buf); diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index 451d83bbe125..9176d2c3efdd 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -32,7 +32,6 @@ * SUCH DAMAGE. * * @(#)sysctl.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD$ */ #ifndef _SYS_SYSCTL_H_ @@ -40,6 +39,7 @@ #ifdef _KERNEL #include <sys/queue.h> +#include <sys/tree.h> #endif /* @@ -173,20 +173,25 @@ struct sysctl_req { int flags; }; -SLIST_HEAD(sysctl_oid_list, sysctl_oid); +struct sysctl_oid; + +/* RB Tree handling */ +RB_HEAD(sysctl_oid_list, sysctl_oid); /* * This describes one "oid" in the MIB tree. Potentially more nodes can * be hidden behind it, expanded by the handler. */ struct sysctl_oid { - struct sysctl_oid_list oid_children; - struct sysctl_oid_list *oid_parent; - SLIST_ENTRY(sysctl_oid) oid_link; + struct sysctl_oid_list oid_children; + struct sysctl_oid_list* oid_parent; + RB_ENTRY(sysctl_oid) oid_link; + /* Sort key for all siblings, and lookup key for userland */ int oid_number; u_int oid_kind; void *oid_arg1; intmax_t oid_arg2; + /* Must be unique amongst all siblings. */ const char *oid_name; int (*oid_handler)(SYSCTL_HANDLER_ARGS); const char *oid_fmt; @@ -196,6 +201,19 @@ struct sysctl_oid { const char *oid_label; }; +static inline int +cmp_sysctl_oid(struct sysctl_oid *a, struct sysctl_oid *b) +{ + if (a->oid_number > b->oid_number) + return (1); + else if (a->oid_number < b->oid_number) + return (-1); + else + return (0); +} + +RB_PROTOTYPE(sysctl_oid_list, sysctl_oid, oid_link, cmp_sysctl_oid); + #define SYSCTL_IN(r, p, l) (r->newfunc)(r, p, l) #define SYSCTL_OUT(r, p, l) (r->oldfunc)(r, p, l) #define SYSCTL_OUT_STR(r, p) (r->oldfunc)(r, p, strlen(p) + 1) @@ -275,7 +293,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); #define SYSCTL_OID_RAW(id, parent_child_head, nbr, name, kind, a1, a2, handler, fmt, descr, label) \ struct sysctl_oid id = { \ .oid_parent = (parent_child_head), \ - .oid_children = SLIST_HEAD_INITIALIZER(&id.oid_children), \ + .oid_children = RB_INITIALIZER(&id.oid_children), \ .oid_number = (nbr), \ .oid_kind = (kind), \ .oid_arg1 = (a1), \ @@ -738,8 +756,8 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); /* Oid for an array of counter(9)s. The pointer and length must be non zero. */ #define SYSCTL_COUNTER_U64_ARRAY(parent, nbr, name, access, ptr, len, descr) \ SYSCTL_OID(parent, nbr, name, \ - CTLTYPE_OPAQUE | CTLFLAG_MPSAFE | CTLFLAG_STATS | (access), \ - (ptr), (len), sysctl_handle_counter_u64_array, "S", descr); \ + CTLTYPE_U64 | CTLFLAG_MPSAFE | CTLFLAG_STATS | (access), \ + (ptr), (len), sysctl_handle_counter_u64_array, "QU", descr);\ CTASSERT((((access) & CTLTYPE) == 0 || \ ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE) && \ sizeof(counter_u64_t) == sizeof(*(ptr)) && \ @@ -899,6 +917,9 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); NULL); \ }) +#define SYSCTL_FOREACH(oidp, list) \ + RB_FOREACH(oidp, sysctl_oid_list, list) + /* * A macro to generate a read-only sysctl to indicate the presence of optional * kernel features. @@ -950,7 +971,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); #define KERN_HOSTNAME 10 /* string: hostname */ #define KERN_HOSTID 11 /* int: host identifier */ #define KERN_CLOCKRATE 12 /* struct: struct clockrate */ -#define KERN_VNODE 13 /* struct: vnode structures */ +/* was: #define KERN_VNODE 13 ; disabled in 2003 and removed in 2023 */ #define KERN_PROC 14 /* struct: process entries */ #define KERN_FILE 15 /* struct: file entries */ #define KERN_PROF 16 /* node: kernel profiling info */ diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h index f677050db769..3f52848af982 100644 --- a/sys/sys/sysent.h +++ b/sys/sys/sysent.h @@ -27,8 +27,6 @@ * 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$ */ #ifndef _SYS_SYSENT_H_ @@ -117,7 +115,6 @@ struct sysentvec { const char *sv_elf_core_abi_vendor; void (*sv_elf_core_prepare_notes)(struct thread *, struct note_info_list *, size_t *); - int (*sv_imgact_try)(struct image_params *); int (*sv_copyout_auxargs)(struct image_params *, uintptr_t); int sv_minsigstksz; /* minimum signal stack size */ @@ -137,19 +134,19 @@ struct sysentvec { void (*sv_set_syscall_retval)(struct thread *, int); int (*sv_fetch_syscall_args)(struct thread *); const char **sv_syscallnames; - vm_offset_t sv_timekeep_base; + vm_offset_t sv_timekeep_offset; vm_offset_t sv_shared_page_base; vm_offset_t sv_shared_page_len; - vm_offset_t sv_sigcode_base; + vm_offset_t sv_sigcode_offset; void *sv_shared_page_obj; - vm_offset_t sv_vdso_base; + vm_offset_t sv_vdso_offset; void (*sv_schedtail)(struct thread *); void (*sv_thread_detach)(struct thread *); int (*sv_trap)(struct thread *); u_long *sv_hwcap; /* Value passed in AT_HWCAP. */ u_long *sv_hwcap2; /* Value passed in AT_HWCAP2. */ const char *(*sv_machine_arch)(struct proc *); - vm_offset_t sv_fxrng_gen_base; + vm_offset_t sv_fxrng_gen_offset; void (*sv_onexec_old)(struct thread *td); int (*sv_onexec)(struct proc *, struct image_params *); void (*sv_onexit)(struct proc *); diff --git a/sys/sys/syslimits.h b/sys/sys/syslimits.h index 08aae5aaae71..c76792f55b43 100644 --- a/sys/sys/syslimits.h +++ b/sys/sys/syslimits.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)syslimits.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD$ */ #ifndef _SYS_SYSLIMITS_H_ diff --git a/sys/sys/syslog.h b/sys/sys/syslog.h index 071b68427105..1c6921f00642 100644 --- a/sys/sys/syslog.h +++ b/sys/sys/syslog.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)syslog.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD$ */ #ifndef _SYS_SYSLOG_H_ @@ -37,7 +36,6 @@ #define _PATH_LOG "/var/run/log" #define _PATH_LOG_PRIV "/var/run/logpriv" -#define _PATH_OLDLOG "/dev/log" /* backward compatibility */ /* * priorities/facilities are encoded into a single 32-bit quantity, where the diff --git a/sys/sys/sysproto.h b/sys/sys/sysproto.h index e062eaf8c0e6..d0eb5a43d00b 100644 --- a/sys/sys/sysproto.h +++ b/sys/sys/sysproto.h @@ -2,7 +2,6 @@ * System call prototypes. * * DO NOT EDIT-- this file is automatically @generated. - * $FreeBSD$ */ #ifndef _SYS_SYSPROTO_H_ @@ -1855,6 +1854,28 @@ struct swapoff_args { char name_l_[PADL_(const char *)]; const char * name; char name_r_[PADR_(const char *)]; char flags_l_[PADL_(u_int)]; u_int flags; char flags_r_[PADR_(u_int)]; }; +struct kqueuex_args { + char flags_l_[PADL_(u_int)]; u_int flags; char flags_r_[PADR_(u_int)]; +}; +struct membarrier_args { + char cmd_l_[PADL_(int)]; int cmd; char cmd_r_[PADR_(int)]; + char flags_l_[PADL_(unsigned)]; unsigned flags; char flags_r_[PADR_(unsigned)]; + char cpu_id_l_[PADL_(int)]; int cpu_id; char cpu_id_r_[PADR_(int)]; +}; +struct timerfd_create_args { + char clockid_l_[PADL_(int)]; int clockid; char clockid_r_[PADR_(int)]; + char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)]; +}; +struct timerfd_gettime_args { + char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; + char curr_value_l_[PADL_(struct itimerspec *)]; struct itimerspec * curr_value; char curr_value_r_[PADR_(struct itimerspec *)]; +}; +struct timerfd_settime_args { + char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; + char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)]; + char new_value_l_[PADL_(const struct itimerspec *)]; const struct itimerspec * new_value; char new_value_r_[PADR_(const struct itimerspec *)]; + char old_value_l_[PADL_(struct itimerspec *)]; struct itimerspec * old_value; char old_value_r_[PADR_(struct itimerspec *)]; +}; int sys_exit(struct thread *, struct exit_args *); int sys_fork(struct thread *, struct fork_args *); int sys_read(struct thread *, struct read_args *); @@ -2250,6 +2271,11 @@ int sys_aio_readv(struct thread *, struct aio_readv_args *); int sys_fspacectl(struct thread *, struct fspacectl_args *); int sys_sched_getcpu(struct thread *, struct sched_getcpu_args *); int sys_swapoff(struct thread *, struct swapoff_args *); +int sys_kqueuex(struct thread *, struct kqueuex_args *); +int sys_membarrier(struct thread *, struct membarrier_args *); +int sys_timerfd_create(struct thread *, struct timerfd_create_args *); +int sys_timerfd_gettime(struct thread *, struct timerfd_gettime_args *); +int sys_timerfd_settime(struct thread *, struct timerfd_settime_args *); #ifdef COMPAT_43 @@ -3219,6 +3245,11 @@ int freebsd13_swapoff(struct thread *, struct freebsd13_swapoff_args *); #define SYS_AUE_fspacectl AUE_FSPACECTL #define SYS_AUE_sched_getcpu AUE_NULL #define SYS_AUE_swapoff AUE_SWAPOFF +#define SYS_AUE_kqueuex AUE_KQUEUE +#define SYS_AUE_membarrier AUE_NULL +#define SYS_AUE_timerfd_create AUE_TIMERFD +#define SYS_AUE_timerfd_gettime AUE_TIMERFD +#define SYS_AUE_timerfd_settime AUE_TIMERFD #undef PAD_ #undef PADL_ diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 98637c4f4838..2367a7880cfd 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -34,19 +34,18 @@ * SUCH DAMAGE. * * @(#)systm.h 8.7 (Berkeley) 3/29/95 - * $FreeBSD$ */ #ifndef _SYS_SYSTM_H_ #define _SYS_SYSTM_H_ -#include <sys/cdefs.h> -#include <machine/atomic.h> -#include <machine/cpufunc.h> +#include <sys/types.h> #include <sys/callout.h> #include <sys/kassert.h> #include <sys/queue.h> #include <sys/stdint.h> /* for people using printf mainly */ +#include <machine/atomic.h> +#include <machine/cpufunc.h> __NULLABILITY_PRAGMA_PUSH @@ -150,7 +149,6 @@ void *hashinit_flags(int count, struct malloc_type *type, void *phashinit(int count, struct malloc_type *type, u_long *nentries); void *phashinit_flags(int count, struct malloc_type *type, u_long *nentries, int flags); -void g_waitidle(void); void cpu_flush_dcache(void *, size_t); void cpu_rootconf(void); @@ -360,8 +358,6 @@ int SAN_INTERCEPTOR(casueword)(volatile u_long *p, u_long oldval, #endif /* !SAN_RUNTIME */ #endif /* SAN_NEEDS_INTERCEPTORS && !KCSAN */ -void realitexpire(void *); - int sysbeep(int hertz, sbintime_t duration); void hardclock(int cnt, int usermode); @@ -407,7 +403,7 @@ int getenv_array(const char *name, void *data, int size, int *psize, #define GETENV_SIGNED true /* negative numbers allowed */ typedef uint64_t (cpu_tick_f)(void); -void set_cputicker(cpu_tick_f *func, uint64_t freq, unsigned var); +void set_cputicker(cpu_tick_f *func, uint64_t freq, bool isvariable); extern cpu_tick_f *cpu_ticks; uint64_t cpu_tickrate(void); uint64_t cputick2usec(uint64_t tick); @@ -451,8 +447,11 @@ int msleep_spin_sbt(const void * _Nonnull chan, struct mtx *mtx, 0, C_HARDCLOCK) int pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_t pr, int flags); -#define pause(wmesg, timo) \ - pause_sbt((wmesg), tick_sbt * (timo), 0, C_HARDCLOCK) +static __inline int +pause(const char *wmesg, int timo) +{ + return (pause_sbt(wmesg, tick_sbt * timo, 0, C_HARDCLOCK)); +} #define pause_sig(wmesg, timo) \ pause_sbt((wmesg), tick_sbt * (timo), 0, C_HARDCLOCK | C_CATCH) #define tsleep(chan, pri, wmesg, timo) \ @@ -509,10 +508,9 @@ int alloc_unr(struct unrhdr *uh); int alloc_unr_specific(struct unrhdr *uh, u_int item); int alloc_unrl(struct unrhdr *uh); void free_unr(struct unrhdr *uh, u_int item); - -#ifndef __LP64__ -#define UNR64_LOCKED -#endif +void *create_iter_unr(struct unrhdr *uh); +int next_iter_unr(void *handle); +void free_iter_unr(void *handle); struct unrhdr64 { uint64_t counter; @@ -525,16 +523,12 @@ new_unrhdr64(struct unrhdr64 *unr64, uint64_t low) unr64->counter = low; } -#ifdef UNR64_LOCKED -uint64_t alloc_unr64(struct unrhdr64 *); -#else static __inline uint64_t alloc_unr64(struct unrhdr64 *unr64) { return (atomic_fetchadd_64(&unr64->counter, 1)); } -#endif void intr_prof_stack_use(struct thread *td, struct trapframe *frame); diff --git a/sys/sys/taskqueue.h b/sys/sys/taskqueue.h index cc98fe5fab85..34d64a5042a6 100644 --- a/sys/sys/taskqueue.h +++ b/sys/sys/taskqueue.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2000 Doug Rabson * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_TASKQUEUE_H_ diff --git a/sys/sys/terminal.h b/sys/sys/terminal.h index 7a6ee7530294..a26cb44b135a 100644 --- a/sys/sys/terminal.h +++ b/sys/sys/terminal.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2009 The FreeBSD Foundation * @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS_TERMINAL_H_ diff --git a/sys/sys/termios.h b/sys/sys/termios.h index e5bacf46550f..2ae131150386 100644 --- a/sys/sys/termios.h +++ b/sys/sys/termios.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #ifdef __GNUC__ #warning "this file includes <sys/termios.h> which is deprecated, use <termios.h> instead" #endif diff --git a/sys/sys/thr.h b/sys/sys/thr.h index c00b8b25a9f4..5e83ec208f07 100644 --- a/sys/sys/thr.h +++ b/sys/sys/thr.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2003, Jeffrey Roberson <jeff@freebsd.org> * All rights reserved. @@ -25,8 +25,6 @@ * (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$ - * */ #ifndef _SYS_THR_H_ diff --git a/sys/sys/tiio.h b/sys/sys/tiio.h index acda7741d0b7..da75b2e4deb8 100644 --- a/sys/sys/tiio.h +++ b/sys/sys/tiio.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: (BSD-2-Clause-FreeBSD AND BSD-4-Clause) + * SPDX-License-Identifier: (BSD-2-Clause AND BSD-4-Clause) * * Copyright (c) 1999, 2000 Kenneth D. Merry. * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ /* * The ti_stats structure below is from code with the following copyright, diff --git a/sys/sys/tim_filter.h b/sys/sys/tim_filter.h index b316fb0db3da..7eedf4e43bdc 100644 --- a/sys/sys/tim_filter.h +++ b/sys/sys/tim_filter.h @@ -24,8 +24,6 @@ * 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$ */ /* * Author: Randall Stewart <rrs@netflix.com> diff --git a/sys/sys/time.h b/sys/sys/time.h index ce4c7c1b555e..31020bbdfdd8 100644 --- a/sys/sys/time.h +++ b/sys/sys/time.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)time.h 8.5 (Berkeley) 5/4/95 - * $FreeBSD$ */ #ifndef _SYS_TIME_H_ @@ -159,117 +158,124 @@ sbttobt(sbintime_t _sbt) } /* - * Decimal<->sbt conversions. Multiplying or dividing by SBT_1NS results in - * large roundoff errors which sbttons() and nstosbt() avoid. Millisecond and - * microsecond functions are also provided for completeness. - * - * These functions return the smallest sbt larger or equal to the - * number of seconds requested so that sbttoX(Xtosbt(y)) == y. Unlike - * top of second computations below, which require that we tick at the - * top of second, these need to be rounded up so we do whatever for at - * least as long as requested. - * - * The naive computation we'd do is this - * ((unit * 2^64 / SIFACTOR) + 2^32-1) >> 32 - * However, that overflows. Instead, we compute - * ((unit * 2^63 / SIFACTOR) + 2^31-1) >> 32 - * and use pre-computed constants that are the ceil of the 2^63 / SIFACTOR - * term to ensure we are using exactly the right constant. We use the lesser - * evil of ull rather than a uint64_t cast to ensure we have well defined - * right shift semantics. With these changes, we get all the ns, us and ms - * conversions back and forth right. - * Note: This file is used for both kernel and userland includes, so we can't - * rely on KASSERT being defined, nor can we pollute the namespace by including - * assert.h. + * Scaling functions for signed and unsigned 64-bit time using any + * 32-bit fraction: */ + static __inline int64_t -sbttons(sbintime_t _sbt) +__stime64_scale32_ceil(int64_t x, int32_t factor, int32_t divisor) { - uint64_t ns; + const int64_t rem = x % divisor; -#ifdef KASSERT - KASSERT(_sbt >= 0, ("Negative values illegal for sbttons: %jx", _sbt)); -#endif - ns = _sbt; - if (ns >= SBT_1S) - ns = (ns >> 32) * 1000000000; - else - ns = 0; + return (x / divisor * factor + (rem * factor + divisor - 1) / divisor); +} + +static __inline int64_t +__stime64_scale32_floor(int64_t x, int32_t factor, int32_t divisor) +{ + const int64_t rem = x % divisor; - return (ns + (1000000000 * (_sbt & 0xffffffffu) >> 32)); + return (x / divisor * factor + (rem * factor) / divisor); } -static __inline sbintime_t -nstosbt(int64_t _ns) +static __inline uint64_t +__utime64_scale32_ceil(uint64_t x, uint32_t factor, uint32_t divisor) { - sbintime_t sb = 0; + const uint64_t rem = x % divisor; -#ifdef KASSERT - KASSERT(_ns >= 0, ("Negative values illegal for nstosbt: %jd", _ns)); -#endif - if (_ns >= 1000000000) { - sb = (_ns / 1000000000) * SBT_1S; - _ns = _ns % 1000000000; - } - /* 9223372037 = ceil(2^63 / 1000000000) */ - sb += ((_ns * 9223372037ull) + 0x7fffffff) >> 31; - return (sb); + return (x / divisor * factor + (rem * factor + divisor - 1) / divisor); } -static __inline int64_t -sbttous(sbintime_t _sbt) +static __inline uint64_t +__utime64_scale32_floor(uint64_t x, uint32_t factor, uint32_t divisor) { + const uint64_t rem = x % divisor; -#ifdef KASSERT - KASSERT(_sbt >= 0, ("Negative values illegal for sbttous: %jx", _sbt)); -#endif - return ((_sbt >> 32) * 1000000 + - (1000000 * (_sbt & 0xffffffffu) >> 32)); + return (x / divisor * factor + (rem * factor) / divisor); } -static __inline sbintime_t -ustosbt(int64_t _us) +/* + * This function finds the common divisor between the two arguments, + * in powers of two. Use a macro, so the compiler will output a + * warning if the value overflows! + * + * Detailed description: + * + * Create a variable with 1's at the positions of the leading 0's + * starting at the least significant bit, producing 0 if none (e.g., + * 01011000 -> 0000 0111). Then these two variables are bitwise AND'ed + * together, to produce the greatest common power of two minus one. In + * the end add one to flip the value to the actual power of two (e.g., + * 0000 0111 + 1 -> 0000 1000). + */ +#define __common_powers_of_two(a, b) \ + ((~(a) & ((a) - 1) & ~(b) & ((b) - 1)) + 1) + +/* + * Scaling functions for signed and unsigned 64-bit time assuming + * reducable 64-bit fractions to 32-bit fractions: + */ + +static __inline int64_t +__stime64_scale64_ceil(int64_t x, int64_t factor, int64_t divisor) { - sbintime_t sb = 0; + const int64_t gcd = __common_powers_of_two(factor, divisor); -#ifdef KASSERT - KASSERT(_us >= 0, ("Negative values illegal for ustosbt: %jd", _us)); -#endif - if (_us >= 1000000) { - sb = (_us / 1000000) * SBT_1S; - _us = _us % 1000000; - } - /* 9223372036855 = ceil(2^63 / 1000000) */ - sb += ((_us * 9223372036855ull) + 0x7fffffff) >> 31; - return (sb); + return (__stime64_scale32_ceil(x, factor / gcd, divisor / gcd)); } static __inline int64_t -sbttoms(sbintime_t _sbt) +__stime64_scale64_floor(int64_t x, int64_t factor, int64_t divisor) { -#ifdef KASSERT - KASSERT(_sbt >= 0, ("Negative values illegal for sbttoms: %jx", _sbt)); -#endif - return ((_sbt >> 32) * 1000 + (1000 * (_sbt & 0xffffffffu) >> 32)); + const int64_t gcd = __common_powers_of_two(factor, divisor); + + return (__stime64_scale32_floor(x, factor / gcd, divisor / gcd)); } -static __inline sbintime_t -mstosbt(int64_t _ms) +static __inline uint64_t +__utime64_scale64_ceil(uint64_t x, uint64_t factor, uint64_t divisor) { - sbintime_t sb = 0; + const uint64_t gcd = __common_powers_of_two(factor, divisor); -#ifdef KASSERT - KASSERT(_ms >= 0, ("Negative values illegal for mstosbt: %jd", _ms)); -#endif - if (_ms >= 1000) { - sb = (_ms / 1000) * SBT_1S; - _ms = _ms % 1000; - } - /* 9223372036854776 = ceil(2^63 / 1000) */ - sb += ((_ms * 9223372036854776ull) + 0x7fffffff) >> 31; - return (sb); + return (__utime64_scale32_ceil(x, factor / gcd, divisor / gcd)); +} + +static __inline uint64_t +__utime64_scale64_floor(uint64_t x, uint64_t factor, uint64_t divisor) +{ + const uint64_t gcd = __common_powers_of_two(factor, divisor); + + return (__utime64_scale32_floor(x, factor / gcd, divisor / gcd)); +} + +/* + * Decimal<->sbt conversions. Multiplying or dividing by SBT_1NS + * results in large roundoff errors which sbttons() and nstosbt() + * avoid. Millisecond and microsecond functions are also provided for + * completeness. + * + * When converting from sbt to another unit, the result is always + * rounded down. When converting back to sbt the result is always + * rounded up. This gives the property that sbttoX(Xtosbt(y)) == y . + * + * The conversion functions can also handle negative values. + */ +#define SBT_DECLARE_CONVERSION_PAIR(name, units_per_second) \ +static __inline int64_t \ +sbtto##name(sbintime_t sbt) \ +{ \ + return (__stime64_scale64_floor(sbt, units_per_second, SBT_1S)); \ +} \ +static __inline sbintime_t \ +name##tosbt(int64_t name) \ +{ \ + return (__stime64_scale64_ceil(name, SBT_1S, units_per_second)); \ } +SBT_DECLARE_CONVERSION_PAIR(ns, 1000000000) +SBT_DECLARE_CONVERSION_PAIR(us, 1000000) +SBT_DECLARE_CONVERSION_PAIR(ms, 1000) + /*- * Background information: * @@ -289,8 +295,8 @@ bintime2timespec(const struct bintime *_bt, struct timespec *_ts) { _ts->tv_sec = _bt->sec; - _ts->tv_nsec = ((uint64_t)1000000000 * - (uint32_t)(_bt->frac >> 32)) >> 32; + _ts->tv_nsec = __utime64_scale64_floor( + _bt->frac, 1000000000, 1ULL << 32) >> 32; } static __inline uint64_t @@ -299,8 +305,8 @@ bintime2ns(const struct bintime *_bt) uint64_t ret; ret = (uint64_t)(_bt->sec) * (uint64_t)1000000000; - ret += (((uint64_t)1000000000 * - (uint32_t)(_bt->frac >> 32)) >> 32); + ret += __utime64_scale64_floor( + _bt->frac, 1000000000, 1ULL << 32) >> 32; return (ret); } @@ -309,8 +315,8 @@ timespec2bintime(const struct timespec *_ts, struct bintime *_bt) { _bt->sec = _ts->tv_sec; - /* 18446744073 = int(2^64 / 1000000000) */ - _bt->frac = _ts->tv_nsec * (uint64_t)18446744073LL; + _bt->frac = __utime64_scale64_floor( + (uint64_t)_ts->tv_nsec << 32, 1ULL << 32, 1000000000); } static __inline void @@ -318,7 +324,8 @@ bintime2timeval(const struct bintime *_bt, struct timeval *_tv) { _tv->tv_sec = _bt->sec; - _tv->tv_usec = ((uint64_t)1000000 * (uint32_t)(_bt->frac >> 32)) >> 32; + _tv->tv_usec = __utime64_scale64_floor( + _bt->frac, 1000000, 1ULL << 32) >> 32; } static __inline void @@ -326,8 +333,8 @@ timeval2bintime(const struct timeval *_tv, struct bintime *_bt) { _bt->sec = _tv->tv_sec; - /* 18446744073709 = int(2^64 / 1000000) */ - _bt->frac = _tv->tv_usec * (uint64_t)18446744073709LL; + _bt->frac = __utime64_scale64_floor( + (uint64_t)_tv->tv_usec << 32, 1ULL << 32, 1000000); } static __inline struct timespec @@ -497,6 +504,7 @@ extern volatile time_t time_second; extern volatile time_t time_uptime; extern struct bintime tc_tick_bt; extern sbintime_t tc_tick_sbt; +extern time_t tick_seconds_max; extern struct bintime tick_bt; extern sbintime_t tick_sbt; extern int tc_precexp; @@ -569,12 +577,20 @@ void getboottimebin(struct bintime *boottimebin); /* Other functions */ int itimerdecr(struct itimerval *itp, int usec); int itimerfix(struct timeval *tv); -int ppsratecheck(struct timeval *, int *, int); +int eventratecheck(struct timeval *, int *, int); +#define ppsratecheck(t, c, m) eventratecheck(t, c, m) int ratecheck(struct timeval *, const struct timeval *); void timevaladd(struct timeval *t1, const struct timeval *t2); void timevalsub(struct timeval *t1, const struct timeval *t2); int tvtohz(struct timeval *tv); +/* + * The following HZ limits allow the tvtohz() function + * to only use integer computations. + */ +#define HZ_MAXIMUM (INT_MAX / (1000000 >> 6)) /* 137kHz */ +#define HZ_MINIMUM 8 /* hz */ + #define TC_DEFAULTPERC 5 #define BT2FREQ(bt) \ diff --git a/sys/sys/timeb.h b/sys/sys/timeb.h index 001ec3b5cfaf..952a5e83b8a7 100644 --- a/sys/sys/timeb.h +++ b/sys/sys/timeb.h @@ -34,7 +34,6 @@ * SUCH DAMAGE. * * @(#)timeb.h 8.2 (Berkeley) 1/21/94 - * $FreeBSD$ */ #ifndef _SYS_TIMEB_H_ diff --git a/sys/sys/timeet.h b/sys/sys/timeet.h index a809106b2369..0bd3f7c8941f 100644 --- a/sys/sys/timeet.h +++ b/sys/sys/timeet.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2010-2013 Alexander Motin <mav@FreeBSD.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_TIMEEC_H_ diff --git a/sys/sys/timeffc.h b/sys/sys/timeffc.h index 493a212b3f96..a83b62b1672c 100644 --- a/sys/sys/timeffc.h +++ b/sys/sys/timeffc.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2011 The University of Melbourne * All rights reserved. @@ -27,8 +27,6 @@ * 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$ */ #ifndef _SYS_TIMEFF_H_ diff --git a/sys/sys/timepps.h b/sys/sys/timepps.h index 292f7ea1b0f6..f32c7832ae0e 100644 --- a/sys/sys/timepps.h +++ b/sys/sys/timepps.h @@ -13,8 +13,6 @@ * Portions of this software were developed by Julien Ridoux at the University * of Melbourne under sponsorship from the FreeBSD Foundation. * - * $FreeBSD$ - * * The is a FreeBSD version of the RFC 2783 API for Pulse Per Second * timing interfaces. */ diff --git a/sys/sys/timerfd.h b/sys/sys/timerfd.h new file mode 100644 index 000000000000..cace3b71498c --- /dev/null +++ b/sys/sys/timerfd.h @@ -0,0 +1,72 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2023 Jake Freeland <jfree@FreeBSD.org> + * + * 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. + */ + +#ifndef _SYS_TIMERFD_H_ +#define _SYS_TIMERFD_H_ + +#include <sys/types.h> +#include <sys/fcntl.h> +/* + * We only need <sys/timespec.h>, but glibc pollutes the namespace + * with <time.h>. This pollution is expected by most programs, so + * reproduce it by including <sys/time.h> here. + */ +#include <sys/time.h> + +typedef uint64_t timerfd_t; + +/* Creation flags. */ +#define TFD_NONBLOCK O_NONBLOCK +#define TFD_CLOEXEC O_CLOEXEC + +/* Timer flags. */ +#define TFD_TIMER_ABSTIME 0x01 +#define TFD_TIMER_CANCEL_ON_SET 0x02 + +#ifndef _KERNEL + +__BEGIN_DECLS +int timerfd_create(int clockid, int flags); +int timerfd_gettime(int fd, struct itimerspec *curr_value); +int timerfd_settime(int fd, int flags, const struct itimerspec *new_value, + struct itimerspec *old_value); +__END_DECLS + +#else /* _KERNEL */ + +struct thread; + +int kern_timerfd_create(struct thread *td, int clockid, int flags); +int kern_timerfd_gettime(struct thread *td, int fd, + struct itimerspec *curr_value); +int kern_timerfd_settime(struct thread *td, int fd, int flags, + const struct itimerspec *new_value, struct itimerspec *old_value); +void timerfd_jumped(void); + +#endif /* !_KERNEL */ + +#endif /* !_SYS_TIMERFD_H_ */ diff --git a/sys/sys/timers.h b/sys/sys/timers.h index 9e4597bca21b..e62a15def52f 100644 --- a/sys/sys/timers.h +++ b/sys/sys/timers.h @@ -32,8 +32,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ - * * Description : Basic timers header. */ diff --git a/sys/sys/times.h b/sys/sys/times.h index 0c690e5635fc..f9fdf735879b 100644 --- a/sys/sys/times.h +++ b/sys/sys/times.h @@ -34,7 +34,6 @@ * SUCH DAMAGE. * * @(#)times.h 8.4 (Berkeley) 1/21/94 - * $FreeBSD$ */ #ifndef _SYS_TIMES_H_ diff --git a/sys/sys/timespec.h b/sys/sys/timespec.h index fa3812a08388..4de69e3417a7 100644 --- a/sys/sys/timespec.h +++ b/sys/sys/timespec.h @@ -30,7 +30,6 @@ * * @(#)time.h 8.5 (Berkeley) 5/4/95 * from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp - * $FreeBSD$ */ #ifndef _SYS_TIMESPEC_H_ diff --git a/sys/sys/timetc.h b/sys/sys/timetc.h index 811cc1af461a..fed3284e21b5 100644 --- a/sys/sys/timetc.h +++ b/sys/sys/timetc.h @@ -7,8 +7,6 @@ * can do whatever you want with this stuff. If we meet some day, and you think * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- - * - * $FreeBSD$ */ #ifndef _SYS_TIMETC_H_ diff --git a/sys/sys/timex.h b/sys/sys/timex.h index 4fa5735e2d45..072297375792 100644 --- a/sys/sys/timex.h +++ b/sys/sys/timex.h @@ -18,8 +18,6 @@ * * *********************************************************************** * - * $FreeBSD$ - * * This header file defines the Network Time Protocol (NTP) interfaces * for user and daemon application programs. * diff --git a/sys/sys/tree.h b/sys/sys/tree.h index bc01e4de910a..c11bccfb387c 100644 --- a/sys/sys/tree.h +++ b/sys/sys/tree.h @@ -1,9 +1,8 @@ /* $NetBSD: tree.h,v 1.8 2004/03/28 19:38:30 provos Exp $ */ /* $OpenBSD: tree.h,v 1.7 2002/10/17 21:51:54 art Exp $ */ -/* $FreeBSD$ */ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright 2002 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -56,9 +55,11 @@ * the same, and defines the rank of that node. The rank of the null node * is -1. * - * Different additional conditions define different sorts of balanced - * trees, including "red-black" and "AVL" trees. The set of conditions - * applied here are the "weak-AVL" conditions of Haeupler, Sen and Tarjan: + * Different additional conditions define different sorts of balanced trees, + * including "red-black" and "AVL" trees. The set of conditions applied here + * are the "weak-AVL" conditions of Haeupler, Sen and Tarjan presented in in + * "Rank Balanced Trees", ACM Transactions on Algorithms Volume 11 Issue 4 June + * 2015 Article No.: 30pp 1–26 https://doi.org/10.1145/2689412 (the HST paper): * - every rank-difference is 1 or 2. * - the rank of any leaf is 1. * @@ -163,7 +164,7 @@ static __unused __inline struct type * \ name##_SPLAY_MIN_MAX(struct name *head, int val) \ { \ name##_SPLAY_MINMAX(head, val); \ - return (SPLAY_ROOT(head)); \ + return (SPLAY_ROOT(head)); \ } /* Main splay operation. @@ -176,7 +177,7 @@ name##_SPLAY_INSERT(struct name *head, struct type *elm) \ if (SPLAY_EMPTY(head)) { \ SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \ } else { \ - int __comp; \ + __typeof(cmp(NULL, NULL)) __comp; \ name##_SPLAY(head, elm); \ __comp = (cmp)(elm, (head)->sph_root); \ if (__comp < 0) { \ @@ -219,7 +220,7 @@ void \ name##_SPLAY(struct name *head, struct type *elm) \ { \ struct type __node, *__left, *__right, *__tmp; \ - int __comp; \ + __typeof(cmp(NULL, NULL)) __comp; \ \ SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\ __left = __right = &__node; \ @@ -318,14 +319,9 @@ struct name { \ #define RB_ENTRY(type) \ struct { \ - struct type *rbe_left; /* left element */ \ - struct type *rbe_right; /* right element */ \ - struct type *rbe_parent; /* parent element */ \ + struct type *rbe_link[3]; \ } -#define RB_LEFT(elm, field) (elm)->field.rbe_left -#define RB_RIGHT(elm, field) (elm)->field.rbe_right - /* * With the expectation that any object of struct type has an * address that is a multiple of 4, and that therefore the @@ -333,74 +329,79 @@ struct { \ * always zero, this implementation sets those bits to indicate * that the left or right child of the tree node is "red". */ -#define RB_UP(elm, field) (elm)->field.rbe_parent -#define RB_BITS(elm, field) (*(__uintptr_t *)&RB_UP(elm, field)) -#define RB_RED_L ((__uintptr_t)1) -#define RB_RED_R ((__uintptr_t)2) -#define RB_RED_MASK ((__uintptr_t)3) -#define RB_FLIP_LEFT(elm, field) (RB_BITS(elm, field) ^= RB_RED_L) -#define RB_FLIP_RIGHT(elm, field) (RB_BITS(elm, field) ^= RB_RED_R) -#define RB_RED_LEFT(elm, field) ((RB_BITS(elm, field) & RB_RED_L) != 0) -#define RB_RED_RIGHT(elm, field) ((RB_BITS(elm, field) & RB_RED_R) != 0) -#define RB_PARENT(elm, field) ((__typeof(RB_UP(elm, field))) \ - (RB_BITS(elm, field) & ~RB_RED_MASK)) +#define _RB_LINK(elm, dir, field) (elm)->field.rbe_link[dir] +#define _RB_UP(elm, field) _RB_LINK(elm, 0, field) +#define _RB_L ((__uintptr_t)1) +#define _RB_R ((__uintptr_t)2) +#define _RB_LR ((__uintptr_t)3) +#define _RB_BITS(elm) (*(__uintptr_t *)&elm) +#define _RB_BITSUP(elm, field) _RB_BITS(_RB_UP(elm, field)) +#define _RB_PTR(elm) (__typeof(elm)) \ + ((__uintptr_t)elm & ~_RB_LR) + +#define RB_PARENT(elm, field) _RB_PTR(_RB_UP(elm, field)) +#define RB_LEFT(elm, field) _RB_LINK(elm, _RB_L, field) +#define RB_RIGHT(elm, field) _RB_LINK(elm, _RB_R, field) #define RB_ROOT(head) (head)->rbh_root #define RB_EMPTY(head) (RB_ROOT(head) == NULL) #define RB_SET_PARENT(dst, src, field) do { \ - RB_BITS(dst, field) &= RB_RED_MASK; \ - RB_BITS(dst, field) |= (__uintptr_t)src; \ + _RB_BITSUP(dst, field) = (__uintptr_t)src | \ + (_RB_BITSUP(dst, field) & _RB_LR); \ } while (/*CONSTCOND*/ 0) #define RB_SET(elm, parent, field) do { \ - RB_UP(elm, field) = parent; \ + _RB_UP(elm, field) = parent; \ RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL; \ } while (/*CONSTCOND*/ 0) -#define RB_COLOR(elm, field) (RB_PARENT(elm, field) == NULL ? 0 : \ - RB_LEFT(RB_PARENT(elm, field), field) == elm ? \ - RB_RED_LEFT(RB_PARENT(elm, field), field) : \ - RB_RED_RIGHT(RB_PARENT(elm, field), field)) - /* - * Something to be invoked in a loop at the root of every modified subtree, - * from the bottom up to the root, to update augmented node data. + * Either RB_AUGMENT or RB_AUGMENT_CHECK is invoked in a loop at the root of + * every modified subtree, from the bottom up to the root, to update augmented + * node data. RB_AUGMENT_CHECK returns true only when the update changes the + * node data, so that updating can be stopped short of the root when it returns + * false. */ +#ifndef RB_AUGMENT_CHECK #ifndef RB_AUGMENT -#define RB_AUGMENT(x) break +#define RB_AUGMENT_CHECK(x) 0 +#else +#define RB_AUGMENT_CHECK(x) (RB_AUGMENT(x), 1) +#endif #endif -#define RB_SWAP_CHILD(head, out, in, field) do { \ - if (RB_PARENT(out, field) == NULL) \ +#define RB_UPDATE_AUGMENT(elm, field) do { \ + __typeof(elm) rb_update_tmp = (elm); \ + while (RB_AUGMENT_CHECK(rb_update_tmp) && \ + (rb_update_tmp = RB_PARENT(rb_update_tmp, field)) != NULL) \ + ; \ +} while (0) + +#define RB_SWAP_CHILD(head, par, out, in, field) do { \ + if (par == NULL) \ RB_ROOT(head) = (in); \ - else if ((out) == RB_LEFT(RB_PARENT(out, field), field)) \ - RB_LEFT(RB_PARENT(out, field), field) = (in); \ + else if ((out) == RB_LEFT(par, field)) \ + RB_LEFT(par, field) = (in); \ else \ - RB_RIGHT(RB_PARENT(out, field), field) = (in); \ + RB_RIGHT(par, field) = (in); \ } while (/*CONSTCOND*/ 0) -#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \ - (tmp) = RB_RIGHT(elm, field); \ - if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field)) != NULL) { \ - RB_SET_PARENT(RB_RIGHT(elm, field), elm, field); \ - } \ - RB_SET_PARENT(tmp, RB_PARENT(elm, field), field); \ - RB_SWAP_CHILD(head, elm, tmp, field); \ - RB_LEFT(tmp, field) = (elm); \ - RB_SET_PARENT(elm, tmp, field); \ - RB_AUGMENT(elm); \ -} while (/*CONSTCOND*/ 0) - -#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \ - (tmp) = RB_LEFT(elm, field); \ - if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field)) != NULL) { \ - RB_SET_PARENT(RB_LEFT(elm, field), elm, field); \ - } \ - RB_SET_PARENT(tmp, RB_PARENT(elm, field), field); \ - RB_SWAP_CHILD(head, elm, tmp, field); \ - RB_RIGHT(tmp, field) = (elm); \ +/* + * RB_ROTATE macro partially restructures the tree to improve balance. In the + * case when dir is _RB_L, tmp is a right child of elm. After rotation, elm + * is a left child of tmp, and the subtree that represented the items between + * them, which formerly hung to the left of tmp now hangs to the right of elm. + * The parent-child relationship between elm and its former parent is not + * changed; where this macro once updated those fields, that is now left to the + * caller of RB_ROTATE to clean up, so that a pair of rotations does not twice + * update the same pair of pointer fields with distinct values. + */ +#define RB_ROTATE(elm, tmp, dir, field) do { \ + if ((_RB_LINK(elm, dir ^ _RB_LR, field) = \ + _RB_LINK(tmp, dir, field)) != NULL) \ + RB_SET_PARENT(_RB_LINK(tmp, dir, field), elm, field); \ + _RB_LINK(tmp, dir, field) = (elm); \ RB_SET_PARENT(elm, tmp, field); \ - RB_AUGMENT(elm); \ } while (/*CONSTCOND*/ 0) /* Generates prototypes and inline functions */ @@ -409,23 +410,37 @@ struct { \ #define RB_PROTOTYPE_STATIC(name, type, field, cmp) \ RB_PROTOTYPE_INTERNAL(name, type, field, cmp, __unused static) #define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr) \ + RB_PROTOTYPE_RANK(name, type, attr) \ RB_PROTOTYPE_INSERT_COLOR(name, type, attr); \ RB_PROTOTYPE_REMOVE_COLOR(name, type, attr); \ + RB_PROTOTYPE_INSERT_FINISH(name, type, attr); \ RB_PROTOTYPE_INSERT(name, type, attr); \ RB_PROTOTYPE_REMOVE(name, type, attr); \ RB_PROTOTYPE_FIND(name, type, attr); \ RB_PROTOTYPE_NFIND(name, type, attr); \ RB_PROTOTYPE_NEXT(name, type, attr); \ + RB_PROTOTYPE_INSERT_NEXT(name, type, attr); \ RB_PROTOTYPE_PREV(name, type, attr); \ + RB_PROTOTYPE_INSERT_PREV(name, type, attr); \ RB_PROTOTYPE_MINMAX(name, type, attr); \ RB_PROTOTYPE_REINSERT(name, type, attr); +#ifdef _RB_DIAGNOSTIC +#define RB_PROTOTYPE_RANK(name, type, attr) \ + attr int name##_RB_RANK(struct type *); +#else +#define RB_PROTOTYPE_RANK(name, type, attr) +#endif #define RB_PROTOTYPE_INSERT_COLOR(name, type, attr) \ - attr void name##_RB_INSERT_COLOR(struct name *, struct type *) + attr struct type *name##_RB_INSERT_COLOR(struct name *, \ + struct type *, struct type *) #define RB_PROTOTYPE_REMOVE_COLOR(name, type, attr) \ - attr void name##_RB_REMOVE_COLOR(struct name *, \ + attr struct type *name##_RB_REMOVE_COLOR(struct name *, \ struct type *, struct type *) #define RB_PROTOTYPE_REMOVE(name, type, attr) \ attr struct type *name##_RB_REMOVE(struct name *, struct type *) +#define RB_PROTOTYPE_INSERT_FINISH(name, type, attr) \ + attr struct type *name##_RB_INSERT_FINISH(struct name *, \ + struct type *, struct type **, struct type *) #define RB_PROTOTYPE_INSERT(name, type, attr) \ attr struct type *name##_RB_INSERT(struct name *, struct type *) #define RB_PROTOTYPE_FIND(name, type, attr) \ @@ -434,8 +449,14 @@ struct { \ attr struct type *name##_RB_NFIND(struct name *, struct type *) #define RB_PROTOTYPE_NEXT(name, type, attr) \ attr struct type *name##_RB_NEXT(struct type *) +#define RB_PROTOTYPE_INSERT_NEXT(name, type, attr) \ + attr struct type *name##_RB_INSERT_NEXT(struct name *, \ + struct type *, struct type *) #define RB_PROTOTYPE_PREV(name, type, attr) \ attr struct type *name##_RB_PREV(struct type *) +#define RB_PROTOTYPE_INSERT_PREV(name, type, attr) \ + attr struct type *name##_RB_INSERT_PREV(struct name *, \ + struct type *, struct type *) #define RB_PROTOTYPE_MINMAX(name, type, attr) \ attr struct type *name##_RB_MINMAX(struct name *, int) #define RB_PROTOTYPE_REINSERT(name, type, attr) \ @@ -449,189 +470,371 @@ struct { \ #define RB_GENERATE_STATIC(name, type, field, cmp) \ RB_GENERATE_INTERNAL(name, type, field, cmp, __unused static) #define RB_GENERATE_INTERNAL(name, type, field, cmp, attr) \ + RB_GENERATE_RANK(name, type, field, attr) \ RB_GENERATE_INSERT_COLOR(name, type, field, attr) \ RB_GENERATE_REMOVE_COLOR(name, type, field, attr) \ + RB_GENERATE_INSERT_FINISH(name, type, field, attr) \ RB_GENERATE_INSERT(name, type, field, cmp, attr) \ RB_GENERATE_REMOVE(name, type, field, attr) \ RB_GENERATE_FIND(name, type, field, cmp, attr) \ RB_GENERATE_NFIND(name, type, field, cmp, attr) \ RB_GENERATE_NEXT(name, type, field, attr) \ + RB_GENERATE_INSERT_NEXT(name, type, field, cmp, attr) \ RB_GENERATE_PREV(name, type, field, attr) \ + RB_GENERATE_INSERT_PREV(name, type, field, cmp, attr) \ RB_GENERATE_MINMAX(name, type, field, attr) \ RB_GENERATE_REINSERT(name, type, field, cmp, attr) +#ifdef _RB_DIAGNOSTIC +#ifndef RB_AUGMENT +#define _RB_AUGMENT_VERIFY(x) RB_AUGMENT_CHECK(x) +#else +#define _RB_AUGMENT_VERIFY(x) 0 +#endif +#define RB_GENERATE_RANK(name, type, field, attr) \ +/* \ + * Return the rank of the subtree rooted at elm, or -1 if the subtree \ + * is not rank-balanced, or has inconsistent augmentation data. + */ \ +attr int \ +name##_RB_RANK(struct type *elm) \ +{ \ + struct type *left, *right, *up; \ + int left_rank, right_rank; \ + \ + if (elm == NULL) \ + return (0); \ + up = _RB_UP(elm, field); \ + left = RB_LEFT(elm, field); \ + left_rank = ((_RB_BITS(up) & _RB_L) ? 2 : 1) + \ + name##_RB_RANK(left); \ + right = RB_RIGHT(elm, field); \ + right_rank = ((_RB_BITS(up) & _RB_R) ? 2 : 1) + \ + name##_RB_RANK(right); \ + if (left_rank != right_rank || \ + (left_rank == 2 && left == NULL && right == NULL) || \ + _RB_AUGMENT_VERIFY(elm)) \ + return (-1); \ + return (left_rank); \ +} +#else +#define RB_GENERATE_RANK(name, type, field, attr) +#endif + #define RB_GENERATE_INSERT_COLOR(name, type, field, attr) \ -attr void \ -name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ +attr struct type * \ +name##_RB_INSERT_COLOR(struct name *head, \ + struct type *parent, struct type *elm) \ { \ - struct type *child, *parent; \ - while ((parent = RB_PARENT(elm, field)) != NULL) { \ - if (RB_LEFT(parent, field) == elm) { \ - if (RB_RED_LEFT(parent, field)) { \ - RB_FLIP_LEFT(parent, field); \ - return; \ - } \ - RB_FLIP_RIGHT(parent, field); \ - if (RB_RED_RIGHT(parent, field)) { \ - elm = parent; \ - continue; \ - } \ - if (!RB_RED_RIGHT(elm, field)) { \ - RB_FLIP_LEFT(elm, field); \ - RB_ROTATE_LEFT(head, elm, child, field);\ - if (RB_RED_LEFT(child, field)) \ - RB_FLIP_RIGHT(elm, field); \ - else if (RB_RED_RIGHT(child, field)) \ - RB_FLIP_LEFT(parent, field); \ - elm = child; \ - } \ - RB_ROTATE_RIGHT(head, parent, elm, field); \ - } else { \ - if (RB_RED_RIGHT(parent, field)) { \ - RB_FLIP_RIGHT(parent, field); \ - return; \ - } \ - RB_FLIP_LEFT(parent, field); \ - if (RB_RED_LEFT(parent, field)) { \ - elm = parent; \ - continue; \ - } \ - if (!RB_RED_LEFT(elm, field)) { \ - RB_FLIP_RIGHT(elm, field); \ - RB_ROTATE_RIGHT(head, elm, child, field);\ - if (RB_RED_RIGHT(child, field)) \ - RB_FLIP_LEFT(elm, field); \ - else if (RB_RED_LEFT(child, field)) \ - RB_FLIP_RIGHT(parent, field); \ - elm = child; \ - } \ - RB_ROTATE_LEFT(head, parent, elm, field); \ + /* \ + * Initially, elm is a leaf. Either its parent was previously \ + * a leaf, with two black null children, or an interior node \ + * with a black non-null child and a red null child. The \ + * balance criterion "the rank of any leaf is 1" precludes the \ + * possibility of two red null children for the initial parent. \ + * So the first loop iteration cannot lead to accessing an \ + * uninitialized 'child', and a later iteration can only happen \ + * when a value has been assigned to 'child' in the previous \ + * one. \ + */ \ + struct type *child, *child_up, *gpar; \ + __uintptr_t elmdir, sibdir; \ + \ + do { \ + /* the rank of the tree rooted at elm grew */ \ + gpar = _RB_UP(parent, field); \ + elmdir = RB_RIGHT(parent, field) == elm ? _RB_R : _RB_L; \ + if (_RB_BITS(gpar) & elmdir) { \ + /* shorten the parent-elm edge to rebalance */ \ + _RB_BITSUP(parent, field) ^= elmdir; \ + return (NULL); \ } \ - RB_BITS(elm, field) &= ~RB_RED_MASK; \ - break; \ - } \ + sibdir = elmdir ^ _RB_LR; \ + /* the other edge must change length */ \ + _RB_BITSUP(parent, field) ^= sibdir; \ + if ((_RB_BITS(gpar) & _RB_LR) == 0) { \ + /* both edges now short, retry from parent */ \ + child = elm; \ + elm = parent; \ + continue; \ + } \ + _RB_UP(parent, field) = gpar = _RB_PTR(gpar); \ + if (_RB_BITSUP(elm, field) & elmdir) { \ + /* \ + * Exactly one of the edges descending from elm \ + * is long. The long one is in the same \ + * direction as the edge from parent to elm, \ + * so change that by rotation. The edge from \ + * parent to z was shortened above. Shorten \ + * the long edge down from elm, and adjust \ + * other edge lengths based on the downward \ + * edges from 'child'. \ + * \ + * par par \ + * / \ / \ \ + * elm z / z \ + * / \ child \ + * / child / \ \ + * / / \ elm \ \ + * w / \ / \ y \ + * x y w \ \ + * x \ + */ \ + RB_ROTATE(elm, child, elmdir, field); \ + child_up = _RB_UP(child, field); \ + if (_RB_BITS(child_up) & sibdir) \ + _RB_BITSUP(parent, field) ^= elmdir; \ + if (_RB_BITS(child_up) & elmdir) \ + _RB_BITSUP(elm, field) ^= _RB_LR; \ + else \ + _RB_BITSUP(elm, field) ^= elmdir; \ + /* if child is a leaf, don't augment elm, \ + * since it is restored to be a leaf again. */ \ + if ((_RB_BITS(child_up) & _RB_LR) == 0) \ + elm = child; \ + } else \ + child = elm; \ + \ + /* \ + * The long edge descending from 'child' points back \ + * in the direction of 'parent'. Rotate to make \ + * 'parent' a child of 'child', then make both edges \ + * of 'child' short to rebalance. \ + * \ + * par child \ + * / \ / \ \ + * / z x par \ + * child / \ \ + * / \ / z \ + * x \ y \ + * y \ + */ \ + RB_ROTATE(parent, child, sibdir, field); \ + _RB_UP(child, field) = gpar; \ + RB_SWAP_CHILD(head, gpar, parent, child, field); \ + /* \ + * Elements rotated down have new, smaller subtrees, \ + * so update augmentation for them. \ + */ \ + if (elm != child) \ + (void)RB_AUGMENT_CHECK(elm); \ + (void)RB_AUGMENT_CHECK(parent); \ + return (child); \ + } while ((parent = gpar) != NULL); \ + return (NULL); \ } +#ifndef RB_STRICT_HST +/* + * In REMOVE_COLOR, the HST paper, in figure 3, in the single-rotate case, has + * 'parent' with one higher rank, and then reduces its rank if 'parent' has + * become a leaf. This implementation always has the parent in its new position + * with lower rank, to avoid the leaf check. Define RB_STRICT_HST to 1 to get + * the behavior that HST describes. + */ +#define RB_STRICT_HST 0 +#endif + #define RB_GENERATE_REMOVE_COLOR(name, type, field, attr) \ -attr void \ +attr struct type * \ name##_RB_REMOVE_COLOR(struct name *head, \ struct type *parent, struct type *elm) \ { \ - struct type *sib; \ - if (RB_LEFT(parent, field) == elm && \ - RB_RIGHT(parent, field) == elm) { \ - RB_BITS(parent, field) &= ~RB_RED_MASK; \ + struct type *gpar, *sib, *up; \ + __uintptr_t elmdir, sibdir; \ + \ + if (RB_RIGHT(parent, field) == elm && \ + RB_LEFT(parent, field) == elm) { \ + /* Deleting a leaf that is an only-child creates a \ + * rank-2 leaf. Demote that leaf. */ \ + _RB_UP(parent, field) = _RB_PTR(_RB_UP(parent, field)); \ elm = parent; \ - parent = RB_PARENT(elm, field); \ - if (parent == NULL) \ - return; \ + if ((parent = _RB_UP(elm, field)) == NULL) \ + return (NULL); \ } \ - do { \ - if (RB_LEFT(parent, field) == elm) { \ - if (!RB_RED_LEFT(parent, field)) { \ - RB_FLIP_LEFT(parent, field); \ - return; \ - } \ - if (RB_RED_RIGHT(parent, field)) { \ - RB_FLIP_RIGHT(parent, field); \ - elm = parent; \ - continue; \ - } \ - sib = RB_RIGHT(parent, field); \ - if ((~RB_BITS(sib, field) & RB_RED_MASK) == 0) {\ - RB_BITS(sib, field) &= ~RB_RED_MASK; \ - elm = parent; \ - continue; \ - } \ - RB_FLIP_RIGHT(sib, field); \ - if (RB_RED_LEFT(sib, field)) \ - RB_FLIP_LEFT(parent, field); \ - else if (!RB_RED_RIGHT(sib, field)) { \ - RB_FLIP_LEFT(parent, field); \ - RB_ROTATE_RIGHT(head, sib, elm, field); \ - if (RB_RED_RIGHT(elm, field)) \ - RB_FLIP_LEFT(sib, field); \ - if (RB_RED_LEFT(elm, field)) \ - RB_FLIP_RIGHT(parent, field); \ - RB_BITS(elm, field) |= RB_RED_MASK; \ - sib = elm; \ - } \ - RB_ROTATE_LEFT(head, parent, sib, field); \ + do { \ + /* the rank of the tree rooted at elm shrank */ \ + gpar = _RB_UP(parent, field); \ + elmdir = RB_RIGHT(parent, field) == elm ? _RB_R : _RB_L; \ + _RB_BITS(gpar) ^= elmdir; \ + if (_RB_BITS(gpar) & elmdir) { \ + /* lengthen the parent-elm edge to rebalance */ \ + _RB_UP(parent, field) = gpar; \ + return (NULL); \ + } \ + if (_RB_BITS(gpar) & _RB_LR) { \ + /* shorten other edge, retry from parent */ \ + _RB_BITS(gpar) ^= _RB_LR; \ + _RB_UP(parent, field) = gpar; \ + gpar = _RB_PTR(gpar); \ + continue; \ + } \ + sibdir = elmdir ^ _RB_LR; \ + sib = _RB_LINK(parent, sibdir, field); \ + up = _RB_UP(sib, field); \ + _RB_BITS(up) ^= _RB_LR; \ + if ((_RB_BITS(up) & _RB_LR) == 0) { \ + /* shorten edges descending from sib, retry */ \ + _RB_UP(sib, field) = up; \ + continue; \ + } \ + if ((_RB_BITS(up) & sibdir) == 0) { \ + /* \ + * The edge descending from 'sib' away from \ + * 'parent' is long. The short edge descending \ + * from 'sib' toward 'parent' points to 'elm*' \ + * Rotate to make 'sib' a child of 'elm*' \ + * then adjust the lengths of the edges \ + * descending from 'sib' and 'elm*'. \ + * \ + * par par \ + * / \ / \ \ + * / sib elm \ \ + * / / \ elm* \ + * elm elm* \ / \ \ + * / \ \ / \ \ + * / \ z / \ \ + * x y x sib \ + * / \ \ + * / z \ + * y \ + */ \ + elm = _RB_LINK(sib, elmdir, field); \ + /* elm is a 1-child. First rotate at elm. */ \ + RB_ROTATE(sib, elm, sibdir, field); \ + up = _RB_UP(elm, field); \ + _RB_BITSUP(parent, field) ^= \ + (_RB_BITS(up) & elmdir) ? _RB_LR : elmdir; \ + _RB_BITSUP(sib, field) ^= \ + (_RB_BITS(up) & sibdir) ? _RB_LR : sibdir; \ + _RB_BITSUP(elm, field) |= _RB_LR; \ } else { \ - if (!RB_RED_RIGHT(parent, field)) { \ - RB_FLIP_RIGHT(parent, field); \ - return; \ - } \ - if (RB_RED_LEFT(parent, field)) { \ - RB_FLIP_LEFT(parent, field); \ - elm = parent; \ - continue; \ - } \ - sib = RB_LEFT(parent, field); \ - if ((~RB_BITS(sib, field) & RB_RED_MASK) == 0) {\ - RB_BITS(sib, field) &= ~RB_RED_MASK; \ - elm = parent; \ - continue; \ - } \ - RB_FLIP_LEFT(sib, field); \ - if (RB_RED_RIGHT(sib, field)) \ - RB_FLIP_RIGHT(parent, field); \ - else if (!RB_RED_LEFT(sib, field)) { \ - RB_FLIP_RIGHT(parent, field); \ - RB_ROTATE_LEFT(head, sib, elm, field); \ - if (RB_RED_LEFT(elm, field)) \ - RB_FLIP_RIGHT(sib, field); \ - if (RB_RED_RIGHT(elm, field)) \ - RB_FLIP_LEFT(parent, field); \ - RB_BITS(elm, field) |= RB_RED_MASK; \ - sib = elm; \ - } \ - RB_ROTATE_RIGHT(head, parent, sib, field); \ + if ((_RB_BITS(up) & elmdir) == 0 && \ + RB_STRICT_HST && elm != NULL) { \ + /* if parent does not become a leaf, \ + do not demote parent yet. */ \ + _RB_BITSUP(parent, field) ^= sibdir; \ + _RB_BITSUP(sib, field) ^= _RB_LR; \ + } else if ((_RB_BITS(up) & elmdir) == 0) { \ + /* demote parent. */ \ + _RB_BITSUP(parent, field) ^= elmdir; \ + _RB_BITSUP(sib, field) ^= sibdir; \ + } else \ + _RB_BITSUP(sib, field) ^= sibdir; \ + elm = sib; \ } \ - break; \ - } while ((parent = RB_PARENT(elm, field)) != NULL); \ + \ + /* \ + * The edge descending from 'elm' away from 'parent' \ + * is short. Rotate to make 'parent' a child of 'elm', \ + * then lengthen the short edges descending from \ + * 'parent' and 'elm' to rebalance. \ + * \ + * par elm \ + * / \ / \ \ + * e \ / \ \ + * elm / \ \ + * / \ par s \ + * / \ / \ \ + * / \ e \ \ + * x s x \ + */ \ + RB_ROTATE(parent, elm, elmdir, field); \ + RB_SET_PARENT(elm, gpar, field); \ + RB_SWAP_CHILD(head, gpar, parent, elm, field); \ + /* \ + * An element rotated down, but not into the search \ + * path has a new, smaller subtree, so update \ + * augmentation for it. \ + */ \ + if (sib != elm) \ + (void)RB_AUGMENT_CHECK(sib); \ + return (parent); \ + } while (elm = parent, (parent = gpar) != NULL); \ + return (NULL); \ } +#define _RB_AUGMENT_WALK(elm, match, field) \ +do { \ + if (match == elm) \ + match = NULL; \ +} while (RB_AUGMENT_CHECK(elm) && \ + (elm = RB_PARENT(elm, field)) != NULL) + #define RB_GENERATE_REMOVE(name, type, field, attr) \ attr struct type * \ -name##_RB_REMOVE(struct name *head, struct type *elm) \ +name##_RB_REMOVE(struct name *head, struct type *out) \ { \ - struct type *child, *old, *parent, *right; \ + struct type *child, *in, *opar, *parent; \ \ - old = elm; \ - parent = RB_PARENT(elm, field); \ - right = RB_RIGHT(elm, field); \ - if (RB_LEFT(elm, field) == NULL) \ - elm = child = right; \ - else if (right == NULL) \ - elm = child = RB_LEFT(elm, field); \ - else { \ - if ((child = RB_LEFT(right, field)) == NULL) { \ - child = RB_RIGHT(right, field); \ - RB_RIGHT(old, field) = child; \ - parent = elm = right; \ - } else { \ - do \ - elm = child; \ - while ((child = RB_LEFT(elm, field)) != NULL); \ - child = RB_RIGHT(elm, field); \ - parent = RB_PARENT(elm, field); \ + child = RB_LEFT(out, field); \ + in = RB_RIGHT(out, field); \ + opar = _RB_UP(out, field); \ + if (in == NULL || child == NULL) { \ + in = child = (in == NULL ? child : in); \ + parent = opar = _RB_PTR(opar); \ + } else { \ + parent = in; \ + while (RB_LEFT(in, field)) \ + in = RB_LEFT(in, field); \ + RB_SET_PARENT(child, in, field); \ + RB_LEFT(in, field) = child; \ + child = RB_RIGHT(in, field); \ + if (parent != in) { \ + RB_SET_PARENT(parent, in, field); \ + RB_RIGHT(in, field) = parent; \ + parent = RB_PARENT(in, field); \ RB_LEFT(parent, field) = child; \ - RB_SET_PARENT(RB_RIGHT(old, field), elm, field);\ } \ - RB_SET_PARENT(RB_LEFT(old, field), elm, field); \ - elm->field = old->field; \ + _RB_UP(in, field) = opar; \ + opar = _RB_PTR(opar); \ } \ - RB_SWAP_CHILD(head, old, elm, field); \ + RB_SWAP_CHILD(head, opar, out, in, field); \ if (child != NULL) \ - RB_SET_PARENT(child, parent, field); \ - if (parent != NULL) \ - name##_RB_REMOVE_COLOR(head, parent, child); \ - while (parent != NULL) { \ - RB_AUGMENT(parent); \ - parent = RB_PARENT(parent, field); \ + _RB_UP(child, field) = parent; \ + if (parent != NULL) { \ + opar = name##_RB_REMOVE_COLOR(head, parent, child); \ + /* if rotation has made 'parent' the root of the same \ + * subtree as before, don't re-augment it. */ \ + if (parent == in && RB_LEFT(parent, field) == NULL) { \ + opar = NULL; \ + parent = RB_PARENT(parent, field); \ + } \ + _RB_AUGMENT_WALK(parent, opar, field); \ + if (opar != NULL) { \ + /* \ + * Elements rotated into the search path have \ + * changed subtrees, so update augmentation for \ + * them if AUGMENT_WALK didn't. \ + */ \ + (void)RB_AUGMENT_CHECK(opar); \ + (void)RB_AUGMENT_CHECK(RB_PARENT(opar, field)); \ + } \ } \ - return (old); \ + return (out); \ +} + +#define RB_GENERATE_INSERT_FINISH(name, type, field, attr) \ +/* Inserts a node into the RB tree */ \ +attr struct type * \ +name##_RB_INSERT_FINISH(struct name *head, struct type *parent, \ + struct type **pptr, struct type *elm) \ +{ \ + struct type *tmp = NULL; \ + \ + RB_SET(elm, parent, field); \ + *pptr = elm; \ + if (parent != NULL) \ + tmp = name##_RB_INSERT_COLOR(head, parent, elm); \ + _RB_AUGMENT_WALK(elm, tmp, field); \ + if (tmp != NULL) \ + /* \ + * An element rotated into the search path has a \ + * changed subtree, so update augmentation for it if \ + * AUGMENT_WALK didn't. \ + */ \ + (void)RB_AUGMENT_CHECK(tmp); \ + return (NULL); \ } #define RB_GENERATE_INSERT(name, type, field, cmp, attr) \ @@ -640,32 +843,20 @@ attr struct type * \ name##_RB_INSERT(struct name *head, struct type *elm) \ { \ struct type *tmp; \ + struct type **tmpp = &RB_ROOT(head); \ struct type *parent = NULL; \ - int comp = 0; \ - tmp = RB_ROOT(head); \ - while (tmp) { \ + \ + while ((tmp = *tmpp) != NULL) { \ parent = tmp; \ - comp = (cmp)(elm, parent); \ + __typeof(cmp(NULL, NULL)) comp = (cmp)(elm, parent); \ if (comp < 0) \ - tmp = RB_LEFT(tmp, field); \ + tmpp = &RB_LEFT(parent, field); \ else if (comp > 0) \ - tmp = RB_RIGHT(tmp, field); \ + tmpp = &RB_RIGHT(parent, field); \ else \ - return (tmp); \ + return (parent); \ } \ - RB_SET(elm, parent, field); \ - if (parent == NULL) \ - RB_ROOT(head) = elm; \ - else if (comp < 0) \ - RB_LEFT(parent, field) = elm; \ - else \ - RB_RIGHT(parent, field) = elm; \ - name##_RB_INSERT_COLOR(head, elm); \ - while (elm != NULL) { \ - RB_AUGMENT(elm); \ - elm = RB_PARENT(elm, field); \ - } \ - return (NULL); \ + return (name##_RB_INSERT_FINISH(head, parent, tmpp, elm)); \ } #define RB_GENERATE_FIND(name, type, field, cmp, attr) \ @@ -674,7 +865,7 @@ attr struct type * \ name##_RB_FIND(struct name *head, struct type *elm) \ { \ struct type *tmp = RB_ROOT(head); \ - int comp; \ + __typeof(cmp(NULL, NULL)) comp; \ while (tmp) { \ comp = cmp(elm, tmp); \ if (comp < 0) \ @@ -694,7 +885,7 @@ name##_RB_NFIND(struct name *head, struct type *elm) \ { \ struct type *tmp = RB_ROOT(head); \ struct type *res = NULL; \ - int comp; \ + __typeof(cmp(NULL, NULL)) comp; \ while (tmp) { \ comp = cmp(elm, tmp); \ if (comp < 0) { \ @@ -719,19 +910,41 @@ name##_RB_NEXT(struct type *elm) \ while (RB_LEFT(elm, field)) \ elm = RB_LEFT(elm, field); \ } else { \ - if (RB_PARENT(elm, field) && \ - (elm == RB_LEFT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - else { \ - while (RB_PARENT(elm, field) && \ - (elm == RB_RIGHT(RB_PARENT(elm, field), field)))\ - elm = RB_PARENT(elm, field); \ + while (RB_PARENT(elm, field) && \ + (elm == RB_RIGHT(RB_PARENT(elm, field), field))) \ elm = RB_PARENT(elm, field); \ - } \ + elm = RB_PARENT(elm, field); \ } \ return (elm); \ } +#if defined(_KERNEL) && defined(DIAGNOSTIC) +#define _RB_ORDER_CHECK(cmp, lo, hi) do { \ + KASSERT((cmp)(lo, hi) < 0, ("out of order insertion")); \ +} while (0) +#else +#define _RB_ORDER_CHECK(cmp, lo, hi) do {} while (0) +#endif + +#define RB_GENERATE_INSERT_NEXT(name, type, field, cmp, attr) \ +/* Inserts a node into the next position in the RB tree */ \ +attr struct type * \ +name##_RB_INSERT_NEXT(struct name *head, \ + struct type *elm, struct type *next) \ +{ \ + struct type *tmp; \ + struct type **tmpp = &RB_RIGHT(elm, field); \ + \ + _RB_ORDER_CHECK(cmp, elm, next); \ + if (name##_RB_NEXT(elm) != NULL) \ + _RB_ORDER_CHECK(cmp, next, name##_RB_NEXT(elm)); \ + while ((tmp = *tmpp) != NULL) { \ + elm = tmp; \ + tmpp = &RB_LEFT(elm, field); \ + } \ + return (name##_RB_INSERT_FINISH(head, elm, tmpp, next)); \ +} + #define RB_GENERATE_PREV(name, type, field, attr) \ /* ARGSUSED */ \ attr struct type * \ @@ -742,19 +955,33 @@ name##_RB_PREV(struct type *elm) \ while (RB_RIGHT(elm, field)) \ elm = RB_RIGHT(elm, field); \ } else { \ - if (RB_PARENT(elm, field) && \ - (elm == RB_RIGHT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - else { \ - while (RB_PARENT(elm, field) && \ - (elm == RB_LEFT(RB_PARENT(elm, field), field)))\ - elm = RB_PARENT(elm, field); \ + while (RB_PARENT(elm, field) && \ + (elm == RB_LEFT(RB_PARENT(elm, field), field))) \ elm = RB_PARENT(elm, field); \ - } \ + elm = RB_PARENT(elm, field); \ } \ return (elm); \ } +#define RB_GENERATE_INSERT_PREV(name, type, field, cmp, attr) \ +/* Inserts a node into the prev position in the RB tree */ \ +attr struct type * \ +name##_RB_INSERT_PREV(struct name *head, \ + struct type *elm, struct type *prev) \ +{ \ + struct type *tmp; \ + struct type **tmpp = &RB_LEFT(elm, field); \ + \ + _RB_ORDER_CHECK(cmp, prev, elm); \ + if (name##_RB_PREV(elm) != NULL) \ + _RB_ORDER_CHECK(cmp, name##_RB_PREV(elm), prev); \ + while ((tmp = *tmpp) != NULL) { \ + elm = tmp; \ + tmpp = &RB_RIGHT(elm, field); \ + } \ + return (name##_RB_INSERT_FINISH(head, elm, tmpp, prev)); \ +} + #define RB_GENERATE_MINMAX(name, type, field, attr) \ attr struct type * \ name##_RB_MINMAX(struct name *head, int val) \ @@ -791,6 +1018,8 @@ name##_RB_REINSERT(struct name *head, struct type *elm) \ #define RB_INF 1 #define RB_INSERT(name, x, y) name##_RB_INSERT(x, y) +#define RB_INSERT_NEXT(name, x, y, z) name##_RB_INSERT_NEXT(x, y, z) +#define RB_INSERT_PREV(name, x, y, z) name##_RB_INSERT_PREV(x, y, z) #define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y) #define RB_FIND(name, x, y) name##_RB_FIND(x, y) #define RB_NFIND(name, x, y) name##_RB_NFIND(x, y) diff --git a/sys/sys/tslog.h b/sys/sys/tslog.h index af3c0931cac8..9cd58b63ae4b 100644 --- a/sys/sys/tslog.h +++ b/sys/sys/tslog.h @@ -22,13 +22,12 @@ * 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$ */ #ifndef _TSLOG_H_ #define _TSLOG_H_ +#ifdef _KERNEL #ifdef TSLOG #include <sys/_types.h> #include <sys/pcpu.h> @@ -66,4 +65,5 @@ void tslog_user(pid_t, pid_t, const char *, const char *); #define TSRAW_USER(a, b, c, d) /* Timestamp logging disabled */ #endif +#endif /* _KERNEL */ #endif /* _TSLOG_H_ */ diff --git a/sys/sys/tty.h b/sys/sys/tty.h index 4ee76b343c3a..f1b2646c942d 100644 --- a/sys/sys/tty.h +++ b/sys/sys/tty.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> * All rights reserved. @@ -27,8 +27,6 @@ * 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$ */ #ifndef _SYS_TTY_H_ @@ -144,7 +142,7 @@ struct xtty { size_t xt_size; /* Structure size. */ size_t xt_insize; /* Input queue size. */ size_t xt_incc; /* Canonicalized characters. */ - size_t xt_inlc; /* Input line charaters. */ + size_t xt_inlc; /* Input line characters. */ size_t xt_inlow; /* Input low watermark. */ size_t xt_outsize; /* Output queue size. */ size_t xt_outcc; /* Output queue usage. */ diff --git a/sys/sys/ttycom.h b/sys/sys/ttycom.h index a7309d4c5d6b..9a10c6079de0 100644 --- a/sys/sys/ttycom.h +++ b/sys/sys/ttycom.h @@ -34,7 +34,6 @@ * SUCH DAMAGE. * * @(#)ttycom.h 8.1 (Berkeley) 3/28/94 - * $FreeBSD$ */ #ifndef _SYS_TTYCOM_H_ diff --git a/sys/sys/ttydefaults.h b/sys/sys/ttydefaults.h index c269c56fd23f..7e64babbc7f1 100644 --- a/sys/sys/ttydefaults.h +++ b/sys/sys/ttydefaults.h @@ -34,7 +34,6 @@ * SUCH DAMAGE. * * @(#)ttydefaults.h 8.4 (Berkeley) 1/21/94 - * $FreeBSD$ */ /* diff --git a/sys/sys/ttydevsw.h b/sys/sys/ttydevsw.h index d6b544e80323..b4b5102bfc3f 100644 --- a/sys/sys/ttydevsw.h +++ b/sys/sys/ttydevsw.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> * All rights reserved. @@ -27,8 +27,6 @@ * 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$ */ #ifndef _SYS_TTYDEVSW_H_ diff --git a/sys/sys/ttydisc.h b/sys/sys/ttydisc.h index 295a92c36842..0458fae6e34b 100644 --- a/sys/sys/ttydisc.h +++ b/sys/sys/ttydisc.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> * All rights reserved. @@ -27,8 +27,6 @@ * 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$ */ #ifndef _SYS_TTYDISC_H_ diff --git a/sys/sys/ttyhook.h b/sys/sys/ttyhook.h index e4bd7ac53d1b..555526fb5d6d 100644 --- a/sys/sys/ttyhook.h +++ b/sys/sys/ttyhook.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_TTYHOOK_H_ diff --git a/sys/sys/ttyqueue.h b/sys/sys/ttyqueue.h index c1ddaa42b41b..fd5a6bf7719e 100644 --- a/sys/sys/ttyqueue.h +++ b/sys/sys/ttyqueue.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> * All rights reserved. @@ -27,8 +27,6 @@ * 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$ */ #ifndef _SYS_TTYQUEUE_H_ diff --git a/sys/sys/turnstile.h b/sys/sys/turnstile.h index c74d069041ce..81e6b9737c1c 100644 --- a/sys/sys/turnstile.h +++ b/sys/sys/turnstile.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002 John Baldwin <jhb@FreeBSD.org> * @@ -23,8 +23,6 @@ * 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$ */ #ifndef _SYS_TURNSTILE_H_ diff --git a/sys/sys/types.h b/sys/sys/types.h index d37ab8b823dc..b97ad9b5cccb 100644 --- a/sys/sys/types.h +++ b/sys/sys/types.h @@ -34,7 +34,6 @@ * SUCH DAMAGE. * * @(#)types.h 8.6 (Berkeley) 2/19/95 - * $FreeBSD$ */ #ifndef _SYS_TYPES_H_ @@ -273,7 +272,7 @@ typedef __rman_res_t rman_res_t; typedef __register_t syscallarg_t; #ifdef _KERNEL -typedef int boolean_t; +typedef unsigned int boolean_t; typedef struct _device *device_t; typedef __intfptr_t intfptr_t; @@ -310,68 +309,7 @@ typedef _Bool bool; * The following are all things that really shouldn't exist in this header, * since its purpose is to provide typedefs, not miscellaneous doodads. */ - -#ifdef __POPCNT__ -#define __bitcount64(x) __builtin_popcountll((__uint64_t)(x)) -#define __bitcount32(x) __builtin_popcount((__uint32_t)(x)) -#define __bitcount16(x) __builtin_popcount((__uint16_t)(x)) -#define __bitcountl(x) __builtin_popcountl((unsigned long)(x)) -#define __bitcount(x) __builtin_popcount((unsigned int)(x)) -#else -/* - * Population count algorithm using SWAR approach - * - "SIMD Within A Register". - */ -static __inline __uint16_t -__bitcount16(__uint16_t _x) -{ - - _x = (_x & 0x5555) + ((_x & 0xaaaa) >> 1); - _x = (_x & 0x3333) + ((_x & 0xcccc) >> 2); - _x = (_x + (_x >> 4)) & 0x0f0f; - _x = (_x + (_x >> 8)) & 0x00ff; - return (_x); -} - -static __inline __uint32_t -__bitcount32(__uint32_t _x) -{ - - _x = (_x & 0x55555555) + ((_x & 0xaaaaaaaa) >> 1); - _x = (_x & 0x33333333) + ((_x & 0xcccccccc) >> 2); - _x = (_x + (_x >> 4)) & 0x0f0f0f0f; - _x = (_x + (_x >> 8)); - _x = (_x + (_x >> 16)) & 0x000000ff; - return (_x); -} - -#ifdef __LP64__ -static __inline __uint64_t -__bitcount64(__uint64_t _x) -{ - - _x = (_x & 0x5555555555555555) + ((_x & 0xaaaaaaaaaaaaaaaa) >> 1); - _x = (_x & 0x3333333333333333) + ((_x & 0xcccccccccccccccc) >> 2); - _x = (_x + (_x >> 4)) & 0x0f0f0f0f0f0f0f0f; - _x = (_x + (_x >> 8)); - _x = (_x + (_x >> 16)); - _x = (_x + (_x >> 32)) & 0x000000ff; - return (_x); -} - -#define __bitcountl(x) __bitcount64((unsigned long)(x)) -#else -static __inline __uint64_t -__bitcount64(__uint64_t _x) -{ - - return (__bitcount32(_x >> 32) + __bitcount32(_x)); -} - -#define __bitcountl(x) __bitcount32((unsigned long)(x)) -#endif -#define __bitcount(x) __bitcount32((unsigned int)(x)) -#endif +#include <sys/bitcount.h> #if __BSD_VISIBLE @@ -408,6 +346,18 @@ __makedev(int _Major, int _Minor) ((dev_t)(_Minor & 0xff00) << 24) | (_Minor & 0xffff00ff)); } +#if (defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 13)) +#define __enum_uint8_decl(name) enum enum_ ## name ## _uint8 : uint8_t +#define __enum_uint8(name) enum enum_ ## name ## _uint8 +#else +/* + * Note: there is no real size checking here, but the code below can be + * removed once we require GCC 13. + */ +#define __enum_uint8_decl(name) enum __attribute__((packed)) enum_ ## name ## _uint8 +#define __enum_uint8(name) enum __attribute__((packed)) enum_ ## name ## _uint8 +#endif + /* * These declarations belong elsewhere, but are repeated here and in * <stdio.h> to give broken programs a better chance of working with diff --git a/sys/sys/ucontext.h b/sys/sys/ucontext.h index 65a331b79086..0df76f4e4004 100644 --- a/sys/sys/ucontext.h +++ b/sys/sys/ucontext.h @@ -26,8 +26,6 @@ * 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$ */ #ifndef _SYS_UCONTEXT_H_ diff --git a/sys/sys/ucred.h b/sys/sys/ucred.h index 6a9becb54c75..eb92776c158a 100644 --- a/sys/sys/ucred.h +++ b/sys/sys/ucred.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)ucred.h 8.4 (Berkeley) 1/9/95 - * $FreeBSD$ */ #ifndef _SYS_UCRED_H_ @@ -61,8 +60,9 @@ struct loginclass; #if defined(_KERNEL) || defined(_WANT_UCRED) struct ucred { struct mtx cr_mtx; - u_int cr_ref; /* (c) reference count */ + long cr_ref; /* (c) reference count */ u_int cr_users; /* (c) proc + thread using this cred */ + u_int cr_flags; /* credential flags */ struct auditinfo_addr cr_audit; /* Audit properties. */ #define cr_startcopy cr_uid uid_t cr_uid; /* effective user id */ @@ -75,7 +75,6 @@ struct ucred { struct uidinfo *cr_ruidinfo; /* per ruid resource consumption */ struct prison *cr_prison; /* jail(2) */ struct loginclass *cr_loginclass; /* login class */ - u_int cr_flags; /* credential flags */ void *cr_pspare2[2]; /* general use 2 */ #define cr_endcopy cr_label struct label *cr_label; /* MAC label */ diff --git a/sys/sys/uio.h b/sys/sys/uio.h index ae07a074d46a..6250b3cfbf03 100644 --- a/sys/sys/uio.h +++ b/sys/sys/uio.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)uio.h 8.5 (Berkeley) 2/22/94 - * $FreeBSD$ */ #ifndef _SYS_UIO_H_ diff --git a/sys/sys/umtx.h b/sys/sys/umtx.h index 82a8e0e4b0f0..0bc2e3efe594 100644 --- a/sys/sys/umtx.h +++ b/sys/sys/umtx.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002, Jeffrey Roberson <jeff@freebsd.org> * All rights reserved. @@ -25,8 +25,6 @@ * (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$ - * */ #ifndef _SYS_UMTX_H_ @@ -103,6 +101,8 @@ #define UMTX_OP_SEM2_WAKE 24 #define UMTX_OP_SHM 25 #define UMTX_OP_ROBUST_LISTS 26 +#define UMTX_OP_GET_MIN_TIMEOUT 27 +#define UMTX_OP_SET_MIN_TIMEOUT 28 /* * Flags for ops; the double-underbar convention must be maintained for future diff --git a/sys/sys/umtxvar.h b/sys/sys/umtxvar.h index b6d89b6b8559..216c7a3e2cd1 100644 --- a/sys/sys/umtxvar.h +++ b/sys/sys/umtxvar.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002, Jeffrey Roberson <jeff@freebsd.org> * All rights reserved. @@ -25,8 +25,6 @@ * (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$ - * */ #ifndef _SYS_UMTXVAR_H_ diff --git a/sys/sys/un.h b/sys/sys/un.h index e02484151814..366942fe8294 100644 --- a/sys/sys/un.h +++ b/sys/sys/un.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)un.h 8.3 (Berkeley) 2/19/95 - * $FreeBSD$ */ #ifndef _SYS_UN_H_ diff --git a/sys/sys/unistd.h b/sys/sys/unistd.h index 449d35678275..77df90cd26b1 100644 --- a/sys/sys/unistd.h +++ b/sys/sys/unistd.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)unistd.h 8.2 (Berkeley) 1/7/94 - * $FreeBSD$ */ #ifndef _SYS_UNISTD_H_ diff --git a/sys/sys/unpcb.h b/sys/sys/unpcb.h index 5944e83e96a0..8549ea279c16 100644 --- a/sys/sys/unpcb.h +++ b/sys/sys/unpcb.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)unpcb.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD$ */ #ifndef _SYS_UNPCB_H_ @@ -174,7 +173,7 @@ struct xunpgen { u_int xug_count; unp_gen_t xug_gen; so_gen_t xug_sogen; -} __aligned(8);; +} __aligned(8); #endif /* _SYS_SOCKETVAR_H_ */ #if defined(_KERNEL) diff --git a/sys/sys/user.h b/sys/sys/user.h index cf64f8e8eda4..bd460d452bcc 100644 --- a/sys/sys/user.h +++ b/sys/sys/user.h @@ -31,7 +31,6 @@ * SUCH DAMAGE. * * @(#)user.h 8.2 (Berkeley) 9/23/93 - * $FreeBSD$ */ #ifndef _SYS_USER_H_ @@ -265,6 +264,7 @@ struct user { #define KF_TYPE_PROCDESC 11 #define KF_TYPE_DEV 12 #define KF_TYPE_EVENTFD 13 +#define KF_TYPE_TIMERFD 14 #define KF_TYPE_UNKNOWN 255 #define KF_VTYPE_VNON 0 @@ -389,7 +389,9 @@ struct kinfo_file { int kf_file_type; /* Space for future use */ int kf_spareint[3]; - uint64_t kf_spareint64[30]; + uint64_t kf_spareint64[29]; + /* Number of references to file. */ + uint64_t kf_file_nlink; /* Vnode filesystem id. */ uint64_t kf_file_fsid; /* File device. */ @@ -420,8 +422,9 @@ struct kinfo_file { uint64_t kf_pipe_addr; uint64_t kf_pipe_peer; uint32_t kf_pipe_buffer_cnt; - /* Round to 64 bit alignment. */ - uint32_t kf_pipe_pad0[3]; + uint32_t kf_pipe_buffer_in; + uint32_t kf_pipe_buffer_out; + uint32_t kf_pipe_buffer_size; } kf_pipe; struct { uint32_t kf_spareint[4]; @@ -440,7 +443,19 @@ struct kinfo_file { struct { uint64_t kf_eventfd_value; uint32_t kf_eventfd_flags; + uint32_t kf_eventfd_spareint[3]; + uint64_t kf_eventfd_addr; } kf_eventfd; + struct { + uint32_t kf_timerfd_clockid; + uint32_t kf_timerfd_flags; + uint64_t kf_timerfd_addr; + } kf_timerfd; + struct { + uint64_t kf_kqueue_addr; + int32_t kf_kqueue_count; + int32_t kf_kqueue_state; + } kf_kqueue; } kf_un; }; uint16_t kf_status; /* Status flags. */ @@ -479,7 +494,7 @@ struct kinfo_lockf { * another process as a series of entries. */ #define KVME_TYPE_NONE 0 -#define KVME_TYPE_DEFAULT 1 +#define KVME_TYPE_DEFAULT 1 /* no longer returned */ #define KVME_TYPE_VNODE 2 #define KVME_TYPE_SWAP 3 #define KVME_TYPE_DEVICE 4 @@ -625,6 +640,7 @@ struct kinfo_sigtramp { #define KMAP_FLAG_ASLR_IGNSTART 0x04 /* ASLR may map into sbrk grow region */ #define KMAP_FLAG_WXORX 0x08 /* W^X mapping policy is enforced */ #define KMAP_FLAG_ASLR_STACK 0x10 /* the stack location is randomized */ +#define KMAP_FLAG_ASLR_SHARED_PAGE 0x20 /* the shared page location is randomized */ struct kinfo_vm_layout { uintptr_t kvm_min_user_addr; @@ -636,7 +652,9 @@ struct kinfo_vm_layout { uintptr_t kvm_stack_addr; size_t kvm_stack_size; int kvm_map_flags; - uintptr_t kvm_spare[14]; + uintptr_t kvm_shp_addr; + size_t kvm_shp_size; + uintptr_t kvm_spare[12]; }; #ifdef _KERNEL diff --git a/sys/sys/utsname.h b/sys/sys/utsname.h index 27d3c25e42a3..ec24b3023618 100644 --- a/sys/sys/utsname.h +++ b/sys/sys/utsname.h @@ -32,7 +32,6 @@ * SUCH DAMAGE. * * @(#)utsname.h 8.1 (Berkeley) 1/4/94 - * $FreeBSD$ */ #ifndef _SYS_UTSNAME_H diff --git a/sys/sys/uuid.h b/sys/sys/uuid.h index bbb85732dd50..5fc5e61457de 100644 --- a/sys/sys/uuid.h +++ b/sys/sys/uuid.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002 Marcel Moolenaar * All rights reserved. @@ -24,8 +24,6 @@ * 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$ */ #ifndef _SYS_UUID_H_ diff --git a/sys/sys/vdso.h b/sys/sys/vdso.h index a98e3e9ebabe..6c2f3a549a56 100644 --- a/sys/sys/vdso.h +++ b/sys/sys/vdso.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright 2012 Konstantin Belousov <kib@FreeBSD.ORG>. * All rights reserved. @@ -23,8 +23,6 @@ * 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$ */ #ifndef _SYS_VDSO_H diff --git a/sys/sys/vmem.h b/sys/sys/vmem.h index e74d1e3fe803..20eee9f6ccd3 100644 --- a/sys/sys/vmem.h +++ b/sys/sys/vmem.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c)2006 YAMAMOTO Takashi, * All rights reserved. @@ -27,7 +27,6 @@ */ /* From $NetBSD: vmem.h,v 1.20 2013/01/29 21:26:24 para Exp $ */ -/* $FreeBSD$ */ #ifndef _SYS_VMEM_H_ #define _SYS_VMEM_H_ diff --git a/sys/sys/vmmeter.h b/sys/sys/vmmeter.h index 3714a06983bf..3442843f4b5d 100644 --- a/sys/sys/vmmeter.h +++ b/sys/sys/vmmeter.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)vmmeter.h 8.2 (Berkeley) 7/10/94 - * $FreeBSD$ */ #ifndef _SYS_VMMETER_H_ diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index ed292835c12f..07b1a419b916 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)vnode.h 8.7 (Berkeley) 2/4/94 - * $FreeBSD$ */ #ifndef _SYS_VNODE_H_ @@ -56,10 +55,34 @@ /* * Vnode types. VNON means no type. */ -enum vtype { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO, VBAD, - VMARKER }; +__enum_uint8_decl(vtype) { + VNON, + VREG, + VDIR, + VBLK, + VCHR, + VLNK, + VSOCK, + VFIFO, + VBAD, + VMARKER, + VLASTTYPE = VMARKER, +}; + +__enum_uint8_decl(vstate) { + VSTATE_UNINITIALIZED, + VSTATE_CONSTRUCTED, + VSTATE_DESTROYING, + VSTATE_DEAD, + VLASTSTATE = VSTATE_DEAD, +}; + +enum vgetstate { + VGET_NONE, + VGET_HOLDCNT, + VGET_USECOUNT, +}; -enum vgetstate { VGET_NONE, VGET_HOLDCNT, VGET_USECOUNT }; /* * Each underlying filesystem allocates its own private area and hangs * it from v_data. If non-null, this area is freed in getnewvnode(). @@ -105,7 +128,8 @@ struct vnode { * Fields which define the identity of the vnode. These fields are * owned by the filesystem (XXX: and vgone() ?) */ - enum vtype v_type:8; /* u vnode type */ + __enum_uint8(vtype) v_type; /* u vnode type */ + __enum_uint8(vstate) v_state; /* u vnode state */ short v_irflag; /* i frequently read flags */ seqc_t v_seqc; /* i modification count */ uint32_t v_nchash; /* u namecache hash */ @@ -193,36 +217,6 @@ _Static_assert(sizeof(struct vnode) <= 448, "vnode size crosses 448 bytes"); /* XXX: These are temporary to avoid a source sweep at this time */ #define v_object v_bufobj.bo_object -/* - * Userland version of struct vnode, for sysctl. - */ -struct xvnode { - size_t xv_size; /* sizeof(struct xvnode) */ - void *xv_vnode; /* address of real vnode */ - u_long xv_flag; /* vnode vflags */ - int xv_usecount; /* reference count of users */ - int xv_writecount; /* reference count of writers */ - int xv_holdcnt; /* page & buffer references */ - u_long xv_id; /* capability identifier */ - void *xv_mount; /* address of parent mount */ - long xv_numoutput; /* num of writes in progress */ - enum vtype xv_type; /* vnode type */ - union { - void *xvu_socket; /* unpcb, if VSOCK */ - void *xvu_fifo; /* fifo, if VFIFO */ - dev_t xvu_rdev; /* maj/min, if VBLK/VCHR */ - struct { - dev_t xvu_dev; /* device, if VDIR/VREG/VLNK */ - ino_t xvu_ino; /* id, if VDIR/VREG/VLNK */ - } xv_uns; - } xv_un; -}; -#define xv_socket xv_un.xvu_socket -#define xv_fifo xv_un.xvu_fifo -#define xv_rdev xv_un.xvu_rdev -#define xv_dev xv_un.xv_uns.xvu_dev -#define xv_ino xv_un.xv_uns.xvu_ino - /* We don't need to lock the knlist */ #define VN_KNLIST_EMPTY(vp) ((vp)->v_pollinfo == NULL || \ KNLIST_EMPTY(&(vp)->v_pollinfo->vpi_selinfo.si_note)) @@ -252,6 +246,7 @@ struct xvnode { never cleared once set */ #define VIRF_MOUNTPOINT 0x0004 /* This vnode is mounted on */ #define VIRF_TEXT_REF 0x0008 /* Executable mappings ref the vnode */ +#define VIRF_CROSSMP 0x0010 /* Cross-mp vnode, no locking */ #define VI_UNUSED0 0x0001 /* unused */ #define VI_MOUNT 0x0002 /* Mount in progress */ @@ -276,6 +271,7 @@ struct xvnode { #define VV_FORCEINSMQ 0x1000 /* force the insmntque to succeed */ #define VV_READLINK 0x2000 /* fdescfs linux vnode */ #define VV_UNREF 0x4000 /* vunref, do not drop lock in inactive() */ +#define VV_CROSSLOCK 0x8000 /* vnode lock is shared w/ root mounted here */ #define VMP_LAZYLIST 0x0001 /* Vnode is on mnt's lazy list */ @@ -284,7 +280,7 @@ struct xvnode { * is unavailable (getattr) or which is not to be changed (setattr). */ struct vattr { - enum vtype va_type; /* vnode type (for create) */ + __enum_uint8(vtype) va_type; /* vnode type (for create) */ u_short va_mode; /* files access mode and type */ u_short va_padding0; uid_t va_uid; /* owner user id */ @@ -408,7 +404,7 @@ extern const u_int io_hold_cnt; * Convert between vnode types and inode formats (since POSIX.1 * defines mode word of stat structure in terms of inode formats). */ -extern enum vtype iftovt_tab[]; +extern __enum_uint8(vtype) iftovt_tab[]; extern int vttoif_tab[]; #define IFTOVT(mode) (iftovt_tab[((mode) & S_IFMT) >> 12]) #define VTTOIF(indx) (vttoif_tab[(int)(indx)]) @@ -431,7 +427,8 @@ extern int vttoif_tab[]; #define V_WAIT 0x0001 /* vn_start_write: sleep for suspend */ #define V_NOWAIT 0x0002 /* vn_start_write: don't sleep for suspend */ #define V_XSLEEP 0x0004 /* vn_start_write: just return after sleep */ -#define V_MNTREF 0x0010 /* vn_start_write: mp is already ref-ed */ +#define V_PCATCH 0x0008 /* vn_start_write: make the sleep interruptible */ +#define V_VALID_FLAGS (V_WAIT | V_NOWAIT | V_XSLEEP | V_PCATCH) #define VR_START_WRITE 0x0001 /* vfs_write_resume: start write atomically */ #define VR_NO_SUSPCLR 0x0002 /* vfs_write_resume: do not clear suspension */ @@ -672,14 +669,27 @@ int cache_symlink_resolve(struct cache_fpl *fpl, const char *string, void cache_vop_rename(struct vnode *fdvp, struct vnode *fvp, struct vnode *tdvp, struct vnode *tvp, struct componentname *fcnp, struct componentname *tcnp); void cache_vop_rmdir(struct vnode *dvp, struct vnode *vp); +void cache_vop_vector_register(struct vop_vector *); #ifdef INVARIANTS void cache_validate(struct vnode *dvp, struct vnode *vp, struct componentname *cnp); +void cache_validate_vop_vector(struct mount *mp, struct vop_vector *vops); +void cache_assert_no_entries(struct vnode *vp); #else static inline void cache_validate(struct vnode *dvp, struct vnode *vp, struct componentname *cnp) { } + +static inline void +cache_validate_vop_vector(struct mount *mp, struct vop_vector *vops) +{ +} + +static inline void +cache_assert_no_entries(struct vnode *vp) +{ +} #endif void cache_fast_lookup_enabled_recalc(void); int change_dir(struct vnode *vp, struct thread *td); @@ -706,13 +716,16 @@ struct vnode * int vn_commname(struct vnode *vn, char *buf, u_int buflen); int vn_path_to_global_path(struct thread *td, struct vnode *vp, char *path, u_int pathlen); -int vaccess(enum vtype type, mode_t file_mode, uid_t file_uid, +int vn_path_to_global_path_hardlink(struct thread *td, struct vnode *vp, + struct vnode *dvp, char *path, u_int pathlen, const char *leaf_name, + size_t leaf_length); +int vaccess(__enum_uint8(vtype) type, mode_t file_mode, uid_t file_uid, gid_t file_gid, accmode_t accmode, struct ucred *cred); int vaccess_vexec_smr(mode_t file_mode, uid_t file_uid, gid_t file_gid, struct ucred *cred); -int vaccess_acl_nfs4(enum vtype type, uid_t file_uid, gid_t file_gid, +int vaccess_acl_nfs4(__enum_uint8(vtype) type, uid_t file_uid, gid_t file_gid, struct acl *aclp, accmode_t accmode, struct ucred *cred); -int vaccess_acl_posix1e(enum vtype type, uid_t file_uid, +int vaccess_acl_posix1e(__enum_uint8(vtype) type, uid_t file_uid, gid_t file_gid, struct acl *acl, accmode_t accmode, struct ucred *cred); void vattr_null(struct vattr *vap); @@ -763,8 +776,8 @@ bool vn_isdisk_error(struct vnode *vp, int *errp); bool vn_isdisk(struct vnode *vp); int _vn_lock(struct vnode *vp, int flags, const char *file, int line); #define vn_lock(vp, flags) _vn_lock(vp, flags, __FILE__, __LINE__) -void vn_lock_pair(struct vnode *vp1, bool vp1_locked, struct vnode *vp2, - bool vp2_locked); +void vn_lock_pair(struct vnode *vp1, bool vp1_locked, int lkflags1, + struct vnode *vp2, bool vp2_locked, int lkflags2); int vn_open(struct nameidata *ndp, int *flagp, int cmode, struct file *fp); int vn_open_cred(struct nameidata *ndp, int *flagp, int cmode, u_int vn_open_flags, struct ucred *cred, struct file *fp); @@ -785,6 +798,10 @@ int vn_rdwr_inchunks(enum uio_rw rw, struct vnode *vp, void *base, int vn_read_from_obj(struct vnode *vp, struct uio *uio); int vn_rlimit_fsize(const struct vnode *vp, const struct uio *uio, struct thread *td); +int vn_rlimit_fsizex(const struct vnode *vp, struct uio *uio, + off_t maxfsz, ssize_t *resid_adj, struct thread *td); +void vn_rlimit_fsizex_res(struct uio *uio, ssize_t resid_adj); +int vn_rlimit_trunc(u_quad_t size, struct thread *td); int vn_start_write(struct vnode *vp, struct mount **mpp, int flags); int vn_start_secondary_write(struct vnode *vp, struct mount **mpp, int flags); @@ -1100,8 +1117,11 @@ void vfs_hash_remove(struct vnode *vp); int vfs_kqfilter(struct vop_kqfilter_args *); struct dirent; +int vn_dir_next_dirent(struct vnode *vp, struct thread *td, + char *dirbuf, size_t dirbuflen, + struct dirent **dpp, size_t *len, off_t *off, int *eofflag); +int vn_dir_check_empty(struct vnode *vp); int vfs_read_dirent(struct vop_readdir_args *ap, struct dirent *dp, off_t off); -int vfs_emptydir(struct vnode *vp); int vfs_unixify_accmode(accmode_t *accmode); @@ -1114,12 +1134,33 @@ int vn_chmod(struct file *fp, mode_t mode, struct ucred *active_cred, struct thread *td); int vn_chown(struct file *fp, uid_t uid, gid_t gid, struct ucred *active_cred, struct thread *td); +int vn_getsize_locked(struct vnode *vp, off_t *size, struct ucred *active_cred); +int vn_getsize(struct vnode *vp, off_t *size, struct ucred *active_cred); void vn_fsid(struct vnode *vp, struct vattr *va); int vn_dir_check_exec(struct vnode *vp, struct componentname *cnp); int vn_lktype_write(struct mount *mp, struct vnode *vp); +#ifdef INVARIANTS +void vn_set_state_validate(struct vnode *vp, __enum_uint8(vstate) state); +#endif + +static inline void +vn_set_state(struct vnode *vp, __enum_uint8(vstate) state) +{ +#ifdef INVARIANTS + vn_set_state_validate(vp, state); +#endif + vp->v_state = state; +} + +static inline __enum_uint8(vstate) +vn_get_state(struct vnode *vp) +{ + return (vp->v_state); +} + #define VOP_UNLOCK_FLAGS(vp, flags) ({ \ struct vnode *_vp = (vp); \ int _flags = (flags); \ diff --git a/sys/sys/vtoc.h b/sys/sys/vtoc.h deleted file mode 100644 index 85b5fb6d6614..000000000000 --- a/sys/sys/vtoc.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ -/* $FreeBSD$ */ -#include <sys/disk/vtoc.h> diff --git a/sys/sys/wait.h b/sys/sys/wait.h index e34faef3d803..9eb2fed2ebc0 100644 --- a/sys/sys/wait.h +++ b/sys/sys/wait.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * @(#)wait.h 8.2 (Berkeley) 7/10/94 - * $FreeBSD$ */ #ifndef _SYS_WAIT_H_ diff --git a/sys/sys/watchdog.h b/sys/sys/watchdog.h index 3728d742e4d1..4a16b18509f5 100644 --- a/sys/sys/watchdog.h +++ b/sys/sys/watchdog.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2003 Poul-Henning Kamp * Copyright (c) 2013 iXsystems.com, @@ -27,8 +27,6 @@ * 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$ */ #ifndef _SYS_WATCHDOG_H #define _SYS_WATCHDOG_H |