Commit Graph

280586 Commits

Author SHA1 Message Date
Konstantin Belousov
9c996882b0 libcxx: Implement atomic::wait/notify using _umtx_op(2) for 64bit arches
Only 64bit architectures can be supported this way, because libcxx
defines __cxx_contention_t to be int64_t for FreeBSD, and 32bit arches
do not have a kind of UMTX_OP_WAIT_INT64_PRIVATE operation.

LLVM review:	https://reviews.llvm.org/D142134

Tested by:	emaste
Reviewed by:	dim, emaste, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D38132
2023-01-24 02:52:42 +02:00
Warner Losh
62adb1e953 UPDATING: fix typo
I'd forgotten to fix this from the review, and a couple of people have
pointed it out after the commit.

Sponsored by:		Netflix
2023-01-23 17:09:08 -07:00
Ed Maste
247e03ed8b Add git-blame ignore file
.git-blame-ignore-revs lists commit hashes that should be skipped by
`git blame` e.g. non-functional whitespace or style cleanup.

The file is populated with a few sample entries.

Reviewed by:	brooks, imp
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36525

fixup ignore revs
2023-01-23 15:27:25 -05:00
Mark Johnston
df40e30c97 netmap: Try to count packet drops in emulated mode
Right now we have little visibility into packet drops within netmap.
Start trying to make packet loss issues more visible by counting queue
drops in the transmit path, and in the input path for interfaces running
in emulated mode, where we place received packets in a bounded software
queue that is processed by rxsync.

Reviewed by:	vmaffione
MFC after:	1 week
Sponsored by:	Zenarmor
Sponsored by:	OPNsense
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D38064
2023-01-23 14:42:41 -05:00
Mark Johnston
854b2f302d netmap: Correct a comment
Reviewed by:	vmaffione
MFC after:	1 week
Sponsored by:	Zenarmor
Sponsored by:	OPNsense
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D38063
2023-01-23 14:42:19 -05:00
Mark Johnston
539437c828 netmap: Fix a queue length check in the generic port rx path
The check is ok by default, since the default value of
netmap_generic_ringsize is 1024.  But we should check against the
configured "ring" size.

Reviewed by:	vmaffione
MFC after:	1 week
Sponsored by:	Zenarmor
Sponsored by:	OPNsense
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D38062
2023-01-23 14:41:55 -05:00
Mark Johnston
56c438fcd4 netmap: Tell the compiler to avoid reloading ring indices
Per the removed comments these fields should be loaded only once, since
they can in principle be modified concurrently, though this would be a
violation of the userspace contract with netmap.

No functional change intended.

Reviewed by:	vmaffione
MFC after:	1 week
Sponsored by:	Zenarmor
Sponsored by:	OPNsense
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D38061
2023-01-23 14:41:05 -05:00
Mitchell Horne
6f5141456e vtblk: secondary fix for dumping
The code paths while dumping do not got through busdma. As such,
safeguard against calling bus_dmamap_sync() with a NULL map. The x86
implementation tolerates this but others do not, resulting in a
NULL dereference panic when dumping to a vtblk device on arm64, riscv,
etc.

Fixes:		782105f7c8 ("vtblk: Use busdma")
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37990
2023-01-23 15:21:36 -04:00
Mitchell Horne
5644850620 ddb: have 'reset' command use normal reboot path
This conditionally gives all registered shutdown handlers a chance to
perform the reboot, with cpu_reset() being the fallback. The '\s'
modifier can be used with the command to get the previous behaviour.

The motivation is that some platforms may not be able do anything
meaningful via cpu_reset(), due to a lack of standardized reset
mechanism and/or firmware shortcomings. However, they may have a
separate device driver attached that normally performs the reboot. Such
is the case for some versions of the Raspberry Pi, where reset via PSCI
fails, but the BCM2835 watchdog driver has a shutdown hook.

Reported by:	bz
Reviewed by:	markj (slightly earlier version)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D37981
2023-01-23 15:10:24 -04:00
Mitchell Horne
627ca221c3 kern_reboot: unconditionally call shutdown_reset()
Currently shutdown_reset() is registered as the final entry of the
shutdown_final event handler. However, if a panic occurs early in boot
before the event is registered (SI_SUB_INTRINSIC), we may end up
spinning in the subsequent infinite for loop and failing to reset
altogether. Instead we can simply call this function unconditionally.

