Commit Graph

249497 Commits

Author SHA1 Message Date
Alexander V. Chernikov
dd4776f0cc Reorganise nd6 notification code to avoid direct rtentry field access.
One of the goals of the new routing KPI defined in r359823 is to entirely hide
 `struct rtentry` from the consumers. Doing so will allow to improve routing
 subsystem internals and deliver features more easily. This change is one of
  the ongoing changes to eliminate direct struct rtentry field accesses.

It introduces rtfree_func() wrapper around RTFREE() and reorganises nd6 notification
 code to avoid accessing most of the rtentry fields.

Reviewed by:	ae
Differential Revision:	https://reviews.freebsd.org/D24404
2020-04-14 22:48:33 +00:00
Emmanuel Vadot
47d45507e8 modules: dtb: allwinner: Remove sun50i-a64-sid.dtso
File was removed in r359935

MFC after:	2 month
X-MFC-With:	r359935
2020-04-14 22:16:40 +00:00
Brooks Davis
618a20d4f9 Remove bogus use of useracc() in (clock_)nanosleep.
There's no point in pre-checking that we can access the user's rmtp
pointer before we do it in copyout().

While here, improve style(9) compliance.

Reviewed by:	imp
MFC after:	1 week
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D24409
2020-04-14 20:53:12 +00:00
Brooks Davis
562894f0dc Centralize compatability translation macros.
Copy the CP, PTRIN, etc macros from freebsd32.h into a sys/abi_compat.h
and replace existing definitation with includes where required. This
eliminates duplicate code and allows Linux and FreeBSD compatability
headers to be included in the same files.

Input from:	cem, jhb
Obtained from:	CheriBSD
MFC after:	2 weeks
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D24275
2020-04-14 20:30:48 +00:00
Emmanuel Vadot
c23ca622a2 modules: dtb: allwinner: Remove non existant files
Those files have been removed in r359935.

MFC after:	2 months
X-MFC-With:	r359935
2020-04-14 20:20:08 +00:00
Emmanuel Vadot
d6b4447496 allwinner: aw_thermal: Cope with DTS changes
The upstream DTS now include the thermal device node and the SID
calibration entry.
Update our driver to cope with this change and remove the DTB
overlays that aren't needed anymore.

MFC after:	2 months
X-MFC-With:	r359934
2020-04-14 19:05:17 +00:00
Emmanuel Vadot
211b4e4259 dts: Import DTS from Linux 5.6 2020-04-14 18:57:00 +00:00
Emmanuel Vadot
62dc472bdb files: Add mmc_fdt_helpers for mmccam enabled config
MFC after:	1 month
X-MFC-With:	r359924
2020-04-14 18:11:54 +00:00
Kyle Evans
e19b97f7a0 sysent: re-roll after r359930 2020-04-14 18:11:26 +00:00
Kyle Evans
7d03e08112 Mark closefrom(2) COMPAT12, reimplement in libc to wrap close_range
Include a temporarily compatibility shim as well for kernels predating
close_range, since closefrom is used in some critical areas.

Reviewed by:	markj (previous version), kib
Differential Revision:	https://reviews.freebsd.org/D24399
2020-04-14 18:07:42 +00:00
Emmanuel Vadot
937eaf8bbd Import DTS files from Linux 5.6 2020-04-14 16:56:11 +00:00
Emmanuel Vadot
a1af70e58b arm: dwmmc: Use mmc_fdt_helpers
Use the mmc_fdt_parse function instead of parsing everything in the
driver.

MFC after:	1 month
2020-04-14 16:35:18 +00:00
Michael Tuexen
b89af8e16d Improve the TCP blackhole detection. The principle is to reduce the
MSS in two steps and try each candidate two times. However, if two
candidates are the same (which is the case in TCP/IPv6), this candidate
was tested four times. This patch ensures that each candidate actually
reduced the MSS and is only tested 2 times. This reduces the time window
of missclassifying a temporary outage as an MTU issue.

Reviewed by:		jtl
MFC after:		1 week
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D24308
2020-04-14 16:35:05 +00:00
Emmanuel Vadot
9ed8321078 arm: allwinner: aw_mmc: Use the mmc_fdt_helper
The fdt properties are now parsed via the help of mmc_fdt_helper functions.
This also adds card detection.
Note that on some boards (like the Pine64) card detection is broken due to
a missing resistor on the cd pin.

MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D23268
2020-04-14 16:34:13 +00:00
Emmanuel Vadot
e63fbd7bb7 Those functions are here to help fdt mmc controller drivers to parse
the dts to find the supported speeds and the regulators.
Not all DTS have every settings properly defined so host controller
will still have to add some caps themselves.
It also add a mmc_fdt_gpio_setup function which will read the cd-gpios
property and register it as the CD pin.
If the pin support interrupts one will be registered and the cd_helper
function will be called.
If the pin doesn't support interrupts the internal taskqueue will poll
for change and call the same cd_helper function.
mmc_fdt_gpio_setup will also parse the wp-gpio property and MMC drivers
can know the write-protect pin value by calling the
mmc_fdt_gpio_get_readonly function.

MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D23267
2020-04-14 16:30:54 +00:00
Jonathan T. Looney
fb401f1bba Make sonewconn() overflow messages have per-socket rate-limits and values.
sonewconn() emits debug-level messages when a listen socket's queue
overflows. Currently, sonewconn() tracks overflows on a global basis. It
will only log one message every 60 seconds, regardless of how many sockets
experience overflows. And, when it next logs at the end of the 60 seconds,
it records a single message referencing a single PCB with the total number
of overflows across all sockets.

This commit changes to per-socket overflow tracking. The code will now
log one message every 60 seconds per socket. And, the code will provide
per-socket queue length and overflow counts. It also provides a way to
change the period between log messages using a sysctl.

Reviewed by:	jhb (previous version), bcr (manpages)
MFC after:	2 weeks
Sponsored by:	Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D24316
2020-04-14 15:38:18 +00:00
Jonathan T. Looney
f6ab9795d4 Print more detail as part of the sonewconn() overflow message.
When a socket's listen queue overflows, sonewconn() emits a debug-level
log message. These messages are sometimes useful to systems administrators
in highlighting a process which is not keeping up with its listen queue.

This commit attempts to enhance the usefulness of this message by printing
more details about the socket's address. If all else fails, it will at
least print the domain name of the socket.

Reviewed by:	bz, jhb, kbowling
MFC after:	2 weeks
Sponsored by:	Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D24272
2020-04-14 15:30:34 +00:00
Jonathan T. Looney
a5d22a7fed Make the path length of UNIX domain sockets specified by a #define.
Also, add a comment describing the historical context for this length.

Reviewed by:	bz, jhb, kbowling (previous version)
MFC after:	2 weeks
Sponsored by:	Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D24272
2020-04-14 15:27:24 +00:00
Andrew Gallatin
4d77243c65 Bump FreeBSD version after r359919 (KTLS / unmapped mbuf changes)
The above changes mbufs, and any module using unmapped mbufs
would need to be re-compiled.

Sponsored by:	Netflix
2020-04-14 14:48:00 +00:00
Andrew Gallatin
23feb56348 KTLS: Re-work unmapped mbufs to carry ext_pgs in the mbuf itself.
While the original implementation of unmapped mbufs was a large
step forward in terms of reducing cache misses by enabling mbufs
to carry more than a single page for sendfile, they are rather
cache unfriendly when accessing the ext_pgs metadata and
data. This is because the ext_pgs part of the mbuf is allocated
separately, and almost guaranteed to be cold in cache.

This change takes advantage of the fact that unmapped mbufs
are never used at the same time as pkthdr mbufs. Given this
fact, we can overlap the ext_pgs metadata with the mbuf
pkthdr, and carry the ext_pgs meta directly in the mbuf itself.
Similarly, we can carry the ext_pgs data (TLS hdr/trailer/array
of pages) directly after the existing m_ext.

In order to be able to carry 5 pages (which is the minimum
required for a 16K TLS record which is not perfectly aligned) on
LP64, I've had to steal ext_arg2. The only user of this in the
xmit path is sendfile, and I've adjusted it to use arg1 when
using unmapped mbufs.

This change is almost entirely mechanical, except that we
change mb_alloc_ext_pgs() to no longer allow allocating
pkthdrs, the change to avoid ext_arg2 as mentioned above,
and the removal of the ext_pgs zone,

