Commit graph

147825 commits

Author SHA1 Message Date
John Baldwin
36c2fec31d riscv: Remove MACHINE_ARCH-specific remnants of riscv64sf.
- Remove now unnecessary MACHINE_ARCHES definition.  The default logic
  in kern_mib.c works fine now for RISC-V.

- Remove custom sv_machine_arch hook from sysentvec.

Fixes:		1ca12bd927 Remove the riscv64sf architecture.
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D40648
2023-06-27 10:19:31 -07:00
Warner Losh
2d38d9839b openzfs: Remove broken symlinks
These symlinks are broken. They point to files that don't exist, and
rely on having them be built using a 'in-tree' build that FreeBSD
doesn't use. They also show up as errors on grep -r. Since they are
broken and can't possibly work, remove them for now since non-functional
symlinks matching an upstrem repo that can't work in our repo aren't
worth the error messages.

Though one could argue the whole debian directory should be removed, I
did the minimal change necessary. These can return when the fundamental
issue is fixed and the contrib/debian tree is useful on FreeBSD systems.
2023-06-27 11:15:20 -06:00
John Baldwin
5ae4463498 nvme: Fix typo in "Command Aborted by Host" constant name.
Reviewed by:	chuck, imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D40763
2023-06-27 10:06:22 -07:00
Doug Moore
9cfed089ac radix_trie: clean up overlong lines
This is purely a cosmetic change. vm_radix.c has lines that reach past
column 80 and this change cleans that up. The associated changes to
subr_pctrie.c are just to keep mirroring vm_radix.c.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D40764
2023-06-27 12:01:33 -05:00
Konstantin Belousov
4a402dfe0b VFS: Remove VV_READLINK flag
since its only reason to exist is removed.

Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D40700
2023-06-27 13:43:25 +03:00
Konstantin Belousov
3bffa22623 fdescfs: improve linrdlnk mount option
Instead of using VV_READLINK vnode flag and checking it in one place,
just assign VLNK type to the Fdesc vnodes for linrdlnk mounts.  Then all
places where symlinks needs to be followed, e.g. lookup(), are handled.

PR:	272127
Reported by:	Peter Eriksson <pen@lysator.liu.se>
Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D40700
2023-06-27 13:43:17 +03:00
Doug Moore
72c3a43b16 radix_trie: skip compare in lookup_le, lookup_ge
In _lookup_ge, where a loop "looks for an available edge or val within
the current bisection node" (to quote the code comment), the value of
index has already been modified to guarantee that it is the least
value than can be found in the non-NULL child node being
examined. Therefore, if the non-NULL child is a leaf, there's no need
to compare 'index' to anything, and the value can just be returned.

The same is true for _lookup_le with 'most' replacing 'least'.
Reviewed by:	alc
Tested by:	pho
Differential Revision:	https://reviews.freebsd.org/D40746
2023-06-27 00:42:41 -05:00
Alan Cox
d8e6f4946c vm: Fix anonymous memory clustering under ASLR
By default, our ASLR implementation is supposed to cluster anonymous
memory allocations, unless the application's mmap(..., MAP_ANON, ...)
call included a non-zero address hint.  Unfortunately, clustering
never occurred because kern_mmap() always replaced the given address
hint when it was zero.  So, the ASLR implementation always believed
that a non-zero hint had been provided and randomized the mapping's
location in the address space.  To fix this problem, I'm pushing down
the point at which we convert a hint of zero to the minimum allocatable
address from kern_mmap() to vm_map_find_min().

Reviewed by:	kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D40743
2023-06-26 23:42:48 -05:00
John Baldwin
af296130ea nvme_xpt: Tidy nvme_announce_periph for fabrics support.
- Read the version from cts.protocol_version.

- Only check xport_specific.nvme for PCI-e info for XPORT_NVME.

Reviewed by:	chuck, imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D40618
2023-06-26 20:37:43 -07:00
John Baldwin
e932f0d2a3 cam_xpt: Properly fail if a sim uses an unsupported transport.
The default xport ops for a new bus is xport_default, not NULL, so
check for that when determining if a bus failed to find a suitable
transport.  In addition, the path needs to be freed with xpt_free_path
instead of a plain free so that the path's reference on the sim is
dropped; otherwise, cam_sim_free in the caller after xpt_bus_register
returns failure will hang forever.

Note that we have to exempt the xpt bus from this check as it uses
xport_default on purpose.

