Commit graph

5641 commits

Author SHA1 Message Date
Mark Johnston
f9c3b1be36 thread: Add a return value to cpu_set_upcall()
Some implementations copy data to userspace, an operation which can in
principle fail.  In preparation for adding a __result_use_check
annotation to copyin() and related functions, let implementations of
cpu_set_upcall() return an error, and check for errors when copying data
to user memory.

Reviewed by:	kib, jhb
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43100

(cherry picked from commit 7b68fb5ab2a276ccd081cc1a43cebf0fb315e952)
2024-01-01 19:29:48 -05:00
Mark Johnston
f5ae760cfe arm: Disable the VFP during boot
The VFP code expects the kernel to boot with VFP disabled, but some
boards will boot with it enabled.  Make sure that vfp_init() disables
the VFP on each CPU during boot.

PR:		273752
Reviewed by:	andrew
Diagnosed by:	Thomas Skibo <thomas-bsd@skibo.net>
MFC after:	1 week

(cherry picked from commit ce2f34ade8b787b068085fa8a8ddd295b06c2737)
2023-12-17 21:07:49 -05:00
Mark Johnston
42d1aa8862 arm: Handle VFP exceptions from the kernel
vfp_bounce() is called when handling an undefined instruction exception,
to see if we need to enable the VFP.  Previously it would
unconditionally panic if the exception came from the kernel, which was
simply wrong, and it did not permit lazy initialization of VFP state in
the kernel.  However, this functionality can be useful and is supported
by arm's fpu_kern_enter() implementation.  Thus, relax assertions and
consume the exception if the thread was in an FPU section.

Based on a patch from Stormshield.

Reviewed by:	andrew
MFC after:	2 weeks
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D42971

(cherry picked from commit 03a07de0d5ee7d58069152070c42d55f7ec32b7c)
2023-12-17 21:07:48 -05:00
Mark Johnston
bc394ad824 arm: Fix handling of undefined instructions in kernel mode
Only panic if no undefined instruction handler matched the exception.
This can arise in practice if the VFP is enabled lazily.

While here, fix the panic string to not include a newline.

Reviewed by:	andrew
Obtained from:	Stormshield
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D42970

(cherry picked from commit ecc2e6deae71b69a30bf3b7e3354aba002a37d69)
2023-12-17 21:07:47 -05:00
Mark Johnston
1126dcdf40 arm: Add fpu_kern_alloc_ctx()
This enables the use of some out-of-tree crypto libraries on arm.
No functional change intended, there are no callers of this function in
the tree currently.

Reviewed by:	andrew
MFC after:	1 week
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D42969

(cherry picked from commit a6a481eaa2e0f02e24b874f1a08bb494a68972c0)
2023-12-17 21:07:47 -05:00
Mark Johnston
c976896db7 arm: Compile vfp.c conditionally rather than using an ifdef
No functional change intended.

MFC after:	1 week

(cherry picked from commit 96465c789a5ff2619c5d49305517b35db9754ffb)
2023-12-17 21:07:45 -05:00
Mitchell Horne
165cc0eea9 busdma: emit a warning for use of filters
Filter functions are deprecated, and unused in the tree. If either of
the filter or filterarg arguments to bus_dma_tag_create() are non-NULL,
print a warning.

This is a direct commit to stable/14.

Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D42897
2023-12-06 19:23:14 -04:00
Mark Johnston
7cb0bacf53 arm: Update declarations for arm_dcache_align{,_mask}
Reported by:	Jenkins
Fixes:		3d8f548b9e57 ("uma: Make the cache alignment mask unsigned")

(cherry picked from commit 185aa8c9c3d7a01d616cfaafd492f61b37ed2551)
2023-11-16 10:07:27 -05:00
Olivier Certner
690ca45aeb uma: Make the cache alignment mask unsigned
In uma_set_align_mask(), ensure that the passed value doesn't have its
highest bit set, which would lead to problems since keg/zone alignment
is internally stored as signed integers.  Such big values do not make
sense anyway and indicate some programming error.  A future commit will
introduce checks for this case and other ones.

Reviewed by:            kib, markj
MFC after:              2 weeks
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D42262

(cherry picked from commit 3d8f548b9e5772ff6890bdc01f7ba7b76203857d)
2023-11-16 10:07:16 -05:00
Olivier Certner
0c7a1e66f1 arm: Simplify get_cachetype_cp15()
There's no point in setting 'arm_dcache_align_mask' before the
function's end.

Reviewed by:            markj, kib
MFC after:              2 weeks
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D42261