Reviewed by:	markj
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D37981
2023-01-23 15:10:24 -04:00
Jiajie Chen
dec7db4960 Add kf_file_nlink field to kf_file and populate it
This will allow user-space programs (e.g. lsof) to locate deleted files
whose nlink equals zero. Prior to this commit, programs has to use
stat(kf_path) to get nlink, but that will fail if the file is deleted.

[mjg: s/fail/file in the commit message]

Reviewed by:	mjg
Differential Revision:  https://reviews.freebsd.org/D38169
2023-01-23 17:09:52 +00:00
Ed Maste
8089749d38 blacklistd: diff reduction against upstream
Add `conf_` prefix, maching https://github.com/zoulasc/blocklist

Sponsored by:	The FreeBSD Foundation
2023-01-23 11:22:10 -05:00
Mike Karels
7d189f6698 growfs(7): conditionalize mention of adding dump device
The growfs_fstab script will add a new swap partition as a dump
device as well, but only if dumpdev is set to AUTO.

MFC after:	3 days
Reviewed by:	pauamma
Differential Revision:	https://reviews.freebsd.org/D38166
2023-01-23 08:37:07 -06:00
Xin LI
047153b416 MFV: xz 5.4.1.
MFC after:	3 days
2023-01-22 16:50:36 -08:00
Alexander V. Chernikov
30dd227cff netinet6: honor blackhole/unreach routes in the non-fastforwading code.
Currently, under the conditions specified below, IPv6 ingress packet
 processing can ignore blackhole/reject flag on the prefix. The packet
 will instead be looped locally till TTL expiration and a single ICMPv6
 unreachable message will be send to the source even in case of
 RTF_BLACKHOLE.
The following conditions needs hold to make the scenario happen:
* IPv6 forwarding is enabled
* Packet is not fast-forwarded
* Destination prefix has either RTF_BLACKHOLE or RTF_REJECT flag
Fix this behavior by checking for the blackhole/reject flags in
ip6_forward().

Reported by:	Dmitriy Smirnov <fox@sage.su>
Reviewed by:	ae
Differential Revision: https://reviews.freebsd.org/D38164
MFC after:	3 days
2023-01-22 18:48:07 +00:00
Xin LI
2690f2feae Vendor import of xz 5.4.1 (trimmed) 2023-01-22 09:32:29 -08:00
Peter Holm
7a56009cf5 stress2: Added a regression test 2023-01-22 10:35:28 +01:00
Poul-Henning Kamp
2da12891da Document another example for "binat". 2023-01-22 09:31:18 +00:00
Kajetan Staszkiewicz
06012728be netpfil tests: improve pfsync_defer.py
Return different exit code depending on which failure was encountered.
The pfsync test expect a very particular failure, not just any.

MFC after:	1 week
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D38123
2023-01-22 04:26:32 +01:00
Kajetan Staszkiewicz
f57218e469 netpfil tests: improve pft_ping.py
Multiple improvements to pft_ping.py:

* Automatically use IPv6 when IPv6 addresses are used, --ip6 is not needed.
* Building of ping requests and parsing of ping replies is done layer by
  layer. This way most arguments are available both for IPv6 and IPv4,
  for ICMP and TCP.
* Use argument groups for improved readability.
* Change ToS and TTL argument name to TC and HL to reflect the modern
  IPv6 nomenclature. The argument still set related IPv4 header fields
  properly.
* Instead of sniffing for the very specific case of duplicated packets,
  allow for sniffing on multiple interfaces.
* Report which sniffer has failed by setting bits of error code.
* Raise meaningful exceptions when irrecoverable errors happen.
* Make IPv4 fragmentation flags configurable.
* Make IPv6 HL / IPv4 TTL configurable.
* Make TCP MSS configurable.
* Make TCP sequence number configurable.
* Make ICMP payload size configurable.
* Add debug output.
* Move command line argument parsing out of network functions.
* Make the code somehow PEP-8 compliant.

MFC after:	1 week
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D38122
2023-01-22 04:26:32 +01:00
Kajetan Staszkiewicz
a39dedeb31 netpfil tests: improve sniffer.py
Multiple improvements to sniffer.py:

* Remove ambiguity of configuring recvif, it must be now explicitly specified.
* Don't catch exceptions around creating the sniffer, let it properly
  fail and display the whole stack trace.
* Count correct packets so that duplicates can be found.

MFC after:	1 week
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D38120
2023-01-22 04:26:32 +01:00
Andrew Gallatin
9cb6ba29cb vm: centralize VM_BATCHQUEUE_SIZE definition
Remove the platform-specific definitions of VM_BATCHQUEUE_SIZE
for amd64 and powerpc64, and instead treat all 64-bit platforms
identically.  This has the effect of increasing the arm64
and riscv VM_BATCHQUEUE_SIZE to match that of other platforms.

Reviewed by: jhb, markj
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37707
2023-01-21 14:30:00 -05:00
Alexander V. Chernikov
10f2a38769 netlink: fix OOB write when creating attribute bitmask.
Fix wrong arithmetics by moving to the standard bitset(9) functions.

Reported by:	markj, KASAN
2023-01-21 18:03:47 +00:00
Alexander V. Chernikov
0079d177ab netlink: allow creating sockets with SOCK_DGRAM.
Some existing applications setup Netlink socket with
SOCK_DGRAM instead of SOCK_RAW. Update the manpage to clarify
that the default way of creating the socket should be with
SOCK_RAW. Update the code to support both SOCK_RAW and SOCK_DGRAM.

Reviewed By: pauamma
Differential Revision: https://reviews.freebsd.org/D38075
2023-01-21 14:58:19 +00:00
Warner Losh
03a1b75950 elf: EF_ARM_EABI_VERSION_UNKNOWN is no longer used, retire
EF_ARM_EABI_VERSION_UNKNOWN was used when we could run either eabi or
oabi. That was armv[45] only, and went away when we migrated to eabi
many major releases ago. No standard defines this symbol, so retire it.

Pointed out by:		jrtc27
Sponsored by:		Netflix
2023-01-20 22:12:32 -07:00
Adrian Chadd
ffc58e2ca3 asmc: Add MacbookAir6,2
Add in the zones for my MacbookAir6,2, a 2013 Macbook Air.

Tested - said Macbook Air 2013.  Thermal Zones and keyboard backlight
control works fine.

Differential Revision: https://reviews.freebsd.org/D38073
Approved by: jrtc27
2023-01-21 04:34:31 +00:00
Warner Losh
34784d17eb elf: Catch up with defining EF_ARM_EABI_VERSION in elf_common.h
FreeBSD defines EF_ARM_EABI_VERSION in a non-standard way (at least
differently than everybody else). We use this only in elf*machdep.c to
make sure the image is new enough. Switch to the more standard way of
defining this and adjust other constants to match.

Fixes:			c52c98e69a
Sponsored by:		Netflix
2023-01-20 19:18:15 -07:00
Warner Losh
c52c98e69a elf_common.h: Add parens to EF_ARM_EABI_VERSION macro
Due to my haste, I missed John's suggestion in the review that I add ()
here. Belatedly add them. It didn't matter for my test case, but there's
some pathological uses where it might matter.

Suggested by:		jrtc23, jhb
Sponsored by:		Netflix
2023-01-20 16:46:05 -07:00
Warner Losh
1761b09bf4 byteswap.h: Add a glibc/linux compatible byteswap.h
For endian.h to work instead of sys/endian.h, some software needs
byteswap.h available. It must define {__,}byteswap_{16,32,64}.
Included sys/_endian.h to get an appropriate __byteswap16, etc
and defines the new macros in terms of them. Enhance _endian.h
to allow it to be included from here too.

Sponsored by:		Netflix
Reviewed by:		markj
Differential Revision:	https://reviews.freebsd.org/D32051
2023-01-20 16:37:39 -07:00
Warner Losh
30e0d2a510 linux: For better compatibility, provide compatible endian.h
Add endian.h. This includes sys/endian.h and then adds extra defines
that glibc defines with double underscores for our
_{BIG,BYTE,LITTLE,PDP}_ENDIAN macros. We also define __FLOAT_WORD_ORDER
to be the same as _BYTE_ENDIAN since FreeBSD doesn't currently define
this, and the default with glibc is exactly this for our platforms.
Move common parts of endian.h and sys/endian.h into sys/_endian.h
to limit namespace pollution from endian.h

