Commit Graph

270590 Commits

Author SHA1 Message Date
Warner Losh
1c7d15b030 Make device_busy/unbusy work w/o Giant held
The vast majority of the busy/unbusy users in the tree don't acquire
Giant before calling device_busy/unbusy. However, if multiple threads
are opening a file, say, that causes the device to busy/unbusy, then we
can race to the root marking things busy. Move to using a reference
count to keep track of how many times a device_t has been made busy. Use
that count to make the same decisions that we'd make with the old device
state.

Note: gpiopps.c uses D_TRACKCLOSE. Others do as well. However, there's a
known race with closes that will be corrected for all the drivers that
do this in a future commit.

Sponsored by:		Netflix
Reviewed by:		hselasky, jhb
Differential Revision:	https://reviews.freebsd.org/D26284
2021-11-30 15:18:01 -07:00
Warner Losh
25c49c426c Revert "Make device_busy/unbusy work w/o Giant held"
This reverts commit 08e7819153.

Commit message was for a very old version of the patch. Will re-commit
with the right one since it's so bad. There's no locked versions of
it...that code was reworked to use refcnt APIs.

Noticed by:	jhb, jtrc27
Sponsored by:	Netflix
2021-11-30 15:17:07 -07:00
Warner Losh
08e7819153 Make device_busy/unbusy work w/o Giant held
The vast majority of the busy/unbusy users in the tree don't acquire Giant
before calling device_busy/unbusy. However, if multiple threads are opening a
file, say, that causes the device to busy/unbusy, then we can race to the root
marking things busy. Create a new device_busy_locked and device_unbusy_locked
that are the current implemntations of device_busy and device_unbusy. Make
device_busy and unbusy acquire Giant before calling the _locked versrions. Since
we never sleep in the busy/unbusy path, Giant's single threaded semantics
suffice to keep this safe.

Sponsored by:		Netflix
Reviewed by:		hselasky, jhb
Differential Revision:	https://reviews.freebsd.org/D26284
2021-11-30 15:03:26 -07:00
Chuck Tuffli
d8c1d7b652 bhyve blockif: fix blockif_candelete with Capsicum
NVMe conformance tests for the Format command failed if the
backing-storage for the bhyve device was a file instead of a Zvol. The
tests (and the specification) expect a Format to destroy all previously
written data. The bhyve NVMe emulation implements this by trimming /
deallocating all data from the backing-storage.

The blockif_candelete() function indicated the file did not support
deallocation (i.e. fpathconf(..., _PC_DEALLOC_PRESENT) returned FALSE)
even though the kernel supported file hole punching. This occurs on
builds with Capsicum enabled because blockif did not allow the
fpathconf(2) right.

Fix is to add CAP_FPATHCONF to the cap_rights_init(3) call.

PR:		260081
Reviewed by:	allanjude, markj, jhb
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D33203
2021-11-30 21:49:34 -08:00
Warner Losh
3846662dab cam: Initialize wired to false
As part of converting the code to a while loop, the unconditional
initialization of wired to false was lost.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D33163
2021-11-30 14:40:30 -07:00
Vladimir Kondratyev
c508b0818b iichid(4): Perform acknowledgement of I2C device interrupt after RESET command
in sampling mode to workaround firmware bug.

This fixes reboot or poweroff on frame.work laptops after first touch.

Reported by:	many
PR:		259230
MFC after:	1 week
Tested by:	kevans, markj
2021-12-01 00:29:50 +03:00
Elliott Mitchell
d893d9e94d xen/dev: remove write-only variable
This was found while looking for driver_filter_t functions which got the
trap frame from the argument.  This particular instance it isn't even
used, so remove now lest someone else get to it first.

Reviewed by:	mhorne
2021-11-30 17:11:57 -04:00
Ed Maste
1b9344add4 OptionalObsoleteFiles: remove GCC remnants
g++ and cc1plus were GCC components that are already removed
unconditionally in ObsoleteFiles.inc.

Reported by:	jhb (in review D33108)
Fixes:		57f804675e ("remove GCC 4.2.1 build infrastructure")
Sponsored by:	The FreeBSD Foundation
2021-11-30 13:41:41 -05:00
Alan Somers
943c446629 Revert "libc: Some enhancements to syslog(3)"
This reverts commit 2886c93d1b.
The original commit has two problems:

