]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agolibc/nss: Restore iterator state when doing passwd/group lookups
Mark Johnston [Thu, 21 Jan 2021 19:30:19 +0000 (14:30 -0500)]
libc/nss: Restore iterator state when doing passwd/group lookups

The getpwent(3) and getgrent(3) implementations maintain some internal
iterator state.  Interleaved calls to functions which do passwd/group
lookups using a key, such as getpwnam(3), would in some cases clobber
this state, causing a subsequent getpwent() or getgrent() call to
restart iteration from the beginning of the database or to terminate
early.  This is particularly troublesome in programming environments
where execution of green threads is interleaved within a single OS
thread.

Take care to restore any iterator state following a keyed lookup.  The
"files" provider for the passwd database was already handling this
correctly, but "compat" was not, and both providers had this problem
when accessing the group database.

PR: 252094
Submitted by: Viktor Dukhovni <ietf-dane@dukhovni.org>
MFC after: 1 month

3 years agolibc/nss tests: Fix getpw and getgr single-pass tests
Mark Johnston [Thu, 21 Jan 2021 19:30:19 +0000 (14:30 -0500)]
libc/nss tests: Fix getpw and getgr single-pass tests

Some NSS regression tests for getgrent(3) and getpwent(3) were not
testing anything because the test incorrectly requested creation of a
database snapshot.

Sponsored by: The FreeBSD Foundation
MFC after: 1 month

3 years agolibc/nss tests: Style
Mark Johnston [Thu, 21 Jan 2021 19:30:18 +0000 (14:30 -0500)]
libc/nss tests: Style

Sponsored by: The FreeBSD Foundation
MFC after: 1 month

3 years agoDefine PNP info after defining driver modules
Mark Johnston [Thu, 21 Jan 2021 19:30:18 +0000 (14:30 -0500)]
Define PNP info after defining driver modules

PNP info definitions currently have an unfortunate requirement in that
they must follow the associated module definition in the module metadata
linker set.  Otherwise devmatch can segfault while processing the linker
hints file since kldxref maintains the order in the linker set.

A number of drivers violate this requirement.  In some cases this can
cause devmatch(8) to segfault when processing the linker hints file.
Work around the problem for now simply by adjusting the drivers.

Reviewed by: imp
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D28260

3 years agonewvers.sh: avoid bare git invocation
Ed Maste [Thu, 21 Jan 2021 15:00:20 +0000 (10:00 -0500)]
newvers.sh: avoid bare git invocation

git may not be in the path, and $git_cmd includes some commandline
arguments.

Reported by: mjg
Tested by: mjg

3 years agoiflib: Fix a NULL pointer deref
Andrew Gallatin [Thu, 21 Jan 2021 14:45:15 +0000 (09:45 -0500)]
iflib: Fix a NULL pointer deref

rxd_frag_to_sd() have pf_rv parameter as NULL with the current
code. This patch fixes the NULL pointer dereference in that
case thus avoiding a possible panic.

Submitted by: rajesh1.kumar at amd.com
Reviewed by: gallatin
Differential Revision: https://reviews.freebsd.org/D28115

3 years agox86: switch vdso TSC timecounter to RDTSCP on AMD Zen CPUs
Konstantin Belousov [Thu, 21 Jan 2021 12:54:28 +0000 (14:54 +0200)]
x86: switch vdso TSC timecounter to RDTSCP on AMD Zen CPUs

Reported by: many
Tested by: gallatin, mikael, rhurlin
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

3 years agox86: switch kernel TSC timecounter to RDTSCP on AMD Zen CPUs
Konstantin Belousov [Thu, 21 Jan 2021 12:53:15 +0000 (14:53 +0200)]
x86: switch kernel TSC timecounter to RDTSCP on AMD Zen CPUs

Reported by: many
Tested by: gallatin, mikael, rhurlin
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

3 years agoelf: add some definitions for i386 and amd64 relocations
Konstantin Belousov [Sun, 17 Jan 2021 07:03:31 +0000 (09:03 +0200)]
elf: add some definitions for i386 and amd64 relocations

I believe that rtld does not need to implement them, they are mostly for
the static linker.  'Mostly' because for amd64 our kernel linker loads
object files, and amd64 relocation types could be observed.

Defines were taken from glibc sources.

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

3 years agoRemove FirstBurstLength limit for software iSCSI.
Alexander Motin [Thu, 21 Jan 2021 02:33:14 +0000 (21:33 -0500)]
Remove FirstBurstLength limit for software iSCSI.

For hardware offload solicited data may potentially be handled more
efficiently than unsolicited due to direct data placement.  Or there
can be some unsolicited write buffering limitations.  It may create
situations where FirstBurstLength limit is really useful.

Software driver though has no those factors, having to do memcopy()
any way and having no so hard limit on the temporary storage.  Same
time more active use of unsolicited transfers allows to avoid some
of Ready To Transfer (R2T) PDU round-trip times and processing.

This change effectively doubles from 64KB to 128KB the maximum size
of write command that can be transferred within one link RTT.  Tests
of (64KB, 128KB] QD1 writes mixed with simultaneous QD8 reads over
the same connection, increasing RTT, shows almost double write speed
and half latency, while we should be able to afford few megabytes of
RAM for additional buffering on a target these days.

MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

3 years agopkgbase: allow update-packages for first-run of packaging
Kyle Evans [Mon, 18 Jan 2021 20:11:58 +0000 (14:11 -0600)]
pkgbase: allow update-packages for first-run of packaging

If ${REPODIR}/${PKG_ABI} does not exist when we begin real-update-packages,
skip the comparison with the non-existent previous repository and just
finish the repo off. This allows external scripts to just assume they can
run `update-packages` rather than figuring out if they'd previously run
`packages` for this Version/Arch combo.