This change saves roughly 2% "raw" CPU (~59% -> 57%), or over
3% "scaled" CPU on a Netflix 100% software kTLS workload at
90+ Gb/s on Broadwell Xeons.

In a follow-on commit, I plan to remove some hacks to avoid
access ext_pgs fields of mbufs, since they will now be in
cache.

Many thanks to glebius for helping to make this better in
the Netflix tree.

Reviewed by:	hselasky, jhb, rrs, glebius (early version)
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D24213
2020-04-14 14:46:06 +00:00
Kyle Evans
51a16c8412 posixshm: fix counting of writable mappings
Similar to mmap'ing vnodes, posixshm should count any mapping where maxprot
contains VM_PROT_WRITE (i.e. fd opened r/w with no write-seal applied) as
writable and thus blocking of any write-seal.

The memfd tests have been amended to reflect the fixes here, which notably
includes:

1. Fix for error return bug; EPERM is not a documented failure mode for mmap
2. Fix rejection of write-seal with active mappings that can be upgraded via
    mprotect(2).

Reported by:	markj
Discussed with:	markj, kib
2020-04-14 13:32:03 +00:00
Alexander V. Chernikov
6722086045 Plug netmask NULL check during route addition causing kernel panic.
This bug was introduced by the r359823.

Reported by:	hselasky
2020-04-14 13:12:22 +00:00
Mateusz Piotrowski
789e4d2f20 Improve manual page formatting
-	Use appropriate macros for command arguments.
-	Increase option list indentation for better readability.

MFC after:	3 days
2020-04-14 10:10:31 +00:00
Alexander V. Chernikov
1968b7eb21 Postpone multipath seed init till SI_SUB_LAST, as it is needed only after
some useland program installs multiple paths to the same destination.

While here, make multipath init conditional.

Discussed with:	cem,ian
2020-04-14 07:38:34 +00:00
Rick Macklem
9897e357de Re-organize the NFS file handle affinity code for the NFS server.
The file handle affinity code was configured to be used by both the
old and new NFS servers. This no longer makes sense, since there is
only one NFS server.
This patch copies a majority of the code in sys/nfs/nfs_fha.c and
sys/nfs/nfs_fha.h into sys/fs/nfsserver/nfs_fha_new.c and
sys/fs/nfsserver/nfs_fha_new.h, so that the files in sys/nfs can be
deleted. The code is simplified by deleting the function callback pointers
used to call functions in either the old or new NFS server and they were
replaced by calls to the functions.

As well as a cleanup, this re-organization simplifies the changes
required for handling of external page mbufs, which is required for KERN_TLS.

This patch should not result in a semantic change to file handle affinity.
2020-04-14 00:01:26 +00:00
Olivier Houchard
77a1348b3c Remove FreeBSD/armv4 specific bits from CK.
Now that armv4/v5 is gone, remove the bits that implemented atomic operations
by disabling interrupts.
Those were specific to FreeBSD and never reached upstream.
2020-04-13 23:16:32 +00:00
Andrew Gallatin
bd673b9942 lagg: stop double-counting output errors and counting drops as errors
Before this change, lagg double-counted errors from lagg members, and counted
every drop by a lagg member as an error.  Eg, if lagg sent a packet, and the
underlying hardware driver dropped it, a counter would be incremented by both
lagg and the underlying driver.

This change attempts to fix that by incrementing lagg's counters only for
errors that do not come from underlying drivers.

Reviewed by:	hselasky, jhb
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D24331
2020-04-13 23:06:56 +00:00
Vladimir Kondratyev
68cc053763 [evdev] Use proper mutex reference in autorepeat callout initialization.
This fixes panic occuring when evdev key autorepeat is enabled by driver
which initializes evdev with external mutex.
2020-04-13 22:06:28 +00:00
Li-Wen Hsu
862ac3b74a Ensure kyua list working when there is no /dev/nvme*
Sponsored by:	The FreeBSD Foundation
2020-04-13 21:08:54 +00:00
Warner Losh
ab485b018a Checks here against useracc are not useful and are racy.
copyin/copyout are sufficient to guard against bad addresses. They will return
EFAULT if the user is up to no good (by choice or ignorance). There's no point
in checking, since it doesn't even improve the error messages.