Reviewed by:	mav, imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D40617
2023-06-26 20:36:06 -07:00
John Baldwin
9c2203a691 nvme: Tidy up transfer rate settings in XPT_GET_TRAN_SETTINGS.
- Replace a magic number with CTS_NVME_VALID_SPEC.

- Set the transport and protocol versions the same as for XPT_PATH_INQ.

Probably we shouldn't bother with setting the version in the 'spec'
member of ccb_trans_settings_nvme at all and use the transport
and/or protocol version field instead.

Reviewed by:	chuck, imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D40616
2023-06-26 20:32:29 -07:00
Reid Linnemann
f0c9703301 sys/dev/ichsmb: Silence unhandled SMBALERT device_printfs
The ichsmb driver does not actually handle SMBALERT, other than by logging the
first 16 occurences of the ICH_HST_STA_SMBALERT_STS_SMBALERT status
flag. Because the SMBALERT is not acknowledged by the host, clearing it in the
host status register does not appear to work as long as some slave device is
pulling the SMBALERT line low, at least for C2000 chips. As a result, if a slave
device does pull SMBALERT low the interrupt handler will always loop its maximum
of 16 times attempting to clear all status register flags and device_printf the
status register. The result is the kernel message buffer is littered with these
device_printfs at every interrupt.

To remedy the problem, the ICH_HST_STA_SMBALERT_STS flag is zeroed in the read
host status register value, just as with ICH_HST_STA_INUSE_STS and
ICH_HST_STA_HOST_BUSY. This allows the loop to break when no other flags that
must be handled are set in the host status register. Additionally, because the
SMBALERT is not actually handled the SMBALERT logging is omitted as it has no
actual function at this time.

Reviewed by:	imp
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D39966
2023-06-26 10:29:34 +02:00
Bjoern A. Zeeb
08bc2cc4c4 LinuxKPI: cast jiffies_to_msecs() result
jiffies_to_msecs() is expected to return an uint_t.  In order to avoid
changing printf format strings, properly cast the result to the
expected type.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D40486
2023-06-26 07:54:24 +00:00
Doug Moore
a42d8fe001 radix_trie: simplify trimkey functions
Replacing a branch and two shifts with a single masking operation saves 64 bytes the pair of functions lookup_le and lookup_ge on amd64.  Refresh the associated comments.
Reviewed by:	alc
Differential Revision:	https://reviews.freebsd.org/D40722
2023-06-25 12:49:15 -05:00
Martin Matuska
f190c36b5d zfs: merge openzfs/zfs@8e8acabdc
Notable upstream pull request merges:
  #14987 Fix memory leak in zil_parse()

Obtained from:	OpenZFS
OpenZFS commit:	8e8acabdca
2023-06-25 10:32:42 +02:00
Mitchell Horne
17e97d41e7 hwpmc: add 'flags' local to pmc_op_do_pmcallocate()
Similar to the other allocation parameters. No functional change.

MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2023-06-24 16:29:59 -03:00
Alan Cox
0d2f98c2f0 amd64 pmap: Tidy up pmap_promote_pde() calls
Since pmap_ps_enabled() is true by default, check it inside of
pmap_promote_pde() instead of at every call site.

Modify pmap_promote_pde() to return true if the promotion succeeded and
false otherwise.  Use this return value in a couple places.

Reviewed by:	kib, markj
Differential Revision:	https://reviews.freebsd.org/D40744
2023-06-24 13:09:04 -05:00
Christos Margiolis
59833b089e arm64: improve KTR_TRAP trace entries
Follow-up of 7756232199 ("riscv: improve KTR_TRAP trace entries").

Reviewed by:	markj
Approved by:    markj (mentor)
Sponsored by:   The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40696
2023-06-24 08:23:14 +03:00
Ed Maste
9ead001d5b Bump __FreeBSD_version for OpenSSL 3.0 update
Reported by:	bofh
Sponsored by:	The FreeBSD Foundation
2023-06-23 22:16:34 -04:00
Doug Moore
e8efee297c radix_trie: avoid reloading radix node
In the vm_radix:remove loop that searches for the last child, load
that child once, without loading it again after the search is over.
Change KASSERTS from index check to NULL node check.
Reviewed by:	alc
Differential Revision:	https://reviews.freebsd.org/D40721
2023-06-23 18:47:23 -05:00
Kyle Evans
b08ee10c06 wg: fix a number of issues with module load failure handling
If MOD_LOAD fails, then MOD_UNLOAD will be called to unwind module
state, but wg_module_init() will have already deinitialized everything
it needs to in a manner that renders it unsafe to call MOD_UNLOAD
after (e.g., freed zone not reset to NULL, wg_osd_jail_slot not reset
to 0).  Let's simply stop trying to handle freeing everything in
wg_module_init() to simplify it; let the subsequent MOD_UNLOAD deal with
it, and let's make that robust against partially-constructed state.