PKG_VERSION_FROM_DIR was added so that we could perhaps detect the three
distinct cases:

1.) If the repo has not yet been created, PKG_VERSION_FROM_DIR will be
  empty.
2.) If the repo is in some intermediate state between created and fully
  initialized, PKG_VERSION_FROM_DIR may point to the ABI directory.
3.) If the repo is fully initialized, then PKG_VERSION_FROM_DIR points to
  the latest build to compare to.

Option #2 is explicitly unhandled at the moment, but this is no different
than it was before.

Reviewed-by: manu
Differential-Revision: https://reviews.freebsd.org/D28229

3 years agovirtio_mmio: Delete a stale #if 0'ed debug print
Jessica Clarke [Thu, 21 Jan 2021 02:14:41 +0000 (02:14 +0000)]
virtio_mmio: Delete a stale #if 0'ed debug print

This was blindly moved in r360722 but the variable being printed is not
yet initialised. It's of little use and can easily be added back in the
right place if needed by someone debugging, so just delete it.

Reported by: bryanv

3 years agolinux64: Don't pass unnecessary -S and -g to objcopy
Jessica Clarke [Thu, 21 Jan 2021 01:54:52 +0000 (01:54 +0000)]
linux64: Don't pass unnecessary -S and -g to objcopy

Since we use --input-type binary these options are rather meaningless. Both
binutils and elftoolchain ignore the option in this case, but LLVM does not,
and instead strips all symbols from the output file, causing missing symbols at
run time if building with llvm-objcopy. Thus simply remove the options; the
linux module has never included them for building its VDSO (added in r283407),
but for some reason the original commit of linux64 (r283424) added them.

These should however eventually be changed to use template assembly files as is
now done for firmware and MFS_IMAGE.

Reviewed by: emaste, trasz
Differential Revision: https://reviews.freebsd.org/D27740

3 years agoRename i386's Linux ELF to Linux ELF32
Jessica Clarke [Thu, 21 Jan 2021 01:54:12 +0000 (01:54 +0000)]
Rename i386's Linux ELF to Linux ELF32

This is what amd64 calls the i386 Linux ABI in order to distinguish it
from the amd64 Linux ABI, and matches the nomenclature used for the
FreeBSD ABIs where they always have the size suffix in the name.

Reviewed by: trasz
Differential Revision: https://reviews.freebsd.org/D27647

3 years agoBuild VirtIO modules on all architectures
Jessica Clarke [Thu, 21 Jan 2021 01:21:35 +0000 (01:21 +0000)]
Build VirtIO modules on all architectures

Currently only amd64, i386 and powerpc build VirtIO modules, yet all other
architectures have at least one kernel configuration that includes the
transport drivers, and so they lack drivers for all the devices they don't
statically compile into the kernel. Instead, enable the build everywhere so all
architectures have the full set of device drivers available.

Reviewed by: bryanv (earlier version), imp (earlier version)
Differential Revision: https://reviews.freebsd.org/D28058

3 years agovirtio: Reduce boilerplate for device driver module definitions
Jessica Clarke [Thu, 21 Jan 2021 01:07:23 +0000 (01:07 +0000)]
virtio: Reduce boilerplate for device driver module definitions

Rather than have every device register itself for both virtio_pci and
virtio_mmio, provide a VIRTIO_DRIVER_MODULE wrapper to declare both,
merge VIRTIO_SIMPLE_PNPTABLE with VIRTIO_SIMPLE_PNPINFO and make the
latter register for both buses. This also has the benefit of abstracting
away the available transports and their names.

Reviewed by: bryanv
Differential Revision: https://reviews.freebsd.org/D28073

3 years agovirtio_mmio: Fix V1 device probing spec conformance (section 4.2.3.1.1)
Jessica Clarke [Thu, 21 Jan 2021 01:03:44 +0000 (01:03 +0000)]
virtio_mmio: Fix V1 device probing spec conformance (section 4.2.3.1.1)

We must check MagicValue not just Version before anything else, and then
we must check DeviceID and immediately abort if zero (and this must not
be an error).

Do all this when probing rather than at the start of attaching as that's
where this belongs, and provides a clear boundary between the device
detection and device initialisation parts of the specified driver
initialisation process. This also means we don't create empty device
instances for placeholder devices, reducing clutter on systems that
pre-allocate a large number, such as QEMU's AArch64 virt machine (which
provides 32).

Reviewed by: bryanv
Differential Revision: https://reviews.freebsd.org/D28070

3 years agovirtio_mmio: Fix a style(9) issue
Jessica Clarke [Thu, 21 Jan 2021 01:02:30 +0000 (01:02 +0000)]
virtio_mmio: Fix a style(9) issue

3 years agoTidy some crypto-related lines in sys/conf/files.
John Baldwin [Thu, 21 Jan 2021 00:39:04 +0000 (16:39 -0800)]
Tidy some crypto-related lines in sys/conf/files.

Reviewed by: cem (earlier version)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D27835

3 years agoRestructure the crypto(7) manpage and add authentication algorithms.
John Baldwin [Thu, 21 Jan 2021 00:37:55 +0000 (16:37 -0800)]
Restructure the crypto(7) manpage and add authentication algorithms.

Add separate sections for authentication algorithms, block ciphers,
stream ciphers, and AEAD algorithms.  Describe properties commmon to
algorithms in each section to avoid duplication.

Use flat tables to list algorithm properties rather than nested
tables.

List implemented authentication algorithms.

Reviewed by: gbe (manpages)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D27833

3 years agoSimplify dynamic ipfilter sysctls.
John Baldwin [Thu, 21 Jan 2021 00:33:34 +0000 (16:33 -0800)]
Simplify dynamic ipfilter sysctls.