* It sets SO_SNDBUF to be as large as MAXLINE.  But for unix domain
  sockets, the send buffer is bypassed.  Packets go directly to the
  peer's receive buffer, so setting and querying SO_SNDBUF is
  ineffective.  To ensure that the socket can accept messages of a
  certain size, it would be necessary to add a SO_PEERRCVBUF socket
  option that could query the connected peer's receive buffer size.

* It sets MAXLINE to 8 kB, which is larger than the default sockbuf size
  of 4 kB.  That's ok for the builtin syslogd, which sets its recvbuf
  to 80 kB, but not ok for alternative sysloggers, like rsyslogd, which
  use the default size.

As a consequence, writing messages of more than 4 kB with syslog() as a
non-root user while running rsyslogd would cause the logging application
to spin indefinitely within syslog().

PR:		260126
MFC:		2 weeks
Sponsored by:	Axcient
Reviewed by:	markj
Differential Revision: https://reviews.freebsd.org/D33199
2021-11-30 11:11:43 -07:00
Stefan Eßer
10041e99a0 contrib/bc: merge version 5.2.1 from vendor branch
Merge commit 'e63540eed295749528548c2e3a90f5a6e57275c8'
2021-11-30 18:40:32 +01:00
Stefan Eßer
e63540eed2 vendor/bc: import release 5.2.1
This release fixes two parse bugs when in POSIX standard mode. One of
these bugs was due to a quirk of the POSIX grammar, and the other was
because bc was too strict.
2021-11-30 18:33:40 +01:00
Stefan Eßer
23aff12408 vendor/bc: import release 5.2.0
This version is imported only for documentary purposes since it does
not contain any changes that are relevant for the FreeBSD base system.
2021-11-30 18:26:22 +01:00
Kristof Provost
439da7f06d if_stf: KASAN fix
In in_stf_input() we grabbed a pointer to the IPv4 header and later did
an m_pullup() before we look at the IPv6 header. However, m_pullup()
could rearrange the mbuf chain and potentially invalidate the pointer to
the IPv4 header.

Avoid this issue by copying the IP header rather than getting a pointer
to it.

Reported by:	markj, Jenkins (KASAN job)
Reviewed by:	markj
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D33192
2021-11-30 17:35:15 +01:00
Mitchell Horne
0d2224733e Implement GET_STACK_USAGE on remaining archs
This definition enables callers to estimate remaining space on the
kstack, and take action on it. Notably, it enables optimizations in the
GEOM and netgraph subsystems to directly dispatch work items when there
is sufficient stack space, rather than queuing them for a worker thread.

Implement it for riscv, arm, and mips. Remove the #ifdefs, so it will
not go unimplemented elsewhere.

PR:		259157
Reviewed by:	mav, kib, markj (previous version)
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32580
2021-11-30 11:15:56 -04:00
Mitchell Horne
b02908b051 arm64, powerpc: fix calculation of 'used' in GET_STACK_USAGE
We do not consider the space reserved for the pcb to be part of the
total kstack size, so it should not be included in the calculation of
the used stack size.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2021-11-30 11:15:44 -04:00
Mitchell Horne
8bc792b384 i386: take pcb and fpu area into account in GET_STACK_USAGE
On this platform, the pcb and FPU save area are allocated from the top
of each kernel stack, so they should be excluded from the calculation of
the total and used stack sizes.

Reviewed by:	kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32581
2021-11-30 11:03:46 -04:00
Bjoern A. Zeeb
b394e16ef0 fw_stub: fix -Wunused-but-set-variable for firmware files
In case we are only embedding a single firmware image the variable
"parent" gets set but never used.  Add checks for the number of files
for it and only print it out if we are exceeding the single file count.
This fixes -Wunused-but-set-variable warnings for the majority of
firmware files in the tree.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2021-11-30 14:23:18 +00:00
Andriy Gapon
3d9d64aa18 kern_tc: unify timecounter to bintime delta conversion
There are two places where we convert from a timecounter delta to
a bintime delta: tc_windup and bintime_off.
Both functions use the same calculations when the timecounter delta is
small.  But for a large delta (greater than approximately an equivalent
of 1 second) the calculations were different.  Both functions use
approximate calculations based on th_scale that avoid division.  Both
produce values slightly greater than a true value, calculated with
division by tc_frequency, would be.  tc_windup is slightly more
accurate, so its result is closer to the true value and, thus, smaller
than bintime_off result.

As a consequence there can be a jump back in time when time hands are
switched after a long period of time (a large delta).  Just before the
switch the time would be calculated with a large delta from
th_offset_count in bintime_off.  tc_windup does the switch using its own
calculations of a new th_offset using the large delta.  As explained
earlier, the new th_offset may end up being less than the previously
produced binuptime.  So, for a period of time new binuptime values may
be "back in time" comparing to values just before the switch.

