Commit graph

147986 commits

Author SHA1 Message Date
Christos Margiolis
ea89133dbc kinst: check for 'push %rbp' anywhere in the function
Currently kinst checks if only the first instruction is 'push %rbp',
essentially excluding functions that do push RBP, but not in the first
instruction. This patch modifies kinst to check for 'push %rbp', as
well, as a following 'pop %rbp', anywhere in the function. This behavior
also matches that of FBT.

Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40283
2023-07-19 17:53:08 +03:00
Christos Margiolis
8ada3f78e6 kinst.h: reorder function declarations based on implementation file
Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41032
2023-07-19 17:50:24 +03:00
Doug Moore
6f251ef228 radix_trie: simplify ge, le lookups
Replace the implementations of lookup_le and lookup_ge with ones
that do not use a stack or climb back up the tree, and instead
exploit the popmap field to quickly identify the place to resume
searching if the straightforward indexed search fails.

The code size of the original functions shrinks by a combined 160
bytes on amd64, and the cumulative cycle count per invocation of
the two functions together is reduced 20% in a buildworld test.

Reviewed by:	alc, markj
Tested by:	pho
Differential Revision:	https://reviews.freebsd.org/D40936
2023-07-19 09:43:31 -05:00
Dmitry Chagin
e38c634b77 vfs: Add a parenthese to vn_lock_pair() asserts to silence gcc
Reviewed by:		kib, markj
Differential Revision:	https://reviews.freebsd.org/D41070
2023-07-19 16:51:07 +03:00
Michael Tuexen
e4a873bf10 tcp: improve layout of struct tcpcb
Put optional fields at the end to minimize run time problems in
case CC modules are build from within its directory.

Reviewed by:		cc, gallatin, glebius, imp
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D41059
2023-07-19 14:47:36 +02:00
John Baldwin
c5312bd79e cam: Move bus_dmamap_load_ccb into cam.c.
This routine is specific to CAM and no longer assumes any internal
bus_dma knowledge as it is simple wrapper around bus_dmamap_load_mem.

Fixes:		60381fd1ee memdesc: Retire MEMDESC_CCB.
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D41058
2023-07-18 18:19:27 -07:00
Dmitry Chagin
b834497c6d linux(4): Use M_LINUX for malloc type of proc emuldata
MFC after:		2 weeks
2023-07-19 00:44:17 +03:00
Dmitry Chagin
7729467781 linux(4): Use M_LINUX for malloc type in getdents
MFC after:		2 weeks
2023-07-19 00:44:16 +03:00
Dmitry Chagin
e27e3fa71c linux(4): Use M_LINUX for malloc type in getdents64
MFC after:		2 weeks
2023-07-19 00:44:16 +03:00
Dmitry Chagin
b27f3237c8 linux(4): Delete a useless variable in getdents64
MFC after:		2 weeks
2023-07-19 00:44:16 +03:00
Dmitry Chagin
13d049ab8d linux(4): Use M_LINUX for malloc type in readdir
MFC after:		2 weeks
2023-07-19 00:44:15 +03:00
Dmitry Chagin
fffb2e8de6 linux(4): Delete a useless variable in readdir
MFC after:		2 weeks
2023-07-19 00:44:15 +03:00
Dmitry Chagin
fc1c787aa0 linux(4): Properly allocate buffer for kern_getdirentries in readdir
Looks like prior to ino64 project the size of the struct linux_dirent
was greater (or equal) to the size of the native struct dirent so the
native dirent fit into the buffer. After ino64 project the size of the
native struct dirent has increased.

