Commit graph

150291 commits

Author SHA1 Message Date
Kyle Evans
b5d2165b90 kern: poll: tap out the pollfd array on successful return
We do this in kern_poll() to include freebsd32 but exclude the linux
compat layer.  The ABI should be the same, but the POLL constants are
probably different or should be assumed so.

Reviewed by:	bapt, jhb
Differential Revision:	https://reviews.freebsd.org/D44158
2024-03-04 23:44:08 -06:00
John Baldwin
291079d0eb pci_host_generic: Simplify generic_pcie_translate_resource
Inline generic_pcie_translate_resource_common into its sole caller.
No functional change.

Reviewed by:	tuexen
Differential Revision:	https://reviews.freebsd.org/D44206
2024-03-04 20:53:21 -08:00
John Baldwin
332dbd3a2f pci_host_generic: Pass a valid end address in generic_pcie_translate_resource
The generic_pcie_containing_range helper added in commit d79b6b8ec2
assumed that the passed in (start, end) range used to locate the
containing mapping range was a valid address range (with end >=
start).  The previous version of
generic_pcie_translate_resource_common only used the start address to
locate a mapping range, so the end address of 0 did not matter, but an
end of 0 now causes the first range to match and an incorrect
translation for resources using a later range.

PR:		277211
Reported by:	dch, tuexen
Reviewed by:	tuexen
Fixes:		d79b6b8ec2 pci_host_generic: Don't rewrite resource start address for translation
Differential Revision:	https://reviews.freebsd.org/D44205
2024-03-04 20:52:54 -08:00
John Baldwin
364d1b2f8c imgact_elf: Add const to the checknote parameter to __elfN(parse_notes)
Reviewed by:	imp, kib
Sponsored by:	University of Cambridge, Google, Inc.
Differential Revision:	https://reviews.freebsd.org/D44215
2024-03-04 20:52:21 -08:00
Alex Richardson
169641f7dd imgact_elf: Add const to a few struct image_params pointers
This makes it more obvious which functions modify fields in this struct.

Reviewed by:	imp, kib
Obtained from:	CheriBSD
Differential Revision:	https://reviews.freebsd.org/D44214
2024-03-04 20:51:49 -08:00
Alex Richardson
327ada0b0e imgact_elf: Add const to the header_supported callback arguments
This callback shouldn't be modifying any of the arguments.

Reviewed by:	imp, kib, emaste, jhb
Obtained from:	CheriBSD
Differential Revision:	https://reviews.freebsd.org/D44193
2024-03-04 11:52:21 -08:00
Mitchell Horne
da48ddbf7c riscv: catch up with EARLY_PRINTF changes
On this platform early console access is possible via SBI. Follow recent
changes to EARLY_PRINTF option and give it a named constant.

Update the commented option in GENERIC so that it compiles.

Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D44100
2024-03-04 14:45:17 -04:00
Tom Coldrick
d3befb534b LinuxKPI: Queue skbuffs at tail in __skb_queue_tail
Correct skb_queue_tail to queue the buffer at the tail of the skbuff.
The skbuff is a circular doubly-linked list, and we call with a pointer
to the head of the list.  Thus queueing before the head gives us a
queueing at the tail.

As a motivating factor, the current behaviour (queueing at the head) was
causing frequent kernel panics from my RTL8822BE wireless card, which
uses the rtw88 driver.  Interrupts can cause buffers to be added to the
rtwdev c2h_queue while the queue is being drained in rtw_c2h_work.
Queueing at the head would leave the nascent entry in the linked list
pointing to the old, now freed, memory for the buffer being processed.
When rtw_c2h_work is next called, we try reading this and so panic.

