Compare commits

..

11 Commits

Author SHA1 Message Date
Alexander Ziaee
f3e6a4cbc8
Merge f4fa0561ae into 8502c68d29 2024-06-26 17:39:26 +08:00
Doug Moore
8502c68d29 x86_iommu: use roundup_pow_of_two
Drop a private implementation of roundup_pow_of_two and use the global
one instead.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D45739
2024-06-26 04:23:54 -05:00
Andrew Turner
5afc347944 arm: Start to remove the now unneeded acle-compat.h
All supported compilers provide the acle macros so we don't need the
backup versions.

Keep the file around for anything that included it directly, but make
it an error to not support the acle macros.

Reviewed by:	imp
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45726
2024-06-26 08:52:08 +00:00
Doug Moore
7d37fcbf52 cxgbe: replace a loop with rounddown_pow_of_two
Replace a loop with a function call.

Reviewed by:	np, alc
Differential Revision:	https://reviews.freebsd.org/D45716
2024-06-26 03:19:16 -05:00
Konstantin Belousov
7e5574f9e5 sched_unpin(): assert that curthread was pinned
Reviewed by:	emaste, imp, markj, olce
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D45736
2024-06-26 10:04:10 +03:00
Warner Losh
b2351a4ba5 test: disable sys.kern.unix_seqpacket_test.random_eor_and_waitall
It's been failing for a while, at least some of the time.

PR: 279994
Sponsored by:		Netflix
2024-06-25 19:35:13 -06:00
Kyle Evans
3da568710f stand: module: unlink the entire tail when dependencies fail to load
Assume you have loader configured to load linux64, which has a
dependency on both linux_common and mqueuefs but neither the kernel
nor kernel config in question have the mqueuefs module included.

When the load command for linux64 fails to find mqueuefs, it will
free both linux64 and linux_common as they were loaded first, but only
linux64 gets removed from the module list.  As a result, future
traversals hit an easy use-after-free with linux_common.

Fix it so that we unlink the entire tail of the list.  Anything after
the initially loaded module is, by definition, a dependency on the
loaded module while we're still in the load command, so we can just
discard the entire tail.  If linux_common were loaded before linux64, it
should not move to a position during this load where it would suddenly
be missing from the view presented to the kernel.

Reported by:	philip
Reviewed by:	imp, philip, tsoome
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D45731
2024-06-25 15:32:08 -05:00
Mark Johnston
7d6932d20a ctladm: Fix a race when loading ctl.ko
If multiple ctladm processes try to load ctl.ko at the same time, only
one will succeed.  Handle this possibility by retrying the operation
(open /dev/cam/ctl) if kldload returns EEXIST, rather than bailing.
This at least helps ensure that ctladm tests can be run in parallel
when ctl.ko is not preloaded.

Reviewed by:	asomers
MFC after:	1 week
2024-06-25 15:29:03 -04:00
Ryan Libby
f29bdea047 ext4_ext_tree_init: correct memset initialization
gcc -Wmemset-elt-size diagnosed this.  The code was only initializing
1/4 of the array.  However, it was actually harmless, as the only caller
had done an M_ZERO allocation anyway.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D45701
2024-06-25 10:41:11 -07:00
Ryan Libby
07cc7ea738 libmsun: remove duplicates after cdefs.h added inline to __always_inline
Reviewed by:	kib, olce
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D45712
2024-06-25 10:40:14 -07:00
Ryan Libby
d25f0bdceb cdefs.h: add __inline to __always_inline
Add __inline to the __always_inline macro to quiet dozens of gcc
warnings of the form:
warning: 'always_inline' function might not be inlinable [-Wattributes]

It's clearly the intention of the __always_inline macro applied to a
function to inline the function.  However, gcc seems to be picky with
the -Wattributes.  It appears that __attribute__((__always_inline__))
was intended to apply to inline functions, as in, function declarations
with the attribute should also be declared as inline.  Both clang and
gcc sources themselves use the two in combination:
inline __attribute__((__always_inline__))

FreeBSD sources mostly only use __always_inline, without the inline
keyword.  Only a few files in libmsun used both.

Reviewed by:	imp, kib, olce
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D45711
2024-06-25 10:39:13 -07:00
15 changed files with 44 additions and 180 deletions

View File