All this gives us good compatibility with Linux. There may be one or two
upstreams that haven't integrated the patches I tried to send up.

There are some minor differences:
	o The extra glibc macros are not defined. These are all
	  controlled with either __ at the start, or only defined
	  when glibc is being built. We also don't define macros
	  that are used internally in glibc that would pollute
	  the namespace.
	o For complete compatibility, this change must also be
	  paired with providing a glibc-compatible byteswap.h.

Sponsored by:		Netflix
Reviewed by:		mhorne, markj, jhb
Differential Revision:	https://reviews.freebsd.org/D31962
2023-01-20 16:32:45 -07:00
Warner Losh
e8c1bd7257 UPDATING: Remove old entries
Belatedly remove the entries older than the stable/11 branch point after
stable/13 was created. This should be done shortly after the branch, not
well after the branch point.

Document this policy in UPDATING, though other checklists should likely
be updated as well.

Sponsored by:		Netflix
Reviewed by:		emaste
Differential Revision:	https://reviews.freebsd.org/D37514
2023-01-20 16:17:45 -07:00
Warner Losh
2c6b910716 elf_common.h: define EF_ARM_EABI_VERSION
The Linux distributions have had the EF_ARM_EABI_VERSION macro for a
while now. The kernel of arm* targets build depends on it being in the
host's elf.h environment. Add it here so it gets pulled in so there's
one fewer hack required to build a Linux kernel on a FreeBSD host.

Sponsored by:		Netflix
Reviewed by:		jrtc27, kib, jhb
Differential Revision:	https://reviews.freebsd.org/D38139
2023-01-20 16:15:04 -07:00
Warner Losh
0cd612664e UPDATING: update notes on EFI booting
The notes on EFI booting and updating for ZFS had become dated and only
partially updated. Expand the notes with a few more details and a
pointer to laoder.efi(8) and uefi(8).

Sponsored by:		Netflix
Discussed with:		pauamma, karels
Differential Revision:	https://reviews.freebsd.org/D36629
2023-01-20 16:13:54 -07:00
Konstantin Belousov
456f05756b Handle int rank issues in in vn_getsize_locked() and vn_seek()
In vn_getsize_locked(), when storing vattr.va_size of type u_quad_t into
off_t size, we must avoid overflow.

Then, the check for fsize < 0, introduced in the commit
f45feecfb2 'vfs: add vn_getsize', is nop [1].

Reported and reviewed by:	jhb
Coverity CID:	1502346
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D38133
2023-01-20 23:56:29 +02:00
Konstantin Belousov
5657f49ef3 kern_umtx.c do_wait(): correct confusing indent
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2023-01-20 23:33:11 +02:00
Yuri
6f7b5d5d3c hms(4): Fix a copy/paste issue and check both _X and _Y
instead of checking _X 2 times.

Reviewed by:	wulf
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D38135
2023-01-20 23:29:53 +03:00
Robert Wing
27029bc08f vmm: fix use after free in ppt_detach()
The vmm module destroys the host_domain before unloading the ppt module
causing a use after free. This can happen when kldunload'ing vmm.

Reviewed by:	markj, jhb
Differential Revision:	https://reviews.freebsd.org/D38072
2023-01-20 11:25:27 +00:00
Robert Wing
c668e8173a vmm: take exclusive mem_segs_lock in vm_cleanup()
The consumers of vm_cleanup() are vm_reinit() and vm_destroy().

The vm_reinit() call path is, here vmmdev_ioctl() takes mem_segs_lock:
    vmmdev_ioctl()
    vm_reinit()
    vm_cleanup(destroy=false)

The call path for vm_destroy() is (mem_segs_lock not taken):
    sysctl_vmm_destroy()
    vmmdev_destroy()
    vm_destroy()
    vm_cleanup(destroy=true)

Fix this by taking mem_segs_lock in vm_cleanup() when destroy == true.

Reviewed by:	corvink, markj, jhb
Fixes:  67b69e76e8 ("vmm: Use an sx lock to protect the memory map.")
Differential Revision:	https://reviews.freebsd.org/D38071
2023-01-20 11:10:53 +00:00
Robert Wing
ccf32a68f8 vmm: take exclusive mem_segs_lock when (un)assigning ppt dev
PR:             268744
Reported by:    mmatalka@gmail.com
Reviewed by:	corvink, markj, jhb
Fixes:  67b69e76e8 ("vmm: Use an sx lock to protect the memory map.")
Differential Revision:	https://reviews.freebsd.org/D37962
2023-01-20 10:03:59 +00:00
Brooks Davis
fa1d803c0f epoch: replace hand coded assertion
The assertion is equivalent to kstack_contains() so use that rather
than spelling it out.

