]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agoamd64/linux*: add required header to get the constant value
Konstantin Belousov [Tue, 25 May 2021 22:19:44 +0000 (01:19 +0300)]
amd64/linux*: add required header to get the constant value

Otherwise asm silently interpret it as the external global symbol.

Reported by: bz
Sponsored by: The FreeBSD Foundation
Fixes: 91aae953cb80

2 years agonfscl: Use hash lists to improve expected search performance for opens
Rick Macklem [Tue, 25 May 2021 21:19:29 +0000 (14:19 -0700)]
nfscl: Use hash lists to improve expected search performance for opens

A problem was reported via email, where a large (130000+) accumulation
of NFSv4 opens on an NFSv4 mount caused significant lock contention
on the mutex used to protect the client mount's open/lock state.
Although the root cause for the accumulation of opens was not
resolved, it is obvious that the NFSv4 client is not designed to
handle 100000+ opens efficiently.  When searching for an open,
usually for a match by file handle, a linear search of all opens
is done.

Commit 3f7e14ad9345 added a hash table of lists hashed on file handle
for the opens.  This patch uses the hash lists for searching for
a matching open based of file handle instead of an exhaustive
linear search of all opens.
This change appears to be performance neutral for a small number
of opens, but should improve expected performance for a large
number of opens.  This patch also moves any found match to the front
of the hash list, to try and maintain the hash lists in recently
used ordering (least recently used at the end of the list).

This commit should not affect the high level semantics of open
handling.

MFC after: 2 weeks

2 years agoipfilter: Fix ip_nat memory leak and use-after-free
Cy Schubert [Tue, 25 May 2021 18:54:49 +0000 (11:54 -0700)]
ipfilter: Fix ip_nat memory leak and use-after-free

Unfortunately the wrong elemet is freed, also resulting in use-after-free.

PR: 255859
Submitted by: lylgood@foxmail.com
Reported by: lylgood@foxmail.com
MFC after: 3 days

2 years agoBump __FreeBSD_version to 1400015 for LinuxKPI changes.
Bjoern A. Zeeb [Tue, 25 May 2021 17:37:15 +0000 (17:37 +0000)]
Bump __FreeBSD_version to 1400015 for LinuxKPI changes.

Commits 17accc08ae15 and de102f870501 add new files to LinuxKPI
which break drm-kmod.  In addition various other additions where
comitted. Bump __FreeBSD_version to 1400015 to be able to detect this.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks

2 years agoLinuxKPI: add addrconf_addr_solict_mult()
Bjoern A. Zeeb [Mon, 24 May 2021 17:49:12 +0000 (17:49 +0000)]
LinuxKPI: add addrconf_addr_solict_mult()

Introduce net/addrconf.h with an implementation to
addrconf_addr_solict_mult() used by WiFi drivers.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30416

2 years agoLinuxKPI: add Exponentially Weighted Moving Average implementation
Bjoern A. Zeeb [Mon, 24 May 2021 17:42:25 +0000 (17:42 +0000)]
LinuxKPI: add Exponentially Weighted Moving Average implementation

Add DECLARE_EWMA() which expands to a per-name EWMA implementation
as used by multiple wireless drivers.

Sposnored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky, cperciva, dwmalone
Differential Revision: https://reviews.freebsd.org/D30415

2 years agoLinuxKPI: add linux/bsearch.h for sort(9)
Bjoern A. Zeeb [Mon, 24 May 2021 17:52:02 +0000 (17:52 +0000)]
LinuxKPI: add linux/bsearch.h for sort(9)

Add linux/bsearch.h which only includes libkern.h as the sort(9)
functions seem to be compatible.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30417

2 years agoLinuxKPI: byteorder.h
Bjoern A. Zeeb [Mon, 24 May 2021 17:54:16 +0000 (17:54 +0000)]
LinuxKPI: byteorder.h

Add a few more le<n>_{tp,add}_cpu*() #defines/functions found in
wireless drivers.  While here fill most of the combinatorics gaps
and also add the remaining combinations [1].

Suggested by: emaste [1] (for one part)
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30418

2 years agoLinuxKPI: cache.h add SMP_CACHE_BYTES
Bjoern A. Zeeb [Mon, 24 May 2021 17:56:53 +0000 (17:56 +0000)]
LinuxKPI: cache.h add SMP_CACHE_BYTES

Add a definition for SMP_CACHE_BYTES and while here include sys/param.h
for CACHE_LINE_SIZE as otherwise code might not compile standalone.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30419

2 years agoLinuxKPI: compiler.h add three more defines
Bjoern A. Zeeb [Mon, 24 May 2021 17:59:13 +0000 (17:59 +0000)]
LinuxKPI: compiler.h add three more defines

Add fallthrough, ____cacheline_aligned_in_smp, and smp_mb() to
linux/compiler.h.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30420

2 years agoLinuxKPI: add cpu.h for cpumask_*()
Bjoern A. Zeeb [Mon, 24 May 2021 18:01:59 +0000 (18:01 +0000)]
LinuxKPI: add cpu.h for cpumask_*()

Add linux/cpu.h for cpumask_*() functions found in wireless drivers
and make sure cpu_online_mask is always initialised.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30421

2 years agoLinuxKPI: add devcoredump.h
Bjoern A. Zeeb [Mon, 24 May 2021 18:04:31 +0000 (18:04 +0000)]
LinuxKPI: add devcoredump.h

Add linux/devcoredump.h with stub implementation of dev_coredumpv()
and dev_coredumpsg() which only free the passed in SG table as needed
for iwlwifi.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30423