jhb@ notes that MOD_UNLOAD being called if MOD_LOAD fails is kind of an
anomaly that doesn't match other paradigms in the kernel; e.g., if
device_attach() fails, we don't invoke device_detach().  It's likely
that a future commit will revert this and instead stop calling
MOD_UNLOAD if MOD_LOAD fails, expecting modules to clean up after
themselves in MOD_LOAD upon failure.  Some other modules already do this
and may see similar problems to the wg module (see: carp).  The proper
fix is decidedly a bit too invasive to do this close to 14 branching,
and it requires auditing all kmods (base + ports) for potential leaks.

PR:		272089
Reviewed by:	emaste
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D40708
2023-06-23 12:00:09 -05:00
Kyle Evans
ad9f4e6351 wg: fix MOD_LOAD to fail properly if cookie_init() fails
Previously we'd jump to the `free_crypto` label, but never set `ret` to
a failure value -- it would retain success from the call just prior.

Set ret up properly.

This is part of D40708, but not the main point of the change.
2023-06-23 11:55:00 -05:00
John Baldwin
c3e58ace31 arm64 iommu: Fix build without INVARIANTS.
Obtained from:	CheriBSD
Sponsored by:	DARPA
2023-06-23 09:41:26 -07:00
Mark Johnston
de0a2eb2ef tcp: Disallow connecting a disconnected socket
Currently nothing prevents tcp_usr_connect() from attempting to connect
when the socket has been disconnected.  At the moment, doing so triggers
an assertion in in_pcbconnect() because inp_faddr is not unspecified.  I
believe this may have been caught in the past by TIMEWAIT checks, but
those are now removed.

Check for additional socket states in tcp_connect().

Reported by:	syzbot+f0f7871ec5397602b446@syzkaller.appspotmail.com
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40579
2023-06-23 10:00:52 -04:00
Mark Johnston
6775ef4188 netinet6: Implement in6_cksum_partial() using m_apply()
This ensures that in6_cksum_partial() can be applied to unmapped mbufs,
which can happen at least when icmp6_reflect() quotes a packet.

The basic idea is to restructure in6_cksum_partial() to operate on one
mbuf at a time.  If the buffer length is odd or unaligned, an extra
residual byte may be returned, to be incorporated into the checksum when
processing the next buffer.

PR:		268400
Reviewed by:	cy
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40598
2023-06-23 09:55:43 -04:00
Mark Johnston
fc915f1be1 pseudofs: Fix a potential out-of-bounds access in pfs_lookup()
pseudofs nodes store their name in a flexible array member, so the node
allocation is sized using the length of the name, including a nul
terminator.  pfs_lookup() scans a directory of nodes, comparing names to
find a match.  The comparison was incorrect and assumed that all node
names were at least as long as the name being looked up, which of course
isn't true.

I believe the bug is mostly harmless since it cannot result in false
positive or negative matches from the lookup, but it triggers a KASAN
check.

Reported by:	pho
Reviewed by:	kib, Olivier Certner <olce.freebsd@certner.fr>
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40692
2023-06-23 09:54:39 -04:00
Warner Losh
e6f37dce96 scsi_all.c: Update to latest asc-num.txt at T10
This updates our table to Sat Mar 25 2023 at 04:30 of the T10
asc-num.txt. I added all the codes that weren't present in the tree,
corrected a couple of the 'alphabet' comments about where the ASC/ASCQ
was defined. I did not, however, make the transition that the
asc-num.txt file made (it deleted W between P and R and added Z after D
so the first few letters shifted a bit). I've not removed the 'W' nor
added the 'Z' at this time. I'm looking for some way to do this
automatically. Try to pick reasonable responses for new entries. When in
doubt, I selected SS_RDEF.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D40718
2023-06-22 20:51:30 -06:00
Warner Losh
92c8803ce3 scsi_all.c: Minor formatting nits
Noticed the whitespace nits when updating for other reasons.