Such a jump must never happen.  All the code assumes that the uptime is
monotonically nondecreasing and some code works incorrectly when that
assumption is broken.  For example, we have observed sleepq_timeout()
ignoring a timeout when the sbinuptime value obtained by the callout
code was greater than the expiration value, but the sbinuptime obtained
in sleepq_timeout() was less than it.  In that case the target thread
would never get woken up.

The unified calculations should ensure the monotonic property of the
uptime.

The problem is quite rare as normally tc_windup should be called HZ
times per second (typically 1000 or 100).  But it may happen in VMs on
very busy hypervisors where a VM's virtual CPU may not get an execution
time slot for a second or more.

Reviewed by:	kib
MFC after:	2 weeks
Sponsored by:	Panzura LLC
2021-11-30 15:23:23 +02:00
Gordon Bergling
1b0602f2db mips: Fix a typo in a source code comment
- s/segement/segment/

MFC after:	3 days
2021-11-30 10:41:46 +01:00
Gordon Bergling
ddeb702f7b mpr(4): Fix a typo in a source code comment
- s/segement/segment/

MFC after:	3 days
2021-11-30 10:40:50 +01:00
Gordon Bergling
e3080a9cca xen(4): Fix two typos in source code comments
- s/segement/segment/

MFC after:	3 days
2021-11-30 10:39:42 +01:00
Gordon Bergling
c8ca80e223 elf(3): Fix a typo in a sysctl description
- s/segement/segment/

MFC after:	3 days
2021-11-30 10:38:34 +01:00
Gordon Bergling
1dadeab367 netinet: Fix a common typo in source code comments
- s/segement/segment/

MFC after:	3 days
2021-11-30 10:37:20 +01:00
Gordon Bergling
54c1a65736 ficl: Fix a typo in a comment
- s/segement/segment/

MFC after:	3 days
2021-11-30 10:36:29 +01:00
Gordon Bergling
b15a632c41 if_hn: Fix a few typos in comments and a sysctl description
- s/segement/segment/

MFC after:	3 days
2021-11-30 10:35:14 +01:00
Gordon Bergling
5f8ccf6515 nvme(4): Correct a typo in a sysctl description
- s/printting/printing/

MFC after:	3 days
2021-11-30 10:26:25 +01:00
Gordon Bergling
27c4abc7cd inet(3): Fix two typos in sysctl descriptions
- s/sequental/sequential/

MFC after:	3 days
2021-11-30 10:21:47 +01:00
Juraj Lutter
aaa4cd7f3c Makefile.inc1: Silence an error in make packages
Silence an error in "packages" target, like:

eval: /usr/src: Permission denied

on systems without subversion present.

Reviewed by:	emaste
Approved by:	emaste
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D33153
2021-11-30 09:53:20 +01:00
Gordon Bergling
b6f4818a7e vfs: Fix a typo in a sysctl description
- s/dependecies/dependencies/

MFC after:	3 days
2021-11-30 07:28:40 +01:00
Gordon Bergling
3cf59750eb netinet6: Fix a typo in a sysctl description
- remove a double 'a'

MFC after:	3 days
2021-11-30 07:24:44 +01:00
Gordon Bergling
b4aa9cb217 tcp(4): Fix a typo in a sysctl description
- s/entires/entries/

MFC after:	3 days
2021-11-30 07:17:30 +01:00
Wojciech Macek
94e25b7acb flex_spi: Support for FlexSPI Flash controller.
NXP FlexSPI is a complex SPI controller which provides
full offload for accessing NOR Flash.
Create a Flash driver which attaches to existing FreeBSD
infrastructure and exports generic READ and WRITE disk commands.
The Flash has to be identified first to configure controller
internals. For now, only one NOR Flash chip is supported.
Future commits shall either increase number of known chips
or implement SFDP mechanism which can be used by other Flash
drivers.