2 years agoLinuxKPI: add dev_crit() to linux/device.h
Bjoern A. Zeeb [Mon, 24 May 2021 18:07:31 +0000 (18:07 +0000)]
LinuxKPI: add dev_crit() to linux/device.h

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: emaste, hselasky
Differential Revision: https://reviews.freebsd.org/D30424

2 years agoLinuxKPI: add ether_addr_equal_unaligned()
Bjoern A. Zeeb [Mon, 24 May 2021 18:09:37 +0000 (18:09 +0000)]
LinuxKPI: add ether_addr_equal_unaligned()

Replace the implementation for ether_addr_equal() with
ether_addr_equal_unaligned() and add a define for ether_addr_equal()
pointing to the now ether_addr_equal_unaligned() implementation.
This way ether_addr_equal_unaligned() cannot be broken by accident [1].

Suggested by: emaste [1]
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30425

2 years agoLinuxKPI: net/if_inet6.h add struct inet6_dev { }
Bjoern A. Zeeb [Mon, 24 May 2021 18:11:56 +0000 (18:11 +0000)]
LinuxKPI: net/if_inet6.h add struct inet6_dev { }

Add a dummy struct inet6_dev {}; to net/if_inet6.h.  This is currently
not used for anything but in a declaration.  Just needs to be there.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30426

2 years agoLinuxKPI: add irq_set_affinity_hint()
Bjoern A. Zeeb [Mon, 24 May 2021 18:14:37 +0000 (18:14 +0000)]
LinuxKPI: add irq_set_affinity_hint()

Add an implementation for irq_set_affinity_hint() to linux/interrupt.h
and include linux/hardirq.h for synchronize_irq() as needed by
wireless drivers.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30427

2 years agoLinuxKPI: add linux/{ip,tcp,udp}.h
Bjoern A. Zeeb [Mon, 24 May 2021 18:17:30 +0000 (18:17 +0000)]
LinuxKPI: add linux/{ip,tcp,udp}.h

Add header files for struct and accessors for IPv4, UDP, and TCP.
Only parts of the fields of the structs have been seen while working
on wireless drivers.  The remaining field names are filled up with
the FreeBSD field names for now.  If you have insights into their
correct naming in Linux, feel free to adjust.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30428

2 years agoLinuxKPI: ipv6.h add missing #include
Bjoern A. Zeeb [Mon, 24 May 2021 18:21:55 +0000 (18:21 +0000)]
LinuxKPI: ipv6.h add missing #include

Include linux/bitops.h for a definition of BITS_PER_LONG so that this
file can be used independently.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30429

2 years agoLinuxKPI: add time_is_after_jiffies() definition
Bjoern A. Zeeb [Mon, 24 May 2021 18:24:13 +0000 (18:24 +0000)]
LinuxKPI: add time_is_after_jiffies() definition

This is used by wireless drivers.  Use the time_after() macro as
done for the "after_eq" version.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30430

2 years agoLinuxKPI: change BUILD_BUG_ON()
Bjoern A. Zeeb [Mon, 24 May 2021 18:26:41 +0000 (18:26 +0000)]
LinuxKPI: change BUILD_BUG_ON()

BUILD_BUG_ON() can be used inside functions where the definition to
CTASSERT() (_Static_assert()) seems to not work.
Go back to an old-style CTASSERT() implementation but also add a
variable dclaration to avoid "unsued typedef" errors and dummy-use
the variable to avoid "unusued variable" errors.  Given it is all
self-contained in a block and not used outside this should be
optimised away.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30431

2 years agoLinuxKPI: add ktime_get_boottime_ns() implementation to ktime.h
Bjoern A. Zeeb [Mon, 24 May 2021 18:30:33 +0000 (18:30 +0000)]
LinuxKPI: add ktime_get_boottime_ns() implementation to ktime.h

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30432

2 years agoLinuxKPI: add LINUXKPI_PARAM_charp()
Bjoern A. Zeeb [Mon, 24 May 2021 18:32:11 +0000 (18:32 +0000)]
LinuxKPI: add LINUXKPI_PARAM_charp()

Add yet another version of the various module_param_named() use cases.
This one deals with "charp".

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30433

2 years agoLinuxKPI: add more #defines to pci.h
Bjoern A. Zeeb [Mon, 24 May 2021 18:36:18 +0000 (18:36 +0000)]
LinuxKPI: add more #defines to pci.h

Add more definitions for various PCI uses to linux/pci.h.  Almost all
are defined to their FreeBSD counterparts which are described there.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30434

2 years agoLinuxKPI: add prandom_u32() as used by wireless drivers.
Bjoern A. Zeeb [Mon, 24 May 2021 18:38:58 +0000 (18:38 +0000)]
LinuxKPI: add prandom_u32() as used by wireless drivers.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30435

2 years agoLinuxKPI: add rcu_dereference_check()
Bjoern A. Zeeb [Mon, 24 May 2021 18:40:42 +0000 (18:40 +0000)]
LinuxKPI: add rcu_dereference_check()

Add a define for rcu_dereference_check() to rcu_dereference_protected()
which ignores the check argument.  Our lockdep compat implementation
for use cases found in iwlwifi would return 1 anyway.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30436

2 years agoLinuxKPI: add kfree_sensitive() using zfree().
Bjoern A. Zeeb [Mon, 24 May 2021 18:43:33 +0000 (18:43 +0000)]
LinuxKPI: add kfree_sensitive() using zfree().

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30437