Suggested by:	jhb
Reviewed by:	jhb
MFC after:	1 week
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D38107
2023-01-20 18:04:40 +00:00
John Baldwin
cf57f20edc bhyve: Fix a buffer overread in the PCI hda device model.
The sc->codecs array contains HDA_CODEC_MAX (15) entries.  The
guest-supplied cad field in the verb provided to hda_send_command is a
4-bit field that was used as an index into sc->codecs without any
bounds checking.  The highest value (15) would overflow the array.

Other uses of sc->codecs in the device model used sc->codecs_no to
determine which array indices have been initialized, so use a similar
check to reject requests for uninitialized or invalid cad indices in
hda_send_command.

PR:		264582
Reported by:	Robert Morris <rtm@lcs.mit.edu>
Reviewed by:	corvink, markj, emaste
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D38128
2023-01-20 09:58:38 -08:00
John Baldwin
bfe8e339eb bhyve: Fix a global buffer overread in the PCI hda device model.
hda_write did not validate the relative register offset before using
it as an index into the hda_set_reg_table array to lookup a function
pointer to execute after updating the register's value.

PR:		264435
Reported by:	Robert Morris <rtm@lcs.mit.edu>
Reviewed by:	corvink, markj, emaste
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D38127
2023-01-20 09:57:45 -08:00
Alan Somers
5205908816 Revert "ifconfig: abort if loading a module fails other than for ENOENT"
This reverts commit 2c24ad3377.

This change causes some commands to fail, for example when working with
renamed interfaces or when trying to list a nonexistent interface by
name.

PR:		269042
Reported by:	dbaio, Michael Paepcke <bugs.fbsd@paepcke.de>
MFC with:	2c24ad3377
2023-01-20 10:17:21 -07:00
Alex Richardson
34ac629b40 Shell-escape assignments to PATH in the top-level makefiles
Since 16fbf01912 PATH is no longer set
to a hardcoded value on non-FreeBSD build hosts, so we can end up with
spaces in $PATH. Instead of only escaping PATH I updated all `env PATH=`
uses in the toplevel makefile. While many of these currently can't
contain any special characters (since the build would have failed
already), in theory this gets us closer to allowing build/source
directory to contain e.g. spaces.
2023-01-20 10:47:17 +00:00
Elliott Mitchell
e5c30ac930 vmstat: fix overflow of interrupt name buffer
sysctl() provides a count of number of bytes in the buffer.  That is the
actual buffer length.  Whereas looking for an interrupt entry with an
empty name could terminate too early, or overflow the end of the buffer.
The overflow will occur if the table of interrupt names is full.

Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D36628
2023-01-20 04:51:13 +02:00
Elliott Mitchell
d4d7971849 vmstat: remove shadow variables
These appear to simply be the style of arguments are left untouched and
only local variables are modified.  While some may prefer that style
this simply serves to complicate things as they're perfectly writeable.

Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D36628
2023-01-20 04:51:12 +02:00
Konstantin Belousov
ad8feb1ed9 md.c: another style fix
Noted by:	jkim
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2023-01-20 04:39:36 +02:00
Konstantin Belousov
6189672e60 Handle ERELOOKUP from VOP_FSYNC() in several other places
We need to repeat the operation if the vnode was relocked.

Reported and reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D38114
2023-01-20 03:54:56 +02:00
Konstantin Belousov
70e1b11216 vm_object.c: minor style
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2023-01-20 03:54:42 +02:00
John Baldwin
43703bc489 stdlib.h: Fix qsort_r compatibility with GCC 12.
GCC 12 (unlike GCC 9) does not match a function argument passed to the
old qsort_r() API (as is used in the qsort_r_compat test) to a
function pointer type via __generic.  It treats the function type as a
distinct type from a function pointer.  As a workaround, add a second
definition of qsort_r for GCC 12 which uses the bare function type.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D37410
2023-01-19 14:48:52 -08:00