Sponsored by:		Alstom
Obtained from:		Semihalf
Differential revision:	https://reviews.freebsd.org/D33117
2021-11-30 06:41:34 +01:00
Konstantin Belousov
f16ec9c6e3 Add tests for posix_spawn_file_actions_add{chdir,fchdir}_np(3)
Reviewed by:	kevans, ngie (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33143
2021-11-30 03:43:54 +02:00
Konstantin Belousov
78963d796d Document posix_spawn_file_actions_addclosefrom_np(3)
Reviewed by:    kevans, ngie (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33143
2021-11-30 03:43:54 +02:00
Konstantin Belousov
a18ddf7757 posix_spawn: add closefrom non-portable action
Namely posix_spawn_file_actions_addclosefrom_np, in the form it is
provided by glibc.

Reviewed by:	kevans, ngie (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33143
2021-11-30 03:43:54 +02:00
Konstantin Belousov
bd44dce5b3 Document posix_spawn_file_actions_addchdir_np(3)
Reviewed by:	kevans, ngie (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33143
2021-11-30 03:43:54 +02:00
Konstantin Belousov
25cda42a49 posix_spawn: add chdir-related non-portable actions
Namely posix_spawn_file_actions_addchdir_np and
posix_spawn_file_actions_addfchdir_np.

Reviewed by:	kevans, ngie (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33143
2021-11-30 03:43:54 +02:00
Konstantin Belousov
8ed1e4a5c1 posix_spawn(3), posix_spawn_file_actions_addopen(3): use .Fo/.Fc
to wrap too long lines with function prototypes.

Reviewed by:	kevans, ngie (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33143
2021-11-30 03:43:54 +02:00
Konstantin Belousov
b239cc204a posix_spawn: style, use return ()
Reviewed by:	kevans, ngie (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33143
2021-11-30 03:43:54 +02:00
Konstantin Belousov
adbaf1b443 posix_spawn.c: format fae_action anon enum more stylish
Reviewed by:	kevans, ngie (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33143
2021-11-30 03:43:54 +02:00
Alexander Motin
f5b0083302 mpsutil: Fix data truncation by too short buffers.
Length of some string buffers was insufficient for cases of more that
99 targets per HBA or slots per enclosure.  Some others are tuned just
for better alignment.  While there also fix output formatting issues.

MFC after:	1 week
Sponsored by:	iXsystems, Inc.
2021-11-29 20:20:03 -05:00
Daniel Ebdrup Jensen
bd6dce978c rc.conf(5): Add _limits, _login_class, and _oomprotect
Add a few very useful variables that might easily be overlooked, since
they're only documented in rc.subr(8) which might not be the first place
that people look.

At least _oomprotect has existed since 11.0-RELEASE, and doesn't appear
to be very well-known. While the others aren't as new, in my estimation,
a lot more people would use them if they knew about them.

While here, also add a reference to rc.subr(8) and login.conf(5), and
sort the variables alphabetically.

Reported by: 	Daniel Dettlaff <dmilith at gmail.com>
Reviewed by:	ceri, gbe, 0mp, ygy, a.wolk, pauamma
2021-11-30 02:06:40 +01:00
Brooks Davis
0e765d9b08 syscalls: regen 2021-11-29 22:04:58 +00:00
Brooks Davis
6d37a1670b syscalls: mprotect does not take a const
The mprotect syscall decleration is not const.  I added this one
incorrectly in a944d28d0e.

Reported by:	kib
Reviewed by:	kib, imp
2021-11-29 22:04:47 +00:00
Brooks Davis
401eec3635 syscalls: regen 2021-11-29 22:04:44 +00:00
Brooks Davis
a8efd4d1b3 syscalls: make syscall and __syscall SYSMUX
Rather than combining the declearation of nosys with the registration
of SYS_syscall, declare syscall(2) and __syscall(2) with the new
SYSMUX type in syscalls.master and declare nosys directly.  This
eliminates the last use of syscall aliases in the tree.

Reviewed by:	kib, imp
2021-11-29 22:04:44 +00:00
Brooks Davis
d7f306c5be makesyscalls: add a new SYSMUX type
This type is for system call multiplexers (syscall(2), __syscall(2))
that don't have a normal handler and instead are handled in the
machine-dependent syscall code.

Reviewed by:	kib, imp
2021-11-29 22:04:43 +00:00
Brooks Davis
5c1835b1d4 syscalls: regen 2021-11-29 22:04:43 +00:00
Brooks Davis
cffb55f0f3 syscalls: normalize exit
Declare the exit system call normally.  This results in the
implementation being named sys_exit rather than sys_sys_exit and
being decalred as returning an int.  Infact it does not return
at all because exit1 does not, so add an __unreachable() to let the
compiler know that.

Reviewed by:	kib, imp
2021-11-29 22:04:43 +00:00
Brooks Davis
7fb006e7d6 syscalls: regen 2021-11-29 22:04:42 +00:00