Noticed by: jhb
Reviewed by: brooks, jhb
2020-04-13 21:04:33 +00:00
Warner Losh
450a2e2a12 Remove stale comment
There's no useracc here, and even if there was it shouldn't be here. vmapbuf is
sufficient and as the comment says, useracc is racy.
2020-04-13 21:03:30 +00:00
John Baldwin
64c4dfcd26 Export a sysctl count of RX FIFO overrun events.
uart(4) backends currently detect RX FIFO overrun errors and report
them to the uart(4) core layer.  They are then reported to the generic
TTY layer which promptly ignores them.  As a result, there is
currently no good way to determine if a uart is experiencing RX FIFO
overruns.  One could add a generic per-tty counter, but there did not
appear to be a good way to export those.  Instead, add a sysctl under
the uart(4) sysctl tree to export the count of overruns.

Reviewed by:	brooks
MFC after:	2 weeks
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D24368
2020-04-13 20:59:09 +00:00
John Baldwin
b47c1eda0c Correct baud rate error calculation.
Shifting right by 1 is not the same as dividing by 2 for signed
values.  In particular, dividing a signed value by 2 gives the integer
ceiling of the (e.g. -5 / 2 == -2) whereas shifting right by 1 always
gives the floor (-5 >> 1 == -3).

An embedded board with a 25 Mhz base clock results in an error of
-30.5% when used with a baud rate of 115200.  Using division, this
truncates to -30% and is permitted.  Using the shift, this fails and
is rejected causing TIOCSETA requests to fail with EINVAL and breaking
getty(8).

Using division gives the same error range for both over and under baud
rates and also makes the code match the behavior documented in the
existing comment about supporting boards with 25 Mhz clocks.

Reported by:	imp
MFC after:	2 weeks
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D24367
2020-04-13 20:43:57 +00:00
Conrad Meyer
3fcdcab087 Disable QUEUE_MACRO_DEBUG_TRACE in LINT kernels
It changes the size of TAILQ_ENTRY, which obviously impacts ABI in a variety of
ways.  Some of these things are _Static_asserted.  For now, mask the option
from LINT.

Reported by:	crees, np, jhb
X-MFC-With:	r359829
Sponsored by:	Dell EMC Isilon
2020-04-13 20:25:01 +00:00
Navdeep Parhar
843b264a85 cxgbe(4): Make sure 'flags' is at the same offset in structs toepcb and
synq_entry.  TAILQ_ENTRY isn't always the same size as two pointers.

Reported by:	rmacklem@
MFC after:	3 days
Sponsored by:	Chelsio Communications
2020-04-13 20:12:47 +00:00
Kyle Evans
18041d4ec5 depend-cleanup: fix typo, ^/lib/libc/sys/Makefile.inc generates .S stubs
Pointy hat:	kevans
2020-04-13 20:00:44 +00:00
Kyle Evans
6fe257c780 Move shm_open dependency cleanup into a new home
r359461 introduced this nifty script to centralize these things, so add
shm_open.c there to remove a total of one (1) bad example from
Makefile.inc1.

Looked over by:	emaste
2020-04-13 19:50:47 +00:00
Mark Johnston
bd136d88f0 snd_hda(4): Recognize the ALC257 codec.
PR:		245524
Submitted by:	Jose Luis Duran <jlduran@gmail.com>
MFC after:	1 week
2020-04-13 19:45:45 +00:00
Mark Johnston
b36871af6d Fix sendto() on unconnected SOCK_STREAM/SEQPACKET unix sockets.
Previously the unpcb pointer of the newly connected remote socket was
not initialized correctly, so attempting to lock it would result in a
null pointer dereference.

Reported by:	syzkaller
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-04-13 19:22:05 +00:00
Mark Johnston
c7841c6b8e Relax restrictions on private mappings of POSIX shm objects.
When creating a private mapping of a POSIX shared memory object,
VM_PROT_WRITE should always be included in maxprot regardless of
permissions on the underlying FD.  Otherwise it is possible to open a
shm object read-only, map it with MAP_PRIVATE and PROT_WRITE, and
violate the invariant in vm_map_insert() that (prot & maxprot) == prot.