(cherry picked from commit 1bce6f951a902f03bfb354f5b11473a0d12b3d7d)
2023-11-16 10:07:13 -05:00
Olivier Certner
4587326893 uma: Hide 'uma_align_cache'; Create/rename accessors
Create the uma_get_cache_align_mask() accessor and put it in a separate
private header so as to minimize namespace pollution in header/source
files that need only this function and not the whole 'uma.h' header.

Make sure the accessors have '_mask' as a suffix, so that callers are
aware that the real alignment is the power of two that is the mask plus
one.  Rename the stem to something more explicit.  Rename
uma_set_cache_align_mask()'s single parameter to 'mask'.

Hide 'uma_align_cache' to ensure that it cannot be set in any other way
then by a call to uma_set_cache_align_mask(), which will perform sanity
checks in a further commit.  While here, rename it to
'uma_cache_align_mask'.

This is also in preparation for some further changes, such as improving
the sanity checks, eliminating internal resolving of UMA_ALIGN_CACHE and
changing the type of the 'uma_cache_align_mask' variable.

Reviewed by:            markj, kib
MFC after:              2 weeks
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D42258

(cherry picked from commit dc8f7692fd1de628814f4eaf4a233dccf4c92199)
2023-11-16 10:07:07 -05:00
John Baldwin
5db9e9e296 Remove a few more stray __FBSDID uses
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41954

(cherry picked from commit 16837d353cdde87672d08112610e51e4121c4e50)
2023-10-24 10:08:46 -07:00
Mark Johnston
2d49b111a3 uiomove: Add some assertions
Make sure that we don't try to copy with a negative resid.

Make sure that we don't walk off the end of the iovec array.

Reviewed by:	kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D42098

(cherry picked from commit 8fd0ec53deaad34383d4b344714b74d67105b258)
2023-10-24 09:19:01 -04:00
Zhenlei Huang
e53f8ca323 pmap: Prefer consistent naming for loader tunable
The sysctl knob 'vm.pmap.pv_entry_max' becomes a loader tunable since
7ff48af704 (Allow a specific setting for pv entries) but is fetched
from system environment 'vm.pmap.pv_entries'. That is inconsistent and
obscure.

This reverts 36e1b9702e (Correct the tunable name in the message).

PR:		231577
Reviewed by:	jhibbits, alc, kib
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D42274

(cherry picked from commit 02320f64209563e35fa371fc5eac94067f688f7f)
2023-10-23 18:12:21 +08:00
Nicolas Provost
141fe209e3 arm/allwinner: fix variables initialization in clkng
Signed-off-by: Nicolas Provost <dev@npsoft.fr>
Pull-Request:	https://github.com/freebsd/freebsd-src/pull/849
(cherry picked from commit e39e6bef6725bde54f94aac7f0cda47c2170dc48)
2023-10-18 16:37:35 +02:00
Emmanuel Vadot
a5b3cbe6cc iicbus: Move twsi under a new controller subdirectory
The folder is a mess so start moving stuff into sub-directories.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D41907

(cherry picked from commit 580d00f42fdd94ce43583cc45fe3f1d9fdff47d4)
2023-10-18 16:32:05 +02:00
John Baldwin
b7f6b86ee7 gic_acpi: Limit the number of CPUs to GIC_MAXCPU
madt_table_data contains an array of pointers for each CPU and was
allocated on the stack.  If MAXCPU is raised to a sufficiently large
value this can overflow the kernel stack.  Cap the stack growth by
using GIC_MAXCPU instead as for other parts of the gicv1/v2 driver in
commit a0e20c0ded.

Suggested by:	andrew
Reviewed by:	andrew, emaste
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D41800

(cherry picked from commit d0af08c4ba3e400049d246d72401ce36d3bee98a)
2023-10-11 08:10:32 -07:00
John Baldwin
f9984cda96 arm unwind: Reject unaligned stack pointers
Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D41533

(cherry picked from commit 247e8662d2c080c27937ec4d62e80b2358e8c74f)
2023-10-11 08:10:31 -07:00
Konstantin Belousov
45ebb15ab1 sysentvec: add SV_SIGSYS flag
(cherry picked from commit b82b4ae752501469053979393e33bbfa74fbc9d2)
2023-10-09 06:24:31 +03:00
Konstantin Belousov
e0f1021386 syscalls: fix missing SIGSYS for several ENOSYS errors
(cherry picked from commit 39024a89146902ca9aba250130b828ad9aced99d)
2023-10-09 06:24:31 +03:00
Glen Barber
29a16ce065 release: update stable/14 following branching from main
Approved by:	re (implicit)
Sponsored by:	GoFundMe https://www.gofundme.com/f/gjbbsd
Sponsored by:	PayPal https://paypal.me/gjbbsd
2023-08-24 19:07:33 -04:00
Konstantin Belousov
74ccb8ecf6 Add cpu_sync_core()
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D32360
2023-08-23 03:02:21 +03:00
Konstantin Belousov
8882b7852a add pmap_active_cpus()
For amd64, i386, arm, and riscv, i.e. all architectures except arm64,
the custom implementation is provided since we maintain the bitmask of
active CPUs anyway.