Pass the structure offset in arg2 instead of arg1.  This avoids
having to undo the pointer arithmetic on arg1.  Instead arg2 can
be used directly as an offset relative to the desired structure.

Reviewed by: cy
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D27961

3 years agojail: Use refcount(9) for prison references.
Jamie Gritton [Wed, 20 Jan 2021 23:08:27 +0000 (15:08 -0800)]
jail: Use refcount(9) for prison references.

Use refcount(9) for both pr_ref and pr_uref in struct prison.  This
allows prisons to held and freed without requiring the prison mutex.
An exception to this is that dropping the last reference will still
lock the prison, to keep the guarantee that a locked prison remains
valid and alive (provided it was at the time it was locked).

Among other things, this honors the promise made in a comment in
crcopy(9), that it will not block, which hasn't been true for two
decades.

3 years agodevinfo sysctl handler: Do not write zero-length strings in to sbuf twice
Vladimir Kondratyev [Wed, 20 Jan 2021 23:06:16 +0000 (02:06 +0300)]
devinfo sysctl handler: Do not write zero-length strings in to sbuf twice

This fixes missing PnPinfo and location strings in devinfo(8) output
for devices with no attached drivers.

3 years agopms: handle maximum size IO with any alignment
Ryan Libby [Wed, 20 Jan 2021 21:59:49 +0000 (13:59 -0800)]
pms: handle maximum size IO with any alignment

Define the maximum numbers of segments to allow for non-page alignment
at the beginning and end of a maxphys size transfer.  Also set
ccb_pathinq.maxio consistent with maxphys.

Reviewed by: imp
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D28043

3 years agopms: quiet -Wunused-variable
Ryan Libby [Wed, 20 Jan 2021 21:59:49 +0000 (13:59 -0800)]
pms: quiet -Wunused-variable

Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D27994

3 years agoevdev: Make variable-size ioctls return actual length of copyouted data
Vladimir Kondratyev [Wed, 20 Jan 2021 20:10:07 +0000 (23:10 +0300)]
evdev: Make variable-size ioctls return actual length of copyouted data

on success instead of 0 to match Linux.
Imprivata binary depends on this.

Submitted by: Shunchao Hu <ankohuu_outlook.com>
Reviewed by: wulf
Differential revision: https://reviews.freebsd.org/D28218

3 years agohmt: Allow I2C sampling mode support to be compiled out.
Vladimir Kondratyev [Wed, 20 Jan 2021 20:10:07 +0000 (23:10 +0300)]
hmt: Allow I2C sampling mode support to be compiled out.

3 years agohms: Workaround idle mouse drift in I2C sampling mode.
Vladimir Kondratyev [Wed, 20 Jan 2021 20:10:07 +0000 (23:10 +0300)]
hms: Workaround idle mouse drift in I2C sampling mode.

Many I2C "compatibility" mouse devices found on touchpads continue to
return last report data in sampling mode after touch has been ended.
That results in cursor drift.  Filter out such a reports with comparing
content of current report with content of previous one.

Reported by: many
Tested by: omatsuda, gllb (github.com)
Obtained from: sysutils/iichid

3 years agohconf(4): Do not fetch report before writing new usage values back.
Vladimir Kondratyev [Wed, 20 Jan 2021 20:10:06 +0000 (23:10 +0300)]
hconf(4): Do not fetch report before writing new usage values back.

There is a report that reading of surface/button switch feature report
causes SYN1B7D touchpad malfunction.  As specs does not require it to
be readable assume that report usages have default value on attach and
last written value during operation. Do not apply default usage values
on attachment and resume.
While here fix manpage typos and add avg@ to copyright header.

Reported by: Jakob Alvermark <jakob_AT_alvermark_DOT_net>
Reviewed by: avg
Differential revision: https://reviews.freebsd.org/D28196

3 years agoHandle arm64 undefied instructions on msr exceptions
Andrew Turner [Wed, 20 Jan 2021 09:56:47 +0000 (09:56 +0000)]
Handle arm64 undefied instructions on msr exceptions

When userspace tries to access a special register that it doesn't have
access to the kernel receives an exception. On most cores this exception
has been observed to be the undefined instruction exception, however on
the Apple M1 under a QEMU based hypervisor it can be the MSR exception.

Handle this second case by also running the undefined exception handler
on these exceptions.

Sponsored by: Innovate UK

3 years agoReuse the amd64 loader relocation code on arm64
Andrew Turner [Sun, 17 Jan 2021 18:11:11 +0000 (18:11 +0000)]
Reuse the amd64 loader relocation code on arm64

There is no need to keep multiple copies of the relocation code. The
amd64 code works on arm64 with a few small changes to relocation types.

Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D28213

3 years agocat: style nits
Mariusz Zaborski [Wed, 20 Jan 2021 17:46:26 +0000 (18:46 +0100)]
cat: style nits

Pointed out by: jhb

3 years agorelease: fix PORT variable
Glen Barber [Wed, 20 Jan 2021 17:15:13 +0000 (12:15 -0500)]
release: fix PORT variable

Reported by: Yasuhiro Kimura (yasu xat utahime dot org)
Sponsored by: Rubicon Communications, LLC ("Netgate")

3 years agoaio: micro-optimize the lio_opcode assignments
Alan Somers [Sun, 3 Jan 2021 04:25:05 +0000 (21:25 -0700)]
aio: micro-optimize the lio_opcode assignments

This allows slightly more efficient opcode testing in-kernel.  It is
transparent to userland, except to applications that sneakily submit
aio fsync or aio mlock operations via lio_listio, which has never been
documented, requires the use of deliberately undefined constants
(LIO_SYNC and LIO_MLOCK), and is arguably a bug.

Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D27942