Spotted by gcc12.
MFC after:		2 weeks
2023-07-19 00:44:15 +03:00
Yuri Pankov
b36f469a15 zfs: set autotrim default to 'off'
As it turns out having autotrim default to 'on' on FreeBSD never really
worked due to mess with defines where userland and kernel module were
getting different default values (userland was defaulting to 'off',
module was thinking it's 'on').

PR:		264234
Reviewed by:	mav (zfs)
Differential Revision: https://reviews.freebsd.org/D41056
2023-07-18 11:20:11 +02:00
Simon J. Gerraty
89f361f742 kern.post.mk allow NEWVERS_{ENV,ARGS}
Allow makefiles better control of newvers.sh env and args.
Also allow variable overrides on command line.

Reviewed by:	imp, stevek
Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D41012
2023-07-17 12:03:35 -07:00
Warner Losh
d3152ab23e tcbpcb: Always define t_osd
Always define t_osd. congestion control modules access it
unconditionally. This fixes the build.

However, this is, at best, a temporary band-aide until the
larger issues are sorted.

Sponsored by:		Netflix
2023-07-17 11:22:45 -06:00
Doug Moore
b8cc13fa21 riscv pmap: another vm_radix_init
pmap_pinit0 also needs to initialize a vm_radix, in case vm_radix_init
does anything but zeroing fields.

Reported by:	alc
Reviewed by:	alc
Differential Revision:	https://reviews.freebsd.org/D41055
2023-07-16 15:48:43 -05:00
John Baldwin
c9b1980394 memdesc: Retire MEMDESC_BIO.
Instead, change memdesc_bio to examine the bio and return a memdesc of
a more generic type describing the data buffer.

Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D41029
2023-07-14 11:32:40 -07:00
John Baldwin
bab38b44dd memdesc: Add a MEMDESC_VMPAGES descriptor type.
This memory descriptor is backed by an array of VM pages.  This type
requires adding a new field to 'struct memdesc' to hold the offset
within the first page.  For LP64 systems, this new field is added in
an existing padding hole so does not increase the size.  For ILP32
systems, this grows 'struct memdesc' from 12 to 16 bytes.

Reviewed by:	imp, markj
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D41028
2023-07-14 11:32:24 -07:00
John Baldwin
3dba010e49 memdesc: Replace md_opaque with a union of type-specific fields.
Reviewed by:	imp, markj
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D41027
2023-07-14 11:32:21 -07:00
John Baldwin
60381fd1ee memdesc: Retire MEMDESC_CCB.
Instead, change memdesc_ccb to examine the CCB and return a memdesc of
a more generic type describing the data buffer.

Reviewed by:	imp, markj
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D40880
2023-07-14 11:32:16 -07:00
John Baldwin
6582301f83 PCI DEN0115: Reliably check for a memory resource during probe.
rid was stack garbage, so the bus_alloc_resource_any() call could fail
and fall through to the SMCCC version check even if a bridge had a
memory resource.

Debugging help:	jrtc27
Reviewed by:	jrtc27
Fixes:		c9a05c0722 Add a PCI driver that follows the Arm DEN0115 spec
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D41025
2023-07-14 10:27:40 -07:00
Olivier Certner
f58378393f vn_lock_pair(): Support passing LK_NODDLKTREAT
Since this function ultimately calls vn_lock() or VOP_LOCK1(), allows it to
receive and pass this flag which is used in the lookup code and doesn't
interfere with the function's operation.

Reviewed by:    kib, markj
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D40954
2023-07-14 14:36:12 +03:00
Kristof Provost
f53b28c6df Fix i386 MINIMAL build
Include systm.h in i386's counter.h, so it can use critical_*().

In file included from /usr/src/sys/netinet6/ip6_var.h:250:
In file included from /usr/src/sys/sys/counter.h:37:
./machine/counter.h:191:3: error: call to undeclared function 'critical_enter'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration]
                critical_enter();
                ^
./machine/counter.h:193:3: error: call to undeclared function 'critical_exit'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration]
                critical_exit();
                ^
2023-07-14 09:18:44 +02:00
Kristof Provost
b8039bf5b3 Fix MINIMAL build
Pre-declare struct ucred, to fix build issues on the MINIMAL config:

In file included from /usr/src/sys/netpfil/pf/pfsync_nv.c:40:
/usr/src/sys/netinet6/ip6_var.h:384:31: error: declaration of 'struct ucred' will not be visible outside of this function [-Werror,-Wvisibility]
        struct ip6_pktopts *, struct ucred *, int);
                                     ^
/usr/src/sys/netinet6/ip6_var.h:408:28: error: declaration of 'struct ucred' will not be visible outside of this function [-Werror,-Wvisibility]
    struct inpcb *, struct ucred *, int, struct in6_addr *, int *);
                           ^
2 errors generated.
2023-07-14 09:18:43 +02:00
Kristof Provost
208fcb55e3 Fix MINIMAL build on amd64
amd64/include/counter.h uses KASSERT, but failed to include the
kassert.h header.
2023-07-14 09:18:43 +02:00
Kristof Provost
77c9e60885 pfsync: fix NOINET6 build
While here also fix a few minor style(9) issues.
2023-07-14 09:18:43 +02:00
Doug Moore
3e04ae433f vm_radix_init: use initializer
Several vm_radix tries are not initialized with vm_radix_init. That
works, for now, since static initialization zeroes the root field
anyway, but if initialization changes, these tries will fail. Add
missing initializer calls.

