diff options
Diffstat (limited to 'include/os/freebsd/spl/sys')
42 files changed, 817 insertions, 1163 deletions
diff --git a/include/os/freebsd/spl/sys/acl.h b/include/os/freebsd/spl/sys/acl.h index ee50b0a18368..e757a601a842 100644 --- a/include/os/freebsd/spl/sys/acl.h +++ b/include/os/freebsd/spl/sys/acl.h @@ -6,7 +6,7 @@ * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. + * or https://opensource.org/licenses/CDDL-1.0. * See the License for the specific language governing permissions * and limitations under the License. * diff --git a/include/os/freebsd/spl/sys/acl_impl.h b/include/os/freebsd/spl/sys/acl_impl.h index 1efbd6d73bd0..de5961ef7740 100644 --- a/include/os/freebsd/spl/sys/acl_impl.h +++ b/include/os/freebsd/spl/sys/acl_impl.h @@ -6,7 +6,7 @@ * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. + * or https://opensource.org/licenses/CDDL-1.0. * See the License for the specific language governing permissions * and limitations under the License. * diff --git a/include/os/freebsd/spl/sys/atomic.h b/include/os/freebsd/spl/sys/atomic.h index 1a68bfc4de23..40a67704fde0 100644 --- a/include/os/freebsd/spl/sys/atomic.h +++ b/include/os/freebsd/spl/sys/atomic.h @@ -57,7 +57,9 @@ extern uint64_t atomic_cas_64(volatile uint64_t *target, uint64_t cmp, uint64_t newval); #endif -#define membar_producer atomic_thread_fence_rel +#define membar_consumer() atomic_thread_fence_acq() +#define membar_producer() atomic_thread_fence_rel() +#define membar_sync() atomic_thread_fence_seq_cst() static __inline uint32_t atomic_add_32_nv(volatile uint32_t *target, int32_t delta) @@ -165,7 +167,7 @@ atomic_dec_64_nv(volatile uint64_t *target) return (atomic_add_64_nv(target, -1)); } -#if !defined(COMPAT_32BIT) && defined(__LP64__) +#ifdef __LP64__ static __inline void * atomic_cas_ptr(volatile void *target, void *cmp, void *newval) { @@ -179,7 +181,7 @@ atomic_cas_ptr(volatile void *target, void *cmp, void *newval) return ((void *)atomic_cas_32((volatile uint32_t *)target, (uint32_t)cmp, (uint32_t)newval)); } -#endif /* !defined(COMPAT_32BIT) && defined(__LP64__) */ +#endif /* __LP64__ */ #else /* _STANDALONE */ /* @@ -188,6 +190,8 @@ atomic_cas_ptr(volatile void *target, void *cmp, void *newval) */ #undef atomic_add_64 #define atomic_add_64(ptr, val) *(ptr) += val +#undef atomic_sub_64 +#define atomic_sub_64(ptr, val) *(ptr) -= val #endif /* !_STANDALONE */ #endif /* !_OPENSOLARIS_SYS_ATOMIC_H_ */ diff --git a/include/os/freebsd/spl/sys/byteorder.h b/include/os/freebsd/spl/sys/byteorder.h index 0b3d01eb3759..0c09757c8e15 100644 --- a/include/os/freebsd/spl/sys/byteorder.h +++ b/include/os/freebsd/spl/sys/byteorder.h @@ -6,7 +6,7 @@ * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. + * or https://opensource.org/licenses/CDDL-1.0. * See the License for the specific language governing permissions * and limitations under the License. * @@ -44,6 +44,18 @@ #include <sys/endian.h> +#ifdef __COVERITY__ +/* + * Coverity's taint warnings from byteswapping are false positives for us. + * Suppress them by hiding byteswapping from Coverity. + */ +#define BSWAP_8(x) ((x) & 0xff) +#define BSWAP_16(x) ((x) & 0xffff) +#define BSWAP_32(x) ((x) & 0xffffffff) +#define BSWAP_64(x) (x) + +#else /* __COVERITY__ */ + /* * Macros to reverse byte order */ @@ -52,6 +64,8 @@ #define BSWAP_32(x) ((BSWAP_16(x) << 16) | BSWAP_16((x) >> 16)) #define BSWAP_64(x) ((BSWAP_32(x) << 32) | BSWAP_32((x) >> 32)) +#endif /* __COVERITY__ */ + #define BMASK_8(x) ((x) & 0xff) #define BMASK_16(x) ((x) & 0xffff) #define BMASK_32(x) ((x) & 0xffffffff) diff --git a/include/os/freebsd/spl/sys/callb.h b/include/os/freebsd/spl/sys/callb.h index d51132d4e612..006a90cae8c0 100644 --- a/include/os/freebsd/spl/sys/callb.h +++ b/include/os/freebsd/spl/sys/callb.h @@ -6,7 +6,7 @@ * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. + * or https://opensource.org/licenses/CDDL-1.0. * See the License for the specific language governing permissions * and limitations under the License. * diff --git a/include/os/freebsd/spl/sys/ccompat.h b/include/os/freebsd/spl/sys/ccompat.h index eaee9159eabd..e34bab7e896d 100644 --- a/include/os/freebsd/spl/sys/ccompat.h +++ b/include/os/freebsd/spl/sys/ccompat.h @@ -1,5 +1,5 @@ /* - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/include/os/freebsd/spl/sys/ccompile.h b/include/os/freebsd/spl/sys/ccompile.h index 90b077a7be4e..26cf4db87aea 100644 --- a/include/os/freebsd/spl/sys/ccompile.h +++ b/include/os/freebsd/spl/sys/ccompile.h @@ -7,7 +7,7 @@ * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. + * or https://opensource.org/licenses/CDDL-1.0. * See the License for the specific language governing permissions * and limitations under the License. * diff --git a/include/os/freebsd/spl/sys/cmn_err.h b/include/os/freebsd/spl/sys/cmn_err.h index ddc2f0049e59..87fce4955bc1 100644 --- a/include/os/freebsd/spl/sys/cmn_err.h +++ b/include/os/freebsd/spl/sys/cmn_err.h @@ -7,7 +7,7 @@ * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. + * or https://opensource.org/licenses/CDDL-1.0. * See the License for the specific language governing permissions * and limitations under the License. * @@ -33,6 +33,7 @@ #if !defined(_ASM) #include <sys/_stdarg.h> +#include <sys/atomic.h> #endif #ifdef __cplusplus @@ -71,7 +72,39 @@ extern void vuprintf(const char *, __va_list) __attribute__((format(printf, 1, 0))); extern void panic(const char *, ...) - __attribute__((format(printf, 1, 2))); + __attribute__((format(printf, 1, 2), __noreturn__)); + +#define cmn_err_once(ce, ...) \ +do { \ + static volatile uint32_t printed = 0; \ + if (atomic_cas_32(&printed, 0, 1) == 0) { \ + cmn_err(ce, __VA_ARGS__); \ + } \ +} while (0) + +#define vcmn_err_once(ce, fmt, ap) \ +do { \ + static volatile uint32_t printed = 0; \ + if (atomic_cas_32(&printed, 0, 1) == 0) { \ + vcmn_err(ce, fmt, ap); \ + } \ +} while (0) + +#define zcmn_err_once(zone, ce, ...) \ +do { \ + static volatile uint32_t printed = 0; \ + if (atomic_cas_32(&printed, 0, 1) == 0) { \ + zcmn_err(zone, ce, __VA_ARGS__); \ + } \ +} while (0) + +#define vzcmn_err_once(zone, ce, fmt, ap) \ +do { \ + static volatile uint32_t printed = 0; \ + if (atomic_cas_32(&printed, 0, 1) == 0) { \ + vzcmn_err(zone, ce, fmt, ap); \ + } \ +} while (0) #endif /* !_ASM */ diff --git a/include/os/freebsd/spl/sys/cred.h b/include/os/freebsd/spl/sys/cred.h index db986af57bf5..06d537126285 100644 --- a/include/os/freebsd/spl/sys/cred.h +++ b/include/os/freebsd/spl/sys/cred.h @@ -6,7 +6,7 @@ * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. + * or https://opensource.org/licenses/CDDL-1.0. * See the License for the specific language governing permissions * and limitations under the License. * diff --git a/include/os/freebsd/spl/sys/ctype.h b/include/os/freebsd/spl/sys/ctype.h index 53afd8b8bd42..b9ca0f8ef2c4 100644 --- a/include/os/freebsd/spl/sys/ctype.h +++ b/include/os/freebsd/spl/sys/ctype.h @@ -39,5 +39,6 @@ ((C) >= 0x3A && (C) <= 0x40) || \ ((C) >= 0x5B && (C) <= 0x60) || \ ((C) >= 0x7B && (C) <= 0x7E)) +#define isspace(C) ((C) == 0x20 || ((C) >= 0x9 && (C) <= 0xD)) #endif diff --git a/include/os/freebsd/spl/sys/debug.h b/include/os/freebsd/spl/sys/debug.h index 86fad18e17d2..f041dde34fc8 100644 --- a/include/os/freebsd/spl/sys/debug.h +++ b/include/os/freebsd/spl/sys/debug.h @@ -39,12 +39,14 @@ * ASSERT3U() - Assert unsigned X OP Y is true, if not panic. * ASSERT3P() - Assert pointer X OP Y is true, if not panic. * ASSERT0() - Assert value is zero, if not panic. + * ASSERT0P() - Assert pointer is null, if not panic. * VERIFY() - Verify X is true, if not panic. * VERIFY3B() - Verify boolean X OP Y is true, if not panic. * VERIFY3S() - Verify signed X OP Y is true, if not panic. * VERIFY3U() - Verify unsigned X OP Y is true, if not panic. * VERIFY3P() - Verify pointer X OP Y is true, if not panic. * VERIFY0() - Verify value is zero, if not panic. + * VERIFY0P() - Verify pointer is null, if not panic. */ #ifndef _SPL_DEBUG_H @@ -54,23 +56,63 @@ /* * Common DEBUG functionality. */ -int spl_panic(const char *file, const char *func, int line, +#ifdef __FreeBSD__ +#include <linux/compiler.h> +#endif + +#ifndef __printflike +#define __printflike(a, b) __printf(a, b) +#endif + +#ifndef __maybe_unused +#define __maybe_unused __attribute__((unused)) +#endif + +/* + * Without this, we see warnings from objtool during normal Linux builds when + * the kernel is built with CONFIG_STACK_VALIDATION=y: + * + * warning: objtool: tsd_create() falls through to next function __list_add() + * warning: objtool: .text: unexpected end of section + * + * Until the toolchain stops doing this, we must only define this attribute on + * spl_panic() when doing static analysis. + */ +#if defined(__COVERITY__) || defined(__clang_analyzer__) +__attribute__((__noreturn__)) +#endif +extern void spl_panic(const char *file, const char *func, int line, const char *fmt, ...); -void spl_dumpstack(void); +extern void spl_dumpstack(void); + +static inline int +spl_assert(const char *buf, const char *file, const char *func, int line) +{ + spl_panic(file, func, line, "%s", buf); + return (0); +} #ifndef expect #define expect(expr, value) (__builtin_expect((expr), (value))) #endif +#ifndef __linux__ #define likely(expr) expect((expr) != 0, 1) #define unlikely(expr) expect((expr) != 0, 0) +#endif #define PANIC(fmt, a...) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, fmt, ## a) #define VERIFY(cond) \ (void) (unlikely(!(cond)) && \ - spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "%s", "VERIFY(" #cond ") failed\n")) + spl_assert("VERIFY(" #cond ") failed\n", \ + __FILE__, __FUNCTION__, __LINE__)) + +#define VERIFYF(cond, str, ...) do { \ + if (unlikely(!cond)) \ + spl_panic(__FILE__, __FUNCTION__, __LINE__, \ + "VERIFY(" #cond ") failed " str "\n", __VA_ARGS__);\ + } while (0) #define VERIFY3B(LEFT, OP, RIGHT) do { \ const boolean_t _verify3_left = (boolean_t)(LEFT); \ @@ -79,8 +121,8 @@ void spl_dumpstack(void); spl_panic(__FILE__, __FUNCTION__, __LINE__, \ "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ "failed (%d " #OP " %d)\n", \ - (boolean_t)(_verify3_left), \ - (boolean_t)(_verify3_right)); \ + (boolean_t)_verify3_left, \ + (boolean_t)_verify3_right); \ } while (0) #define VERIFY3S(LEFT, OP, RIGHT) do { \ @@ -90,8 +132,8 @@ void spl_dumpstack(void); spl_panic(__FILE__, __FUNCTION__, __LINE__, \ "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ "failed (%lld " #OP " %lld)\n", \ - (long long) (_verify3_left), \ - (long long) (_verify3_right)); \ + (long long)_verify3_left, \ + (long long)_verify3_right); \ } while (0) #define VERIFY3U(LEFT, OP, RIGHT) do { \ @@ -101,8 +143,8 @@ void spl_dumpstack(void); spl_panic(__FILE__, __FUNCTION__, __LINE__, \ "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ "failed (%llu " #OP " %llu)\n", \ - (unsigned long long) (_verify3_left), \ - (unsigned long long) (_verify3_right)); \ + (unsigned long long)_verify3_left, \ + (unsigned long long)_verify3_right); \ } while (0) #define VERIFY3P(LEFT, OP, RIGHT) do { \ @@ -112,20 +154,116 @@ void spl_dumpstack(void); spl_panic(__FILE__, __FUNCTION__, __LINE__, \ "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ "failed (%px " #OP " %px)\n", \ - (void *) (_verify3_left), \ - (void *) (_verify3_right)); \ + (void *)_verify3_left, \ + (void *)_verify3_right); \ } while (0) #define VERIFY0(RIGHT) do { \ + const int64_t _verify0_right = (int64_t)(RIGHT); \ + if (unlikely(!(0 == _verify0_right))) \ + spl_panic(__FILE__, __FUNCTION__, __LINE__, \ + "VERIFY0(" #RIGHT ") " \ + "failed (0 == %lld)\n", \ + (long long)_verify0_right); \ + } while (0) + +#define VERIFY0P(RIGHT) do { \ + const uintptr_t _verify0_right = (uintptr_t)(RIGHT); \ + if (unlikely(!(0 == _verify0_right))) \ + spl_panic(__FILE__, __FUNCTION__, __LINE__, \ + "VERIFY0P(" #RIGHT ") " \ + "failed (NULL == %px)\n", \ + (void *)_verify0_right); \ + } while (0) + +/* + * Note that you should not put any operations you want to always happen + * in the print section for ASSERTs unless you only want them to run on + * debug builds! + * e.g. ASSERT3UF(2, <, 3, "%s", foo(x)), foo(x) won't run on non-debug + * builds. + */ + +#define VERIFY3BF(LEFT, OP, RIGHT, STR, ...) do { \ + const boolean_t _verify3_left = (boolean_t)(LEFT); \ + const boolean_t _verify3_right = (boolean_t)(RIGHT); \ + if (unlikely(!(_verify3_left OP _verify3_right))) \ + spl_panic(__FILE__, __FUNCTION__, __LINE__, \ + "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ + "failed (%d " #OP " %d) " STR "\n", \ + (boolean_t)(_verify3_left), \ + (boolean_t)(_verify3_right), \ + __VA_ARGS__); \ + } while (0) + +#define VERIFY3SF(LEFT, OP, RIGHT, STR, ...) do { \ + const int64_t _verify3_left = (int64_t)(LEFT); \ + const int64_t _verify3_right = (int64_t)(RIGHT); \ + if (unlikely(!(_verify3_left OP _verify3_right))) \ + spl_panic(__FILE__, __FUNCTION__, __LINE__, \ + "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ + "failed (%lld " #OP " %lld) " STR "\n", \ + (long long)(_verify3_left), \ + (long long)(_verify3_right), \ + __VA_ARGS); \ + } while (0) + +#define VERIFY3UF(LEFT, OP, RIGHT, STR, ...) do { \ + const uint64_t _verify3_left = (uint64_t)(LEFT); \ + const uint64_t _verify3_right = (uint64_t)(RIGHT); \ + if (unlikely(!(_verify3_left OP _verify3_right))) \ + spl_panic(__FILE__, __FUNCTION__, __LINE__, \ + "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ + "failed (%llu " #OP " %llu) " STR "\n", \ + (unsigned long long)(_verify3_left), \ + (unsigned long long)(_verify3_right), \ + __VA_ARGS); \ + } while (0) + +#define VERIFY3PF(LEFT, OP, RIGHT, STR, ...) do { \ + const uintptr_t _verify3_left = (uintptr_t)(LEFT); \ + const uintptr_t _verify3_right = (uintptr_t)(RIGHT); \ + if (unlikely(!(_verify3_left OP _verify3_right))) \ + spl_panic(__FILE__, __FUNCTION__, __LINE__, \ + "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ + "failed (%px " #OP " %px) " STR "\n", \ + (void *) (_verify3_left), \ + (void *) (_verify3_right), \ + __VA_ARGS__); \ + } while (0) + +#define VERIFY0PF(RIGHT, STR, ...) do { \ + const uintptr_t _verify3_left = (uintptr_t)(0); \ + const uintptr_t _verify3_right = (uintptr_t)(RIGHT); \ + if (unlikely(!(_verify3_left == _verify3_right))) \ + spl_panic(__FILE__, __FUNCTION__, __LINE__, \ + "VERIFY0(0 == " #RIGHT ") " \ + "failed (0 == %px) " STR "\n", \ + (long long) (_verify3_right), \ + __VA_ARGS__); \ + } while (0) + +#define VERIFY0F(RIGHT, STR, ...) do { \ const int64_t _verify3_left = (int64_t)(0); \ const int64_t _verify3_right = (int64_t)(RIGHT); \ if (unlikely(!(_verify3_left == _verify3_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY3(0 == " #RIGHT ") " \ - "failed (0 == %lld)\n", \ - (long long) (_verify3_right)); \ + "VERIFY0(0 == " #RIGHT ") " \ + "failed (0 == %lld) " STR "\n", \ + (long long) (_verify3_right), \ + __VA_ARGS__); \ } while (0) +#define VERIFY_IMPLY(A, B) \ + ((void)(likely((!(A)) || (B)) || \ + spl_assert("(" #A ") implies (" #B ")", \ + __FILE__, __FUNCTION__, __LINE__))) + +#define VERIFY_EQUIV(A, B) \ + ((void)(likely(!!(A) == !!(B)) || \ + spl_assert("(" #A ") is equivalent to (" #B ")", \ + __FILE__, __FUNCTION__, __LINE__))) + /* * Debugging disabled (--disable-debug) */ @@ -141,6 +279,14 @@ void spl_dumpstack(void); #define ASSERT3P(x, y, z) \ ((void) sizeof ((uintptr_t)(x)), (void) sizeof ((uintptr_t)(z))) #define ASSERT0(x) ((void) sizeof ((uintptr_t)(x))) +#define ASSERT0P(x) ((void) sizeof ((uintptr_t)(x))) +#define ASSERT3BF(x, y, z, str, ...) ASSERT3B(x, y, z) +#define ASSERT3SF(x, y, z, str, ...) ASSERT3S(x, y, z) +#define ASSERT3UF(x, y, z, str, ...) ASSERT3U(x, y, z) +#define ASSERT3PF(x, y, z, str, ...) ASSERT3P(x, y, z) +#define ASSERT0PF(x, str, ...) ASSERT0P(x) +#define ASSERT0F(x, str, ...) ASSERT0(x) +#define ASSERTF(x, str, ...) ASSERT(x) #define IMPLY(A, B) \ ((void) sizeof ((uintptr_t)(A)), (void) sizeof ((uintptr_t)(B))) #define EQUIV(A, B) \ @@ -156,15 +302,17 @@ void spl_dumpstack(void); #define ASSERT3U VERIFY3U #define ASSERT3P VERIFY3P #define ASSERT0 VERIFY0 +#define ASSERT0P VERIFY0P +#define ASSERT3BF VERIFY3BF +#define ASSERT3SF VERIFY3SF +#define ASSERT3UF VERIFY3UF +#define ASSERT3PF VERIFY3PF +#define ASSERT0PF VERIFY0PF +#define ASSERT0F VERIFY0F +#define ASSERTF VERIFYF #define ASSERT VERIFY -#define IMPLY(A, B) \ - ((void)(likely((!(A)) || (B)) || \ - spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "(" #A ") implies (" #B ")"))) -#define EQUIV(A, B) \ - ((void)(likely(!!(A) == !!(B)) || \ - spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "(" #A ") is equivalent to (" #B ")"))) +#define IMPLY VERIFY_IMPLY +#define EQUIV VERIFY_EQUIV #endif /* NDEBUG */ diff --git a/include/os/freebsd/spl/sys/disp.h b/include/os/freebsd/spl/sys/disp.h index 2be1b76e4334..d46a7d2c0143 100644 --- a/include/os/freebsd/spl/sys/disp.h +++ b/include/os/freebsd/spl/sys/disp.h @@ -31,6 +31,8 @@ #include <sys/proc.h> +#define KPREEMPT_SYNC (-1) + #define kpreempt(x) kern_yield(PRI_USER) #endif /* _OPENSOLARIS_SYS_DISP_H_ */ diff --git a/include/os/freebsd/spl/sys/dkio.h b/include/os/freebsd/spl/sys/dkio.h deleted file mode 100644 index aed54ba50893..000000000000 --- a/include/os/freebsd/spl/sys/dkio.h +++ /dev/null @@ -1,494 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * $FreeBSD$ - */ -/* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _OPENSOLARIS_SYS_DKIO_H_ -#define _OPENSOLARIS_SYS_DKIO_H_ - -#include <sys/types.h> /* Needed for NDKMAP define */ - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined(_SUNOS_VTOC_16) -#define NDKMAP 16 /* # of logical partitions */ -#define DK_LABEL_LOC 1 /* location of disk label */ -#elif defined(_SUNOS_VTOC_8) -#define NDKMAP 8 /* # of logical partitions */ -#define DK_LABEL_LOC 0 /* location of disk label */ -#else -#error "No VTOC format defined." -#endif - -/* - * Structures and definitions for disk io control commands - */ - -/* - * Structures used as data by ioctl calls. - */ - -#define DK_DEVLEN 16 /* device name max length, including */ - /* unit # & NULL (ie - "xyc1") */ - -/* - * Used for controller info - */ -struct dk_cinfo { - char dki_cname[DK_DEVLEN]; /* controller name (no unit #) */ - ushort_t dki_ctype; /* controller type */ - ushort_t dki_flags; /* flags */ - ushort_t dki_cnum; /* controller number */ - uint_t dki_addr; /* controller address */ - uint_t dki_space; /* controller bus type */ - uint_t dki_prio; /* interrupt priority */ - uint_t dki_vec; /* interrupt vector */ - char dki_dname[DK_DEVLEN]; /* drive name (no unit #) */ - uint_t dki_unit; /* unit number */ - ushort_t dki_partition; /* partition number */ - ushort_t dki_maxtransfer; /* max. transfer size in DEV_BSIZE */ -}; - -/* - * Controller types - */ -#define DKC_UNKNOWN 0 -#define DKC_CDROM 1 /* CD-ROM, SCSI or otherwise */ -#define DKC_WDC2880 2 -#define DKC_XXX_0 3 /* unassigned */ -#define DKC_XXX_1 4 /* unassigned */ -#define DKC_DSD5215 5 -#define DKC_ACB4000 7 -#define DKC_MD21 8 -#define DKC_XXX_2 9 /* unassigned */ -#define DKC_NCRFLOPPY 10 -#define DKC_SMSFLOPPY 12 -#define DKC_SCSI_CCS 13 /* SCSI CCS compatible */ -#define DKC_INTEL82072 14 /* native floppy chip */ -#define DKC_MD 16 /* meta-disk (virtual-disk) driver */ -#define DKC_INTEL82077 19 /* 82077 floppy disk controller */ -#define DKC_DIRECT 20 /* Intel direct attached device i.e. IDE */ -#define DKC_PCMCIA_MEM 21 /* PCMCIA memory disk-like type */ -#define DKC_PCMCIA_ATA 22 /* PCMCIA AT Attached type */ -#define DKC_VBD 23 /* virtual block device */ - -/* - * Sun reserves up through 1023 - */ - -#define DKC_CUSTOMER_BASE 1024 - -/* - * Flags - */ -#define DKI_BAD144 0x01 /* use DEC std 144 bad sector fwding */ -#define DKI_MAPTRK 0x02 /* controller does track mapping */ -#define DKI_FMTTRK 0x04 /* formats only full track at a time */ -#define DKI_FMTVOL 0x08 /* formats only full volume at a time */ -#define DKI_FMTCYL 0x10 /* formats only full cylinders at a time */ -#define DKI_HEXUNIT 0x20 /* unit number is printed as 3 hex digits */ -#define DKI_PCMCIA_PFD 0x40 /* PCMCIA pseudo-floppy memory card */ - -/* - * partition headers: section 1 - * Returned in struct dk_allmap by ioctl DKIOC[SG]APART (dkio(7I)) - */ -struct dk_map { - uint64_t dkl_cylno; /* starting cylinder */ - uint64_t dkl_nblk; /* number of blocks; if == 0, */ - /* partition is undefined */ -}; - -/* - * Used for all partitions - */ -struct dk_allmap { - struct dk_map dka_map[NDKMAP]; -}; - -#if defined(_SYSCALL32) -struct dk_allmap32 { - struct dk_map32 dka_map[NDKMAP]; -}; -#endif /* _SYSCALL32 */ - -/* - * Definition of a disk's geometry - */ -struct dk_geom { - unsigned short dkg_ncyl; /* # of data cylinders */ - unsigned short dkg_acyl; /* # of alternate cylinders */ - unsigned short dkg_bcyl; /* cyl offset (for fixed head area) */ - unsigned short dkg_nhead; /* # of heads */ - unsigned short dkg_obs1; /* obsolete */ - unsigned short dkg_nsect; /* # of data sectors per track */ - unsigned short dkg_intrlv; /* interleave factor */ - unsigned short dkg_obs2; /* obsolete */ - unsigned short dkg_obs3; /* obsolete */ - unsigned short dkg_apc; /* alternates per cyl (SCSI only) */ - unsigned short dkg_rpm; /* revolutions per minute */ - unsigned short dkg_pcyl; /* # of physical cylinders */ - unsigned short dkg_write_reinstruct; /* # sectors to skip, writes */ - unsigned short dkg_read_reinstruct; /* # sectors to skip, reads */ - unsigned short dkg_extra[7]; /* for compatible expansion */ -}; - -/* - * These defines are for historic compatibility with old drivers. - */ -#define dkg_bhead dkg_obs1 /* used to be head offset */ -#define dkg_gap1 dkg_obs2 /* used to be gap1 */ -#define dkg_gap2 dkg_obs3 /* used to be gap2 */ - -/* - * Disk io control commands - * Warning: some other ioctls with the DIOC prefix exist elsewhere. - * The Generic DKIOC numbers are from 0 - 50. - * The Floppy Driver uses 51 - 100. - * The Hard Disk (except SCSI) 101 - 106. (these are obsolete) - * The CDROM Driver 151 - 200. - * The USCSI ioctl 201 - 250. - */ -#define DKIOC (0x04 << 8) - -/* - * The following ioctls are generic in nature and need to be - * supported as appropriate by all disk drivers - */ -#define DKIOCGGEOM (DKIOC|1) /* Get geometry */ -#define DKIOCINFO (DKIOC|3) /* Get info */ -#define DKIOCEJECT (DKIOC|6) /* Generic 'eject' */ -#define DKIOCGVTOC (DKIOC|11) /* Get VTOC */ -#define DKIOCSVTOC (DKIOC|12) /* Set VTOC & Write to Disk */ - -/* - * Disk Cache Controls. These ioctls should be supported by - * all disk drivers. - * - * DKIOCFLUSHWRITECACHE when used from user-mode ignores the ioctl - * argument, but it should be passed as NULL to allow for future - * reinterpretation. From user-mode, this ioctl request is synchronous. - * - * When invoked from within the kernel, the arg can be NULL to indicate - * a synchronous request or can be the address of a struct dk_callback - * to request an asynchronous callback when the flush request is complete. - * In this case, the flag to the ioctl must include FKIOCTL and the - * dkc_callback field of the pointed to struct must be non-null or the - * request is made synchronously. - * - * In the callback case: if the ioctl returns 0, a callback WILL be performed. - * If the ioctl returns non-zero, a callback will NOT be performed. - * NOTE: In some cases, the callback may be done BEFORE the ioctl call - * returns. The caller's locking strategy should be prepared for this case. - */ -#define DKIOCFLUSHWRITECACHE (DKIOC|34) /* flush cache to phys medium */ - -struct dk_callback { - void (*dkc_callback)(void *dkc_cookie, int error); - void *dkc_cookie; - int dkc_flag; -}; - -/* bit flag definitions for dkc_flag */ -#define FLUSH_VOLATILE 0x1 /* Bit 0: if set, only flush */ - /* volatile cache; otherwise, flush */ - /* volatile and non-volatile cache */ - -#define DKIOCGETWCE (DKIOC|36) /* Get current write cache */ - /* enablement status */ -#define DKIOCSETWCE (DKIOC|37) /* Enable/Disable write cache */ - -/* - * The following ioctls are used by Sun drivers to communicate - * with their associated format routines. Support of these ioctls - * is not required of foreign drivers - */ -#define DKIOCSGEOM (DKIOC|2) /* Set geometry */ -#define DKIOCSAPART (DKIOC|4) /* Set all partitions */ -#define DKIOCGAPART (DKIOC|5) /* Get all partitions */ -#define DKIOCG_PHYGEOM (DKIOC|32) /* get physical geometry */ -#define DKIOCG_VIRTGEOM (DKIOC|33) /* get virtual geometry */ - -/* - * The following ioctl's are removable media support - */ -#define DKIOCLOCK (DKIOC|7) /* Generic 'lock' */ -#define DKIOCUNLOCK (DKIOC|8) /* Generic 'unlock' */ -#define DKIOCSTATE (DKIOC|13) /* Inquire insert/eject state */ -#define DKIOCREMOVABLE (DKIOC|16) /* is media removable */ - - -/* - * ioctl for hotpluggable devices - */ -#define DKIOCHOTPLUGGABLE (DKIOC|35) /* is hotpluggable */ - -/* - * Ioctl to force driver to re-read the alternate partition and rebuild - * the internal defect map. - */ -#define DKIOCADDBAD (DKIOC|20) /* Re-read the alternate map (IDE) */ -#define DKIOCGETDEF (DKIOC|21) /* read defect list (IDE) */ - -/* - * Used by applications to get disk defect information from IDE - * drives. - */ -#ifdef _SYSCALL32 -struct defect_header32 { - int head; - caddr32_t buffer; -}; -#endif /* _SYSCALL32 */ - -struct defect_header { - int head; - caddr_t buffer; -}; - -#define DKIOCPARTINFO (DKIOC|22) /* Get partition or slice parameters */ - -/* - * Used by applications to get partition or slice information - */ -#ifdef _SYSCALL32 -struct part_info32 { - uint32_t p_start; - int p_length; -}; -#endif /* _SYSCALL32 */ - -struct part_info { - uint64_t p_start; - int p_length; -}; - -/* The following ioctls are for Optical Memory Device */ -#define DKIOC_EBP_ENABLE (DKIOC|40) /* enable by pass erase on write */ -#define DKIOC_EBP_DISABLE (DKIOC|41) /* disable by pass erase on write */ - -/* - * This state enum is the argument passed to the DKIOCSTATE ioctl. - */ -enum dkio_state { DKIO_NONE, DKIO_EJECTED, DKIO_INSERTED, DKIO_DEV_GONE }; - -#define DKIOCGMEDIAINFO (DKIOC|42) /* get information about the media */ - -/* - * ioctls to read/write mboot info. - */ -#define DKIOCGMBOOT (DKIOC|43) /* get mboot info */ -#define DKIOCSMBOOT (DKIOC|44) /* set mboot info */ - -/* - * ioctl to get the device temperature. - */ -#define DKIOCGTEMPERATURE (DKIOC|45) /* get temperature */ - -/* - * Used for providing the temperature. - */ - -struct dk_temperature { - uint_t dkt_flags; /* Flags */ - short dkt_cur_temp; /* Current disk temperature */ - short dkt_ref_temp; /* reference disk temperature */ -}; - -#define DKT_BYPASS_PM 0x1 -#define DKT_INVALID_TEMP 0xFFFF - - -/* - * Media types or profiles known - */ -#define DK_UNKNOWN 0x00 /* Media inserted - type unknown */ - - -/* - * SFF 8090 Specification Version 3, media types 0x01 - 0xfffe are retained to - * maintain compatibility with SFF8090. The following define the - * optical media type. - */ -#define DK_REMOVABLE_DISK 0x02 /* Removable Disk */ -#define DK_MO_ERASABLE 0x03 /* MO Erasable */ -#define DK_MO_WRITEONCE 0x04 /* MO Write once */ -#define DK_AS_MO 0x05 /* AS MO */ -#define DK_CDROM 0x08 /* CDROM */ -#define DK_CDR 0x09 /* CD-R */ -#define DK_CDRW 0x0A /* CD-RW */ -#define DK_DVDROM 0x10 /* DVD-ROM */ -#define DK_DVDR 0x11 /* DVD-R */ -#define DK_DVDRAM 0x12 /* DVD_RAM or DVD-RW */ - -/* - * Media types for other rewritable magnetic media - */ -#define DK_FIXED_DISK 0x10001 /* Fixed disk SCSI or otherwise */ -#define DK_FLOPPY 0x10002 /* Floppy media */ -#define DK_ZIP 0x10003 /* IOMEGA ZIP media */ -#define DK_JAZ 0x10004 /* IOMEGA JAZ media */ - -#define DKIOCSETEFI (DKIOC|17) /* Set EFI info */ -#define DKIOCGETEFI (DKIOC|18) /* Get EFI info */ - -#define DKIOCPARTITION (DKIOC|9) /* Get partition info */ - -/* - * Ioctls to get/set volume capabilities related to Logical Volume Managers. - * They include the ability to get/set capabilities and to issue a read to a - * specific underlying device of a replicated device. - */ - -#define DKIOCGETVOLCAP (DKIOC | 25) /* Get volume capabilities */ -#define DKIOCSETVOLCAP (DKIOC | 26) /* Set volume capabilities */ -#define DKIOCDMR (DKIOC | 27) /* Issue a directed read */ - -typedef uint_t volcapinfo_t; - -typedef uint_t volcapset_t; - -#define DKV_ABR_CAP 0x00000001 /* Support Appl.Based Recovery */ -#define DKV_DMR_CAP 0x00000002 /* Support Directed Mirror Read */ - -typedef struct volcap { - volcapinfo_t vc_info; /* Capabilities available */ - volcapset_t vc_set; /* Capabilities set */ -} volcap_t; - -#define VOL_SIDENAME 256 - -typedef struct vol_directed_rd { - int vdr_flags; - offset_t vdr_offset; - size_t vdr_nbytes; - size_t vdr_bytesread; - void *vdr_data; - int vdr_side; - char vdr_side_name[VOL_SIDENAME]; -} vol_directed_rd_t; - -#define DKV_SIDE_INIT (-1) -#define DKV_DMR_NEXT_SIDE 0x00000001 -#define DKV_DMR_DONE 0x00000002 -#define DKV_DMR_ERROR 0x00000004 -#define DKV_DMR_SUCCESS 0x00000008 -#define DKV_DMR_SHORT 0x00000010 - -#ifdef _MULTI_DATAMODEL -#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 -#pragma pack(4) -#endif -typedef struct vol_directed_rd32 { - int32_t vdr_flags; - offset_t vdr_offset; /* 64-bit element on 32-bit alignment */ - size32_t vdr_nbytes; - size32_t vdr_bytesread; - caddr32_t vdr_data; - int32_t vdr_side; - char vdr_side_name[VOL_SIDENAME]; -} vol_directed_rd32_t; -#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 -#pragma pack() -#endif -#endif /* _MULTI_DATAMODEL */ - -/* - * The ioctl is used to fetch disk's device type, vendor ID, - * model number/product ID, firmware revision and serial number together. - * - * Currently there are two device types - DKD_ATA_TYPE which means the - * disk is driven by cmdk/ata or dad/uata driver, and DKD_SCSI_TYPE - * which means the disk is driven by sd/scsi hba driver. - */ -#define DKIOC_GETDISKID (DKIOC|46) - -/* These two labels are for dkd_dtype of dk_disk_id_t */ -#define DKD_ATA_TYPE 0x01 /* ATA disk or legacy mode SATA disk */ -#define DKD_SCSI_TYPE 0x02 /* SCSI disk or native mode SATA disk */ - -#define DKD_ATA_MODEL 40 /* model number length */ -#define DKD_ATA_FWVER 8 /* firmware revision length */ -#define DKD_ATA_SERIAL 20 /* serial number length */ - -#define DKD_SCSI_VENDOR 8 /* vendor ID length */ -#define DKD_SCSI_PRODUCT 16 /* product ID length */ -#define DKD_SCSI_REVLEVEL 4 /* revision level length */ -#define DKD_SCSI_SERIAL 12 /* serial number length */ - -/* - * The argument type for DKIOC_GETDISKID ioctl. - */ -typedef struct dk_disk_id { - uint_t dkd_dtype; - union { - struct { - char dkd_amodel[DKD_ATA_MODEL]; /* 40 bytes */ - char dkd_afwver[DKD_ATA_FWVER]; /* 8 bytes */ - char dkd_aserial[DKD_ATA_SERIAL]; /* 20 bytes */ - } ata_disk_id; - struct { - char dkd_svendor[DKD_SCSI_VENDOR]; /* 8 bytes */ - char dkd_sproduct[DKD_SCSI_PRODUCT]; /* 16 bytes */ - char dkd_sfwver[DKD_SCSI_REVLEVEL]; /* 4 bytes */ - char dkd_sserial[DKD_SCSI_SERIAL]; /* 12 bytes */ - } scsi_disk_id; - } disk_id; -} dk_disk_id_t; - -/* - * The ioctl is used to update the firmware of device. - */ -#define DKIOC_UPDATEFW (DKIOC|47) - -/* The argument type for DKIOC_UPDATEFW ioctl */ -typedef struct dk_updatefw { - caddr_t dku_ptrbuf; /* pointer to firmware buf */ - uint_t dku_size; /* firmware buf length */ - uint8_t dku_type; /* firmware update type */ -} dk_updatefw_t; - -#ifdef _SYSCALL32 -typedef struct dk_updatefw_32 { - caddr32_t dku_ptrbuf; /* pointer to firmware buf */ - uint_t dku_size; /* firmware buf length */ - uint8_t dku_type; /* firmware update type */ -} dk_updatefw_32_t; -#endif /* _SYSCALL32 */ - -/* - * firmware update type - temporary or permanent use - */ -#define FW_TYPE_TEMP 0x0 /* temporary use */ -#define FW_TYPE_PERM 0x1 /* permanent use */ - - -#ifdef __cplusplus -} -#endif - -#endif /* _OPENSOLARIS_SYS_DKIO_H_ */ diff --git a/include/os/freebsd/spl/sys/extdirent.h b/include/os/freebsd/spl/sys/extdirent.h deleted file mode 100644 index b22e8e8563a2..000000000000 --- a/include/os/freebsd/spl/sys/extdirent.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _SYS_EXTDIRENT_H -#define _SYS_EXTDIRENT_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <sys/types.h> -#include <sys/dirent.h> - -/* - * Extended file-system independent directory entry. This style of - * dirent provides additional informational flag bits for each - * directory entry. This dirent will be returned instead of the - * standard dirent if a VOP_READDIR() requests dirent flags via - * V_RDDIR_ENTFLAGS, and if the file system supports the flags. - */ -typedef struct edirent { - ino64_t ed_ino; /* "inode number" of entry */ - off64_t ed_off; /* offset of disk directory entry */ - uint32_t ed_eflags; /* per-entry flags */ - unsigned short ed_reclen; /* length of this record */ - char ed_name[1]; /* name of file */ -} edirent_t; - -#define EDIRENT_RECLEN(namelen) \ - ((offsetof(edirent_t, ed_name[0]) + 1 + (namelen) + 7) & ~ 7) -#define EDIRENT_NAMELEN(reclen) \ - ((reclen) - (offsetof(edirent_t, ed_name[0]))) - -/* - * Extended entry flags - * Extended entries include a bitfield of extra information - * regarding that entry. - */ -#define ED_CASE_CONFLICT 0x10 /* Disconsidering case, entry is not unique */ - -/* - * Extended flags accessor function - */ -#define ED_CASE_CONFLICTS(x) ((x)->ed_eflags & ED_CASE_CONFLICT) -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_EXTDIRENT_H */ diff --git a/include/os/freebsd/spl/sys/ia32/asm_linkage.h b/include/os/freebsd/spl/sys/ia32/asm_linkage.h new file mode 100644 index 000000000000..d1f53cf22f41 --- /dev/null +++ b/include/os/freebsd/spl/sys/ia32/asm_linkage.h @@ -0,0 +1,178 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or https://opensource.org/licenses/CDDL-1.0. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _IA32_SYS_ASM_LINKAGE_H +#define _IA32_SYS_ASM_LINKAGE_H + +#define RET ret + +/* Tell compiler to call assembler like Unix */ +#undef ASMABI +#define ASMABI __attribute__((sysv_abi)) + +#define ENDBR + +#define SECTION_TEXT .text +#define SECTION_STATIC .section .rodata + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _ASM /* The remainder of this file is only for assembly files */ + + +/* + * make annoying differences in assembler syntax go away + */ + +/* + * D16 and A16 are used to insert instructions prefixes; the + * macros help the assembler code be slightly more portable. + */ +#if !defined(__GNUC_AS__) +/* + * /usr/ccs/bin/as prefixes are parsed as separate instructions + */ +#define D16 data16; +#define A16 addr16; + +/* + * (There are some weird constructs in constant expressions) + */ +#define _CONST(const) [const] +#define _BITNOT(const) -1!_CONST(const) +#define _MUL(a, b) _CONST(a \* b) + +#else +/* + * Why not use the 'data16' and 'addr16' prefixes .. well, the + * assembler doesn't quite believe in real mode, and thus argues with + * us about what we're trying to do. + */ +#define D16 .byte 0x66; +#define A16 .byte 0x67; + +#define _CONST(const) (const) +#define _BITNOT(const) ~_CONST(const) +#define _MUL(a, b) _CONST(a * b) + +#endif + +/* + * C pointers are different sizes between i386 and amd64. + * These constants can be used to compute offsets into pointer arrays. + */ +#if defined(__amd64) +#define CLONGSHIFT 3 +#define CLONGSIZE 8 +#define CLONGMASK 7 +#elif defined(__i386) +#define CLONGSHIFT 2 +#define CLONGSIZE 4 +#define CLONGMASK 3 +#endif + +/* + * Since we know we're either ILP32 or LP64 .. + */ +#define CPTRSHIFT CLONGSHIFT +#define CPTRSIZE CLONGSIZE +#define CPTRMASK CLONGMASK + +#if CPTRSIZE != (1 << CPTRSHIFT) || CLONGSIZE != (1 << CLONGSHIFT) +#error "inconsistent shift constants" +#endif + +#if CPTRMASK != (CPTRSIZE - 1) || CLONGMASK != (CLONGSIZE - 1) +#error "inconsistent mask constants" +#endif + +#define ASM_ENTRY_ALIGN 16 + +/* + * SSE register alignment and save areas + */ + +#define XMM_SIZE 16 +#define XMM_ALIGN 16 + +/* + * ENTRY provides the standard procedure entry code and an easy way to + * insert the calls to mcount for profiling. ENTRY_NP is identical, but + * never calls mcount. + */ +#define ENTRY(x) \ + .text; \ + .balign ASM_ENTRY_ALIGN; \ + .globl x; \ +x: MCOUNT(x) + +#define ENTRY_NP(x) \ + .text; \ + .balign ASM_ENTRY_ALIGN; \ + .globl x; \ +x: + +#define ENTRY_ALIGN(x, a) \ + .text; \ + .balign a; \ + .globl x; \ +x: + +/* + * ENTRY2 is identical to ENTRY but provides two labels for the entry point. + */ +#define ENTRY2(x, y) \ + .text; \ + .balign ASM_ENTRY_ALIGN; \ + .globl x, y; \ +x:; \ +y: MCOUNT(x) + +#define ENTRY_NP2(x, y) \ + .text; \ + .balign ASM_ENTRY_ALIGN; \ + .globl x, y; \ +x:; \ +y: + + +/* + * SET_SIZE trails a function and set the size for the ELF symbol table. + */ +#define SET_SIZE(x) + +#define SET_OBJ(x) + + +#endif /* _ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _IA32_SYS_ASM_LINKAGE_H */ diff --git a/include/os/freebsd/spl/sys/idmap.h b/include/os/freebsd/spl/sys/idmap.h index 39eeb905c72b..bd2383794f18 100644 --- a/include/os/freebsd/spl/sys/idmap.h +++ b/include/os/freebsd/spl/sys/idmap.h @@ -6,7 +6,7 @@ * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. + * or https://opensource.org/licenses/CDDL-1.0. * See the License for the specific language governing permissions * and limitations under the License. * diff --git a/include/os/freebsd/spl/sys/isa_defs.h b/include/os/freebsd/spl/sys/isa_defs.h index 399d510b5f9b..9eba593fa797 100644 --- a/include/os/freebsd/spl/sys/isa_defs.h +++ b/include/os/freebsd/spl/sys/isa_defs.h @@ -6,7 +6,7 @@ * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. + * or https://opensource.org/licenses/CDDL-1.0. * See the License for the specific language governing permissions * and limitations under the License. * @@ -41,59 +41,6 @@ * The natural byte order of the processor. A pointer to an int points * to the least/most significant byte of that int. * - * _STACK_GROWS_UPWARD / _STACK_GROWS_DOWNWARD: - * The processor specific direction of stack growth. A push onto the - * stack increases/decreases the stack pointer, so it stores data at - * successively higher/lower addresses. (Stackless machines ignored - * without regrets). - * - * _LONG_LONG_HTOL / _LONG_LONG_LTOH: - * A pointer to a long long points to the most/least significant long - * within that long long. - * - * _BIT_FIELDS_HTOL / _BIT_FIELDS_LTOH: - * The C compiler assigns bit fields from the high/low to the low/high end - * of an int (most to least significant vs. least to most significant). - * - * _IEEE_754: - * The processor (or supported implementations of the processor) - * supports the ieee-754 floating point standard. No other floating - * point standards are supported (or significant). Any other supported - * floating point formats are expected to be cased on the ISA processor - * symbol. - * - * _CHAR_IS_UNSIGNED / _CHAR_IS_SIGNED: - * The C Compiler implements objects of type `char' as `unsigned' or - * `signed' respectively. This is really an implementation choice of - * the compiler writer, but it is specified in the ABI and tends to - * be uniform across compilers for an instruction set architecture. - * Hence, it has the properties of a processor characteristic. - * - * _CHAR_ALIGNMENT / _SHORT_ALIGNMENT / _INT_ALIGNMENT / _LONG_ALIGNMENT / - * _LONG_LONG_ALIGNMENT / _DOUBLE_ALIGNMENT / _LONG_DOUBLE_ALIGNMENT / - * _POINTER_ALIGNMENT / _FLOAT_ALIGNMENT: - * The ABI defines alignment requirements of each of the primitive - * object types. Some, if not all, may be hardware requirements as - * well. The values are expressed in "byte-alignment" units. - * - * _MAX_ALIGNMENT: - * The most stringent alignment requirement as specified by the ABI. - * Equal to the maximum of all the above _XXX_ALIGNMENT values. - * - * _ALIGNMENT_REQUIRED: - * True or false (1 or 0) whether or not the hardware requires the ABI - * alignment. - * - * _LONG_LONG_ALIGNMENT_32 - * The 32-bit ABI supported by a 64-bit kernel may have different - * alignment requirements for primitive object types. The value of this - * identifier is expressed in "byte-alignment" units. - * - * _HAVE_CPUID_INSN - * This indicates that the architecture supports the 'cpuid' - * instruction as defined by Intel. (Intel allows other vendors - * to extend the instruction for their own purposes.) - * * * Implementation Choices: * @@ -112,10 +59,6 @@ * Long/Pointer are 64 bits, Int is 32 bits. This is the chosen * implementation for 64-bit ABIs such as SPARC V9. * - * _I32LPx: - * A compilation environment where 'int' is 32-bit, and - * longs and pointers are simply the same size. - * * In all cases, Char is 8 bits and Short is 16 bits. * * _SUNOS_VTOC_8 / _SUNOS_VTOC_16 / _SVR4_VTOC_16: @@ -141,78 +84,10 @@ * 16 partitions per disk. * * - * _DMA_USES_PHYSADDR / _DMA_USES_VIRTADDR - * This describes the type of addresses used by system DMA: - * - * _DMA_USES_PHYSADDR: - * This type of DMA, used in the x86 implementation, - * requires physical addresses for DMA buffers. The 24-bit - * addresses used by some legacy boards is the source of the - * "low-memory" (<16MB) requirement for some devices using DMA. - * - * _DMA_USES_VIRTADDR: - * This method of DMA allows the use of virtual addresses for - * DMA transfers. - * - * _FIRMWARE_NEEDS_FDISK / _NO_FDISK_PRESENT - * This indicates the presence/absence of an fdisk table. - * - * _FIRMWARE_NEEDS_FDISK - * The fdisk table is required by system firmware. If present, - * it allows a disk to be subdivided into multiple fdisk - * partitions, each of which is equivalent to a separate, - * virtual disk. This enables the co-existence of multiple - * operating systems on a shared hard disk. - * - * _NO_FDISK_PRESENT - * If the fdisk table is absent, it is assumed that the entire - * media is allocated for a single operating system. - * - * _HAVE_TEM_FIRMWARE - * Defined if this architecture has the (fallback) option of - * using prom_* calls for doing I/O if a suitable kernel driver - * is not available to do it. - * - * _DONT_USE_1275_GENERIC_NAMES - * Controls whether or not device tree node names should - * comply with the IEEE 1275 "Generic Names" Recommended - * Practice. With _DONT_USE_GENERIC_NAMES, device-specific - * names identifying the particular device will be used. - * - * __i386_COMPAT - * This indicates whether the i386 ABI is supported as a *non-native* - * mode for the platform. When this symbol is defined: - * - 32-bit xstat-style system calls are enabled - * - 32-bit xmknod-style system calls are enabled - * - 32-bit system calls use i386 sizes -and- alignments - * - * Note that this is NOT defined for the i386 native environment! - * * __x86 * This is ONLY a synonym for defined(__i386) || defined(__amd64) * which is useful only insofar as these two architectures share * common attributes. Analogous to __sparc. - * - * _PSM_MODULES - * This indicates whether or not the implementation uses PSM - * modules for processor support, reading /etc/mach from inside - * the kernel to extract a list. - * - * _RTC_CONFIG - * This indicates whether or not the implementation uses /etc/rtc_config - * to configure the real-time clock in the kernel. - * - * _UNIX_KRTLD - * This indicates that the implementation uses a dynamically - * linked unix + krtld to form the core kernel image at boot - * time, or (in the absence of this symbol) a prelinked kernel image. - * - * _OBP - * This indicates the firmware interface is OBP. - * - * _SOFT_HOSTID - * This indicates that the implementation obtains the hostid - * from the file /etc/hostid, rather than from hardware. */ #ifdef __cplusplus @@ -234,53 +109,12 @@ extern "C" { #endif /* - * Define the appropriate "processor characteristics" - */ -#define _STACK_GROWS_DOWNWARD -#define _LONG_LONG_LTOH -#define _BIT_FIELDS_LTOH -#define _IEEE_754 -#define _CHAR_IS_SIGNED -#define _BOOL_ALIGNMENT 1 -#define _CHAR_ALIGNMENT 1 -#define _SHORT_ALIGNMENT 2 -#define _INT_ALIGNMENT 4 -#define _FLOAT_ALIGNMENT 4 -#define _FLOAT_COMPLEX_ALIGNMENT 4 -#define _LONG_ALIGNMENT 8 -#define _LONG_LONG_ALIGNMENT 8 -#define _DOUBLE_ALIGNMENT 8 -#define _DOUBLE_COMPLEX_ALIGNMENT 8 -#define _LONG_DOUBLE_ALIGNMENT 16 -#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 16 -#define _POINTER_ALIGNMENT 8 -#define _MAX_ALIGNMENT 16 -#define _ALIGNMENT_REQUIRED 1 - -/* - * Different alignment constraints for the i386 ABI in compatibility mode - */ -#define _LONG_LONG_ALIGNMENT_32 4 - -/* * Define the appropriate "implementation choices". */ #if !defined(_LP64) #error "_LP64 not defined" #endif -#if !defined(_I32LPx) -#define _I32LPx -#endif -#define _MULTI_DATAMODEL #define _SUNOS_VTOC_16 -#define _DMA_USES_PHYSADDR -#define _FIRMWARE_NEEDS_FDISK -#define __i386_COMPAT -#define _PSM_MODULES -#define _RTC_CONFIG -#define _SOFT_HOSTID -#define _DONT_USE_1275_GENERIC_NAMES -#define _HAVE_CPUID_INSN /* * The feature test macro __i386 is generic for all processors implementing @@ -298,206 +132,46 @@ extern "C" { #endif /* - * Define the appropriate "processor characteristics" - */ -#define _STACK_GROWS_DOWNWARD -#define _LONG_LONG_LTOH -#define _BIT_FIELDS_LTOH -#define _IEEE_754 -#define _CHAR_IS_SIGNED -#define _BOOL_ALIGNMENT 1 -#define _CHAR_ALIGNMENT 1 -#define _SHORT_ALIGNMENT 2 -#define _INT_ALIGNMENT 4 -#define _FLOAT_ALIGNMENT 4 -#define _FLOAT_COMPLEX_ALIGNMENT 4 -#define _LONG_ALIGNMENT 4 -#define _LONG_LONG_ALIGNMENT 4 -#define _DOUBLE_ALIGNMENT 4 -#define _DOUBLE_COMPLEX_ALIGNMENT 4 -#define _LONG_DOUBLE_ALIGNMENT 4 -#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 4 -#define _POINTER_ALIGNMENT 4 -#define _MAX_ALIGNMENT 4 -#define _ALIGNMENT_REQUIRED 0 - -#define _LONG_LONG_ALIGNMENT_32 _LONG_LONG_ALIGNMENT - -/* * Define the appropriate "implementation choices". */ #if !defined(_ILP32) #define _ILP32 #endif -#if !defined(_I32LPx) -#define _I32LPx -#endif #define _SUNOS_VTOC_16 -#define _DMA_USES_PHYSADDR -#define _FIRMWARE_NEEDS_FDISK -#define _PSM_MODULES -#define _RTC_CONFIG -#define _SOFT_HOSTID -#define _DONT_USE_1275_GENERIC_NAMES -#define _HAVE_CPUID_INSN #elif defined(__aarch64__) /* - * Define the appropriate "processor characteristics" - */ -#define _STACK_GROWS_DOWNWARD -#define _LONG_LONG_LTOH -#define _BIT_FIELDS_LTOH -#define _IEEE_754 -#define _CHAR_IS_UNSIGNED -#define _BOOL_ALIGNMENT 1 -#define _CHAR_ALIGNMENT 1 -#define _SHORT_ALIGNMENT 2 -#define _INT_ALIGNMENT 4 -#define _FLOAT_ALIGNMENT 4 -#define _FLOAT_COMPLEX_ALIGNMENT 4 -#define _LONG_ALIGNMENT 8 -#define _LONG_LONG_ALIGNMENT 8 -#define _DOUBLE_ALIGNMENT 8 -#define _DOUBLE_COMPLEX_ALIGNMENT 8 -#define _LONG_DOUBLE_ALIGNMENT 16 -#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 16 -#define _POINTER_ALIGNMENT 8 -#define _MAX_ALIGNMENT 16 -#define _ALIGNMENT_REQUIRED 1 - -#define _LONG_LONG_ALIGNMENT_32 _LONG_LONG_ALIGNMENT - -/* * Define the appropriate "implementation choices" */ #if !defined(_LP64) #error "_LP64 not defined" #endif #define _SUNOS_VTOC_16 -#define _DMA_USES_PHYSADDR -#define _FIRMWARE_NEEDS_FDISK -#define _PSM_MODULES -#define _RTC_CONFIG -#define _DONT_USE_1275_GENERIC_NAMES -#define _HAVE_CPUID_INSN #elif defined(__riscv) /* - * Define the appropriate "processor characteristics" - */ -#define _STACK_GROWS_DOWNWARD -#define _LONG_LONG_LTOH -#define _BIT_FIELDS_LTOH -#define _IEEE_754 -#define _CHAR_IS_UNSIGNED -#define _BOOL_ALIGNMENT 1 -#define _CHAR_ALIGNMENT 1 -#define _SHORT_ALIGNMENT 2 -#define _INT_ALIGNMENT 4 -#define _FLOAT_ALIGNMENT 4 -#define _FLOAT_COMPLEX_ALIGNMENT 4 -#define _LONG_ALIGNMENT 8 -#define _LONG_LONG_ALIGNMENT 8 -#define _DOUBLE_ALIGNMENT 8 -#define _DOUBLE_COMPLEX_ALIGNMENT 8 -#define _LONG_DOUBLE_ALIGNMENT 16 -#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 16 -#define _POINTER_ALIGNMENT 8 -#define _MAX_ALIGNMENT 16 -#define _ALIGNMENT_REQUIRED 1 - -#define _LONG_LONG_ALIGNMENT_32 _LONG_LONG_ALIGNMENT - -/* * Define the appropriate "implementation choices" */ #if !defined(_LP64) #define _LP64 #endif #define _SUNOS_VTOC_16 -#define _DMA_USES_PHYSADDR -#define _FIRMWARE_NEEDS_FDISK -#define _PSM_MODULES -#define _RTC_CONFIG -#define _DONT_USE_1275_GENERIC_NAMES -#define _HAVE_CPUID_INSN #elif defined(__arm__) /* - * Define the appropriate "processor characteristics" - */ -#define _STACK_GROWS_DOWNWARD -#define _LONG_LONG_LTOH -#define _BIT_FIELDS_LTOH -#define _IEEE_754 -#define _CHAR_IS_SIGNED -#define _BOOL_ALIGNMENT 1 -#define _CHAR_ALIGNMENT 1 -#define _SHORT_ALIGNMENT 2 -#define _INT_ALIGNMENT 4 -#define _FLOAT_ALIGNMENT 4 -#define _FLOAT_COMPLEX_ALIGNMENT 4 -#define _LONG_ALIGNMENT 4 -#define _LONG_LONG_ALIGNMENT 4 -#define _DOUBLE_ALIGNMENT 4 -#define _DOUBLE_COMPLEX_ALIGNMENT 4 -#define _LONG_DOUBLE_ALIGNMENT 4 -#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 4 -#define _POINTER_ALIGNMENT 4 -#define _MAX_ALIGNMENT 4 -#define _ALIGNMENT_REQUIRED 0 - -#define _LONG_LONG_ALIGNMENT_32 _LONG_LONG_ALIGNMENT - -/* * Define the appropriate "implementation choices". */ #if !defined(_ILP32) #define _ILP32 #endif -#if !defined(_I32LPx) -#define _I32LPx -#endif #define _SUNOS_VTOC_16 -#define _DMA_USES_PHYSADDR -#define _FIRMWARE_NEEDS_FDISK -#define _PSM_MODULES -#define _RTC_CONFIG -#define _DONT_USE_1275_GENERIC_NAMES -#define _HAVE_CPUID_INSN #elif defined(__mips__) -/* - * Define the appropriate "processor characteristics" - */ -#define _STACK_GROWS_DOWNWARD -#define _LONG_LONG_LTOH -#define _BIT_FIELDS_LTOH -#define _IEEE_754 -#define _CHAR_IS_SIGNED -#define _BOOL_ALIGNMENT 1 -#define _CHAR_ALIGNMENT 1 -#define _SHORT_ALIGNMENT 2 -#define _INT_ALIGNMENT 4 -#define _FLOAT_ALIGNMENT 4 -#define _FLOAT_COMPLEX_ALIGNMENT 4 #if defined(__mips_n64) -#define _LONG_ALIGNMENT 8 -#define _LONG_LONG_ALIGNMENT 8 -#define _DOUBLE_ALIGNMENT 8 -#define _DOUBLE_COMPLEX_ALIGNMENT 8 -#define _LONG_DOUBLE_ALIGNMENT 8 -#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 8 -#define _POINTER_ALIGNMENT 8 -#define _MAX_ALIGNMENT 8 -#define _ALIGNMENT_REQUIRED 0 - -#define _LONG_LONG_ALIGNMENT_32 _INT_ALIGNMENT /* * Define the appropriate "implementation choices". */ @@ -505,57 +179,21 @@ extern "C" { #error "_LP64 not defined" #endif #else -#define _LONG_ALIGNMENT 4 -#define _LONG_LONG_ALIGNMENT 4 -#define _DOUBLE_ALIGNMENT 4 -#define _DOUBLE_COMPLEX_ALIGNMENT 4 -#define _LONG_DOUBLE_ALIGNMENT 4 -#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 4 -#define _POINTER_ALIGNMENT 4 -#define _MAX_ALIGNMENT 4 -#define _ALIGNMENT_REQUIRED 0 - -#define _LONG_LONG_ALIGNMENT_32 _LONG_LONG_ALIGNMENT - /* * Define the appropriate "implementation choices". */ #if !defined(_ILP32) #define _ILP32 #endif -#if !defined(_I32LPx) -#define _I32LPx -#endif #endif #define _SUNOS_VTOC_16 -#define _DMA_USES_PHYSADDR -#define _FIRMWARE_NEEDS_FDISK -#define _PSM_MODULES -#define _RTC_CONFIG -#define _DONT_USE_1275_GENERIC_NAMES -#define _HAVE_CPUID_INSN #elif defined(__powerpc__) -#if defined(__BIG_ENDIAN__) -#define _BIT_FIELDS_HTOL -#else -#define _BIT_FIELDS_LTOH -#endif - #if !defined(__powerpc) #define __powerpc #endif -#if defined(__powerpc64__) -#define _LONG_LONG_ALIGNMENT 8 -#define _MULTI_DATAMODEL -#else -#define _LONG_LONG_ALIGNMENT 4 -#endif -#define _LONG_LONG_ALIGNMENT_32 4 -#define _ALIGNMENT_REQUIRED 1 - #define _SUNOS_VTOC_16 1 /* @@ -601,33 +239,9 @@ extern "C" { #endif /* - * Define the appropriate "processor characteristics" shared between - * all Solaris on SPARC systems. - */ -#define _STACK_GROWS_DOWNWARD -#define _LONG_LONG_HTOL -#define _BIT_FIELDS_HTOL -#define _IEEE_754 -#define _CHAR_IS_SIGNED -#define _BOOL_ALIGNMENT 1 -#define _CHAR_ALIGNMENT 1 -#define _SHORT_ALIGNMENT 2 -#define _INT_ALIGNMENT 4 -#define _FLOAT_ALIGNMENT 4 -#define _FLOAT_COMPLEX_ALIGNMENT 4 -#define _LONG_LONG_ALIGNMENT 8 -#define _DOUBLE_ALIGNMENT 8 -#define _DOUBLE_COMPLEX_ALIGNMENT 8 -#define _ALIGNMENT_REQUIRED 1 - -/* * Define the appropriate "implementation choices" shared between versions. */ #define _SUNOS_VTOC_8 -#define _DMA_USES_VIRTADDR -#define _NO_FDISK_PRESENT -#define _HAVE_TEM_FIRMWARE -#define _OBP /* * The following set of definitions characterize the implementation of @@ -636,23 +250,9 @@ extern "C" { #if defined(__sparcv8) /* - * Define the appropriate "processor characteristics" - */ -#define _LONG_ALIGNMENT 4 -#define _LONG_DOUBLE_ALIGNMENT 8 -#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 8 -#define _POINTER_ALIGNMENT 4 -#define _MAX_ALIGNMENT 8 - -#define _LONG_LONG_ALIGNMENT_32 _LONG_LONG_ALIGNMENT - -/* * Define the appropriate "implementation choices" */ #define _ILP32 -#if !defined(_I32LPx) -#define _I32LPx -#endif /* * The following set of definitions characterize the implementation of @@ -661,26 +261,11 @@ extern "C" { #elif defined(__sparcv9) /* - * Define the appropriate "processor characteristics" - */ -#define _LONG_ALIGNMENT 8 -#define _LONG_DOUBLE_ALIGNMENT 16 -#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 16 -#define _POINTER_ALIGNMENT 8 -#define _MAX_ALIGNMENT 16 - -#define _LONG_LONG_ALIGNMENT_32 _LONG_LONG_ALIGNMENT - -/* * Define the appropriate "implementation choices" */ #if !defined(_LP64) #error "_LP64 not defined" #endif -#if !defined(_I32LPx) -#define _I32LPx -#endif -#define _MULTI_DATAMODEL #else #error "unknown SPARC version" diff --git a/include/os/freebsd/spl/sys/kmem.h b/include/os/freebsd/spl/sys/kmem.h index a81cb1fb521d..c633799318d5 100644 --- a/include/os/freebsd/spl/sys/kmem.h +++ b/include/os/freebsd/spl/sys/kmem.h @@ -52,8 +52,13 @@ MALLOC_DECLARE(M_SOLARIS); typedef struct vmem vmem_t; -extern char *kmem_asprintf(const char *, ...); -extern char *kmem_vasprintf(const char *fmt, va_list ap); +extern char *kmem_asprintf(const char *, ...) + __attribute__((format(printf, 1, 2))); +extern char *kmem_vasprintf(const char *fmt, va_list ap) + __attribute__((format(printf, 1, 0))); + +extern int kmem_scnprintf(char *restrict str, size_t size, + const char *restrict fmt, ...); typedef struct kmem_cache { char kc_name[32]; @@ -70,6 +75,7 @@ typedef struct kmem_cache { extern uint64_t spl_kmem_cache_inuse(kmem_cache_t *cache); extern uint64_t spl_kmem_cache_entry_size(kmem_cache_t *cache); +__attribute__((malloc, alloc_size(1))) void *zfs_kmem_alloc(size_t size, int kmflags); void zfs_kmem_free(void *buf, size_t size); uint64_t kmem_size(void); @@ -77,6 +83,7 @@ kmem_cache_t *kmem_cache_create(const char *name, size_t bufsize, size_t align, int (*constructor)(void *, void *, int), void (*destructor)(void *, void *), void (*reclaim)(void *) __unused, void *private, vmem_t *vmp, int cflags); void kmem_cache_destroy(kmem_cache_t *cache); +__attribute__((malloc)) void *kmem_cache_alloc(kmem_cache_t *cache, int flags); void kmem_cache_free(kmem_cache_t *cache, void *buf); boolean_t kmem_cache_reap_active(void); diff --git a/include/os/freebsd/spl/sys/kstat.h b/include/os/freebsd/spl/sys/kstat.h index 947dfee62393..7dc2c4753b02 100644 --- a/include/os/freebsd/spl/sys/kstat.h +++ b/include/os/freebsd/spl/sys/kstat.h @@ -94,7 +94,7 @@ void seq_printf(struct seq_file *m, const char *fmt, ...); typedef struct kstat_module { - char ksm_name[KSTAT_STRLEN+1]; /* module name */ + char ksm_name[KSTAT_STRLEN]; /* module name */ struct list_head ksm_module_list; /* module linkage */ struct list_head ksm_kstat_list; /* list of kstat entries */ struct proc_dir_entry *ksm_proc; /* proc entry */ @@ -112,10 +112,10 @@ struct kstat_s { kid_t ks_kid; /* unique kstat ID */ hrtime_t ks_crtime; /* creation time */ hrtime_t ks_snaptime; /* last access time */ - char ks_module[KSTAT_STRLEN+1]; /* provider module name */ + char ks_module[KSTAT_STRLEN]; /* provider module name */ int ks_instance; /* provider module instance */ - char ks_name[KSTAT_STRLEN+1]; /* kstat name */ - char ks_class[KSTAT_STRLEN+1]; /* kstat class */ + char ks_name[KSTAT_STRLEN]; /* kstat name */ + char ks_class[KSTAT_STRLEN]; /* kstat class */ uchar_t ks_type; /* kstat data type */ uchar_t ks_flags; /* kstat flags */ void *ks_data; /* kstat type-specific data */ @@ -181,7 +181,7 @@ typedef struct kstat_io { } kstat_io_t; typedef struct kstat_timer { - char name[KSTAT_STRLEN+1]; /* event name */ + char name[KSTAT_STRLEN]; /* event name */ u_longlong_t num_events; /* number of events */ hrtime_t elapsed_time; /* cumulative elapsed time */ hrtime_t min_time; /* shortest event duration */ diff --git a/include/os/freebsd/spl/sys/list.h b/include/os/freebsd/spl/sys/list.h index 6db92ed42955..6c32402a7bd1 100644 --- a/include/os/freebsd/spl/sys/list.h +++ b/include/os/freebsd/spl/sys/list.h @@ -6,7 +6,7 @@ * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. + * or https://opensource.org/licenses/CDDL-1.0. * See the License for the specific language governing permissions * and limitations under the License. * diff --git a/include/os/freebsd/spl/sys/list_impl.h b/include/os/freebsd/spl/sys/list_impl.h index a6614f9a38c2..06a5c6d1dbc6 100644 --- a/include/os/freebsd/spl/sys/list_impl.h +++ b/include/os/freebsd/spl/sys/list_impl.h @@ -7,7 +7,7 @@ * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. + * or https://opensource.org/licenses/CDDL-1.0. * See the License for the specific language governing permissions * and limitations under the License. * @@ -39,7 +39,6 @@ struct list_node { }; struct list { - size_t list_size; size_t list_offset; struct list_node list_head; }; diff --git a/include/os/freebsd/spl/sys/mod_os.h b/include/os/freebsd/spl/sys/mod_os.h index 3a9ebbfc3bc4..df7be6fc13f6 100644 --- a/include/os/freebsd/spl/sys/mod_os.h +++ b/include/os/freebsd/spl/sys/mod_os.h @@ -31,10 +31,6 @@ #include <sys/sysctl.h> -#define EXPORT_SYMBOL(x) -#define module_param(a, b, c) -#define MODULE_PARM_DESC(a, b) - #define ZMOD_RW CTLFLAG_RWTUN #define ZMOD_RD CTLFLAG_RDTUN @@ -47,7 +43,7 @@ #define ZFS_MODULE_PARAM_CALL_IMPL(parent, name, perm, args, desc) \ SYSCTL_DECL(parent); \ - SYSCTL_PROC(parent, OID_AUTO, name, perm | args, desc) + SYSCTL_PROC(parent, OID_AUTO, name, CTLFLAG_MPSAFE | perm | args, desc) #define ZFS_MODULE_PARAM_CALL( \ scope_prefix, name_prefix, name, func, _, perm, desc) \ @@ -56,42 +52,66 @@ #define ZFS_MODULE_VIRTUAL_PARAM_CALL ZFS_MODULE_PARAM_CALL -#define param_set_arc_long_args(var) \ - CTLTYPE_ULONG, &var, 0, param_set_arc_long, "LU" +#define param_set_arc_u64_args(var) \ + CTLTYPE_U64, &var, 0, param_set_arc_u64, "QU" + +#define param_set_arc_int_args(var) \ + CTLTYPE_INT, &var, 0, param_set_arc_int, "I" #define param_set_arc_min_args(var) \ - CTLTYPE_ULONG, &var, 0, param_set_arc_min, "LU" + CTLTYPE_U64, NULL, 0, param_set_arc_min, "QU" #define param_set_arc_max_args(var) \ - CTLTYPE_ULONG, &var, 0, param_set_arc_max, "LU" + CTLTYPE_U64, NULL, 0, param_set_arc_max, "QU" -#define param_set_arc_int_args(var) \ - CTLTYPE_INT, &var, 0, param_set_arc_int, "I" +#define param_set_arc_free_target_args(var) \ + CTLTYPE_UINT, NULL, 0, param_set_arc_free_target, "IU" + +#define param_set_arc_no_grow_shift_args(var) \ + CTLTYPE_INT, NULL, 0, param_set_arc_no_grow_shift, "I" #define param_set_deadman_failmode_args(var) \ CTLTYPE_STRING, NULL, 0, param_set_deadman_failmode, "A" +#define param_set_active_allocator_args(var) \ + CTLTYPE_STRING, NULL, 0, param_set_active_allocator, "A" + #define param_set_deadman_synctime_args(var) \ - CTLTYPE_ULONG, NULL, 0, param_set_deadman_synctime, "LU" + CTLTYPE_U64, NULL, 0, param_set_deadman_synctime, "QU" #define param_set_deadman_ziotime_args(var) \ - CTLTYPE_ULONG, NULL, 0, param_set_deadman_ziotime, "LU" + CTLTYPE_U64, NULL, 0, param_set_deadman_ziotime, "QU" #define param_set_multihost_interval_args(var) \ - CTLTYPE_ULONG, &var, 0, param_set_multihost_interval, "LU" + CTLTYPE_U64, NULL, 0, param_set_multihost_interval, "QU" #define param_set_slop_shift_args(var) \ - CTLTYPE_INT, &var, 0, param_set_slop_shift, "I" + CTLTYPE_INT, NULL, 0, param_set_slop_shift, "I" #define param_set_min_auto_ashift_args(var) \ - CTLTYPE_U64, &var, 0, param_set_min_auto_ashift, "QU" + CTLTYPE_UINT, NULL, 0, param_set_min_auto_ashift, "IU" #define param_set_max_auto_ashift_args(var) \ - CTLTYPE_U64, &var, 0, param_set_max_auto_ashift, "QU" + CTLTYPE_UINT, NULL, 0, param_set_max_auto_ashift, "IU" + +#define spa_taskq_read_param_set_args(var) \ + CTLTYPE_STRING, NULL, 0, spa_taskq_read_param, "A" + +#define spa_taskq_write_param_set_args(var) \ + CTLTYPE_STRING, NULL, 0, spa_taskq_write_param, "A" #define fletcher_4_param_set_args(var) \ CTLTYPE_STRING, NULL, 0, fletcher_4_param, "A" +#define blake3_param_set_args(var) \ + CTLTYPE_STRING, NULL, 0, blake3_param, "A" + +#define sha256_param_set_args(var) \ + CTLTYPE_STRING, NULL, 0, sha256_param, "A" + +#define sha512_param_set_args(var) \ + CTLTYPE_STRING, NULL, 0, sha512_param, "A" + #include <sys/kernel.h> #define module_init(fn) \ static void \ diff --git a/include/os/freebsd/spl/sys/mutex.h b/include/os/freebsd/spl/sys/mutex.h index e757d12c1502..8cfe56c75309 100644 --- a/include/os/freebsd/spl/sys/mutex.h +++ b/include/os/freebsd/spl/sys/mutex.h @@ -64,6 +64,7 @@ typedef enum { } while (0) #define mutex_destroy(lock) sx_destroy(lock) #define mutex_enter(lock) sx_xlock(lock) +#define mutex_enter_interruptible(lock) sx_xlock_sig(lock) #define mutex_enter_nested(lock, type) sx_xlock(lock) #define mutex_tryenter(lock) sx_try_xlock(lock) #define mutex_exit(lock) sx_xunlock(lock) diff --git a/include/os/freebsd/spl/sys/processor.h b/include/os/freebsd/spl/sys/processor.h index 53149840f21f..40464e53d5c4 100644 --- a/include/os/freebsd/spl/sys/processor.h +++ b/include/os/freebsd/spl/sys/processor.h @@ -6,7 +6,7 @@ * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. + * or https://opensource.org/licenses/CDDL-1.0. * See the License for the specific language governing permissions * and limitations under the License. * diff --git a/include/os/freebsd/spl/sys/procfs_list.h b/include/os/freebsd/spl/sys/procfs_list.h index 4bc603756ea4..4e98675053d2 100644 --- a/include/os/freebsd/spl/sys/procfs_list.h +++ b/include/os/freebsd/spl/sys/procfs_list.h @@ -6,7 +6,7 @@ * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. + * or https://opensource.org/licenses/CDDL-1.0. * See the License for the specific language governing permissions * and limitations under the License. * diff --git a/include/os/freebsd/spl/sys/simd.h b/include/os/freebsd/spl/sys/simd.h index 53503e838912..4560bb05e978 100644 --- a/include/os/freebsd/spl/sys/simd.h +++ b/include/os/freebsd/spl/sys/simd.h @@ -26,13 +26,22 @@ * $FreeBSD$ */ - #ifndef _FREEBSD_SIMD_H #define _FREEBSD_SIMD_H + #if defined(__amd64__) || defined(__i386__) #include <sys/simd_x86.h> -#else +#elif defined(__arm__) +#include <sys/simd_arm.h> + +#elif defined(__aarch64__) +#include <sys/simd_aarch64.h> + +#elif defined(__powerpc__) +#include <sys/simd_powerpc.h> + +#else #define kfpu_allowed() 0 #define kfpu_initialize(tsk) do {} while (0) #define kfpu_begin() do {} while (0) @@ -40,4 +49,5 @@ #define kfpu_init() (0) #define kfpu_fini() do {} while (0) #endif + #endif diff --git a/include/os/freebsd/spl/sys/simd_aarch64.h b/include/os/freebsd/spl/sys/simd_aarch64.h new file mode 100644 index 000000000000..234f401db791 --- /dev/null +++ b/include/os/freebsd/spl/sys/simd_aarch64.h @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2022 Tino Reichardt <milky-zfs@mcmilk.de> + * 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. + * + * $FreeBSD$ + */ + +/* + * SIMD support: + * + * Following functions should be called to determine whether CPU feature + * is supported. All functions are usable in kernel and user space. + * If a SIMD algorithm is using more than one instruction set + * all relevant feature test functions should be called. + * + * Supported features: + * zfs_neon_available() + * zfs_sha256_available() + * zfs_sha512_available() + */ + +#ifndef _FREEBSD_SIMD_AARCH64_H +#define _FREEBSD_SIMD_AARCH64_H + +#include <sys/types.h> +#include <sys/ucontext.h> +#include <machine/elf.h> +#include <machine/fpu.h> +#include <machine/md_var.h> +#include <machine/pcb.h> + +#define kfpu_allowed() 1 +#define kfpu_initialize(tsk) do {} while (0) +#define kfpu_begin() do { \ + if (__predict_false(!is_fpu_kern_thread(0))) \ + fpu_kern_enter(curthread, NULL, FPU_KERN_NOCTX); \ +} while (0) + +#define kfpu_end() do { \ + if (__predict_false(curthread->td_pcb->pcb_fpflags & PCB_FP_NOSAVE)) \ + fpu_kern_leave(curthread, NULL); \ +} while (0) +#define kfpu_init() (0) +#define kfpu_fini() do {} while (0) + +/* + * Check if NEON is available + */ +static inline boolean_t +zfs_neon_available(void) +{ + return (elf_hwcap & HWCAP_FP); +} + +/* + * Check if SHA256 is available + */ +static inline boolean_t +zfs_sha256_available(void) +{ + return (elf_hwcap & HWCAP_SHA2); +} + +/* + * Check if SHA512 is available + */ +static inline boolean_t +zfs_sha512_available(void) +{ + return (elf_hwcap & HWCAP_SHA512); +} + +#endif /* _FREEBSD_SIMD_AARCH64_H */ diff --git a/include/os/freebsd/spl/sys/simd_arm.h b/include/os/freebsd/spl/sys/simd_arm.h new file mode 100644 index 000000000000..178fbc3b3c6e --- /dev/null +++ b/include/os/freebsd/spl/sys/simd_arm.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2022 Tino Reichardt <milky-zfs@mcmilk.de> + * 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. + * + * $FreeBSD$ + */ + +/* + * SIMD support: + * + * Following functions should be called to determine whether CPU feature + * is supported. All functions are usable in kernel and user space. + * If a SIMD algorithm is using more than one instruction set + * all relevant feature test functions should be called. + * + * Supported features: + * zfs_neon_available() + * zfs_sha256_available() + */ + +#ifndef _FREEBSD_SIMD_ARM_H +#define _FREEBSD_SIMD_ARM_H + +#include <sys/types.h> +#include <machine/elf.h> +#include <machine/md_var.h> + +#define kfpu_allowed() 1 +#define kfpu_initialize(tsk) do {} while (0) +#define kfpu_begin() do {} while (0) +#define kfpu_end() do {} while (0) +#define kfpu_init() (0) +#define kfpu_fini() do {} while (0) + +/* + * Check if NEON is available + */ +static inline boolean_t +zfs_neon_available(void) +{ + return (elf_hwcap & HWCAP_NEON); +} + +/* + * Check if SHA256 is available + */ +static inline boolean_t +zfs_sha256_available(void) +{ + return (elf_hwcap2 & HWCAP2_SHA2); +} + +#endif /* _FREEBSD_SIMD_ARM_H */ diff --git a/include/os/freebsd/spl/sys/simd_powerpc.h b/include/os/freebsd/spl/sys/simd_powerpc.h new file mode 100644 index 000000000000..cf3c712c6af2 --- /dev/null +++ b/include/os/freebsd/spl/sys/simd_powerpc.h @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2022 Tino Reichardt <milky-zfs@mcmilk.de> + * 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. + * + * $FreeBSD$ + */ + +/* + * SIMD support: + * + * Following functions should be called to determine whether CPU feature + * is supported. All functions are usable in kernel and user space. + * If a SIMD algorithm is using more than one instruction set + * all relevant feature test functions should be called. + * + * Supported features: + * zfs_altivec_available() + * zfs_vsx_available() + * zfs_isa207_available() + */ + +#ifndef _FREEBSD_SIMD_POWERPC_H +#define _FREEBSD_SIMD_POWERPC_H + +#include <sys/types.h> +#include <sys/cdefs.h> + +#include <machine/pcb.h> +#include <machine/cpu.h> + +#define kfpu_allowed() 0 +#define kfpu_initialize(tsk) do {} while (0) +#define kfpu_begin() do {} while (0) +#define kfpu_end() do {} while (0) +#define kfpu_init() (0) +#define kfpu_fini() do {} while (0) + +/* + * Check if Altivec is available + */ +static inline boolean_t +zfs_altivec_available(void) +{ + return ((cpu_features & PPC_FEATURE_HAS_ALTIVEC) != 0); +} + +/* + * Check if VSX is available + */ +static inline boolean_t +zfs_vsx_available(void) +{ + return ((cpu_features & PPC_FEATURE_HAS_VSX) != 0); +} + +/* + * Check if POWER ISA 2.07 is available (SHA2) + */ +static inline boolean_t +zfs_isa207_available(void) +{ + return ((cpu_features2 & PPC_FEATURE2_ARCH_2_07) != 0); +} + +#endif diff --git a/include/os/freebsd/spl/sys/simd_x86.h b/include/os/freebsd/spl/sys/simd_x86.h index 480bfd28973b..8e93b558dfe8 100644 --- a/include/os/freebsd/spl/sys/simd_x86.h +++ b/include/os/freebsd/spl/sys/simd_x86.h @@ -45,6 +45,10 @@ fpu_kern_enter(curthread, NULL, FPU_KERN_NOCTX);\ } +#ifndef PCB_FPUNOSAVE +#define PCB_FPUNOSAVE PCB_NPXNOSAVE +#endif + #define kfpu_end() { \ if (__predict_false(curpcb->pcb_flags & PCB_FPUNOSAVE)) \ fpu_kern_leave(curthread, NULL); \ @@ -77,7 +81,7 @@ __simd_state_enabled(const uint64_t state) boolean_t has_osxsave; uint64_t xcr0; - has_osxsave = !!(cpu_feature2 & CPUID2_OSXSAVE); + has_osxsave = (cpu_feature2 & CPUID2_OSXSAVE) != 0; if (!has_osxsave) return (B_FALSE); @@ -99,7 +103,7 @@ __simd_state_enabled(const uint64_t state) static inline boolean_t zfs_sse_available(void) { - return (!!(cpu_feature & CPUID_SSE)); + return ((cpu_feature & CPUID_SSE) != 0); } /* @@ -108,7 +112,7 @@ zfs_sse_available(void) static inline boolean_t zfs_sse2_available(void) { - return (!!(cpu_feature & CPUID_SSE2)); + return ((cpu_feature & CPUID_SSE2) != 0); } /* @@ -117,7 +121,7 @@ zfs_sse2_available(void) static inline boolean_t zfs_sse3_available(void) { - return (!!(cpu_feature2 & CPUID2_SSE3)); + return ((cpu_feature2 & CPUID2_SSE3) != 0); } /* @@ -126,7 +130,7 @@ zfs_sse3_available(void) static inline boolean_t zfs_ssse3_available(void) { - return (!!(cpu_feature2 & CPUID2_SSSE3)); + return ((cpu_feature2 & CPUID2_SSSE3) != 0); } /* @@ -135,7 +139,7 @@ zfs_ssse3_available(void) static inline boolean_t zfs_sse4_1_available(void) { - return (!!(cpu_feature2 & CPUID2_SSE41)); + return ((cpu_feature2 & CPUID2_SSE41) != 0); } /* @@ -144,7 +148,7 @@ zfs_sse4_1_available(void) static inline boolean_t zfs_sse4_2_available(void) { - return (!!(cpu_feature2 & CPUID2_SSE42)); + return ((cpu_feature2 & CPUID2_SSE42) != 0); } /* @@ -155,7 +159,7 @@ zfs_avx_available(void) { boolean_t has_avx; - has_avx = !!(cpu_feature2 & CPUID2_AVX); + has_avx = (cpu_feature2 & CPUID2_AVX) != 0; return (has_avx && __ymm_enabled()); } @@ -168,12 +172,25 @@ zfs_avx2_available(void) { boolean_t has_avx2; - has_avx2 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX2); + has_avx2 = (cpu_stdext_feature & CPUID_STDEXT_AVX2) != 0; return (has_avx2 && __ymm_enabled()); } /* + * Check if SHA_NI instruction set is available + */ +static inline boolean_t +zfs_shani_available(void) +{ + boolean_t has_shani; + + has_shani = (cpu_stdext_feature & CPUID_STDEXT_SHA) != 0; + + return (has_shani && __ymm_enabled()); +} + +/* * AVX-512 family of instruction sets: * * AVX512F Foundation @@ -196,7 +213,7 @@ zfs_avx512f_available(void) { boolean_t has_avx512; - has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512F); + has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512F) != 0; return (has_avx512 && __zmm_enabled()); } @@ -207,8 +224,8 @@ zfs_avx512cd_available(void) { boolean_t has_avx512; - has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512F) && - !!(cpu_stdext_feature & CPUID_STDEXT_AVX512CD); + has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512F) != 0 && + (cpu_stdext_feature & CPUID_STDEXT_AVX512CD) != 0; return (has_avx512 && __zmm_enabled()); } @@ -219,8 +236,8 @@ zfs_avx512er_available(void) { boolean_t has_avx512; - has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512F) && - !!(cpu_stdext_feature & CPUID_STDEXT_AVX512CD); + has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512F) != 0 && + (cpu_stdext_feature & CPUID_STDEXT_AVX512CD) != 0; return (has_avx512 && __zmm_enabled()); } @@ -231,8 +248,8 @@ zfs_avx512pf_available(void) { boolean_t has_avx512; - has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512F) && - !!(cpu_stdext_feature & CPUID_STDEXT_AVX512PF); + has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512F) != 0 && + (cpu_stdext_feature & CPUID_STDEXT_AVX512PF) != 0; return (has_avx512 && __zmm_enabled()); } @@ -243,7 +260,7 @@ zfs_avx512bw_available(void) { boolean_t has_avx512 = B_FALSE; - has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512BW); + has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512BW) != 0; return (has_avx512 && __zmm_enabled()); } @@ -254,8 +271,8 @@ zfs_avx512dq_available(void) { boolean_t has_avx512; - has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512F) && - !!(cpu_stdext_feature & CPUID_STDEXT_AVX512DQ); + has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512F) != 0 && + (cpu_stdext_feature & CPUID_STDEXT_AVX512DQ) != 0; return (has_avx512 && __zmm_enabled()); } @@ -266,8 +283,8 @@ zfs_avx512vl_available(void) { boolean_t has_avx512; - has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512F) && - !!(cpu_stdext_feature & CPUID_STDEXT_AVX512VL); + has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512F) != 0 && + (cpu_stdext_feature & CPUID_STDEXT_AVX512VL) != 0; return (has_avx512 && __zmm_enabled()); } @@ -278,8 +295,8 @@ zfs_avx512ifma_available(void) { boolean_t has_avx512; - has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512F) && - !!(cpu_stdext_feature & CPUID_STDEXT_AVX512IFMA); + has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512F) != 0 && + (cpu_stdext_feature & CPUID_STDEXT_AVX512IFMA) != 0; return (has_avx512 && __zmm_enabled()); } @@ -290,8 +307,8 @@ zfs_avx512vbmi_available(void) { boolean_t has_avx512; - has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512F) && - !!(cpu_stdext_feature & CPUID_STDEXT_BMI1); + has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512F) != 0 && + (cpu_stdext_feature & CPUID_STDEXT_BMI1) != 0; return (has_avx512 && __zmm_enabled()); } diff --git a/include/os/freebsd/spl/sys/spl_condvar.h b/include/os/freebsd/spl/sys/spl_condvar.h index 7405f647d59a..2835adafd416 100644 --- a/include/os/freebsd/spl/sys/spl_condvar.h +++ b/include/os/freebsd/spl/sys/spl_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. diff --git a/include/os/freebsd/spl/sys/sysmacros.h b/include/os/freebsd/spl/sys/sysmacros.h index 7e3ab8915542..3e8841ae66bd 100644 --- a/include/os/freebsd/spl/sys/sysmacros.h +++ b/include/os/freebsd/spl/sys/sysmacros.h @@ -6,7 +6,7 @@ * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. + * or https://opensource.org/licenses/CDDL-1.0. * See the License for the specific language governing permissions * and limitations under the License. * @@ -281,46 +281,6 @@ extern unsigned char bcd_to_byte[256]; #define INCR_COUNT(var, mutex) mutex_enter(mutex), (*(var))++, mutex_exit(mutex) #define DECR_COUNT(var, mutex) mutex_enter(mutex), (*(var))--, mutex_exit(mutex) -/* - * Macros to declare bitfields - the order in the parameter list is - * Low to High - that is, declare bit 0 first. We only support 8-bit bitfields - * because if a field crosses a byte boundary it's not likely to be meaningful - * without reassembly in its nonnative endianness. - */ -#if defined(_BIT_FIELDS_LTOH) -#define DECL_BITFIELD2(_a, _b) \ - uint8_t _a, _b -#define DECL_BITFIELD3(_a, _b, _c) \ - uint8_t _a, _b, _c -#define DECL_BITFIELD4(_a, _b, _c, _d) \ - uint8_t _a, _b, _c, _d -#define DECL_BITFIELD5(_a, _b, _c, _d, _e) \ - uint8_t _a, _b, _c, _d, _e -#define DECL_BITFIELD6(_a, _b, _c, _d, _e, _f) \ - uint8_t _a, _b, _c, _d, _e, _f -#define DECL_BITFIELD7(_a, _b, _c, _d, _e, _f, _g) \ - uint8_t _a, _b, _c, _d, _e, _f, _g -#define DECL_BITFIELD8(_a, _b, _c, _d, _e, _f, _g, _h) \ - uint8_t _a, _b, _c, _d, _e, _f, _g, _h -#elif defined(_BIT_FIELDS_HTOL) -#define DECL_BITFIELD2(_a, _b) \ - uint8_t _b, _a -#define DECL_BITFIELD3(_a, _b, _c) \ - uint8_t _c, _b, _a -#define DECL_BITFIELD4(_a, _b, _c, _d) \ - uint8_t _d, _c, _b, _a -#define DECL_BITFIELD5(_a, _b, _c, _d, _e) \ - uint8_t _e, _d, _c, _b, _a -#define DECL_BITFIELD6(_a, _b, _c, _d, _e, _f) \ - uint8_t _f, _e, _d, _c, _b, _a -#define DECL_BITFIELD7(_a, _b, _c, _d, _e, _f, _g) \ - uint8_t _g, _f, _e, _d, _c, _b, _a -#define DECL_BITFIELD8(_a, _b, _c, _d, _e, _f, _g, _h) \ - uint8_t _h, _g, _f, _e, _d, _c, _b, _a -#else -#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined -#endif /* _BIT_FIELDS_LTOH */ - #if !defined(_KMEMUSER) && !defined(offsetof) /* avoid any possibility of clashing with <stddef.h> version */ diff --git a/include/os/freebsd/spl/sys/taskq.h b/include/os/freebsd/spl/sys/taskq.h index 3040549e043d..fa6ff84a0134 100644 --- a/include/os/freebsd/spl/sys/taskq.h +++ b/include/os/freebsd/spl/sys/taskq.h @@ -6,7 +6,7 @@ * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. + * or https://opensource.org/licenses/CDDL-1.0. * See the License for the specific language governing permissions * and limitations under the License. * @@ -30,9 +30,9 @@ #include <sys/types.h> #include <sys/proc.h> +#include <sys/queue.h> #include <sys/taskqueue.h> #include <sys/thread.h> -#include <sys/ck.h> #ifdef __cplusplus extern "C" { @@ -42,22 +42,23 @@ extern "C" { typedef struct taskq { struct taskqueue *tq_queue; + int tq_nthreads; } taskq_t; typedef uintptr_t taskqid_t; typedef void (task_func_t)(void *); typedef struct taskq_ent { - struct task tqent_task; - struct timeout_task tqent_timeout_task; + union { + struct task tqent_task; + struct timeout_task tqent_timeout_task; + }; task_func_t *tqent_func; void *tqent_arg; - taskqid_t tqent_id; - CK_LIST_ENTRY(taskq_ent) tqent_hash; - uint8_t tqent_type; - uint8_t tqent_registered; - uint8_t tqent_cancelled; - volatile uint32_t tqent_rc; + taskqid_t tqent_id; + LIST_ENTRY(taskq_ent) tqent_hash; + uint_t tqent_type; + volatile uint_t tqent_rc; } taskq_ent_t; /* @@ -81,7 +82,6 @@ typedef struct taskq_ent { #define TASKQID_INVALID ((taskqid_t)0) -#define taskq_init_ent(x) extern taskq_t *system_taskq; /* Global dynamic task queue for long delay */ extern taskq_t *system_delay_taskq; @@ -92,7 +92,10 @@ extern taskqid_t taskq_dispatch_delay(taskq_t *, task_func_t, void *, extern void taskq_dispatch_ent(taskq_t *, task_func_t, void *, uint_t, taskq_ent_t *); extern int taskq_empty_ent(taskq_ent_t *); +extern void taskq_init_ent(taskq_ent_t *); taskq_t *taskq_create(const char *, int, pri_t, int, int, uint_t); +taskq_t *taskq_create_synced(const char *, int, pri_t, int, int, uint_t, + kthread_t ***); taskq_t *taskq_create_instance(const char *, int, int, pri_t, int, int, uint_t); taskq_t *taskq_create_proc(const char *, int, pri_t, int, int, struct proc *, uint_t); @@ -117,6 +120,7 @@ void taskq_resume(taskq_t *); #endif /* _KERNEL */ #ifdef _STANDALONE +typedef void taskq_t; typedef int taskq_ent_t; #define taskq_init_ent(x) #endif /* _STANDALONE */ diff --git a/include/os/freebsd/spl/sys/time.h b/include/os/freebsd/spl/sys/time.h index fbc679aacf93..47d64c34756a 100644 --- a/include/os/freebsd/spl/sys/time.h +++ b/include/os/freebsd/spl/sys/time.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$ */ #ifndef _OPENSOLARIS_SYS_TIME_H_ @@ -91,6 +89,6 @@ gethrtime(void) { struct timespec ts; clock_gettime(CLOCK_UPTIME, &ts); - return (((u_int64_t)ts.tv_sec) * NANOSEC + ts.tv_nsec); + return (((uint64_t)ts.tv_sec) * NANOSEC + ts.tv_nsec); } #endif /* !_OPENSOLARIS_SYS_TIME_H_ */ diff --git a/include/os/freebsd/spl/sys/timer.h b/include/os/freebsd/spl/sys/timer.h index d4694bb7c09c..7ff77e9b1b74 100644 --- a/include/os/freebsd/spl/sys/timer.h +++ b/include/os/freebsd/spl/sys/timer.h @@ -33,6 +33,4 @@ #define usleep_range(wakeup, wakeupepsilon) \ pause_sbt("usleep_range", ustosbt(wakeup), \ ustosbt(wakeupepsilon - wakeup), 0) - -#define schedule() pause("schedule", 1) #endif diff --git a/include/os/freebsd/spl/sys/types.h b/include/os/freebsd/spl/sys/types.h index b1308df29503..ebc93f4f4485 100644 --- a/include/os/freebsd/spl/sys/types.h +++ b/include/os/freebsd/spl/sys/types.h @@ -105,5 +105,7 @@ typedef u_longlong_t len_t; typedef longlong_t diskaddr_t; +typedef void zidmap_t; + #include <sys/debug.h> #endif /* !_OPENSOLARIS_SYS_TYPES_H_ */ diff --git a/include/os/freebsd/spl/sys/uio.h b/include/os/freebsd/spl/sys/uio.h index b71f2f2e5625..b9d41903ea63 100644 --- a/include/os/freebsd/spl/sys/uio.h +++ b/include/os/freebsd/spl/sys/uio.h @@ -62,7 +62,7 @@ zfs_uio_setoffset(zfs_uio_t *uio, offset_t off) } static inline void -zfs_uio_advance(zfs_uio_t *uio, size_t size) +zfs_uio_advance(zfs_uio_t *uio, ssize_t size) { zfs_uio_resid(uio) -= size; zfs_uio_offset(uio) += size; diff --git a/include/os/freebsd/spl/sys/uuid.h b/include/os/freebsd/spl/sys/uuid.h index 26d46e8d6214..9e76d07b8014 100644 --- a/include/os/freebsd/spl/sys/uuid.h +++ b/include/os/freebsd/spl/sys/uuid.h @@ -7,7 +7,7 @@ * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. + * or https://opensource.org/licenses/CDDL-1.0. * See the License for the specific language governing permissions * and limitations under the License. * diff --git a/include/os/freebsd/spl/sys/vfs.h b/include/os/freebsd/spl/sys/vfs.h index 22d57cc473e2..f2196da56bc8 100644 --- a/include/os/freebsd/spl/sys/vfs.h +++ b/include/os/freebsd/spl/sys/vfs.h @@ -101,7 +101,7 @@ void vfs_setmntopt(vfs_t *vfsp, const char *name, const char *arg, void vfs_clearmntopt(vfs_t *vfsp, const char *name); int vfs_optionisset(const vfs_t *vfsp, const char *opt, char **argp); int mount_snapshot(kthread_t *td, vnode_t **vpp, const char *fstype, - char *fspath, char *fspec, int fsflags); + char *fspath, char *fspec, int fsflags, vfs_t *parent_vfsp); typedef uint64_t vfs_feature_t; @@ -117,9 +117,5 @@ typedef uint64_t vfs_feature_t; #define VFSFT_ZEROCOPY_SUPPORTED 0x100000200 /* Support loaning /returning cache buffer */ -#define vfs_set_feature(vfsp, feature) do { } while (0) -#define vfs_clear_feature(vfsp, feature) do { } while (0) -#define vfs_has_feature(vfsp, feature) (0) - #include <sys/mount.h> #endif /* _OPENSOLARIS_SYS_VFS_H_ */ diff --git a/include/os/freebsd/spl/sys/vnode.h b/include/os/freebsd/spl/sys/vnode.h index e0f79a1116b2..75c32f221ffd 100644 --- a/include/os/freebsd/spl/sys/vnode.h +++ b/include/os/freebsd/spl/sys/vnode.h @@ -36,7 +36,11 @@ struct xucred; typedef struct flock flock64_t; typedef struct vnode vnode_t; typedef struct vattr vattr_t; +#if __FreeBSD_version < 1400093 typedef enum vtype vtype_t; +#else +#define vtype_t __enum_uint8(vtype) +#endif #include <sys/types.h> #include <sys/queue.h> @@ -52,6 +56,7 @@ enum symfollow { NO_FOLLOW = NOFOLLOW }; #ifndef IN_BASE #include_next <sys/vnode.h> #endif +#include <sys/ccompat.h> #include <sys/mount.h> #include <sys/cred.h> #include <sys/fcntl.h> @@ -96,16 +101,17 @@ vn_flush_cached_data(vnode_t *vp, boolean_t sync) if (vp->v_object->flags & OBJ_MIGHTBEDIRTY) { #endif int flags = sync ? OBJPC_SYNC : 0; + vn_lock(vp, LK_SHARED | LK_RETRY); zfs_vmobject_wlock(vp->v_object); vm_object_page_clean(vp->v_object, 0, 0, flags); zfs_vmobject_wunlock(vp->v_object); + VOP_UNLOCK1(vp); } } #endif #define vn_exists(vp) do { } while (0) #define vn_invalid(vp) do { } while (0) -#define vn_renamepath(tdvp, svp, tnm, lentnm) do { } while (0) #define vn_free(vp) do { } while (0) #define vn_matchops(vp, vops) ((vp)->v_op == &(vops)) @@ -142,6 +148,10 @@ vn_flush_cached_data(vnode_t *vp, boolean_t sync) /* * Attributes of interest to the caller of setattr or getattr. */ + +#undef AT_UID +#undef AT_GID + #define AT_MODE 0x00002 #define AT_UID 0x00004 #define AT_GID 0x00008 @@ -203,15 +213,6 @@ vattr_init_mask(vattr_t *vap) #define RLIM64_INFINITY 0 -static __inline int -vn_rename(char *from, char *to, enum uio_seg seg) -{ - - ASSERT(seg == UIO_SYSSPACE); - - return (kern_renameat(curthread, AT_FDCWD, from, AT_FDCWD, to, seg)); -} - #include <sys/vfs.h> #endif /* _OPENSOLARIS_SYS_VNODE_H_ */ diff --git a/include/os/freebsd/spl/sys/vnode_impl.h b/include/os/freebsd/spl/sys/vnode_impl.h index c82b1fc9ad18..4e04b5e80a06 100644 --- a/include/os/freebsd/spl/sys/vnode_impl.h +++ b/include/os/freebsd/spl/sys/vnode_impl.h @@ -6,7 +6,7 @@ * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. + * or https://opensource.org/licenses/CDDL-1.0. * See the License for the specific language governing permissions * and limitations under the License. * @@ -44,8 +44,6 @@ #define IS_DEVVP(vp) \ ((vp)->v_type == VCHR || (vp)->v_type == VBLK || (vp)->v_type == VFIFO) -#define V_XATTRDIR 0x0000 /* attribute unnamed directory */ - #define AV_SCANSTAMP_SZ 32 /* length of anti-virus scanstamp */ /* @@ -194,11 +192,6 @@ #define PERMMASK 00777 /* permission bits */ /* - * VOP_ACCESS flags - */ -#define V_ACE_MASK 0x1 /* mask represents NFSv4 ACE permissions */ - -/* * Flags for vnode operations. */ enum rm { RMFILE, RMDIRECTORY }; /* rm or rmdir (remove) */ @@ -235,12 +228,6 @@ struct taskq; #define LOOKUP_HAVE_SYSATTR_DIR 0x08 /* Already created virtual GFS dir */ /* - * Flags for VOP_READDIR - */ -#define V_RDDIR_ENTFLAGS 0x01 /* request dirent flags */ -#define V_RDDIR_ACCFILTER 0x02 /* filter out inaccessible dirents */ - -/* * Public vnode manipulation functions. */ diff --git a/include/os/freebsd/spl/sys/zmod.h b/include/os/freebsd/spl/sys/zmod.h index c606b1db5f61..6e26a568bd44 100644 --- a/include/os/freebsd/spl/sys/zmod.h +++ b/include/os/freebsd/spl/sys/zmod.h @@ -6,7 +6,7 @@ * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. + * or https://opensource.org/licenses/CDDL-1.0. * See the License for the specific language governing permissions * and limitations under the License. * |