3 years agoifconfig: add vlanproto "qiniq" as an alias for "802.1ad"
Allan Jude [Tue, 19 Jan 2021 23:22:07 +0000 (23:22 +0000)]
ifconfig: add vlanproto "qiniq" as an alias for "802.1ad"

QinQ is better known by this name, so accept it as an alias

Reported-by: Mike Geiger
Reviewed-by: melifaro, hselasky, rpokala
MFC-with: 366917
Sponsored-by: Klara Inc.
Differential-Revision: https://reviews.freebsd.org/D28245

3 years agowpa_supplicant uses PF_ROUTE to return the routing table in order to
Cy Schubert [Wed, 20 Jan 2021 15:20:22 +0000 (07:20 -0800)]
wpa_supplicant uses PF_ROUTE to return the routing table in order to
determine the length of the routing table buffer. As of 81728a538d24
wpa_supplicant is started before the routing table has been populated
resulting in the length of zero to be returned. This causes
wpa_supplicant to loop endlessly. (The workaround is to kill and restart
wpa_supplicant as by the time it is restarted the routing table is
populated.)

(Personally, I was not able to reproduce this unless wlan0 was a member of
lagg0. However, others experienced this problem on standalone wlan0.)

PR: 252844
Submitted by: shu <ankohuu _ outlook.com>
Reported by: shu <ankohuu _ outlook.com>
Reviewed by: cy
X-MFC with: 81728a538d24f483d0986850fa3f51d5d84d8f26
Differential Revision: https://reviews.freebsd.org/D28249

3 years agoRegenerate src.conf(5) after 7c5a624afae4
Kyle Evans [Wed, 20 Jan 2021 14:29:16 +0000 (08:29 -0600)]
Regenerate src.conf(5) after 7c5a624afae4

WITHOUT_CRYPT no longer implies WITHOUT_WIRELESS after the aforementioned
commit.

3 years agoAddress panic with PRR due to missed initialization of recover_fs
Richard Scheffenegger [Wed, 20 Jan 2021 11:06:34 +0000 (12:06 +0100)]
Address panic with PRR due to missed initialization of recover_fs

Summary:
When using the base stack in conjunction with RACK, it appears that
infrequently, ++tp->t_dupacks is instantly larger than tcprexmtthresh.

This leaves the recover flightsize (sackhint.recover_fs) uninitialized,
leading to a div/0 panic.

Address this by properly initializing the variable just prior to first
use, if it is not properly initialized.

In order to prevent stale information from a prior recovery to
negatively impact the PRR calculations in this event, also clear
recover_fs once loss recovery is finished.

Finally, improve the readability of the initialization of recover_fs
when t_dupacks == tcprexmtthresh by adjusting the indentation and
using the max(1, snd_nxt - snd_una) macro.

Reviewers: rrs, kbowling, tuexen, jtl, #transport, gnn!, jmg, manu, #manpages

Reviewed By: rrs, kbowling, #transport

Subscribers: bdrewery, andrew, rpokala, ae, emaste, bz, bcran, #linuxkpi, imp, melifaro

Differential Revision: https://reviews.freebsd.org/D28114

3 years agolibc: Fix null pointer arithmetic warning in mergesort
Alex Richardson [Wed, 20 Jan 2021 09:56:01 +0000 (09:56 +0000)]
libc: Fix null pointer arithmetic warning in mergesort

This file has other questionable code and "optimizations" (such as copying
one int at a time) that are probably no longer useful, so it might make
sense to replace it with a different implementation at some point.

Reviewed By: jhb
Differential Revision: https://reviews.freebsd.org/D28134

3 years agoEmit uprintf() output for initproc if there is no controlling terminal
Alex Richardson [Wed, 20 Jan 2021 09:54:46 +0000 (09:54 +0000)]
Emit uprintf() output for initproc if there is no controlling terminal

This patch helped me debug why /sbin/init was not being loaded after
making changes to the image activator in CheriBSD.

Reviewed By: jhb (earlier version), kib
Differential Revision: https://reviews.freebsd.org/D28121

3 years agoMinor simplification of MK_PMC case in usr.sbin/Makefile
Alex Richardson [Wed, 20 Jan 2021 09:52:58 +0000 (09:52 +0000)]
Minor simplification of MK_PMC case in usr.sbin/Makefile

MK_PMC is already guarded by MK_CXX in src.opts.mk, so we can actually
merge it with the following SUBDIR statement after c1a3d7f20696.

Suggested By: jrtc27

3 years agonewvers.sh: add support for gitup(1)
Michael Osipov [Tue, 5 Jan 2021 10:48:39 +0000 (11:48 +0100)]
newvers.sh: add support for gitup(1)

gitup writes a .gituprevision file into the shallow clone directory. Read that
file and print commit information only.

Submitted by: Michael Osipov <michael.osipov@siemens.com>
Pull Request: https://github.com/freebsd/freebsd-src/pull/449

While here, drop the redundant branch name from the git output and don't
count commits in shallow clones.

Reported by: Michael Osipov <michael.osipov@siemens.com>
MFC after: 2 weeks

3 years agoRemove the unnecessary space before the colon
Mateusz Piotrowski [Wed, 20 Jan 2021 08:46:15 +0000 (09:46 +0100)]
Remove the unnecessary space before the colon

MFC after: 3 days

3 years agocache: augment sdt probe in cache_fplookup_dot
Mateusz Guzik [Wed, 20 Jan 2021 07:23:14 +0000 (07:23 +0000)]
cache: augment sdt probe in cache_fplookup_dot

Same as 6d386b4c ("cache: save a branch in cache_fplookup_next")