Reviewed by:	alc, kib, markj
Differential Revision:	https://reviews.freebsd.org/D40971
2023-07-14 01:49:55 -05:00
Michael Tuexen
be78a31188 tcp: fix build issue for some cc modules
The TCP_HHOOK option was moved from opt_inet.h to opt_global.h in
https://cgit.FreeBSD.org/src/commit/?id=e68b3792440cac248347afe08ba5881a00ba6523
The corresponding changes in two Makefiles were missed, which resulted
in not building cc_cdg, cc_chd, cc_hd, and cc_vegas anymore.

Reported by:		void@f-m.fm
Reviewed by:		rrs, rscheff
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D41010
2023-07-13 18:56:25 +02:00
Doug Moore
8f056492c5 vfs_bio: initialize pctries
bufobj_init depends on fields bo_dirty.bv_root and bo_clean.bv_root
being zeroed on entry and pctrie_init zeroing whatever is passed to
them, and so does not call pctrie_init for either of them. That fails
if pctrie_init ever changes to do something other that zeroing data,
so add explicit calls to them.

Reviewed by:	cem
Differential Revision:	https://reviews.freebsd.org/D40978
2023-07-13 13:28:21 -05:00
Luiz Amaral
6fc7fc2dbb pfsync: transport over IPv6
Implement pfsync over IPv6.

Submitted by:	Luiz Amaral <email@luiz.eng.br>
Submitted by:	Naman Sood <naman@freebsdfoundation.org>
Reviewed by:	kp
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D40102
2023-07-13 08:09:42 +02:00
Dmitry Chagin
17cb2ac3df signal: Get rid of gsignal() as it not used anywhere
Reviewed by:		imp, kib
Differential Revision:	https://reviews.freebsd.org/D41007
MFC after:		1 week
2023-07-13 10:41:51 +03:00
Kajetan Staszkiewicz
6b4ed16d74 pf: Simplify rule actions logic
Actions applied to a processed packet come in case of stateless
firewalling from a rule or in case of statefull firewalling from a
state. The state obtains the actions from a rule when it is created by a
rule or by pfsync. The logic for deciding if actions come from a rule or
a state is spread across many places in pf.

There already is struct pf_rule_actions in struct pf_pdesc and thus it
can be used as a central place for storing actions and their parameters.
OpenBSD does something similar: they also store the actions in struct
pf_pdesc and have no variables in pf_test() but they use separate
variables instead of a structure. By using struct pf_rule_actions we can
simplify the code even further. Applying of actions is done *only* in
pf_rule_to_actions() no matter if for the legacy scrub rules or for the
normal match / pass rules. The logic of choosing if rule or state
actions are used is applied only once in pf_test() by copying the whole
struct.

Reviewed by:	kp
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D41009
2023-07-13 07:36:39 +02:00
Konstantin Belousov
3905309dfe fdescfs: add a mount option rdlnk
which changes /dev/fd/N files types to symbolic link with the behavior
of symbolic links.

PR:	272127
Reported by:	Peter Eriksson <pen@lysator.liu.se>
Reviewed by:	dchagin
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D40969
2023-07-13 04:14:20 +03:00
Konstantin Belousov
9c3bfe2ad0 Revert "VFS: Remove VV_READLINK flag" and "fdescfs: improve linrdlnk mount option"
This reverts commits 4a402dfe0b and
3bffa22623.

The fix will be implemented in somewhat different manner.  The semantic
adjustment is incompatible with linuxolator expectations.

Reported and reviewed by:	dchagin
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D40969
2023-07-13 04:14:12 +03:00
Kajetan Staszkiewicz
f2064dd1f1 pf: Fix duplicate storage of direction
The variable storing the direction of a processed packet is passed
around to many functions. Most of those functions already have a pointer
to struct pf_pdesc which also contains the direction. By using the one
in struct pf_pdesc we can reduce the amount of arguments passed around.

Reviewed by:	kp
Sponsored by:	InnGames GmbH
Differential Revision:	https://reviews.freebsd.org/D41008
2023-07-12 18:05:47 +02:00
Yufeng Zhou
294c52d969 amd64 pmap: Fix compilation when superpage reservations are disabled
The function pmap_pde_ept_executable() should not be conditionally
compiled based on VM_NRESERVLEVEL. It is required indirectly by
pmap_enter(..., psind=1) even when reservation-based allocation is
disabled at compile time.

Reviewed by:	alc
MFC after:	1 week
2023-07-12 12:07:42 -05:00
Gleb Smirnoff
0d1ff2b04d vmm: don't leak locks exiting vmmdev_ioctl()
At least an error from vcpu_lock_all() at line 553 would leak
memseg lock.  There might be other cases as well.