Reported by:	syzkaller
Reviewed by:	kevans, kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D24398
2020-04-13 19:20:39 +00:00
Kyle Evans
605c4cda2f close_range/closefrom: fix regression from close_range introduction
close_range will clamp the range between [0, fdp->fd_lastfile], but failed
to take into account that fdp->fd_lastfile can become -1 if all fds are
closed. =-( In this scenario, just return because there's nothing further we
can do at the moment.

Add a test case for this, fork() and simply closefrom(0) twice in the child;
on the second invocation, fdp->fd_lastfile == -1 and will trigger a panic
before this change.

X-MFC-With:	r359836
2020-04-13 17:55:31 +00:00
Kyle Evans
7c5e60c72e libc: remove shm_open(2)'s compat fallback
This had been introduced to ease any pain for using slightly older kernels
with a newer libc, e.g., for bisecting a kernel across the introduction of
shm_open2(2). 6 months has passed, retire the fallback and let shm_open()
unconditionally call shm_open2().

Stale includes are removed as well.
2020-04-13 15:59:15 +00:00
Li-Wen Hsu
1c04eb2853 Install expected output file of test missed in r359585
Sponsored by:	The FreeBSD Foundation
2020-04-13 14:35:07 +00:00
Alexander V. Chernikov
6bd75de641 Remove unused 'struct rtentry' definition. 2020-04-13 09:01:46 +00:00
Xin LI
d25a143055 Sync with OpenBSD:
arc4random.c: In the incredibly unbelievable circumstance where
_rs_init() fails to allocate pages, don't call abort() because of
corefile data leakage concerns, but simply _exit().  The reasoning
is _rs_init() will only fail if someone finds a way to apply
specific pressure against this failure point, for the purpose of
leaking information into a core which they can read.  We don't
need a corefile in this instance to debug that.  So take this
"lever" away from whoever in the future wants to do that.

arc4random.3: reference random(4)

arc4random_uniform.c: include stdint.h over sys/types.h
2020-04-13 08:42:13 +00:00
Alexander V. Chernikov
3133002560 Remove tcp_rtlookup6() function signature.
The function itself was removed in r122922 16 years ago.
2020-04-13 08:26:11 +00:00
Rick Macklem
66ea9219a2 Delete the mbuf macros that were used for the Mac OS/X port.
When the code was ported to Mac OS/X, mbuf handling functions were
converted to using the Mac OS/X accessor functions. For FreeBSD, they
are a simple set of macros in sys/fs/nfs/nfskpiport.h.
Since r359757, r359780, r359785, r359810, r359811 have removed all uses
of these macros, this patch deleted the macros from the .h files.

My eventual goal is deleting nfskpiport.h, but that will take some more
editting to replace uses of the remaining macros.
2020-04-13 00:07:37 +00:00
Kyle Evans
9f2dc6078d Bump __FreeBSD_version after r359836, close_range(2)
Reported by:	cy
2020-04-12 22:22:53 +00:00
Kyle Evans
3d224fc909 sysent: re-roll after introduction of close_range in r359836 2020-04-12 21:23:51 +00:00
Kyle Evans
472ced39ef Implement a close_range(2) syscall
close_range(min, max, flags) allows for a range of descriptors to be
closed. The Python folk have indicated that they would much prefer this
interface to closefrom(2), as the case may be that they/someone have special
fds dup'd to higher in the range and they can't necessarily closefrom(min)
because they don't want to hit the upper range, but relocating them to lower
isn't necessarily feasible.

sys_closefrom has been rewritten to use kern_close_range() using ~0U to
indicate closing to the end of the range. This was chosen rather than
requiring callers of kern_close_range() to hold FILEDESC_SLOCK across the
call to kern_close_range for simplicity.

The flags argument of close_range(2) is currently unused, so any flags set
is currently EINVAL. It was added to the interface in Linux so that future
flags could be added for, e.g., "halt on first error" and things of this
nature.

This patch is based on a syscall of the same design that is expected to be
merged into Linux.

Reviewed by:	kib, markj, vangyzen (all slightly earlier revisions)
Differential Revision:	https://reviews.freebsd.org/D21627
2020-04-12 21:23:19 +00:00