3 years agocache: whitespace nit in cache_fplookup_modifying
Mateusz Guzik [Wed, 20 Jan 2021 07:22:04 +0000 (07:22 +0000)]
cache: whitespace nit in cache_fplookup_modifying

3 years agoktls: Improve handling of the bind_threads tunable a bit
Mark Johnston [Wed, 20 Jan 2021 02:32:33 +0000 (21:32 -0500)]
ktls: Improve handling of the bind_threads tunable a bit

- Only check for empty domains if we actually tried to configure domain
  affinity in the first place.  Otherwise setting bind_threads=1 will
  always cause the sysctl value to be reported as zero.  This is
  harmless since the threads end up being bound, but it's confusing.
- Try to improve the sysctl description a bit.

Reviewed by: gallatin, jhb
Submitted by: Klara, Inc.
Sponsored by: Ampere Computing
Differential Revision: https://reviews.freebsd.org/D28161

3 years agoopencrypto: Add comments describing the new crypto_session layout
Mark Johnston [Wed, 20 Jan 2021 02:32:33 +0000 (21:32 -0500)]
opencrypto: Add comments describing the new crypto_session layout

Requested by: rpokala

3 years agoarm64, riscv: Set VM_KMEM_SIZE_SCALE to 1
Mark Johnston [Wed, 20 Jan 2021 01:34:36 +0000 (20:34 -0500)]
arm64, riscv: Set VM_KMEM_SIZE_SCALE to 1

This setting limits the amount of memory that can be allocated to UMA.
On systems with a direct map and ample KVA, however, there is no reason
for VM_KMEM_SIZE_SCALE to be larger than 1.  This appears to have been
inherited from the 32-bit ARM platform definitions.

Also remove VM_KMEM_SIZE_MIN, which is not needed when
VM_KMEM_SIZE_SCALE is defined to be 1.[*]

Reviewed by: alc, kp, kib
Reported by: alc [*]
Submitted by: Klara, Inc.
Sponsored by: Ampere Computing
Differential Revision: https://reviews.freebsd.org/D28225

3 years agoarm64: Stop setting VM_BCACHE_SIZE_MAX
Mark Johnston [Wed, 20 Jan 2021 01:34:35 +0000 (20:34 -0500)]
arm64: Stop setting VM_BCACHE_SIZE_MAX

This setting places a (small) limit on the size of the buffer cache,
constraining UFS performance on large servers.  The setting comes from
the initial arm64 implementation and appears to be vestigal.  Remove it.

Reviewed by: kib
Submitted by: Klara, Inc.
Sponsored by: Ampere Computing
Differential Revision: https://reviews.freebsd.org/D28162

3 years agoopencrypto: Fix assignment of crypto completions to worker threads
Mark Johnston [Wed, 20 Jan 2021 01:34:35 +0000 (20:34 -0500)]
opencrypto: Fix assignment of crypto completions to worker threads

Since r336439 we simply take the session pointer value mod the number of
worker threads (ncpu by default).  On small systems this ends up
funneling all completion work through a single thread, which becomes a
bottleneck when processing IPSec traffic using hardware crypto drivers.
(Software drivers such as aesni(4) are unaffected since they invoke
completion handlers synchonously.)

Instead, maintain an incrementing counter with a unique value per
session, and use that to distribute work to completion threads.

Reviewed by: cem, jhb
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D28159

3 years agoopencrypto: Embed the driver softc in the session structure
Mark Johnston [Wed, 20 Jan 2021 01:34:35 +0000 (20:34 -0500)]
opencrypto: Embed the driver softc in the session structure

Store the driver softc below the fields owned by opencrypto.  This is
a bit simpler and saves a pointer dereference when fetching the driver
softc when processing a request.

Get rid of the crypto session UMA zone.  Session allocations are
frequent or performance-critical enough to warrant a dedicated zone.

No functional change intended.

Reviewed by: cem, jhb
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D28158

3 years agoAdd a new FreeBSD/arm64 kernel configuration, GENERIC-MMCCAM-NODEBUG,
Robert Watson [Sat, 16 Jan 2021 12:42:26 +0000 (12:42 +0000)]
Add a new FreeBSD/arm64 kernel configuration, GENERIC-MMCCAM-NODEBUG,
which is the same as GENERIC-MMCCAM but using a nodebug baseline.

Reviewed by: andrew, br (earlier version), jrtc27 (earlier version)
Differential revision: https://reviews.freebsd.org/D28091

3 years agoadd missing .Xr..
John-Mark Gurney [Tue, 19 Jan 2021 22:18:55 +0000 (14:18 -0800)]
add missing .Xr..

3 years agoRemove remaining uses of ${COMPILER_FEATURES:Mc++11}
Alex Richardson [Tue, 19 Jan 2021 15:05:43 +0000 (15:05 +0000)]
Remove remaining uses of ${COMPILER_FEATURES:Mc++11}

All supported compilers have C++11 support so these checks can be replaced
with MK_CXX guards.
See also https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252759

PR: 252759
Reviewed By: emaste
Differential Revision: https://reviews.freebsd.org/D28234

3 years agoFix macro-redefined warning in gnu/diff for fputc_unlocked
Alex Richardson [Tue, 19 Jan 2021 11:35:15 +0000 (11:35 +0000)]
Fix macro-redefined warning in gnu/diff for fputc_unlocked

While updating config.h to set HAVE_DECL_FPUTC_UNLOCKED to 1 also update
the other macros that are defined in stdio.h.

3 years agogetopt: Fix conversion from string-literal to non-const char *
Alex Richardson [Tue, 19 Jan 2021 11:35:04 +0000 (11:35 +0000)]
getopt: Fix conversion from string-literal to non-const char *

Define a non-const static char EMSG[] = "" to avoid having to add
__DECONST() to all uses of EMSG. Also make current_dash a const char *
to fix this warning.

