diff options
Diffstat (limited to 'sys/contrib/openzfs/lib/libspl/include')
-rw-r--r-- | sys/contrib/openzfs/lib/libspl/include/atomic.h | 7 | ||||
-rw-r--r-- | sys/contrib/openzfs/lib/libspl/include/libshare.h | 3 | ||||
-rw-r--r-- | sys/contrib/openzfs/lib/libspl/include/sys/simd.h | 87 |
3 files changed, 51 insertions, 46 deletions
diff --git a/sys/contrib/openzfs/lib/libspl/include/atomic.h b/sys/contrib/openzfs/lib/libspl/include/atomic.h index 1249d42b604a..4ebdbbda9864 100644 --- a/sys/contrib/openzfs/lib/libspl/include/atomic.h +++ b/sys/contrib/openzfs/lib/libspl/include/atomic.h @@ -314,6 +314,13 @@ extern void membar_enter(void); extern void membar_exit(void); /* + * Make all stores and loads emitted prior to the the barrier complete before + * crossing it, while also making sure stores and loads emitted after the + * barrier only start being executed after crossing it. + */ +extern void membar_sync(void); + +/* * Arrange that all stores issued before this point in the code reach * global visibility before any stores that follow; useful in producer * modules that update a data item, then set a flag that it is available. diff --git a/sys/contrib/openzfs/lib/libspl/include/libshare.h b/sys/contrib/openzfs/lib/libspl/include/libshare.h index d976f096ac39..deeb15c97704 100644 --- a/sys/contrib/openzfs/lib/libspl/include/libshare.h +++ b/sys/contrib/openzfs/lib/libspl/include/libshare.h @@ -22,7 +22,7 @@ /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. - * Copyright (c) 2019, 2020 by Delphix. All rights reserved. + * Copyright (c) 2019, 2022 by Delphix. All rights reserved. */ #ifndef _LIBSPL_LIBSHARE_H #define _LIBSPL_LIBSHARE_H extern __attribute__((visibility("default"))) @@ -88,6 +88,7 @@ _LIBSPL_LIBSHARE_H int sa_enable_share(const char *, const char *, const char *, _LIBSPL_LIBSHARE_H int sa_disable_share(const char *, enum sa_protocol); _LIBSPL_LIBSHARE_H boolean_t sa_is_shared(const char *, enum sa_protocol); _LIBSPL_LIBSHARE_H void sa_commit_shares(enum sa_protocol); +_LIBSPL_LIBSHARE_H void sa_truncate_shares(enum sa_protocol); /* protocol specific interfaces */ _LIBSPL_LIBSHARE_H int sa_validate_shareopts(const char *, enum sa_protocol); diff --git a/sys/contrib/openzfs/lib/libspl/include/sys/simd.h b/sys/contrib/openzfs/lib/libspl/include/sys/simd.h index c9d86a0808f1..c0099dd7919b 100644 --- a/sys/contrib/openzfs/lib/libspl/include/sys/simd.h +++ b/sys/contrib/openzfs/lib/libspl/include/sys/simd.h @@ -20,8 +20,8 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright (c) 2022 Tino Reichardt <milky-zfs@mcmilk.de> */ #ifndef _LIBSPL_SYS_SIMD_H @@ -452,63 +452,60 @@ zfs_avx512vbmi_available(void) #elif defined(__powerpc__) +/* including <sys/auxv.h> clashes with AT_UID and others */ +extern unsigned long getauxval(unsigned long type); +#if defined(__FreeBSD__) +#define AT_HWCAP 25 /* CPU feature flags. */ +#define AT_HWCAP2 26 /* CPU feature flags 2. */ +extern int elf_aux_info(int aux, void *buf, int buflen); +static unsigned long getauxval(unsigned long key) +{ + unsigned long val = 0UL; + + if (elf_aux_info((int)key, &val, sizeof (val)) != 0) + return (0UL); + + return (val); +} +#elif defined(__linux__) +#define AT_HWCAP 16 /* CPU feature flags. */ +#define AT_HWCAP2 26 /* CPU feature flags 2. */ +#endif + #define kfpu_allowed() 1 #define kfpu_initialize(tsk) do {} while (0) #define kfpu_begin() do {} while (0) #define kfpu_end() do {} while (0) -/* - * Check if AltiVec instruction set is available - * No easy way beyond 'altivec works' :-( - */ -#include <signal.h> -#include <setjmp.h> - -#if defined(__ALTIVEC__) && !defined(__FreeBSD__) -static jmp_buf env; -static void sigillhandler(int x) +#define PPC_FEATURE_HAS_ALTIVEC 0x10000000 +static inline boolean_t +zfs_altivec_available(void) { - (void) x; - longjmp(env, 1); + unsigned long hwcap = getauxval(AT_HWCAP); + + return (hwcap & PPC_FEATURE_HAS_ALTIVEC); } -#endif +#define PPC_FEATURE_HAS_VSX 0x00000080 static inline boolean_t -zfs_altivec_available(void) +zfs_vsx_available(void) { - boolean_t has_altivec = B_FALSE; -#if defined(__ALTIVEC__) && !defined(__FreeBSD__) - sighandler_t savesig; - savesig = signal(SIGILL, sigillhandler); - if (setjmp(env)) { - signal(SIGILL, savesig); - has_altivec = B_FALSE; - } else { - __asm__ __volatile__("vor 0,0,0\n" : : : "v0"); - signal(SIGILL, savesig); - has_altivec = B_TRUE; - } -#endif - return (has_altivec); + unsigned long hwcap = getauxval(AT_HWCAP); + + return (hwcap & PPC_FEATURE_HAS_VSX); } + +#define PPC_FEATURE2_ARCH_2_07 0x80000000 static inline boolean_t -zfs_vsx_available(void) +zfs_isa207_available(void) { - boolean_t has_vsx = B_FALSE; -#if defined(__ALTIVEC__) && !defined(__FreeBSD__) - sighandler_t savesig; - savesig = signal(SIGILL, sigillhandler); - if (setjmp(env)) { - signal(SIGILL, savesig); - has_vsx = B_FALSE; - } else { - __asm__ __volatile__("xssubsp 0,0,0\n"); - signal(SIGILL, savesig); - has_vsx = B_TRUE; - } -#endif - return (has_vsx); + unsigned long hwcap = getauxval(AT_HWCAP); + unsigned long hwcap2 = getauxval(AT_HWCAP2); + + return ((hwcap & PPC_FEATURE_HAS_VSX) && + (hwcap2 & PPC_FEATURE2_ARCH_2_07)); } + #else #define kfpu_allowed() 0 |