2 years agoLinuxKPI: extract stringify() in their own header file
Bjoern A. Zeeb [Mon, 24 May 2021 18:53:28 +0000 (18:53 +0000)]
LinuxKPI: extract stringify() in their own header file

Add linux/stringify.h as directly included by drivers.  Remove the
definitions from compiler.h and include the new header in places
where the stringify macros are already used without linuxkpi.

I have adjusted the Copyright of the new file according to the commit
originaly adding the macros (99e690772adbcb78c9e8441bedcf1913d72ea72f).

Sposnored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30440

2 years agoLinuxKPI: add kernel_ulong_t typedef in linux/kernel.h.
Bjoern A. Zeeb [Mon, 24 May 2021 18:47:49 +0000 (18:47 +0000)]
LinuxKPI: add kernel_ulong_t typedef in linux/kernel.h.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30438

2 years agoLinuxKPI: add guid_t for ACPI consumers.
Bjoern A. Zeeb [Mon, 24 May 2021 18:50:10 +0000 (18:50 +0000)]
LinuxKPI: add guid_t for ACPI consumers.

Add a placeholder struct for guid_t which is needed by ACPI consumers
in at least one wireless driver.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30439

2 years agotcp: enter network epoch when calling tfb_tcp_fb_fini
Andrew Gallatin [Tue, 25 May 2021 17:45:37 +0000 (13:45 -0400)]
tcp: enter network epoch when calling tfb_tcp_fb_fini

We need to enter the network epoch when calling into
tfb_tcp_fb_fini.  I noticed this when I hit an assert
running the latest rack

Differential Revision: https://reviews.freebsd.org/D30407
Reviewed by: rrs, tuexen
Sponsored by: Netflix

2 years agotcp: Fix bugs related to the PUSH bit and rack and an ack war
Randall Stewart [Tue, 25 May 2021 17:23:31 +0000 (13:23 -0400)]
tcp: Fix bugs related to the PUSH bit and rack and an ack war

Michaels testing with UDP tunneling found an issue with the push bit, which was only partly fixed
in the last commit. The problem is the left edge gets transmitted before the adjustments are done
to the send_map, this means that right edge bits must be considered to be added only if
the entire RSM is being retransmitted.

Now syzkaller also continued to find a crash, which Michael sent me the reproducer for. Turns
out that the reproducer on default (freebsd) stack made the stack get into an ack-war with itself.
After fixing the reference issues in rack the same ack-war was found in rack (and bbr). Basically
what happens is we go into the reassembly code and lose the FIN bit. The trick here is we
should not be going into the reassembly code if tlen == 0 i.e. the peer never sent you anything.
That then gets the proper action on the FIN bit but then you end up in LAST_ACK with no
timers running. This is because the usrclosed function gets called and the FIN's and such have
already been exchanged. So when we should be entering FIN_WAIT2 (or even FIN_WAIT1) we get
stuck in LAST_ACK. Fixing this means tweaking the usrclosed function so that we properly
recognize the condition and drop into FIN_WAIT2 where a timer will allow at least TP_MAXIDLE
before closing (to allow time for the peer to retransmit its FIN if the ack is lost). Setting the fast_finwait2
timer can speed this up in testing.

Reviewed by: mtuexen,rscheff
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D30451

2 years agofsdb: add missing bufinit() call
Chuck Silvers [Tue, 25 May 2021 16:42:10 +0000 (09:42 -0700)]
fsdb: add missing bufinit() call

The bufinit() call in fsck_ffs was moved in commit f190f9193bc10
from a function that is shared with fsdb to one that is private to fsck_ffs,
so add a bufinit() call in fsdb to compensate for that.

Reviewed by: mckusick
Sponsored by: Netflix

2 years agocam_sim: style: sort includes
Warner Losh [Sat, 22 May 2021 00:52:55 +0000 (18:52 -0600)]
cam_sim: style: sort includes

Sort and remove sys/systm.h, it's not needed.

Sponsored by: Netflix

2 years agoClean up some of the core dumping code.
Edward Tomasz Napierala [Tue, 25 May 2021 10:48:15 +0000 (11:48 +0100)]
Clean up some of the core dumping code.

No functional changes.

Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30397

2 years agoarm64, riscv: remove reference to fsu_intr_fault
Mitchell Horne [Tue, 25 May 2021 15:22:49 +0000 (12:22 -0300)]
arm64, riscv: remove reference to fsu_intr_fault

This variable no longer exists.

MFC after: 3 days

2 years agopf tests: Test cases for fragment reassembly
Kristof Provost [Thu, 25 Feb 2021 08:50:57 +0000 (09:50 +0100)]
pf tests: Test cases for fragment reassembly

Obtained from: Alexander Bluhm, OpenBSD

2 years agoman5/{hosts,resolver}.5: note that IPv6 addresses are allowed.
Ceri Davies [Tue, 25 May 2021 15:16:24 +0000 (16:16 +0100)]
man5/{hosts,resolver}.5: note that IPv6 addresses are allowed.

The patch in the PR largely no longer applied due to age, but
thanks to Evgeniy Khramtsov for the patches in the PR.

PR: 120024
Reported by: bcran
Approved by: blackend (mentor)
Obtained from: Evgeniy Khramtsov <evgeniy@khramtsov.org> (partly)

2 years agoman4/inet6.4: use "effect" rather than "affect"
Ceri Davies [Tue, 25 May 2021 15:14:19 +0000 (16:14 +0100)]
man4/inet6.4: use "effect" rather than "affect"

Approved by: blackend (mentor)