3 years agoFix make includes path to nvpair.h
Alex Richardson [Tue, 19 Jan 2021 11:40:05 +0000 (11:40 +0000)]
Fix make includes path to nvpair.h

Fixes a typo introduced in 9e5787d2284e187abb5b654d924394a65772e004

3 years agoinclude: Delete stale symlinks using find(1) instead of a shell loop.
Alex Richardson [Tue, 19 Jan 2021 11:35:12 +0000 (11:35 +0000)]
include: Delete stale symlinks using find(1) instead of a shell loop.

This reduces the number of execve() syscalls during make includes by 88.

Reviewed By: jhb
Differential Revision: https://reviews.freebsd.org/D27622

3 years agoRequire uint32_t alignment for ipfw_insn
Alex Richardson [Tue, 19 Jan 2021 11:32:33 +0000 (11:32 +0000)]
Require uint32_t alignment for ipfw_insn

There are many casts of this struct to uint32_t, so we also need to ensure
that it is sufficiently aligned to safely perform this cast on architectures
that don't allow unaligned accesses. This fixes lots of -Wcast-align warnings.

Reviewed By: ae
Differential Revision: https://reviews.freebsd.org/D27879

3 years agolibalias: Fix remaining compiler warnings
Alex Richardson [Tue, 19 Jan 2021 11:32:32 +0000 (11:32 +0000)]
libalias: Fix remaining compiler warnings

This fixes some sign-compare warnings and adds a missing static to a
variable declaration.

Differential Revision: https://reviews.freebsd.org/D27883

3 years agolibalias: Fix -Wcast-align compiler warnings
Alex Richardson [Tue, 19 Jan 2021 11:32:32 +0000 (11:32 +0000)]
libalias: Fix -Wcast-align compiler warnings

This fixes -Wcast-align warnings caused by the underaligned `struct ip`.
This also silences them in the public functions by changing the function
signature from char * to void *. This is source and binary compatible and
avoids the -Wcast-align warning.

Reviewed By: ae, gbe (manpages)
Differential Revision: https://reviews.freebsd.org/D27882

3 years agoloader: comment on rgb_to_color_index()
Toomas Soome [Wed, 13 Jan 2021 16:38:08 +0000 (18:38 +0200)]
loader: comment on rgb_to_color_index()

Add small comment block about rgb_to_color_index().

3 years agoloader: handle malloc failures in vbe_init, use consistent naming
Toomas Soome [Mon, 18 Jan 2021 08:52:08 +0000 (10:52 +0200)]
loader: handle malloc failures in vbe_init, use consistent naming

Handle malloc failures in vbe_init().

If it should so happen and we do get malloc failure in vbe_init(),
use original mode list.

Replace nitems with nentries to have naming consistency and avoid
confusion with nitems() macro.

Reported by: yuripv, rpokala

3 years agoConvert unmapped mbufs before computing checksums in IPsec.
John Baldwin [Tue, 19 Jan 2021 19:51:27 +0000 (11:51 -0800)]
Convert unmapped mbufs before computing checksums in IPsec.

This is similar to the logic used in ip_output() to convert mbufs
prior to computing checksums.  Unmapped mbufs can be sent when using
sendfile() over IPsec or using KTLS over IPsec.

Reported by: Sony Arpita Das @ Chelsio QA
Reviewed by: np
Sponsored by: Chelsio
Differential Revision: https://reviews.freebsd.org/D28187

3 years agoarm64: Clear FPU flags in the pcb in cpu_copy_thread().
John Baldwin [Fri, 8 Jan 2021 22:56:54 +0000 (14:56 -0800)]
arm64: Clear FPU flags in the pcb in cpu_copy_thread().

New threads start off with clean FPU state instead of inheriting state
from the parent thread.

PR: 247945
Sponsored by: Netflix

3 years agoarm64: Trim duplicate code from cpu_fork_kthread_handler().
John Baldwin [Fri, 8 Jan 2021 22:56:22 +0000 (14:56 -0800)]
arm64: Trim duplicate code from cpu_fork_kthread_handler().

cpu_fork_kthread_handler() is always called after either cpu_fork() or
cpu_copy_thread().  The arm64 version was duplicating some of the work
already done by both of those functions.

Sponsored by: Netflix

3 years agorelease.sh: bump Copyright year after previous commit
Glen Barber [Tue, 19 Jan 2021 18:53:29 +0000 (13:53 -0500)]
release.sh: bump Copyright year after previous commit

Sponsored by: Rubicon Communications, LLC (netgate.com)

3 years agorelease: Add workaround to use SVN for ports
Glen Barber [Tue, 19 Jan 2021 18:38:33 +0000 (13:38 -0500)]
release: Add workaround to use SVN for ports

The ports tree is scheduled to be converted from Subversion to Git
after the currently-scheduled 13.0-RELEASE, so the source of truth
will be Subversion for the ports tree.

Implement a hack specifically for this case.

Sponsored by: Rubicon Communications, LLC (netgate.com)

3 years agoixl: Permit 802.1ad frames to pass though the chip
Lutz Donnerhacke [Tue, 19 Jan 2021 14:56:16 +0000 (15:56 +0100)]
ixl: Permit 802.1ad frames to pass though the chip

This patch is a quick hack to change the internal Ethertype used
within the chip.  All frames with this type are dropped silently.
This patch allows you to overwrite the factory default 0x88a8, which
is used by IEEE 802.1ad VLAN stacking.

Reviewed by: kp, philip, brueffer
Approved by: kp (mentor)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D24179

3 years agoRELNOTES: correct sense and name for allow_wx sysctl
Ed Maste [Tue, 19 Jan 2021 13:53:07 +0000 (08:53 -0500)]
RELNOTES: correct sense and name for allow_wx sysctl