Reviewed by:	emaste, bz
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D44192
2024-03-04 09:33:12 -05:00
Gleb Smirnoff
2f5a315b30 linux: require vnet(9) context in ifname_bsd_to_linux_name()
This function is used by netlink(9) only.  The netlink(9) taskqueue thread
runs in the vnet of the socket whose request the thread is processing
right now.  This is a correct vnet and resetting it to vnet0 is incorrect.
If the function is to be used by any other caller in addition to
netlink(9), it would be caller's responsiblity to provide correct vnet(9).

Reviewed by:		melifaro, dchagin
Differential Revision:	https://reviews.freebsd.org/D44191
PR:			277286
2024-03-03 12:56:58 -08:00
Konstantin Belousov
2496fb72cf sys/mount.h: align values of MNTK_XXX flags
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2024-03-03 07:15:12 +02:00
Konstantin Belousov
7e4ac11b60 getblkx(9): be more tolerant but also strict with the buffer size checks
It is possible that on-disk filesystem format causes allocation of
buffers of size larger than maxbcachebuf.  Currently, getblkx() and
indirectly bufkva_alloc() panic in that situation.

It is more useful to return an error instead, allowing the system to
continue running.

PR:	277414
Reported by:	Robert Morris <rtm@lcs.mit.edu>
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2024-03-02 07:02:55 +02:00
Warner Losh
c5246cb7b0 nvme: Report only the unknown bits
When we get a smart error that's unknown, report only the unknown
(reserved) bits of the Critical Warning Bitfield.

Sponsored by:		Netflix
2024-03-01 16:04:27 -07:00
John Baldwin
b28670018d pci_host_generic: Enumerate resource ranges under bootverbose
Previously ranges were only enumerated for the FDT attachment but not
ACPI.  This commit moves the enumeration to the shared attach routine
so it is done for both.  While here, don't list empty ranges but do
include the resource type for each range.

Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D44132
2024-03-01 14:20:10 -08:00
John Baldwin
7485926e09 nvme: Firmware revisions in the firmware slot info logpage are ASCII strings
In particular, don't try to byteswap the values as 64-bit integers and
always print a non-empty version as a string.

Reviewed by:	chuck, imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D44121
2024-03-01 14:18:43 -08:00
Randall Stewart
638b5ae1c7 HTPS has actually three states not two so the macro needs to account for that.
Ok lets fix up the tcp_in_hpts() so that it also says yes if you
are in the race state moving and you are scheduled to be put in.
This also requires changing the MPASS to be the old version non
inline function of tcp_in_hpts().

This change also adds a new inline macro so that a uint64_t timestamp can be
obtained by a transport (aka Rack will use this).

Reviewed by: glebius, tuexen
Sponsored by: Netflix Inc.
Differential Revision: https://reviews.freebsd.org/D44157
2024-03-01 15:21:15 -05:00
Alfredo Mazzinghi
c6a6ec85a7 arm64: Fix typo in pagetable_l0_ttbr0_bootstrap symbol name
Obtained from:	CheriBSD
2024-03-01 10:37:18 -08:00
Stefan Eßer
b307cfe419 mqueuefs: fix statfs report to not signal file system full
Synthetic file systems that do not actually allocate file system
blocks or inodes should report that they have space available and
that they provide 0 inodes, in order to prevent capacity monitoring
tools from warning about resource exhaustion.

This has been fixed in all other synthetic file systems in base in
commit 88a795e80c, but this file was overlooked since its name does
not indicate that it also provides a file system.

MFC after:	1 month
2024-03-01 18:31:15 +01:00
Kristof Provost
6460322a0a pf: support if-bound with reply-to
On reply-to we don't know what interface to bind to when we create
the state. Create any reply-to state as floating, but bind to the
appropriate interface once we're handling the reply.

See also:	https://redmine.pfsense.org/issues/15220
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-03-01 09:39:43 +01:00
Brooks Davis
304cdac738 lib{c,sys}: expose _getlogin consistently
Historically we exposed _getlogin as a private symbol on a per-arch basis
(except on aarch64 and riscv) for no obvious reason.  We now need to
expose it for libc's use so remove the special case from
makesyscalls.lua and expose it in the generated syscalls.map.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44116
2024-02-29 19:46:33 +00:00
Warner Losh
3a3afbec38 firmware: unbreak armv7
Use proper format specifiers (with casts) and don't redefine flags.