Sponsored by:		Netflix
2023-06-22 20:51:25 -06:00
Dimitry Andric
a681cba16d Bump __FreeBSD_version for llvm 16.0.6 merge
PR:		271047
MFC after:	1 month
2023-06-22 20:25:05 +02:00
Brooks Davis
b95d2237af le(4): deprecate and mark for removal before 15.0
We kept le(4) in the pre-12.0 purge because it was needed for Qemu/MIPS
(virtio networking didn't work) but the MIPS port has been removed.

Reviewed by:	emaste
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D40683
2023-06-22 00:52:12 +01:00
Michael Tuexen
02b885b09d tcp: fix TCP MD5 computation for the BBR and RACK stack
PR:			253096
Reviewed by:		cc, rscheff
MFC after:		3 days
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D40597
2023-06-21 22:54:33 +02:00
Michael Tuexen
0fb0711dba tcp: fix TCP MD5 digest computation for TCP over UDP
Skip the UDP header for the computation. This is similar to
skipping IPv6 extension headers.

Reviewed by:		cc, rscheff
MFC after:		3 days
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D40596
2023-06-21 22:48:12 +02:00
Mark Johnston
712079d381 unix: Fix uipc_peeraddr() to handle self-connected sockets
Reported by:	syzbot+c2da2dbae5fe006556bc@syzkaller.appspotmail.com
Reported by:	syzbot+b4d6b093b1d78bfa859b@syzkaller.appspotmail.com
Fixes:		e8f6e5b2d9 ("unix: Fix locking in uipc_peeraddr()")
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2023-06-21 14:38:26 -04:00
Stefan Eßer
586164cc09 dev/pci: simplify PCI VPD access functions
This update contains a rewrite of the VPD parser based on the
definition of the structure of the VPD data (ident, R/O resource
data, optional R/W data, end tag).

The parser it replaces was based on a state machine, with the tags
and the parsed data controlling the state changes. The flexibility
of this parser is actually not required, and it has caused kernel
panics when operating on malformed data.

Analysis of the VPD code to make it more robust lead me to believe
that it was easier to write a "strict" parser than to restrict the
flexible state machine to detect and reject non-well-formed data.
A number of restrictions had already been added, but they make the
state machine ever more complex and harder to understand.

This updated parser has been verified to return identical parsed data
as the current implementation for the example VPD data given in the
PCI standard and in some actual PCIe VPD data.

It is strict in the sense that it detects and rejects any deviation
from a well-formed VPD structure.

PR:		272018
Approved by:	kib
MFC after:	4 weeks
Differential Revision:	https://reviews.freebsd.org/D34268
2023-06-21 19:36:39 +02:00
Christos Margiolis
e5c7aa5c70 arm64: print '0x' before hex values
Not making it explicit that we're printing values in hex can be
misleading when the number doesn't contain hex-only symbols (a-f). A
good example of this is print_gp_register(), where we print "(func +
offset)"; if the offset doesn't contain a-f symbols, it's not
immediately clear if that value is in decimal or hex. Using '%#' instead
of '0x%' also isn't a better option, it doesn't print '0x' if the value
is 0, and it also messes up column alignment.

Reviewed by:	imp, markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40583
2023-06-21 18:47:06 +03:00
Andrew Turner
3a1bfe881a arm64: Enable the Hyper-V keyboard driver
Tested on Hyper-V on a Windows Dev Kit 2023

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D40533
2023-06-21 13:17:40 +01:00
Wei Hu
17050a2b5b Hyper-V: vmbus: Prevent load/store reordering when access ring buffer index
When running VM on ARM64 Hyper-V, we have seen netvsc/hn driver hit
assert on reading duplicated network completion packets over vmbus
channel or one of the tx channels stalls completely. This seems to
caused by processor reordering the instructions when vmbus driver
reading or updating its channel ring buffer indexes.

Fix this by using load acquire and store release instructions to
enforce the order of these memory accesses.