The sysctl is kern.elf64.allow_wx and defaults to 1, allow W+X mappings.

Reported by: alc

3 years agohtu21: driver for HTU21D I2C temperature and humidity sensor
Andriy Gapon [Tue, 19 Jan 2021 12:57:24 +0000 (14:57 +0200)]
htu21: driver for HTU21D I2C temperature and humidity sensor

MFC after: 2 weeks
Relnotes: perhaps

3 years agolockmgr: fix upgrade
Mateusz Guzik [Thu, 7 Jan 2021 06:45:49 +0000 (07:45 +0100)]
lockmgr: fix upgrade

TRYUPGRADE requests kept failing when they should not have due to wrong
macro used to count readers.

Fixes: f6b091fbbd77cbb0 ("lockmgr: rewrite upgrade to stop always dropping the lock")
Noted by: asomers
Differential Revision: https://reviews.freebsd.org/D27947

3 years agoarm64 busdma: Fix loading of small bounced buffers.
Michal Meloun [Wed, 13 Jan 2021 12:50:54 +0000 (13:50 +0100)]
arm64 busdma: Fix loading of small bounced buffers.

 - Don't oversize the buffer fragment. PAGE_SIZE - (curaddr & PAGE_MASK)
   may be greater than the total length of the buffer.
 - Don't use roundup2(len, alignment) to calculate the buffer fragment
   size. The length of current bounced fragment is not subject to alignment
   restriction, and next fragment should start at the page boundary.

Tested by: bz, s199p.wa1k9r@gmail.com

3 years agoRemove dependency on files in /usr/bin
Stefan Eßer [Tue, 19 Jan 2021 11:46:52 +0000 (12:46 +0100)]
Remove dependency on files in /usr/bin

In order to reduce the pre-requisites of this file, implement the
pattern matching and creation of a temporary test directory without
use of grep respectively mktemp.

The new version makes it possible to provide a writable /tmp in any
case and independently of other local or remote file systems (except /
and /dev) being mounted.

The use of "dd if=/dev/random" has the same dependency on /dev/random
being operational as the previous version that used "mktemp". If this
is found to be an issue on platforms that do not have gathered
sufficient entropy at the time when this scriot is run, I suggest to
replace the "dd" command with "ps lauxww" to get a somewhat random
test directory name.

Approved by: rgrimes, glebius, cy
MFC after: 4 weeks
Differential Revision: https://reviews.freebsd.org/D28209

3 years agolinux: map EBUSY returned by ptrace into ESRCH
Edward Tomasz Napierala [Fri, 15 Jan 2021 17:11:41 +0000 (17:11 +0000)]
linux: map EBUSY returned by ptrace into ESRCH

The ptrace(2) Linux man page claims the syscall returns ESRCH,
if the tracee is not stopped; the native ptrace(2) returns EBUSY.

Sponsored by: The FreeBSD Foundation

3 years agolinux: fix PTRACE_POKEDATA and PTRACE_POKETEXT.
Edward Tomasz Napierala [Fri, 15 Jan 2021 16:57:24 +0000 (16:57 +0000)]
linux: fix PTRACE_POKEDATA and PTRACE_POKETEXT.

Sponsored by: The FreeBSD Foundation

3 years agolinux: remove spurious newline.
Edward Tomasz Napierala [Thu, 14 Jan 2021 22:48:56 +0000 (22:48 +0000)]
linux: remove spurious newline.

Sponsored by: The FreeBSD Foundation

3 years agocache: fix some typos
Mateusz Guzik [Tue, 19 Jan 2021 09:17:14 +0000 (10:17 +0100)]
cache: fix some typos

3 years agocache: drop-write only var from cache_fplookup_preparse
Mateusz Guzik [Tue, 19 Jan 2021 09:13:30 +0000 (10:13 +0100)]
cache: drop-write only var from cache_fplookup_preparse

3 years agocache: save a branch in cache_fplookup_next
Mateusz Guzik [Tue, 19 Jan 2021 09:08:24 +0000 (10:08 +0100)]
cache: save a branch in cache_fplookup_next

Previously the code would branch on top find out whether it should
branch on SDT probe and bumping the numposhits counter, depending
on cache_fplookup_cross_mount.

Arguably it should be done regardless of what said function returns.

3 years agoSupport COM3 and COM4 serial ports.
Peter Grehan [Tue, 19 Jan 2021 17:30:22 +0000 (03:30 +1000)]
Support COM3 and COM4 serial ports.

Submitted by: Jan Poctavek <janci@binaryparadise.com>, otis
Reviewed by: grehan (bhyve), imp, 0mp (manpages)
Differential Revision: https://reviews.freebsd.org/D28207

3 years agovirtio: Handle possible failure of virtio_finalize_features()
Bryan Venteicher [Tue, 19 Jan 2021 04:55:26 +0000 (04:55 +0000)]
virtio: Handle possible failure of virtio_finalize_features()

Try to standardize how drivers negotiate feature and the
function names

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27930

3 years agoif_vtnet: Add counter for received host LRO
Bryan Venteicher [Tue, 19 Jan 2021 04:55:26 +0000 (04:55 +0000)]
if_vtnet: Add counter for received host LRO

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27928

3 years agoif_vtnet: Misc Tx path cleanup
Bryan Venteicher [Tue, 19 Jan 2021 04:55:26 +0000 (04:55 +0000)]
if_vtnet: Misc Tx path cleanup

  - Add and fix a few error path counters
  - Improve sysctl descriptions
  - Use flags consistently to determine IPv4 vs IPv6

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27926