2 years agousr.bin/chpass: Correct manpage regarding path to temp files
Ceri Davies [Tue, 25 May 2021 15:11:45 +0000 (16:11 +0100)]
usr.bin/chpass: Correct manpage regarding path to temp files

Approved by: blackend (mentor)

2 years agoptrace: add an option to not kill debuggees on debugger exit
Konstantin Belousov [Tue, 18 May 2021 16:26:22 +0000 (19:26 +0300)]
ptrace: add an option to not kill debuggees on debugger exit

Requested by: markj
Reviewed by: jhb (previous version)
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differrential revision: https://reviews.freebsd.org/D30351

2 years agosys_process.c: extract ptrace_unsuspend()
Konstantin Belousov [Tue, 18 May 2021 16:25:50 +0000 (19:25 +0300)]
sys_process.c: extract ptrace_unsuspend()

Reviewed by: jhb
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differrential revision: https://reviews.freebsd.org/D30351

2 years agoamd64: clear PSL.AC in the right frame
Konstantin Belousov [Sat, 22 May 2021 19:48:36 +0000 (22:48 +0300)]
amd64: clear PSL.AC in the right frame

If copyin family of routines fault, kernel does clear PSL.AC on the
fault entry, but the AC flag of the faulted frame is kept intact.  Since
onfault handler is effectively jump, AC survives until syscall exit.

Reported by: m00nbsd, via Sony
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
admbugs: 975

2 years agocam: remove xpt_polled_action
Warner Losh [Tue, 25 May 2021 15:16:49 +0000 (09:16 -0600)]
cam: remove xpt_polled_action

Since periph_runccb now handles all the polling stuff, and
xpt_polled_action is now unused and can be removed.

Sponsored by: Netflix
Reviewed by: mav@
Differential Revision: https://reviews.freebsd.org/D30394

2 years agocam: Remove CAM_SIM_LOCK/UNLOCK macros, they are unused.
Warner Losh [Tue, 25 May 2021 15:16:29 +0000 (09:16 -0600)]
cam: Remove CAM_SIM_LOCK/UNLOCK macros, they are unused.

Sponsored by: Netflix
Reviewed by: mav@
Differential Revision: https://reviews.freebsd.org/D30384

2 years agocam: remove sim callout
Warner Losh [Tue, 25 May 2021 15:14:32 +0000 (09:14 -0600)]
cam: remove sim callout

Nothing is using the sim callout to unfreeze the queue. Remove it to
simplify the SIM. This was introduced in the original CAM commit in 1998
but setting the CAM_SIM_REL_TIMEOUT_PENDING flag was removed in 1999 in
commit 87cfaf0e1fbd which reworked how bus reset worked. That work was
merged just after 3.2R was released. Remove the unused residuals.

Sponsored by: Netflix
Reviewed by: scottl@, mav@
Differential Revision: https://reviews.freebsd.org/D30383

2 years agotaskqueue: Add missing comma to TASKQUEUE_FAST_DEFINE_THREAD
Colin Percival [Tue, 25 May 2021 03:37:55 +0000 (20:37 -0700)]
taskqueue: Add missing comma to TASKQUEUE_FAST_DEFINE_THREAD

Add missing comma to TASKQUEUE_FAST_DEFINE_THREAD arguments to prevent
compilation errors.

Submitted by: ashafer_badland.io
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30449

2 years agoarm64: log vm_fault error for data_abort
Bjoern A. Zeeb [Thu, 20 May 2021 16:43:30 +0000 (16:43 +0000)]
arm64: log vm_fault error for data_abort

Summary:
Log the vm_fault() error in the data_abort panic so it is easier to
find the reason vm_fault() failed (e.g., invalid address).

Reviewed by: andrew
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D30362

2 years agotests/libalias: Add missing copyright statements
Lutz Donnerhacke [Mon, 24 May 2021 19:56:05 +0000 (21:56 +0200)]
tests/libalias: Add missing copyright statements

2 years agotcp: fix a RACK socket buffer lock issue
Michael Tuexen [Mon, 24 May 2021 18:31:23 +0000 (20:31 +0200)]
tcp: fix a RACK socket buffer lock issue

Fix a missing socket buffer unlocking of the socket receive buffer.

Reviewed by: gallatin, rrs
MFC after: 1 week
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D30402

2 years agotcp: Fix an issue with the PUSH bit as well as fill in the missing mtu change for...
Randall Stewart [Mon, 24 May 2021 18:42:15 +0000 (14:42 -0400)]
tcp: Fix an issue with the PUSH bit as well as fill in the missing mtu change for fsb's

The push bit itself was also not actually being properly moved to
the right edge. The FIN bit was incorrectly on the left edge. We
fix these two issues as well as plumb in the mtu_change for
alternate stacks.

Reviewed by: mtuexen
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D30413

2 years agopf: fix ioctl() memory leak
Kristof Provost [Mon, 24 May 2021 06:32:16 +0000 (08:32 +0200)]
pf: fix ioctl() memory leak

When we create an nvlist and insert it into another nvlist we must
remember to destroy it. The nvlist_add_nvlist() function makes a copy,
just like nvlist_add_string() makes a copy of the string. If we don't
we're leaking memory on every (nvlist-based) ioctl() call.

While here remove two redundant 'break' statements.

PR: 255971
MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agoDRIVER_MODULE(9): Correct the SYNOPSIS of EARLY_DRIVER_MODULE()
J.R. Oldroyd [Mon, 24 May 2021 14:54:45 +0000 (16:54 +0200)]
DRIVER_MODULE(9): Correct the SYNOPSIS of EARLY_DRIVER_MODULE()