Fixes:			c7b1e980ae
Sponsored by:		Netflix
2024-02-29 10:53:05 -07:00
Warner Losh
479905a1ed firmware: Allow binary files to be loaded by /boot/loader
Files loaded "-t firmware" (or module_type="firmware").  They are
registered with the firmware system using the full path to the file.
There's only one firmware per file, and it is the entire file. We do an
extra firmware_get() on any firmware we find here to prevent them from
ever being unloaded (we can't handle that case sanely).

Sponsored by:		Netflix
Reviewed by:		tsoome, jhb
Differential Revision:	https://reviews.freebsd.org/D43522
2024-02-29 09:36:31 -07:00
Warner Losh
c7b1e980ae firmware: load binary firmware files
When we can't find a .ko module to satisfy the firmware request, try
harder by looking for a file to read in directly. We compose this file's
name by appending the imagename parameter to the firmware path
(currently hard-wired to be /boot/firmware, future plans are for a
path). Allow this file to be unloaded when firmware_put() releases the
last reference, but we don't need to do the indirection and dance we
need to do when unloading the .ko that will unregister the firmware.

Sponsored by:		Netflix
Reviewed by:		manu, jhb
Differential Revision:	https://reviews.freebsd.org/D43555
2024-02-29 09:36:20 -07:00
Warner Losh
23dff4fdba kernel: Sync ldscript files wrt gnu.attributes and .note.GNU-stack
Bring the keeping of .gnu.attributes to all architectures. Also discard
.note.GNU-stack on all archtiectures. Plus delete obsolete comment that
was removed from i386 in 2010.

Sponsored by:		Netflix
Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D44069
2024-02-29 09:30:37 -07:00
Shawn Anastasio
b52dceb838 powerpc: Bump maximum number of FDT reserved mem entries
Newer firmware on POWER systems, including v2.10 of the Talos II and
Blackbird firmware can end up reserving more than 32 memory regions in
the device tree, which exceeded an assumption made by ofw_machdep.c's
excise_fdt_reserved(). Bump the maximum number of FDT reservations to
the next power of 2 in order to fix booting on newer firmware.

PR:		277097
Reviewed by:	jhibbits
Differential Revision: https://reviews.freebsd.org/D44015
2024-02-28 22:01:15 -05:00
Gleb Smirnoff
7ee47c3bb7 sockets: in solisten_proto() don't call sbdestroy() on a PR_SOCKBUF
A socket marked with PR_SOCKBUF has protocol specific socket buffers
and will take care of the in its pr_listen method.  Right now we don't
have any sockets that can listen and are PR_SOCKBUF, but that will
change soon.
2024-02-28 15:57:25 -08:00
Kristof Provost
706d465dae pf: convert kill/clear state to use netlink
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D44090
2024-02-28 23:26:18 +01:00
Kristof Provost
dfed87b5ce netlink: add bool type support
Reviewed by:	melifaro
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D44089
2024-02-28 23:26:18 +01:00
Kristof Provost
48f33b55b0 netlink: fix casts
Reviewed by:	melifaro
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D44088
2024-02-28 23:26:17 +01:00
Warner Losh
cb4a83cff0 gicv3: If the LPI is already allocated, remember it
If the LPI Configuration Tabel has been pre-allocated by the boot
loader, then we have to remember PROPBASER and use it rather than
allocating memory for it ourselves. Linux provides us with a reserved
table that contains all the gicv3 allocations, so make sure what we read
from PROPBASER matches something in that table. Normally, bare metal
boot loaders leave the gic in a reset state. However, Linux brings it up
fully so it can do I/O to boot the next kernel via kexec. Since the
gicv3 PENDBASER can't be reset while running due to undefined behavior,
we must reuse what's there for both PENDBASER and PROPBASER.

With this commit, the workaround is complete. Details are at
https://lkml.iu.edu/hypermail/linux/kernel/1809.2/06246.html
and pointers in the thread.

Sponsored by:		Netflix
Reviewed by:		andrew
Differential Revision:	https://reviews.freebsd.org/D44038
2024-02-28 07:09:43 -07:00
Warner Losh
1d13cc2008 gicv3: In its_init_cpu_lpi record each cpu's PENDBASER
When we're using the preallocated memory for gicv3, record each cpu's
PENDBASER where we'd normally allocate memory for it. Make sure that
memory is in the excluded list and map the PA to VA and store that, to
mimic what we do with the allocation case.

Sponsored by:		Netflix
Reviewed by:		andrew
Differential Revision:	https://reviews.freebsd.org/D44037
2024-02-28 07:09:42 -07:00
Warner Losh
a3f164a0c7 gicv3: Define PA masks for the PENDBASR and PROPBASER registers
Define masks for these registers to find the PA of where these are
pointing.

Sponsored by:		Netflix
Reviewed by:		andrew
Differential Revision:	https://reviews.freebsd.org/D44096
2024-02-28 07:09:42 -07:00
Warner Losh
b4368e8389 gicv3: Report PENDBASE when bootverbose
Report some stats about PENDBASE when we're running under
bootverbose. We don't do this by default because experience has been
excess output in this routine hangs the system.

Sponsored by:		Netflix
Reviewed by:		andrew
Differential Revision:	https://reviews.freebsd.org/D44036
2024-02-28 07:09:42 -07:00
Warner Losh
ae84491a35 gicv3: Only set the redistributor base if we're not prealloced
Only set the redistributor base if we're not reallocated.  If we are
preallocated, leave it all alone.

Sponsored by:		Netflix
Reviewed by:		andrew
Differential Revision:	https://reviews.freebsd.org/D44035
2024-02-28 07:09:42 -07:00
Warner Losh
ddd98f5a62 gicv3: Don't allocate pend_base if we're already started
If the gicv3 is already started, then don't allocate memory for the
pend_base tables.

Sponsored by:		Netflix
Reviewed by:		andrew
Differential Revision:	https://reviews.freebsd.org/D44034
2024-02-28 07:09:42 -07:00
Warner Losh
51c57ca92e gicv3: Panic if the gicv3 already running
Due to undefined behavior, it's impossible to re-program a gicv3 ITS
table once it's programmed once. Memory corruption happens otherwise.
Panic if we detect the LPI is already enabled.

Sponsored by:		Netflix
Reviewed by:		andrew
Differential Revision:	https://reviews.freebsd.org/D44033
2024-02-28 07:09:42 -07:00
Warner Losh
15c8a610a8 gicv3: Change how we initialize its children.
The current code is written such that all the attach routines can do so
in parallel. However, newbus serializes children today, and is likely to
do so in the future. Only allocate memory for the first time. Add an
assertion that this memory is allocated for larger units.

Sponsored by:		Netflix
Reviewed by:		andrew
Differential Revision:	https://reviews.freebsd.org/D44032
2024-02-28 07:09:42 -07:00
Mitchell Horne
749e318da3 riscv: add starfive kernelconf template
Enable the Synopsis UART driver. Other drivers will be added in the
future.

Reviewed by:	jrtc27
Sponsored by:	The FreeBSD Foundatino
Differential Revision:	https://reviews.freebsd.org/D44105
2024-02-27 18:10:14 -04:00
Mitchell Horne
036ce936a5 riscv: add dwc, dwmmc to NOTES
In the future these drivers will be enabled in GENERIC. For now, ensure
they build with LINT.

Sponsored by:	The FreeBSD Foundation
2024-02-27 18:10:14 -04:00
Mitchell Horne
f84e9df6d0 conf: deduplicate dwmmc config logic
The core of this driver is supported by multiple architectures. Move the
config entries to the MI conf/files.

This hardware is found on several available/emerging RISC-V SoCs, so we
will soon need it on this architecture.

Reviewed by:	manu
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D44104
2024-02-27 18:10:14 -04:00
Mitchell Horne
a01dc140b2 conf: deduplicate dwc config logic
Move the core dwc(4) file entries to the MI conf/files.
Platform-specific versions e.g. rk_dwc are retained in their current
position. On arm64 this necessitates adding an additional 'device dwc'
option.

This hardware is found on several available/emerging RISC-V SoCs, so we
will soon need it on this architecture.

Reviewed by:	manu
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D44103
2024-02-27 18:10:14 -04:00
Mitchell Horne
fae39d8da9 dwc: fix DEBUG macro name
It conflicts with the general "DEBUG" macro defined as an option in LINT
builds. Since this is actually unused, just rename it to GMAC_DEBUG.

Reviewed by:	manu
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D44102
2024-02-27 18:10:14 -04:00
Gleb Smirnoff
41ce9c8b88 netlink: restore original buffer if nlmsgs_to_linux() fails
Caller is responsible to free it or reuse.

Fixes:	17083b94a9
2024-02-27 12:45:54 -08:00
John Baldwin
69945c49fe netlink: Don't use a zero-length array
Define SNL_DECLARE_FIELD_PARSER* macros to create a parser that has
no output attributes only input fields and use this to define the
snl_donemsg_parser.

This removes the need for the zero-length nla_p_donemsg[] variable.
Zero length arrays are not valid in ISO C.

Reviewed by:	jrtc27, melifaro
Differential Revision:	https://reviews.freebsd.org/D43918
2024-02-27 11:59:52 -08:00
John Baldwin
3a48dfe115 bhnd_chipc: Make use of bus_generic_rman_* to simplify some code
This uses bus_generic_rman_alloc/release_resource to reduce some code
duplication.  However, I've left the custom activate/deactivate
methods as-is.

Differential Revision:	https://reviews.freebsd.org/D43939
2024-02-27 11:44:22 -08:00
John Baldwin
b25f03a1a2 bhnd_usb: Use bus_generic_rman_*
For SYS_RES_MEMORY, use bus_generic_rman_* for
activate/deactivate_resource methods as well as custom
map/unmap_resource methods that request submappings of the sc_mem
resource allocated from the parent bus.

Differential Revision:	https://reviews.freebsd.org/D43938
2024-02-27 11:44:03 -08:00
John Baldwin
9b619f0e90 dpaa2: Use bus_generic_rman_*
Reviewed by:	dsl
Differential Revision:	https://reviews.freebsd.org/D43937
2024-02-27 11:43:50 -08:00
John Baldwin
04fc3fb8fc rman: Remove rman_set_start/end
These functions are not safe as the rman implementation assumes that
all regions (including allocated resources) are sorted by address in
the internal linked-list.

Differential Revision:	https://reviews.freebsd.org/D43936
2024-02-27 11:43:34 -08:00
Alexander Motin
7c667affb7 CTL: Drop Format Device and Rigid Disk Geometry mode pages
Those mode pages are obsolete since SBC-2 specification almost 20
years ago.  First I was trying to understand possible relations
between physical block and physical sector terms in different specs.
Then was thinking about possible relations to device CHS geometry
and compatibility issues.  Finally I just decided that none of it
worth the efforts and should rest in piece.

PR:	276524
2024-02-27 13:28:44 -05:00
Gordon Bergling
6bce41a38e carp(4): Fix a typo in a source code comment
- s/successfull/successful/

MFC after:	3 days
2024-02-27 17:39:57 +01:00
Gordon Bergling
e2f3649613 bxe(4): Fix two typos in a kernel messages
- s/successfull/successful/

MFC after:	3 days
2024-02-27 17:38:53 +01:00