Arm64 uses somewhat naive iteration over CPUs and match current vmspace'
pmap with the argument. It is not guaranteed that vmspace->pmap is the
same as the active pmap, but the inaccuracy should be toleratable.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D32360
2023-08-23 03:02:21 +03:00
Jessica Clarke
c9b2751d76 arm: Add missing no-ctfconvert for fw_stub.awk target
This target produces a C file not an object file, so using ctfconvert on
it should not be attempted. This keeps it in sync with all other uses of
fw_stub.awk, squashes a warning seen during the build of TEGRA124 on
FreeBSD and avoids the same issue failing the build on non-FreeBSD (such
errors are #ifdef'ed into being warnings on FreeBSD in ctfconvert, which
should be revisited in the future).

Reviewed by:	manu
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D41542
2023-08-22 21:00:37 +01:00
John Baldwin
5aacf339f6 sys: Remove SND_DECLARE_FILE
Reviewed by:	kbowling, imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41499
2023-08-18 13:05:12 -07:00
Warner Losh
031beb4e23 sys: Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:58 -06:00
Warner Losh
685dc743dc sys: Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:36 -06:00
Warner Losh
dfc016587a sys: Remove $FreeBSD$: two-line .c pattern
Remove /^#include\s+<sys/cdefs.h>.*$\n\s+__FBSDID\("\$FreeBSD\$"\);\n/
2023-08-16 11:54:30 -06:00
Warner Losh
71625ec9ad sys: Remove $FreeBSD$: one-line .c comment pattern
Remove /^/[*/]\s*\$FreeBSD\$.*\n/
2023-08-16 11:54:24 -06:00
Warner Losh
2ff63af9b8 sys: Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:18 -06:00
Warner Losh
95ee2897e9 sys: Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:11 -06:00
Warner Losh
82a265ad9b sys: Remove $FreeBSD$: sound driver version
Remove /SND_DECLARE_FILE\("\$FreeBSD\$"\);/
2023-08-16 11:53:59 -06:00
Emmanuel Vadot
c15106da82 arm64: xilinx: gpio: Add support for ZynqMP SoC
Add support for the gpio controller found in the ZynqMP SoC.
The registers are the same as the Zynq 7000, just the number of
banks/pins per banks differs.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
MFC after:	2 weeks
2023-08-10 09:21:55 +02:00
Emmanuel Vadot
b07fed8180 arm: xilinx: gpio: Make the driver more generic
All other Zynq SoCs have the same GPIO controller, the only difference
is the number of banks/pins so make this driver more generic to add
other SoCs more easily.
No functional changes intended.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
MFC after:	2 weeks
2023-08-10 09:21:55 +02:00
Marius Strobl
37c8ee8847 ath(4): Remove MIPS AHB frontend and join PCI one w/ main support again
Following the removal of general MIPS support, there's no longer a need
to have the AHB bus-frontend in place, which according to Linux sources
also isn't used with any non-MIPS SoCs. For simplicity, PCI bus support
is only made conditional on the main one again, i. e. device ath_pci is
removed, and built into the main module, i. e. if_ath_pci.ko obsoleted,
respectively.
Effectively, this reverts the following commits and associated changes:
dba9c85977
e849bb3ecb

Approved by:	adrian
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D41354
2023-08-08 22:30:13 +02:00
Andrew Turner
a0e20c0ded Limit the number of CPUs in the gicv1/2 driver
The GICv2 can only send IPIs to 8 CPUs. Because of this it should only
be in machines with no more than 8 cores.

Create a new macro to hold this limit to reduce the size of the softc.

Reviewed by:	emaste
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41322
2023-08-04 18:47:47 +01:00
Mark Johnston
1083a8cd85 pcpu: Remove unused definitions of ALT_STACK_SIZE
This was added originally for the sparc64 port and apparently copied to
other platforms.  No functional change intended.

MFC after:	1 week
2023-07-27 16:02:03 -04:00
Mark Johnston
1be56e0bb1 arm/unwind: Check stack pointer boundaries before dereferencing
If the unwinder somehow ends up with a stack pointer that lies outside
the stack, then an attempt to dereference can lead to a fault, which
causes the kernel to panic again and unwind the stack, which leads to a
fault...

Add kstack_contains() checks at points where we dereference the stack
pointer.  This avoids the aforementioned infinite loop in one case I hit
where some OpenSSL assembly code apparently confuses the unwinder.