The man page SYNOPSIS for EARLY_DRIVER_MODULE() shows that it has
an "enum sysinit_elem_order order" argument.

The actual macro in sys/bus.h does not have an order argument.

PR: 256103
Reported by: J.R. Oldroyd <fbsd at opal dot com>
Reviewed by: markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30411

2 years agoDelete obsolete Solaris compat files
Alan Somers [Mon, 24 May 2021 14:47:44 +0000 (08:47 -0600)]
Delete obsolete Solaris compat files

These files have been unused ever since the OpenSolaris import

Sponsored by: Axcient
MFC after: 2 weeks
Reviewed By: freqlabs
Differential Revision: https://reviews.freebsd.org/D30371

2 years agoarm: RPI-B: Add ext_resources driver
Emmanuel Vadot [Mon, 24 May 2021 10:53:00 +0000 (12:53 +0200)]
arm: RPI-B: Add ext_resources driver

mmc_fdt_helpers needs clock and regulators.
Add all the ext_resources driver to RPI-B conf file to fix the build

Reported by: mjg

2 years agoClean up early arm64 pmap code
Andrew Turner [Thu, 20 May 2021 06:52:15 +0000 (06:52 +0000)]
Clean up early arm64 pmap code

Early in the arm64 pmap code we need to translate between a virtual
address and a physical address. Rather than manually walking the page
table we can ask the hardware to do it for us.

Reviewed by: kib, markj
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D30357

2 years agocxgbetool(8): add a 'clip' subcommand to deal with the CLIP table.
Navdeep Parhar [Sun, 23 May 2021 23:28:31 +0000 (16:28 -0700)]
cxgbetool(8): add a 'clip' subcommand to deal with the CLIP table.

MFC after: 2 weeks
Sponsored by: Chelsio Communications

2 years agocxgbe(4): Overhaul CLIP (Compressed Local IPv6) table management.
Navdeep Parhar [Sun, 23 May 2021 21:58:29 +0000 (14:58 -0700)]
cxgbe(4): Overhaul CLIP (Compressed Local IPv6) table management.

- Process the list of local IPs once instead of once per adapter.  Add
  addresses from all VNETs to the driver's list but leave hardware
  updates for later when the global VNET/IFADDR list locks have been
  released.

- Add address to the hardware table synchronously when a CLIP entry is
  requested for an address that's not already in there.

- Provide ioctls that allow userspace tools to manage addresses in the
  CLIP table.

- Add a knob (hw.cxgbe.clip_db_auto) that controls whether local IPs are
  automatically added to the CLIP table or not.

MFC after: 2 weeks
Sponsored by: Chelsio Communications

2 years agoums(4): Start USB xfers on opening of evdev node unconditionally.
Vladimir Kondratyev [Sun, 23 May 2021 22:41:17 +0000 (01:41 +0300)]
ums(4): Start USB xfers on opening of evdev node unconditionally.

This fixes inability to start USB xfers in a case when FIFO has been
already open()-ed but no read() or poll() calls has been issued yet.

MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D30343

2 years agoums(4): Do not stop USB xfers on FIFO close when evdev is still active
Vladimir Kondratyev [Sun, 23 May 2021 22:38:53 +0000 (01:38 +0300)]
ums(4): Do not stop USB xfers on FIFO close when evdev is still active

This fixes lose of evdev events after moused has been killed.

While here use bitwise operations for UMS_EVDEV_OPENED flag.

Reviewed by: hselasky
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D30342

2 years agotests/libalias: Reduce stress
Lutz Donnerhacke [Sun, 23 May 2021 20:41:26 +0000 (22:41 +0200)]
tests/libalias: Reduce stress

Due to the new, external performance test utility, the regular test
suite can reduce the stress test to a fair amount of activity.

MFC after: 1 week

2 years agovfs: elide vnode locking when it is only needed for audit if possible
Mateusz Guzik [Sun, 23 May 2021 19:28:26 +0000 (21:28 +0200)]
vfs: elide vnode locking when it is only needed for audit if possible

2 years agorun(4): add support for DLINK DWA-130 rev F1 wireless adaptor.
Dmitry Chagin [Sun, 23 May 2021 18:31:51 +0000 (21:31 +0300)]
run(4): add support for DLINK DWA-130 rev F1 wireless adaptor.

PR: 256092
Submitted by: Francois Briere <purplefiasco at gmail.com>
MFC After: 2 weeks

2 years agoktrace: Remove vrele() at the end of ktr_writerequest()
Mark Johnston [Sun, 23 May 2021 17:20:05 +0000 (13:20 -0400)]
ktrace: Remove vrele() at the end of ktr_writerequest()

As of commit fc369a353 we no longer ref the vnode when writing a record.
Drop the corresponding vrele() call in the error case.

Fixes: fc369a353 ("ktrace: fix a race between writes and close")
Reported by: syzbot+9b96ea7a5ff8917d3fe4@syzkaller.appspotmail.com
Reported by: syzbot+6120ebbb354cd52e5107@syzkaller.appspotmail.com
Reviewed by: kib
MFC after: 6 days
Differential Revision: https://reviews.freebsd.org/D30404

2 years agolockprof: move panic check after inspecting the state
Mateusz Guzik [Sun, 23 May 2021 16:04:31 +0000 (16:04 +0000)]
lockprof: move panic check after inspecting the state

2 years agolockprof: pass lock type as an argument instead of reading the spin flag
Mateusz Guzik [Sun, 23 May 2021 15:25:42 +0000 (17:25 +0200)]
lockprof: pass lock type as an argument instead of reading the spin flag