@ -54,7 +54,7 @@ pio2_2t = 2.0670321098263988236496903051604844e-43L, /* 0x127044533e63a0105df5
pio2_3 = 2.0670321098263988236499468110329591e-43L, /* 0x127044533e63a0105e00000000000.0p-254 */
pio2_3t = -2.5650587247459238361625433492959285e-65L; /* -0x159c4ec64ddaeb5f78671cbfb2210.0p-327 */
static inline __always_inline int
static __always_inline int
__ieee754_rem_pio2l(long double x, long double *y)
{
union IEEEl2bits u,u1;

View File

@ -444,7 +444,7 @@ struct ld {
#endif
#ifdef STRUCT_RETURN
static inline __always_inline void
static __always_inline void
k_logl(long double x, struct ld *rp)
#else
long double

View File

@ -66,7 +66,7 @@ pio2_2t = 6.36831716351095013979e-25L, /* 0xc51701b839a25205.0p-144 */
pio2_3t = -2.75299651904407171810e-37L; /* -0xbb5bf6c7ddd660ce.0p-185 */
#endif
static inline __always_inline int
static __always_inline int
__ieee754_rem_pio2l(long double x, long double *y)
{
union IEEEl2bits u,u1;

View File

@ -444,7 +444,7 @@ struct ld {
#endif
#ifdef STRUCT_RETURN
static inline __always_inline void
static __always_inline void
k_logl(long double x, struct ld *rp)
#else
long double

View File

@ -45,7 +45,7 @@ pio2_3 = 2.02226624871116645580e-21, /* 0x3BA3198A, 0x2E000000 */
pio2_3t = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */
#ifdef INLINE_REM_PIO2
static __inline __always_inline
static __always_inline
#endif
int
__ieee754_rem_pio2(double x, double *y)

View File

@ -38,7 +38,7 @@ pio2_1 = 1.57079631090164184570e+00, /* 0x3FF921FB, 0x50000000 */
pio2_1t = 1.58932547735281966916e-08; /* 0x3E5110b4, 0x611A6263 */
#ifdef INLINE_REM_PIO2F
static __inline __always_inline
static __always_inline
#endif
int
__ieee754_rem_pio2f(float x, double *y)

View File

@ -64,6 +64,7 @@ static char *mod_searchmodule(char *name, struct mod_depend *verinfo);
static char * mod_searchmodule_pnpinfo(const char *bus, const char *pnpinfo);
static void file_insert_tail(struct preloaded_file *mp);
static void file_remove(struct preloaded_file *fp);
static void file_remove_tail(struct preloaded_file *fp);
struct file_metadata* metadata_next(struct file_metadata *base_mp, int type);
static void moduledir_readhints(struct moduledir *mdp);
static void moduledir_rebuild(void);
@ -876,7 +877,7 @@ mod_loadkld(const char *kldname, int argc, char *argv[])
file_insert_tail(fp); /* Add to the list of loaded files */
if (file_load_dependencies(fp) != 0) {
err = ENOENT;
file_remove(fp);
file_remove_tail(fp);
loadaddr = loadaddr_saved;
fp = NULL;
break;
@ -1637,25 +1638,45 @@ file_insert_tail(struct preloaded_file *fp)
* Remove module from the chain
*/
static void
file_remove(struct preloaded_file *fp)
file_remove_impl(struct preloaded_file *fp, bool keep_tail)
{
struct preloaded_file *cm;
struct preloaded_file *cm, *next;
if (preloaded_files == NULL)
return;
if (keep_tail)
next = fp->f_next;
else
next = NULL;
if (preloaded_files == fp) {
preloaded_files = fp->f_next;
preloaded_files = next;
return;
}
for (cm = preloaded_files; cm->f_next != NULL; cm = cm->f_next) {
if (cm->f_next == fp) {
cm->f_next = fp->f_next;
cm->f_next = next;
return;
}
}
}
static void
file_remove(struct preloaded_file *fp)
{
file_remove_impl(fp, true);
}
static void
file_remove_tail(struct preloaded_file *fp)
{
file_remove_impl(fp, false);
}
static char *
moduledir_fullpath(struct moduledir *mdp, const char *fname)
{

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014 ARM Ltd
* Copyright (c) 2024 Arm Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -27,157 +27,5 @@
*/
#ifndef __ARM_ARCH
/* ACLE standardises a set of pre-defines that describe the ARM architecture.
These were mostly implemented in GCC around GCC-4.8; older versions
have no, or only partial support. To provide a level of backwards
compatibility we try to work out what the definitions should be, given
the older pre-defines that GCC did produce. This isn't complete, but
it should be enough for use by routines that depend on this header. */
/* No need to handle ARMv8, GCC had ACLE support before that. */
#define __ARM_ACLE 101
# ifdef __ARM_ARCH_7__
/* The common subset of ARMv7 in all profiles. */
# define __ARM_ARCH 7
# define __ARM_ARCH_ISA_THUMB 2
# define __ARM_FEATURE_CLZ
# define __ARM_FEATURE_LDREX 7
# define __ARM_FEATURE_UNALIGNED
# endif
# if defined (__ARM_ARCH_7A__) || defined (__ARM_ARCH_7R__)
# define __ARM_ARCH 7
# define __ARM_ARCH_ISA_THUMB 2
# define __ARM_ARCH_ISA_ARM
# define __ARM_FEATURE_CLZ
# define __ARM_FEATURE_SIMD32
# define __ARM_FEATURE_DSP
# define __ARM_FEATURE_QBIT
# define __ARM_FEATURE_SAT
# define __ARM_FEATURE_LDREX 15
# define __ARM_FEATURE_UNALIGNED
# ifdef __ARM_ARCH_7A__
# define __ARM_ARCH_PROFILE 'A'
# else
# define __ARM_ARCH_PROFILE 'R'
# endif
# endif
# ifdef __ARM_ARCH_7EM__
# define __ARM_ARCH 7
# define __ARM_ARCH_ISA_THUMB 2
# define __ARM_FEATURE_CLZ
# define __ARM_FEATURE_SIMD32
# define __ARM_FEATURE_DSP
# define __ARM_FEATURE_QBIT
# define __ARM_FEATURE_SAT
# define __ARM_FEATURE_LDREX 7
# define __ARM_FEATURE_UNALIGNED
# define __ARM_ARCH_PROFILE 'M'
# endif
# ifdef __ARM_ARCH_7M__
# define __ARM_ARCH 7
# define __ARM_ARCH_ISA_THUMB 2
# define __ARM_FEATURE_CLZ
# define __ARM_FEATURE_QBIT
# define __ARM_FEATURE_SAT
# define __ARM_FEATURE_LDREX 7
# define __ARM_FEATURE_UNALIGNED
# define __ARM_ARCH_PROFILE 'M'
# endif
# ifdef __ARM_ARCH_6T2__
# define __ARM_ARCH 6
# define __ARM_ARCH_ISA_THUMB 2
# define __ARM_ARCH_ISA_ARM
# define __ARM_FEATURE_CLZ
# define __ARM_FEATURE_SIMD32
# define __ARM_FEATURE_DSP
# define __ARM_FEATURE_QBIT
# define __ARM_FEATURE_SAT
# define __ARM_FEATURE_LDREX 4
# define __ARM_FEATURE_UNALIGNED
# endif
# ifdef __ARM_ARCH_6M__
# define __ARM_ARCH 6
# define __ARM_ARCH_ISA_THUMB 1
# define __ARM_ARCH_PROFILE 'M'
# endif
# if defined (__ARM_ARCH_6__) || defined (__ARM_ARCH_6J__) \
|| defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6Z__) \
|| defined (__ARM_ARCH_6ZK__)
# define __ARM_ARCH 6
# define __ARM_ARCH_ISA_THUMB 1
# define __ARM_ARCH_ISA_ARM
# define __ARM_FEATURE_CLZ
# define __ARM_FEATURE_SIMD32
# define __ARM_FEATURE_DSP
# define __ARM_FEATURE_QBIT
# define __ARM_FEATURE_SAT
# define __ARM_FEATURE_UNALIGNED
# ifndef __thumb__
# if defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6ZK__)
# define __ARM_FEATURE_LDREX 15
# else
# define __ARM_FEATURE_LDREX 4
# endif
# endif
# endif
# if defined (__ARM_ARCH_5TE__) || defined (__ARM_ARCH_5E__)
# define __ARM_ARCH 5
# define __ARM_ARCH_ISA_ARM
# ifdef __ARM_ARCH_5TE__
# define __ARM_ARCH_ISA_THUMB 1
# endif
# define __ARM_FEATURE_CLZ
# define __ARM_FEATURE_DSP
# endif
# if defined (__ARM_ARCH_5T__) || defined (__ARM_ARCH_5__)
# define __ARM_ARCH 5
# define __ARM_ARCH_ISA_ARM
# ifdef __ARM_ARCH_5TE__
# define __ARM_ARCH_ISA_THUMB 1
# endif
# define __ARM_FEATURE_CLZ
# endif
# ifdef __ARM_ARCH_4T__
# define __ARM_ARCH 4
# define __ARM_ARCH_ISA_ARM
# define __ARM_ARCH_ISA_THUMB 1
# endif
# ifdef __ARM_ARCH_4__
# define __ARM_ARCH 4
# define __ARM_ARCH_ISA_ARM
# endif
# if defined (__ARM_ARCH_3__) || defined (__ARM_ARCH_3M__)
# define __ARM_ARCH 3
# define __ARM_ARCH_ISA_ARM
# endif
# ifdef __ARM_ARCH_2__
# define __ARM_ARCH 2
# define __ARM_ARCH_ISA_ARM
# endif
# ifdef __ARMEB__
# define __ARM_BIG_ENDIAN
# endif
/* If we still don't know what the target architecture is, then we're
probably not using GCC. */
# ifndef __ARM_ARCH
# error Unable to determine architecture version.
# endif
#endif /* __ARM_ARCH */
#error Your compiler is too old
#endif

View File

@ -4349,9 +4349,7 @@ calculate_iaq(struct adapter *sc, struct intrs_and_queues *iaq, int itype,
*/
do {
if (iaq->nrxq > 1) {
do {
iaq->nrxq--;
} while (!powerof2(iaq->nrxq));
iaq->nrxq = rounddown_pow_of_two(iaq->nrxq - 1);
if (iaq->nnmrxq > iaq->nrxq)
iaq->nnmrxq = iaq->nrxq;
}

View File

@ -711,7 +711,7 @@ ext4_ext_tree_init(struct inode *ip)
ip->i_flag |= IN_E4EXTENTS;
memset(ip->i_data, 0, EXT2_NDADDR + EXT2_NIADDR);
memset(ip->i_data, 0, sizeof(ip->i_data));
ehp = (struct ext4_extent_header *)ip->i_data;
ehp->eh_magic = htole16(EXT4_EXT_MAGIC);
ehp->eh_max = htole16(ext4_ext_space_root(ip));

View File

@ -265,7 +265,7 @@
#define __malloc_like __attribute__((__malloc__))
#define __pure __attribute__((__pure__))
#define __always_inline __attribute__((__always_inline__))
#define __always_inline __inline __attribute__((__always_inline__))
#define __noinline __attribute__ ((__noinline__))
#define __fastcall __attribute__((__fastcall__))
#define __result_use_check __attribute__((__warn_unused_result__))

View File

@ -180,6 +180,7 @@ static __inline void
sched_unpin(void)
{
atomic_interrupt_fence();
MPASS(curthread->td_pinned > 0);
curthread->td_pinned--;
}

View File

@ -315,13 +315,6 @@ dmar_ir_free_irte(struct dmar_unit *unit, u_int cookie)
return (0);
}
static u_int
clp2(u_int v)
{
return (powerof2(v) ? v : 1 << fls(v));
}
int
dmar_init_irt(struct dmar_unit *unit)
{
@ -339,7 +332,7 @@ dmar_init_irt(struct dmar_unit *unit)
"QI disabled, disabling interrupt remapping\n");
return (0);
}
unit->irte_cnt = clp2(num_io_irqs);
unit->irte_cnt = roundup_pow_of_two(num_io_irqs);
unit->irt = kmem_alloc_contig(unit->irte_cnt * sizeof(dmar_irte_t),
M_ZERO | M_WAITOK, 0, iommu_high, PAGE_SIZE, 0,
DMAR_IS_COHERENT(unit) ?

View File

@ -1197,6 +1197,9 @@ ATF_TC_BODY(random_eor_and_waitall, tc)
size_t off;
int fd[2], eor;
if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false))
atf_tc_skip("https://bugs.freebsd.org/279994");
arc4random_buf(params.seed, sizeof(params.seed));
printf("Using seed:");
for (u_int i = 0; i < (u_int)sizeof(params.seed)/sizeof(u_short); i++)

View File

@ -4469,7 +4469,7 @@ main(int argc, char **argv)
if (fd == -1 && errno == ENOENT) {
saved_errno = errno;
retval = kldload("ctl");
if (retval != -1)
if (retval != -1 || errno == EEXIST)
fd = open(device, O_RDWR);
else
errno = saved_errno;