3 years agoif_vtnet: Set lro_nsegs for host LRO packets
Bryan Venteicher [Tue, 19 Jan 2021 04:55:25 +0000 (04:55 +0000)]
if_vtnet: Set lro_nsegs for host LRO packets

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27933

3 years agoif_vtnet: Resort softc fields
Bryan Venteicher [Tue, 19 Jan 2021 04:55:25 +0000 (04:55 +0000)]
if_vtnet: Resort softc fields

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27925

3 years agoif_vtnet: Remove unnecessary TUNABLE_INTs because of CTLFLAG_RDTUN
Bryan Venteicher [Tue, 19 Jan 2021 04:55:25 +0000 (04:55 +0000)]
if_vtnet: Remove unnecessary TUNABLE_INTs because of CTLFLAG_RDTUN

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27923

3 years agoif_vtnet: Schedule Rx task if pending items when enabling interrupt
Bryan Venteicher [Tue, 19 Jan 2021 04:55:25 +0000 (04:55 +0000)]
if_vtnet: Schedule Rx task if pending items when enabling interrupt

Prior to V1, the driver would enable interrupts and then notify the
host that DRIVER_OK. Since for V1, DRIVER_OK needs to be set before
notifying the virtqueues, there may be items in the queues waiting
to be processed by the time interrupts are enabled.

This fixes a bug where the Rx queue would appear stuck, only being
usable after an interface down/up cycle.

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27922

3 years agoif_vtnet: Disable F_MTU feature if MTU is invalid
Bryan Venteicher [Tue, 19 Jan 2021 04:55:25 +0000 (04:55 +0000)]
if_vtnet: Disable F_MTU feature if MTU is invalid

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27931

3 years agoif_vtnet: Limit allocations of unused virtqueues
Bryan Venteicher [Tue, 19 Jan 2021 04:55:25 +0000 (04:55 +0000)]
if_vtnet: Limit allocations of unused virtqueues

For multiqueue, we may use fewer than the provided maximum number of
queues. Try to limit allocations of the unused queues: no interrupts,
no indirect descriptors, and no taskqueues.

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27921

3 years agoif_vtnet: Rework 4be723f63 max multiqueue pairs check
Bryan Venteicher [Tue, 19 Jan 2021 04:55:25 +0000 (04:55 +0000)]
if_vtnet: Rework 4be723f63 max multiqueue pairs check

Verify the max_virtqueue_pairs is within the range allowed by
the spec.

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27920

3 years agoif_vtnet: Add support for software LRO
Bryan Venteicher [Tue, 19 Jan 2021 04:55:25 +0000 (04:55 +0000)]
if_vtnet: Add support for software LRO

This useful when running on hosts that support checksum offloading
but not the GUEST_TSO (LRO) feature. Or potentially, some GRO-like
support when doing forwarding.

Only enable SW LRO when the host LRO is not available since both
tends to be harmful, and difficult to enable/disable selectively
with only a single IFCAP_LRO flag.

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27919

3 years agoif_vtnet: Set the interface max TSO values
Bryan Venteicher [Tue, 19 Jan 2021 04:55:25 +0000 (04:55 +0000)]
if_vtnet: Set the interface max TSO values

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27917

3 years agoif_vtnet: Add support for CTRL_GUEST_OFFLOADS feature
Bryan Venteicher [Tue, 19 Jan 2021 04:55:25 +0000 (04:55 +0000)]
if_vtnet: Add support for CTRL_GUEST_OFFLOADS feature

This allows the Rx checksum and LRO to be modified without a full
reinit of the device.

Remove IFCAP_RXCSUM_IPV6 from the interface capabilities since in
VirtIO Rx checksums are just enabled or disabled for all protocols.

Properly update IFCAP_LRO if LRO is becomes disabled when Rx
checksums are disabled.

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27916

3 years agoif_vtnet: Move ioctl handlers into separate functions
Bryan Venteicher [Tue, 19 Jan 2021 04:55:25 +0000 (04:55 +0000)]
if_vtnet: Move ioctl handlers into separate functions

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27914 https://reviews.freebsd.org/D27915

3 years agoif_vtnet: Cleanup the reinit process
Bryan Venteicher [Tue, 19 Jan 2021 04:55:25 +0000 (04:55 +0000)]
if_vtnet: Cleanup the reinit process

In modern VirtIO, the virtqueues cannot be notified before setting
DRIVER_OK status.

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27932

3 years agoif_vtnet: Cleanup the interface setup methods
Bryan Venteicher [Tue, 19 Jan 2021 04:55:25 +0000 (04:55 +0000)]
if_vtnet: Cleanup the interface setup methods

Defer the ether_ifattach until the interface capabilities
are configured

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27913

3 years agoif_vtnet: Only set IFCAP_JUMBO_MTU when jumbo MTU is supported
Bryan Venteicher [Tue, 19 Jan 2021 04:55:24 +0000 (04:55 +0000)]
if_vtnet: Only set IFCAP_JUMBO_MTU when jumbo MTU is supported

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27912

3 years agoif_vtnet: Move the Tx interrupt threshold into the Txq structure
Bryan Venteicher [Tue, 19 Jan 2021 04:55:24 +0000 (04:55 +0000)]
if_vtnet: Move the Tx interrupt threshold into the Txq structure

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27911

3 years agoif_vtnet: Defer updating generated MAC address until attached
Bryan Venteicher [Tue, 19 Jan 2021 04:55:24 +0000 (04:55 +0000)]
if_vtnet: Defer updating generated MAC address until attached

This improves spec compliance because the driver is not suppose
to notify the device prior to setting the DRIVER_OK status, which
could happen with the VIRTIO_NET_F_CTRL_MAC_ADDR.

The VIRTIO_NET_F_MAC feature should always be negotiated so would
be a rare situation.

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27910