2 years agoAdd support for Gemini Lake LPSS UARTs.
Konstantin Belousov [Sun, 23 May 2021 16:38:54 +0000 (19:38 +0300)]
Add support for Gemini Lake LPSS UARTs.

With this patch:
% dmesg | grep -i uart
uart2: <Intel Gemini Lake SIO/LPSS UART 0> mem 0xa1426000-0xa1426fff,0xa1425000-0xa1425fff irq 4 at device 24.0 on pci0
uart3: <Intel Gemini Lake SIO/LPSS UART 1> mem 0xa1424000-0xa1424fff,0xa1423000-0xa1423fff irq 5 at device 24.1 on pci0
uart4: <Intel Gemini Lake SIO/LPSS UART 2> mem 0xfea10000-0xfea10fff irq 6 at device 24.2 on pci0
uart5: <Intel Gemini Lake SIO/LPSS UART 3> mem 0xa1422000-0xa1422fff,0xa1421000-0xa1421fff irq 7 at device 24.3 on pci0

PR: 256101
Submitted by:  Daniel Ponte <amigan@gmail.com>
MFC after: 1 week

2 years agorsu(4): add ASUS WL-167G V3 to the list of supported devices.
Dmitry Chagin [Sun, 23 May 2021 15:42:29 +0000 (18:42 +0300)]
rsu(4): add ASUS WL-167G V3 to the list of supported devices.

MFC After: 2 weeks

2 years agorun(4): fix manual after d6fd321ef60d43dce9f437187c94a7de2b91ab69.
Dmitry Chagin [Sun, 23 May 2021 13:35:31 +0000 (16:35 +0300)]
run(4): fix manual after d6fd321ef60d43dce9f437187c94a7de2b91ab69.

PR: 255759
MFC After: 2 weeks

2 years agotest/libalias: Fix build errors on various platforms
Lutz Donnerhacke [Sun, 23 May 2021 12:43:00 +0000 (14:43 +0200)]
test/libalias: Fix build errors on various platforms

struct timeval has an unspecified integral type, which needs to be
canonfied before beeing usable by printf(3).

2 years agoThe old thread priority must be stored as part of the EPOCH(9) tracker.
Hans Petter Selasky [Fri, 21 May 2021 08:27:20 +0000 (10:27 +0200)]
The old thread priority must be stored as part of the EPOCH(9) tracker.

Else recursive use of EPOCH(9) may cause the wrong priority to be restored.

Bump the __FreeBSD_version due to changing the thread and epoch tracker
structure.

Differential Revision: https://reviews.freebsd.org/D30375
Reviewed by: markj@
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

2 years agoath: bump the default node queue size to 128 frames, not 64
Adrian Chadd [Sun, 23 May 2021 04:23:00 +0000 (21:23 -0700)]
ath: bump the default node queue size to 128 frames, not 64

It turns out that, silly adrian, setting it to 64 means only two
AMPDU frames of 32 subframes each.  Thus, whilst those are in-flight,
any subsequent queues frames to that node get dropped.

This ends up being pretty no bueno for performance if any receive
is also going on at that point.

Instead, set it to 128 for the time being to ensure that SOME
frames get queued in the meantime.  This results in some frames
being immediately available in the software queue for transmit
when the two existing A-MPDU frames have been completely sent,
rather than the queue remaining empty until at least one is sent.

It's not the best solution - I still think I'm scheduling receive
far more often than giving time to schedule transmit work -
but at least now I'm not starving the transmit side.

Before this, a bidirectional iperf would show receive at ~ 150mbit/sec.
but the transmit side at like 10kbit/sec.  With it set to 128 it's
now 150mbit/sec receive, and ~ 10mbit receive.  It's better than 10kbit/sec,
but still not as far as I'd like it to be.

Tested:

* AR9380/QCA934x (TL-WDR4300 AP), Macbook pro test STA + AR9380 test STA

2 years ago[ath] Handle STA + AP beacon programming without stomping over HW AP beacon programming
Adrian Chadd [Sat, 22 May 2021 23:39:16 +0000 (16:39 -0700)]
[ath] Handle STA + AP beacon programming without stomping over HW AP beacon programming

I've been using STA+AP modes at home for a couple years now
and I've been finding and fixing a lot of weird corner cases.
This is the eventual patchset I've landed on.

* Don't force beacon resync in STA mode if we're using sw beacon tracking.
  This stops a variety of stomping issues when the STA VAP is reconfigured;
  the AP hardware beacons were being stomped on!

* Use the first AP VAP to configure beacons on, rather than the first VAP.
  This prevents weird behaviour in ath_beacon_config() when the hardware
  is being reconfigured and the STA VAP was the first one created.
* Ensure the beacon interval / timing programming is within the AR9300
  HAL bounds by masking off any flags that may have been there before
  shifting the value up to 1/8 TUs rather than the 1 TU resolution the
  previous chips used.

Now I don't get weird beacon reprogramming during startup, STA state
changes and hardware recovery which showed up as HI-LARIOUS beacon
configurations and STAs that would just disconnect from the AP very
frequently.

Tested:

* AR9344/AR9380, STA and AP and STA+AP modes

2 years ago[athstats] Add a tag to listen for beacon stuff
Adrian Chadd [Wed, 31 Mar 2021 19:37:47 +0000 (12:37 -0700)]
[athstats] Add a tag to listen for beacon stuff

I'm debugging weird beacon issues and thus here we are.