Reviewed by:	jhb
MFC after:	2 weeks
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D41210
2023-07-27 15:44:00 -04:00
Andrew Turner
7a16546025 arm: Only include sysreg.h when needed in asm.h
We only need sysreg.h for armv6 barriers

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41141
2023-07-24 17:58:16 +01:00
Andrew Turner
29629d9e76 arm: Rename pte-v6.h to pte.h
There is no need for this to be versioned after the removal of armv4/v5

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41139
2023-07-24 17:58:15 +01:00
Andrew Turner
1e7dfc94cc arm: Move contents of pmap-v6.h into pmap.h
Previously we had an armv4/v5 and armv6/v7 copy of the pmap header. As
we have removed armv4/v5 support we can now merge the armv6/v7 code
into pmap.h

Reviewed by:	imp
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41138
2023-07-24 17:58:15 +01:00
Andrew Turner
67d39872e2 arm: Move contents of cpu-v6.h into cpu.h
Previously we had an armv4/v5 and armv6/v7 copy of the cpu.h header. As
we have removed armv4/v5 support we can now merge the armv6/v7 code
into cpu.h

Reviewed by:	imp
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41137
2023-07-24 17:58:14 +01:00
Andrew Turner
835927fd8e arm: Remove swi.h
It has been unneeded since moving to the Arm EABI

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41136
2023-07-24 17:58:14 +01:00
Andrew Turner
04b1532935 arm: Move contents of atomic-v6.h into atomic.h
Previously we had an armv4/v5 and armv6/v7 implementation of the atomic
operations. As we have removed armv4/v5 support we can now merge the
armv6/v7 code into atomic.h

Reviewed by:	imp
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41135
2023-07-24 17:58:13 +01:00
Andrew Turner
554cdf8f57 arm: Explain why _atomic_subword.h is needed
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41134
2023-07-24 17:58:13 +01:00
Andrew Turner
e0e5127ff4 Remove left over includes from armv4/v5
These includes were added for armv4 and armv5 support. Remove them as
this has been removed from the tree.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41133
2023-07-24 17:58:13 +01:00
Mitchell Horne
a89262079e Consistently provide ffs/fls using builtins
Use of compiler builtin ffs/ctz functions will result in optimized
instruction sequences when possible, and fall back to calling a function
provided by the compiler run-time library. We have slowly shifted our
platforms to take advantage of these builtins in 60645781d6 (arm64),
1c76d3a9fb (arm), 9e319462a0 (powerpc, partial).

Some platforms still rely on the libkern implementations of these
functions provided by libkern, namely riscv, powerpc (ffs*, flsll), and
i386 (ffsll and flsll). These routines are slow, as they perform a
linear search for the bit in question. Even on platforms lacking
dedicated bit-search instructions, such as riscv, the compiler library
will provide better-optimized routines, e.g. by using binary search.

Consolidate all definitions of these functions (whether currently using
builtins or not) to libkern.h. This should result in equivalent or
better performing routines in all cases.

One wart in all of this is the existing HAVE_INLINE_F*** macros, which
we use in a few places to conditionally avoid the slow libkern routines.
These aren't easily removed in one commit. For now, provide these
defines unconditionally, but marked for removal after subsequent
cleanup.

Removal of the now unused libkern routines will follow in the next
commit.

Reviewed by:	dougm, imp (previous version)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40698
2023-07-06 14:46:41 -03:00
Mina Galić
3ed646d89a fix qcom_cpu_kpssv2 compile on ASUS_AC1300
Complete afdb42987c by changing the return type from boolean_t to bool
for the definition for qcom_cpu_kpssv2_regulator_start.

PR: 271932
Fixes: afdb42987c
Pull Request: https://github.com/freebsd/freebsd-src/pull/776
2023-06-12 08:30:15 -06:00
Mark Johnston
18282c4772 sysarch: Add includes required for ktrcapfail() calls to be compiled
Reported by:	jfree
MFC after:	1 week
2023-06-01 17:18:23 -04:00
Tetsuya Uemura
9d35469e9a bcm2835_gpio: Handle BCM2711 pin configuration
Add support for GPIO internal pull up/down configuration on RPi4 family.

BCM2711 SoC on 4th generation Raspberry Pi changed the way to configure
its GPIO pins' internal pull up/down resistors. NetBSD already have
support for this change, and port it to FreeBSD is trivial.

This patch, based on the NetBSD commit adds the appropriate method for
BCM2711 and now we can properly configure the GPIO pins' pull status.

PR:		256372
Reviewed by:	mhorne
Obtained from:	NetBSD bb88cfa64ad8
Pull Request:	https://github.com/freebsd/freebsd-src/pull/746
2023-05-29 15:47:12 -03:00