PR:		271764
Reported by:	Souradeep Chakrabarti <schakrabarti@microsoft.com>
Reviewed by:	Souradeep Chakrabarti <schakrabarti@microsoft.com>
Tested by:	whu
Sponsored by:	Microsoft
2023-06-21 10:10:49 +00:00
Doug Moore
1efa7dbc07 vm_radix: drop unused function; use bool.
Replace boolean_t with bool in vm_radix.c. Drop the unused function
vm_radix_is_singleton, which is unused and has no corresponding
function in subr_pctrie.c.
Reviewed by:	alc
Differential Revision:	<https://reviews.freebsd.org/D40586>
2023-06-20 23:52:27 -05:00
Richard Scheffenegger
04682968c3 tcp: expose AccECN mode and TCP FastOpen (TFO) in TCPI
Reviewed By:		tuexen, #transport
Sponsored by:		NetApp, Inc.
Differential Revision:	https://reviews.freebsd.org/D40621
2023-06-20 23:48:56 +02:00
Richard Scheffenegger
7ea8d02798 Update various sys/netinet source files to conform with the style(9)
guide on how to label FALLTHOUGH in switch statements.

No functional chance.

Reviewed By:		tuexen, cc, #transport
Sponsored by:		NetApp, Inc.
Differential Revision:	https://reviews.freebsd.org/D40622
2023-06-20 23:23:19 +02:00
Doug Moore
05963ea4d1 radix_trie: eliminate iteration in keydiff
Use flsll(), instead of a loop, to find where two keys differ, and
then arithmetic to transform that to a trie level.
Approved by:	alc, markj
Differential Revision:	https://reviews.freebsd.org/D40585
2023-06-20 11:30:29 -05:00
Mitchell Horne
7756232199 riscv: improve KTR_TRAP trace entries
For more informative records of exceptions, include key details such as
the exception code and stval register contents. Remove the curthread
argument as it is redundant (saved with every ktr entry), and the
trapframe as it is somewhat meaningless.

Add a new KTR_TRAP trace record for interrupts.

Reviewed by:	markj, jhb
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40584
2023-06-20 11:54:14 -03:00
John Baldwin
474d9290eb ossl: Don't try to initialize the cipher for Chacha20+Poly1305.
Chacha20+Poly1305 doesn't use an ossl_cipher instance the way AES-GCM
does, so ossl_lookup_cipher() failed causing ossl_newsession() to
always fail for Chacha20+Poly1305 sessions.

Reported by:	gallatin (ktls_test fails with ossl.ko loaded)
Fixes:		9a3444d91c ossl: Add a VAES-based AES-GCM implementation for amd64
Tested by:	gallatin
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D40580
2023-06-20 07:53:50 -07:00
Doug Rabson
3a1f834b52 pf: Add code to enable filtering for locally delivered packets
This is disabled by default since it potentially changes the behavior of
existing filter rule sets. To enable this extra filter for packets being
delivered locally, use:

	sysctl net.pf.filter_local=1
	service pf restart

PR:             268717
Reviewed-by:	kp
MFC-after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D40373
2023-06-20 15:34:01 +01:00
Kristof Provost
476f61217b pf: fix build without VIMAGE
Remove the name conflict between the pfsync_defer_tmo variable and
function.

This worked fine in kernels with VIMAGE (the default), but not in those
without.

Reported by:	des@
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-06-20 13:20:11 +02:00
Dag-Erling Smørgrav
91e03758de tarfs: Don't use IO_DIRECT when reading from tarball.
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D40612
2023-06-20 10:02:10 +00:00
Kristof Provost
6983b986e1 pf: allow defer timeout to be configured
Add the net.pfsync.defer_delay sysctl to allow the defer timeout (i.e.
how long pf holds onto packets waiting for the peer to ack the new
state) to be changed.

This is intended to make testing of the defer code more robust, by
allowing longer timeouts to mitigate scheduling/measurement jitter.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-06-20 11:20:26 +02:00
Warner Losh
a960d3c07b cam: Remove duplicate definition for READ_DEFECT_DATA_10
This isn't needed by all devices and is only used by the da device (in
camcontrol). All the other da specific da scsi opcodes are only in
scsi_da.h.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D40527
2023-06-19 14:45:43 -06:00
Mark Johnston
e60316d1ea x86: Add defines for a couple of thermal and PM bits
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2023-06-19 13:32:22 -04:00
Ed Maste
7a91ccd2fb mpi3mr: fix GCC kernel build
Previously every file that included mpi3mr_app.h but did not use
mpi3mr_mgmt_info reported error: 'mpi3mr_mgmt_info' defined but not
used.

Fixes: 2d1d418e1e ("mpi3mr: 3rd Generation Tri-Mode NVMe/SAS/SATA...")
Reported by:	amd64-gcc12 Cirrus-CI job
Sponsored by:	The FreeBSD Foundation
2023-06-19 12:16:39 -04:00