2 years ago[athstats] Add some (but not all, sigh) missing statistics.
Adrian Chadd [Sat, 13 Mar 2021 22:16:37 +0000 (14:16 -0800)]
[athstats] Add some (but not all, sigh) missing statistics.

This adds a few recent statistics, including TSFOOR that I just
added to the driver.

2 years ago[ath] Add ast_tsfoor to the sysctl statistics array.
Adrian Chadd [Sat, 13 Mar 2021 22:16:17 +0000 (14:16 -0800)]
[ath] Add ast_tsfoor to the sysctl statistics array.

2 years ago[ar71xx] During reset, don't spin, just keep trying
Adrian Chadd [Mon, 19 Apr 2021 05:48:13 +0000 (22:48 -0700)]
[ar71xx] During reset, don't spin, just keep trying

I've seen this fail from time to time and just hang during reset.
Instead of it just hanging, just poke it again.  I've not seen it
fail in hundreds of test resets now.

Tested:

* AR9344 AP/STA configuration

2 years agoip_forward: Restore RFC reference
Zhenlei Huang [Sat, 22 May 2021 21:53:52 +0000 (23:53 +0200)]
ip_forward: Restore RFC reference

Add RFC reference lost in 3d846e48227e2e78c1e7b35145f57353ffda56ba

PR: 255388
Reviewed By: rgrimes, donner, karels, marcus, emaste
MFC after: 27 days
Differential Revision: https://reviews.freebsd.org/D30374

2 years agonfscl: Add hash lists for the NFSv4 opens
Rick Macklem [Sat, 22 May 2021 21:51:38 +0000 (14:51 -0700)]
nfscl: Add hash lists for the NFSv4 opens

A problem was reported via email, where a large (130000+) accumulation
of NFSv4 opens on an NFSv4 mount caused significant lock contention
on the mutex used to protect the client mount's open/lock state.
Although the root cause for the accumulation of opens was not
resolved, it is obvious that the NFSv4 client is not designed to
handle 100000+ opens efficiently.  When searching for an open,
usually for a match by file handle, a linear search of all opens
is done.

This patch adds a table of hash lists for the opens, hashed on
file handle.  This table will be used by future commits to
search for an open based on file handle more efficiently.

MFC after: 2 weeks

2 years agotests/libalias: Add perfomance test utility
Lutz Donnerhacke [Fri, 21 May 2021 14:54:24 +0000 (16:54 +0200)]
tests/libalias: Add perfomance test utility

In order to compare upcoming changes for their effectivness, measure
performance by counting opertions and the runtime of each operation
over the time.  Accumulate all tests in a single instance, so make it
complicated over the time.  If you wait long enough, you will notice
the expiry of old flows.

Reviewed by: kp (earlier version)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30379

2 years agoumtx: convert umtxq_lock to a macro
Mateusz Guzik [Sat, 22 May 2021 20:51:37 +0000 (20:51 +0000)]
umtx: convert umtxq_lock to a macro

Then LOCK_PROFILING starts reporting callers instead of the inline.

2 years agoFix limit testing after 1762f674ccb571e6 ktrace commit.
Mateusz Guzik [Sat, 22 May 2021 20:12:31 +0000 (20:12 +0000)]
Fix limit testing after 1762f674ccb571e6 ktrace commit.

The previous:

if ((uoff_t)uio->uio_offset + uio->uio_resid > lim)
signal(....);

was replaced with:

if ((uoff_t)uio->uio_offset + uio->uio_resid < lim)
return;
signal(....);

Making (uoff_t)uio->uio_offset + uio->uio_resid == lim trip over the
limit, when it did not previously.

Unbreaks running 13.0 buildworld.

2 years agoktrace: fix a race between writes and close
Konstantin Belousov [Sat, 22 May 2021 12:40:00 +0000 (15:40 +0300)]
ktrace: fix a race between writes and close

It was possible that termination of ktrace session occured during some
record write, in which case write occured after the close of the vnode.
Use ktr_io_params refcounting to avoid this situation, by taking the
reference on the structure instead of vnode.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D30400

2 years agoFix a braino in previous.
Mateusz Guzik [Sat, 22 May 2021 19:48:31 +0000 (19:48 +0000)]
Fix a braino in previous.

Instead of trying to partially ifdef out ktrace handling, define the
missing identifier to 0. Without this fix lack of ktrace in the kernel
also means there is no SIGXFSZ signal delivery.

2 years agoFix tinderbox build after 1762f674ccb571e6 ktrace commit.
Mateusz Guzik [Sat, 22 May 2021 19:37:53 +0000 (19:37 +0000)]
Fix tinderbox build after 1762f674ccb571e6 ktrace commit.

2 years agolockprof: add contested-only profiling
Mateusz Guzik [Tue, 18 May 2021 19:07:19 +0000 (21:07 +0200)]
lockprof: add contested-only profiling

This allows tracking all wait times with much smaller runtime impact.

For example when doing -j 104 buildkernel on tmpfs:

no profiling: 2921.70s user 282.72s system 6598% cpu 48.562 total
all acquires: 2926.87s user 350.53s system 6656% cpu 49.237 total
contested only: 2919.64s user 290.31s system 6583% cpu 48.756 total

2 years agolockprof: retire lock_prof_skipcount
Mateusz Guzik [Tue, 18 May 2021 19:05:42 +0000 (21:05 +0200)]
lockprof: retire lock_prof_skipcount

The implementation uses a global variable for *ALL* calls, defeating the
point of sampling in the first place. Remove it as it clearly remains
unused.