Reviewed by:		corvink, markj
Differential Revision:	https://reviews.freebsd.org/D40981
2023-07-12 09:16:40 -07:00
Gleb Smirnoff
30f0328a32 vmm: don't return random error from vcpu_lock_all() if vcpu is empty
When vcpu array is empty, function would return random value from
stack.  What I observed was -1.

Reviewed by:		corvink, markj
Differential Revision:	https://reviews.freebsd.org/D40980
2023-07-12 09:16:40 -07:00
Jessica Clarke
d1e44bc944 kmod.mk: Use portable printf '%s' over non-portable echo -n
Whilst /bin/echo on macOS and Linux implement -n, as do the builtin
echos in bash and zsh, the builtin echo in dash does not, causing the
first line of the output to be -n foo rather than just foo, and there to
be an extra newline in the output and thus blank line, both of which
result in "Symbol ... is not present in *.kld" warnings appearing in the
build output (once for -n foo and once for the empty string for each
module where EXPORT_SYMS is a list of symbols).

MFC after:	1 week
2023-07-11 21:30:06 +01:00
Piotr Kubaj
5ddb1aa305 ix, ixv: fix kernel build
struct adapter was renamed to struct sc.

Reported by: FreeBSD User <freebsd@walstatt-de.de>
2023-07-11 19:41:26 +02:00
Piotr Kubaj
6ad2a9a64f ix: remove stale comment
Reported by:	Navdeep Parhar
2023-07-11 18:45:04 +02:00
Piotr Pietruszewski
a0302c9231 ix, ixv: Update link status with autonegotiated baudrate value
Use autonegotiated link speed value while updating link status
to iflib.

This patch is part of change made in NetBSD kernel
by Masanobu Saitoh, NetBSD maintainer.

Differential Revision:	https://reviews.freebsd.org/D19176
Approved by:	erj
2023-07-11 18:14:26 +02:00
Kristof Provost
66f2f9ee08 ipfw: teach ipfw that pfsync is an upper layer protocol
Explicitly add pfsync as a know upper layer protocol so we don't
automatically discard pfsync packets (carried over IPv6).

net.inet6.ip6.fw.deny_unknown_exthdrs defaults to 1, so even if
net.inet.ip.fw.default_to_accept is set to 1 we'd discard pfsync (over
IPv6).

Reviewed by:	ae
Differential Revision:	https://reviews.freebsd.org/D40973
2023-07-11 14:59:08 +02:00
Peter Grehan
43ed91e00b igc: Increase default per-queue interrupt rate to 20000.
The default per-queue packet rate of 8000 will cause packet loss when
forwarding at 2.5G with a single stream, as is common when using e.g.
iperf3 to test a platform.

Bump this to 20000 (the "low latency" value in the Linux driver) which
avoids packet loss for this type of test.

Future work will use adaptive interrupt rate in a similar fashion
to the ixgbe driver.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Reviewed by:	erj, kp
MFC after:	3 weeks
Differential Revision: https://reviews.freebsd.org/D40904
2023-07-11 13:29:37 +10:00
Konstantin Belousov
565a343ae3 sigqueue_delete_set_proc(): initialize sq_proc for worklist
This should fix leaks for the p_killpg_cnt counter, because
sigqueue_flush() drops ksi's.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-07-11 03:52:16 +03:00
Konstantin Belousov
7e4c6b2163 msdosfs: zero partially valid extended cluster
It contains arbitrary garbage, which is not cleared by vfs_bio_clrbuf()
which only zeroes invalid portions of the pages.

Reported by:	Maxim Suhanov <dfirblog@gmail.com>
Discussed with:	so
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-07-11 03:49:09 +03:00
Mitchell Horne
f7a2170606 pmc_events.h: update top-level comment
It points to non-existent documentation. The wiki page still contains a
useful overview, so keep this link.

MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2023-07-10 14:32:27 -03:00
Alan Somers
6c049996ec During F_SETFL, don't change file flags on error
Previously, even if the FIONBIO or FIOASYNC ioctl failed, the file's
f_flags variable would still be changed.  Now, kern_fcntl will restore
the original flags if the ioctl fails.

PR:		265736
Reported by:	Yuval Pavel Zholkover <paulzhol@gmail.com>
MFC after:	2 weeks
Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D40955
2023-07-10 08:13:58 -06:00
Doug Moore
16e01c05c0 radix_trie: avoid code duplication in insert
Two cases in the insert routine are written differently, when
they're really doing the same thing. Writing that case only once
saves 208 bytes in the compiled vm_radix_insert code and reduces
instructions executed by about 2%.
Reviewed by:	alc
Tested by:	pho
Differential Revision:	https://reviews.freebsd.org/D40807
2023-07-09 15:06:02 -05:00