2 years agofsck_ffs(8): fix divide by zero when debug messages are enabled
Robert Wing [Thu, 20 May 2021 20:53:52 +0000 (12:53 -0800)]
fsck_ffs(8): fix divide by zero when debug messages are enabled

Only print buffer cache debug message when a cache lookup has been done.

When running `fsck_ffs -d` on a gjournal'ed filesystem, it's possible
that totalreads is greater than zero when no cache lookup has been
done - causing a divide by zero. This commit fixes the following error:

    Floating point exception (core dumped)

Reviewed by:    mckusick
Differential Revision:  https://reviews.freebsd.org/D30370

2 years agovfs: retire the now unused vnlru_free routine
Mateusz Guzik [Sat, 22 May 2021 18:42:30 +0000 (18:42 +0000)]
vfs: retire the now unused vnlru_free routine

2 years agoktls.4: Remove an obsolete statement
Mark Johnston [Sat, 22 May 2021 16:12:30 +0000 (12:12 -0400)]
ktls.4: Remove an obsolete statement

The default mb_use_ext_pgs value was toggled in commit 52cd25eb1aa.

Reviewed by: jhb
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30393

2 years agoktls.h: Guard includes behind _KERNEL
Mark Johnston [Sat, 22 May 2021 16:12:19 +0000 (12:12 -0400)]
ktls.h: Guard includes behind _KERNEL

These are not needed when including ktls.h to get sockopt definitions.

Reviewed by: gallatin, jhb
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30392

2 years agoktrace: Avoid recursion in namei()
Mark Johnston [Sat, 22 May 2021 16:07:32 +0000 (12:07 -0400)]
ktrace: Avoid recursion in namei()

sys_ktrace() calls namei(), which may call ktrnamei().  But sys_ktrace()
also calls ktrace_enter() first, so if the caller is itself being
traced, the assertion in ktrace_enter() is triggered.  And, ktrnamei()
does not check for recursion like most other ktrace ops do.

Fix the bug by simply deferring the ktrace_enter() call.

Also make the parameter to ktrnamei() const and convert to ANSI.

Reported by: syzbot+d0a4de45e58d3c08af4b@syzkaller.appspotmail.com
Reviewed by: kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30340

2 years agolibkvm: Fix build after removeal of p_tracevp
Konstantin Belousov [Sat, 22 May 2021 12:43:57 +0000 (15:43 +0300)]
libkvm: Fix build after removeal of p_tracevp

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

2 years agotcp: Handle stack switch while processing socket options
Michael Tuexen [Sat, 22 May 2021 12:35:09 +0000 (14:35 +0200)]
tcp: Handle stack switch while processing socket options

Handle the case where during socket option processing, the user
switches a stack such that processing the stack specific socket
option does not make sense anymore. Return an error in this case.

MFC after: 1 week
Reviewed by: markj
Reported by: syzbot+a6e1d91f240ad5d72cd1@syzkaller.appspotmail.com
Sponsored by: Netflix, Inc.
Differential revision: https://reviews.freebsd.org/D30395

2 years agoMove mnt_maxsymlinklen into appropriate fs mount data structures
Konstantin Belousov [Tue, 18 May 2021 01:42:03 +0000 (04:42 +0300)]
Move mnt_maxsymlinklen into appropriate fs mount data structures

Reviewed by: mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
X-MFC-Note: struct mount layout
Differential revision: https://reviews.freebsd.org/D30325

2 years agoktrace: add a kern.ktrace.filesize_limit_signal knob
Konstantin Belousov [Tue, 18 May 2021 16:05:39 +0000 (19:05 +0300)]
ktrace: add a kern.ktrace.filesize_limit_signal knob

When enabled, writes to ktrace.out that exceed the max file size limit
cause SIGXFSZ as it should be, but note that the limit is taken from
the process that initiated ktrace.   When disabled, write is blocked,
but signal is not send.

Note that in either case ktrace for the affected process is stopped.

Requested and reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D30257

2 years agoktrace: use the limit of the trace initiator for file size limit on writes
Konstantin Belousov [Fri, 14 May 2021 23:51:01 +0000 (02:51 +0300)]
ktrace: use the limit of the trace initiator for file size limit on writes

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D30257

2 years agoktrace: pack all ktrace parameters into allocated structure ktr_io_params
Konstantin Belousov [Fri, 14 May 2021 23:22:55 +0000 (02:22 +0300)]
ktrace: pack all ktrace parameters into allocated structure ktr_io_params

Ref-count the ktr_io_params structure instead of vnode/cred.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D30257

2 years agoktrace: do not stop tracing other processes if our cannot write to this vnode
Konstantin Belousov [Sat, 15 May 2021 00:10:05 +0000 (03:10 +0300)]
ktrace: do not stop tracing other processes if our cannot write to this vnode

Other processes might still be able to write, make the decision to stop
based on the per-process situation.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D30257

2 years agoaccounting: explicitly mark the exiting thread as doing accounting
Konstantin Belousov [Thu, 13 May 2021 23:48:58 +0000 (02:48 +0300)]
accounting: explicitly mark the exiting thread as doing accounting

and use the mark to stop applying file size limits on the write of
the accounting record.  This allows to remove hack to clear process
limits in acct_process(), and avoids the bug with the clearing being
ineffective because limits are also cached in the thread structure.

Reported and reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D30257

2 years agokern_descrip.c: Style
Konstantin Belousov [Fri, 14 May 2021 23:22:22 +0000 (02:22 +0300)]
kern_descrip.c: Style

Wrap too long lines.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D30257