]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agonetmap: Fix TOCTOU vulnerability in nmreq_copyin
Vincenzo Maffione [Wed, 16 Mar 2022 06:58:50 +0000 (06:58 +0000)]
netmap: Fix TOCTOU vulnerability in nmreq_copyin

The total size of the user-provided nmreq was first computed and then
trusted during the copyin. This might lead to kernel memory corruption
and escape from jails/containers.

Reported by: Lucas Leong (@_wmliang_) of Trend Micro Zero Day Initiative
Security: CVE-2022-23084
MFC after: 3 days

2 years agonetmap: Fix integer overflow in nmreq_copyin
Vincenzo Maffione [Wed, 16 Mar 2022 06:57:54 +0000 (06:57 +0000)]
netmap: Fix integer overflow in nmreq_copyin

An unsanitized field in an option could be abused, causing an integer
overflow followed by kernel memory corruption. This might be used
to escape jails/containers.

Reported by: Reno Robert and Lucas Leong (@_wmliang_) of Trend Micro
Zero Day Initiative
Security: CVE-2022-23085

2 years agovirtio_random(8): avoid deadlock at shutdown time
Eugene Grosbein [Wed, 16 Mar 2022 04:41:51 +0000 (11:41 +0700)]
virtio_random(8): avoid deadlock at shutdown time

FreeBSD 13+ running as virtual guest may load virtio_random(8) driver
by means of devd(8) unless the driver is blacklisted or disabled
via device.hints(5). Currently, the driver may prevent
the system from rebooting or shutting down correctly.

This change deactivates virtio_random at very late stage
during system shutdown sequence to avoid deadlock
that results in kernel hang.

PR: 253175
Tested by: tom
MFC after: 3 days

2 years agoRemove "/dev/" from geom name in `gpart add` command.
Alexander Motin [Wed, 16 Mar 2022 04:09:09 +0000 (00:09 -0400)]
Remove "/dev/" from geom name in `gpart add` command.

PR: 232462
MFC after: 1 week

2 years agoGEOM: Fix regression after 7f16b501e25.
Alexander Motin [Wed, 16 Mar 2022 03:58:09 +0000 (23:58 -0400)]
GEOM: Fix regression after 7f16b501e25.

find_geom() in some classes trim leading "/dev/" from geom names.
Lack of that in geom_gettree_geom() broke some existing scripts.

PR: 262554
MFC after: 2 months

2 years agobhyve: missing mutex initializations
Andy Fiddaman [Wed, 16 Mar 2022 03:50:36 +0000 (19:50 -0800)]
bhyve: missing mutex initializations

Explicitly initialize the mutex that a PCI virtio module passes back to
virtio.

It so happens that these mutexes were being initialized regardless, no
functional change intended.

Reviewed by:    chuck, jhb
Differential Revision:  https://reviews.freebsd.org/D34372

2 years agospkrtest(8): Replace dialog with bsddialog
Alfonso S. Siciliano [Wed, 16 Mar 2022 00:47:49 +0000 (01:47 +0100)]
spkrtest(8): Replace dialog with bsddialog

Replace (LGPL) dialog with (BSD-2-Clause) bsddialog and update manual.

Approved by: bapt (mentor)
Differential Revision: https://reviews.freebsd.org/D34459

2 years agogpiopower: Fix failure case for attach
Justin Hibbits [Tue, 15 Mar 2022 18:40:48 +0000 (13:40 -0500)]
gpiopower: Fix failure case for attach

Summary:
We really should be checking the return value of
ofw_gpiobus_parse_gpios_impl, not the value of sc_pins, which isn't
changed on failure.

Reported by: alfredo@

Reviewers: #powerpc, alfredo

Reviewed By: #powerpc, alfredo

Subscribers: imp, loos

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

2 years agoOpenSSL: Merge OpenSSL 1.1.1n
Jung-uk Kim [Tue, 15 Mar 2022 23:35:22 +0000 (19:35 -0400)]
OpenSSL: Merge OpenSSL 1.1.1n

2 years agobsdinstall/distfetch: Replace libdialog with libbsddialog
Alfonso S. Siciliano [Tue, 15 Mar 2022 23:27:36 +0000 (00:27 +0100)]
bsdinstall/distfetch: Replace libdialog with libbsddialog

Replace (LGPL) libdialog with (BSD-2-Clause) libbsddialog,
while here diversify error messages to find quickly the exact point
of failure.

Approved by: bapt (mentor)
Differential Revision: https://reviews.freebsd.org/D34464

2 years agoFix arm64 TLB invalidation with non-4k pages
Andrew Turner [Thu, 10 Mar 2022 14:39:03 +0000 (14:39 +0000)]
Fix arm64 TLB invalidation with non-4k pages

When using 16k or 64k pages atop will shift the address by more than
the needed amount for a tlbi instruction. Replace this with a new macro
to shift the address by 12 and use PAGE_SIZE in the for loop to let the
code work with any page size.

Reviewed by: alc, markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34516

2 years agoRemove a redundant L1_BLOCK == L2_BLOCK check
Andrew Turner [Tue, 15 Mar 2022 14:02:38 +0000 (14:02 +0000)]
Remove a redundant L1_BLOCK == L2_BLOCK check

We have two checks for L1_BLOCK == L2_BLOCK. Remove one.

Sponsored by: The FreeBSD Foundation

2 years agoFix a bug in BN_mod_sqrt() that can cause it to loop forever.
Gordon Tetlow [Tue, 15 Mar 2022 16:48:59 +0000 (09:48 -0700)]
Fix a bug in BN_mod_sqrt() that can cause it to loop forever.

Obtained from: OpenSSL Project
Security: CVE-2022-0778

2 years agonullfs.5: Add an example fstab(5) entry
Mateusz Piotrowski [Tue, 15 Mar 2022 16:20:15 +0000 (17:20 +0100)]
nullfs.5: Add an example fstab(5) entry

Some other file system manual pages like msdosfs(5) feature similar
examples as well.

MFC after: 1 week

2 years agopowerpcspe: add virtio in-kernel support
Alfredo Dal'Ava Junior [Mon, 14 Mar 2022 20:54:26 +0000 (17:54 -0300)]
powerpcspe: add virtio in-kernel support

Adding it in order to make easier using powerpcspe images under qemu

Reviewed by: jhibbits
Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D34554

2 years agotools/tools/README: Remove tinybsd entry
Mateusz Piotrowski [Tue, 15 Mar 2022 12:05:39 +0000 (13:05 +0100)]
tools/tools/README: Remove tinybsd entry

Fixes: 0c7a642ae8f5 tinybsd: Remove

2 years agozfs: add missing replay check to an assert in zfs_xvattr_set
Mateusz Guzik [Tue, 15 Mar 2022 11:38:23 +0000 (11:38 +0000)]
zfs: add missing replay check to an assert in zfs_xvattr_set

2 years agoMake page size dynamic in libkvm for arm64
Andrew Turner [Mon, 14 Mar 2022 12:40:25 +0000 (12:40 +0000)]
Make page size dynamic in libkvm for arm64

To allow for a future 16k or 64k page size we need to tell libkvm which
is being used. Add a flag field in unused space in minidumphdr and use
it to signal between the different options.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34548

2 years agoFix calculating l0index in _pmap_alloc_l3 on arm64
Andrew Turner [Thu, 10 Mar 2022 14:40:38 +0000 (14:40 +0000)]
Fix calculating l0index in _pmap_alloc_l3 on arm64

When moving from the l1 index to l0 index we need to use the l1 shift
value not the l0 shift value. With 4k pages they are identical, however
with 16k pages we only have 2 l0 entries so the shift value is incorrect.

Reviewed by: alc, markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34517

2 years agostress2: A unmount of a unionfs file system may return EBUSY.
Peter Holm [Tue, 15 Mar 2022 09:24:55 +0000 (10:24 +0100)]
stress2: A unmount of a unionfs file system may return EBUSY.

2 years agohier: Document /usr/freebsd-dist
Mateusz Piotrowski [Mon, 14 Mar 2022 17:19:53 +0000 (18:19 +0100)]
hier: Document /usr/freebsd-dist

/usr/freebsd-dist is used used by various programs as the location for
FreeBSD distribution files. In-tree programs following this convention
are bsdinstall(8) and release(7).

Reviewed by: Pau Amma <pauamma@gundo.com>
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D34552

2 years agostress2: A unmount of a unionfs file system may return EBUSY.
Peter Holm [Tue, 15 Mar 2022 08:35:22 +0000 (09:35 +0100)]
stress2: A unmount of a unionfs file system may return EBUSY.

2 years agobsnmp: Use mkstemp when creating clients local socket
Tom Jones [Tue, 15 Mar 2022 08:16:36 +0000 (08:16 +0000)]
bsnmp: Use mkstemp when creating clients local socket

Reviewed by: harti, rew
Sponsored by:   NetApp, Inc.
Sponsored by:   Klara, Inc.
X-NetApp-PR:    #72
Differential Revision: https://reviews.freebsd.org/D34550

2 years agoHyper-V: hn: add switch to turn on and off RSC
Wei Hu [Tue, 15 Mar 2022 07:56:38 +0000 (07:56 +0000)]
Hyper-V: hn: add switch to turn on and off RSC

Currently RSC offloading is enabled by default.
With this new change rsc will be disabled by default.
By using sysctl we can enable and disable it.

Reviewed by: whu
Signed-off-by: Souradeep Chakrabarti <schakrabarti@microsoft.com>
Fixes: a491581f3f8df Enable vSwitch RSC support in hn netvsc driver
MFC after: 1 week
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D34507

2 years agopf tests: Test new L3 inspection for pf 'ether' rules
Kristof Provost [Tue, 8 Mar 2022 17:14:39 +0000 (18:14 +0100)]
pf tests: Test new L3 inspection for pf 'ether' rules

Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D34483

2 years agopf: support basic L3 filtering in the Ethernet rules
Kristof Provost [Tue, 8 Mar 2022 08:48:11 +0000 (09:48 +0100)]
pf: support basic L3 filtering in the Ethernet rules

Allow filtering based on the source or destination IP/IPv6 address in
the Ethernet layer rules.

Reviewed by: pauamma_gundo.com (man), debdrup (man)
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D34482

2 years agoMove NO_WUNUSED_BUT_SET_VARIABLE clang helper to the right place.
John Baldwin [Mon, 14 Mar 2022 21:05:25 +0000 (14:05 -0700)]
Move NO_WUNUSED_BUT_SET_VARIABLE clang helper to the right place.

Reviewed by: imp, dim, emaste
Sponsored by: University of Cambridge, Google, Inc.
Differential Revision: https://reviews.freebsd.org/D34537

2 years agomodule_test: Fix some assignments to errno intended to be tests.
John Baldwin [Mon, 14 Mar 2022 21:05:05 +0000 (14:05 -0700)]
module_test: Fix some assignments to errno intended to be tests.

Reported by: vangyzen
Reviewed by: vangyzen, markj
Sponsored by: University of Cambridge, Google, Inc.
Differential Revision: https://reviews.freebsd.org/D34528

2 years agoChase mixer(8) command-line interface changes
Hans Petter Selasky [Mon, 14 Mar 2022 08:36:58 +0000 (09:36 +0100)]
Chase mixer(8) command-line interface changes

Some more nits regarding mute feature.

Differential revision: https://reviews.freebsd.org/D34545
Sponsored by: NVIDIA Networking

2 years agoarmv6/legacy: optimize cpu_getcount performance
Wojciech Macek [Mon, 14 Mar 2022 06:51:21 +0000 (07:51 +0100)]
armv6/legacy: optimize cpu_getcount performance

Use nanotime instread of binuptime.
This change is for old and legacy platforms and does not impact any armv7 and later.
Might be MFCed to 13.0 once armv6 support is finally dropped in 14.0

Sponsored by: Stormshield
Reviewed by: mw
Obtained from: Semihalf
Differential revision: https://reviews.freebsd.org/D33719

2 years agoUpdate leap-seconds to leap-seconds.3676924800
Xin LI [Mon, 14 Mar 2022 06:37:56 +0000 (23:37 -0700)]
Update leap-seconds to leap-seconds.3676924800

Obtained from: ftp://ftp.boulder.nist.gov/pub/time/leap-seconds.3676924800
MFC after: 3 days

2 years agonfscl: Fix NFSv4.1/4.2 Lookup+Open RPC
Rick Macklem [Sun, 13 Mar 2022 20:15:12 +0000 (13:15 -0700)]
nfscl: Fix NFSv4.1/4.2 Lookup+Open RPC

Use of the Lookup+Open RPC is currently disabled,
due to a problem detected during testing.  This
patch fixes this problem.  The problem was that
nfscl_postop_attr() does not parse the attributes
if nd_repstat != 0.  It also would parse the
return status for the operation, where the
Lookup+Open code had already parsed it.

The first change in the patch does not make any
semantics change, but makes the code identical
to what is done later in the function, so that
it is apparent that the semantics should be the
same in both places.

Lookup+Open remains disabled while further
testing is being done, so this patch has no
effect at this time.

2 years agorc.d/*: Use startmsg instead of echo on start messages
Jose Luis Duran [Sun, 13 Mar 2022 17:54:39 +0000 (18:54 +0100)]
rc.d/*: Use startmsg instead of echo on start messages

By rc.conf(5), setting rc_startmsgs="NO" should silence start messages.

Fix a few rc scripts by using startmsg.

PR: 255207
Reported by: Jose Luis Duran <jlduran@gmail.com>
Reviewed by: imp, 0mp
Approved by: imp (src)
Differential Revision: https://reviews.freebsd.org/D34514

2 years agoIntroduce startmsg and use it in rc scripts
Jose Luis Duran [Sun, 13 Mar 2022 17:48:06 +0000 (18:48 +0100)]
Introduce startmsg and use it in rc scripts

startmsg is a new rc.subr(8) function function to be used instead of
echo(1) when for boot messages. It replaces the often forgotten

    check_startmsgs && echo ...

with

    startmsg ...

No functional change intended.

I adjusted the commit message and did some final clean-ups of the patch
before committing.

PR: 255207
Reported by: Jose Luis Duran <jlduran@gmail.com>
Reviewed by: imp, 0mp
Approved by: imp (src)
Differential Revision: https://reviews.freebsd.org/D34514

2 years agoChase mixer(8) command-line interface changes
Mateusz Piotrowski [Sun, 13 Mar 2022 13:13:28 +0000 (14:13 +0100)]
Chase mixer(8) command-line interface changes

FreeBSD 14.0 is going to ship with a new implementation of the mixer(8)
command. Unfortunately, in order to support new features like mute, the
command-line interface of the new implementation is not backwards
compatible.

Update all the remaining documentation and scripts in the src tree
to use the new syntax.

While here, document in usbhidaction.1 that the mute functionality is
now supported.

Reviewed by: christos, debdrup, hselasky
Approved by: hselasky (src)
Fixes: 903873ce1560 Implement and use new mixer(3) library for FreeBSD.
Differential Revision: https://reviews.freebsd.org/D34545

2 years agovfs: prefix lookup and relookup with vfs_
Mateusz Guzik [Sun, 13 Mar 2022 14:44:39 +0000 (14:44 +0000)]
vfs: prefix lookup and relookup with vfs_

Reviewed by: imp, mckusick
Differential Revision: https://reviews.freebsd.org/D34530

2 years agocache: use flexible array member
Mateusz Guzik [Sun, 13 Mar 2022 14:42:20 +0000 (14:42 +0000)]
cache: use flexible array member

... instead of 0-sizing the array

2 years agousbtest: Fix issue when multiple devices are sharing same USB vendor and product ID.
Hans Petter Selasky [Sun, 13 Mar 2022 14:17:06 +0000 (15:17 +0100)]
usbtest: Fix issue when multiple devices are sharing same USB vendor and product ID.

When there are multiple devices sharing the same USB vendor and product ID,
the wrong device may be selected. Fix this by also matching the bus and
device address, ugen<X>.<Y> .

MFC after: 1 week
Sponsored by: NVIDIA Networking

2 years agomixer .8: Clean up the manual page
Mateusz Piotrowski [Sun, 13 Mar 2022 12:30:28 +0000 (13:30 +0100)]
mixer .8: Clean up the manual page

- Use correct macros (e.g., Pa for paths, Ar for arguments, Cm for
  command modifiers).
- Pet igor and mandoc -Tlint (e.g., start sentences after a newline).
- Use Ta instead of a tab character in tables.
- Stylize all table headers with Sy consistency.
- Add a missing "vol" variant to the synopsis of "dev.volume".
- Sort dev.recsrc command modifiers consistency.
- Use "Bd -literal" for code blocks in the examples. "Bl -tag" is not
  the right macro for that.

Fixes: 903873ce1560 Implement and use new mixer(3) library for FreeBSD.

2 years agoriscv: actually enable sanitizers
Piotr Kubaj [Sun, 13 Mar 2022 03:31:35 +0000 (04:31 +0100)]
riscv: actually enable sanitizers

1. Backport https://github.com/llvm/llvm-project/commit/b475ce39e8b1de3a70ea242473f136a567be46e3.
2. Enable libclang_rt for riscv.

Previous commit missed it.

MFC after: 3 days
Reviewed by: dim
Differential Revision: https://reviews.freebsd.org/D34543

2 years agoMerge commit '2f8d4418415511460bd7b3b3e532f6b328cf993f'
Alfonso S. Siciliano [Sun, 13 Mar 2022 01:38:51 +0000 (02:38 +0100)]
Merge commit '2f8d4418415511460bd7b3b3e532f6b328cf993f'

2 years agobsddialog: Import version0.2
Alfonso S. Siciliano [Sun, 13 Mar 2022 01:34:57 +0000 (02:34 +0100)]
bsddialog: Import version0.2

This version provides improvements and fixes mainly to use bsddialog
utility in bsdinstall/scripts. The lib API is not broken so the
previous converted utilities (tzsetup, distextract, etc.) are OK.

Approved by: bapt (mentor)
Differential Revision: https://reviews.freebsd.org/D34458

2 years agopfdenied: match actual variable name to the documented one
Matteo Riondato [Sat, 12 Mar 2022 22:59:25 +0000 (23:59 +0100)]
pfdenied: match actual variable name to the documented one

PR: 262446
Reviewed by: kp

2 years agoGEOM: Introduce partial confxml API
Alexander Motin [Sat, 12 Mar 2022 16:49:37 +0000 (11:49 -0500)]
GEOM: Introduce partial confxml API

Traditionally the GEOM's primary channel of information from kernel to
user-space was confxml, fetched by libgeom through kern.geom.confxml
sysctl.  It is convenient and informative, representing full state of
GEOM in a single XML document.  But problems start to arise on systems
with hundreds of disks, where the full confxml size reaches many
megabytes, taking significant time to first write it and then parse.

This patch introduces alternative solution, allowing to fetch much
smaller XML document, subset of the full confxml, limited to 64KB and
representing only one specified geom and optionally its parents.  It
uses existing GEOM control interface, extended with new "getxml" verb.
In case of any error, such as the buffer overflow, it just transparently
falls back to traditional full confxml.  This patch uses the new API in
user-space GEOM tools where it is possible.

Reviewed by: imp
MFC after: 2 month
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D34529

2 years agousr.bin/who.c: Fix boot time checking
Steve Wills [Sat, 12 Mar 2022 16:48:24 +0000 (11:48 -0500)]
usr.bin/who.c: Fix boot time checking

The boot time entry doesn't have a tty specified, so don't check it.
While here, make ttystat handle that case.

Approved by: kevans (src)
Differential Revision: https://reviews.freebsd.org/D34524

2 years agoamd64: make bcmp in libc just call memcmp
Mateusz Guzik [Sat, 12 Mar 2022 12:27:25 +0000 (12:27 +0000)]
amd64: make bcmp in libc just call memcmp

Preferably bcmp would just alias memcmp but there is build magic which
makes this problematic.

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

2 years agoteken: color #3 is yellow not brown - use TC_YELLOW as the name
Ed Maste [Fri, 11 Mar 2022 21:37:03 +0000 (16:37 -0500)]
teken: color #3 is yellow not brown - use TC_YELLOW as the name

The console escape code standard (ECMA-48) specifies color #3 (escape
code 33) as yellow.  A brown console color is an artifact of the VGA
palette, which replaces dim (but not bright) yellow with brown.

Reviewed by: adrian, imp
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34531

2 years agovfs: reduce spurious zeroing in VOP_STAT
Mateusz Guzik [Sat, 12 Mar 2022 11:49:17 +0000 (11:49 +0000)]
vfs: reduce spurious zeroing in VOP_STAT

clang fails to take advantage of the fact that majority of the struct
gets written to in the routine and decides to bzero the entire thing.

Explicitly zero padding and spare fields, relying on KMSAN to catch
problems should anything pop up later which also needs explicit
zeroing.

fstat on tmpfs (ops/s):
before: 8216636
after:  8508033

2 years agovfs: stop evaluating the argument multpile times in stat macros
Mateusz Guzik [Sat, 12 Mar 2022 11:47:07 +0000 (11:47 +0000)]
vfs: stop evaluating the argument multpile times in stat macros

2 years agotouch: don't leak descriptor if fstat(2) fails
Mariusz Zaborski [Sat, 12 Mar 2022 10:38:12 +0000 (11:38 +0100)]
touch: don't leak descriptor if fstat(2) fails

If fstat(2) fails the close(2) won't be called, which will leak the
file descriptor.

The idea was borrowed from OpenBSD, where similar patch
was applied for futimens(2).

MFC after: 1 week

2 years agoCorrect minor typos/grammos and break long lines to fit in 80 chars.
Jens Schweikhardt [Sat, 12 Mar 2022 09:43:39 +0000 (10:43 +0100)]
Correct minor typos/grammos and break long lines to fit in 80 chars.

2 years agoloader: accept "yellow" as a named color
Ed Maste [Fri, 11 Mar 2022 19:27:46 +0000 (14:27 -0500)]
loader: accept "yellow" as a named color

For historical reasons console color number 3 may be either yellow (most
consoles) or brown (VGA palette).  The console escape code standard
uses "yellow", but teken color name constants appear to be based on the
VGA scheme and use TC_BROWN for color 3.  Even so, the palette table
used 50,50,0 as the RGB percentage tuple, resulting in a dim yellow for
framebuffer consoles at the time teken was introduced.

Amusingly, in 19e2ce2d8367 the comment on the palette entry was changed
from "brown" to "dark yellow" but the colour itself was changed from
a pure yellow to being somewhat brown.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

2 years agoarm64 hwpmc: Support restricting counters to user or kernel mode.
John Baldwin [Fri, 11 Mar 2022 19:29:45 +0000 (11:29 -0800)]
arm64 hwpmc: Support restricting counters to user or kernel mode.

Support the "usr" and "os" qualifiers on arm64 events to restrict
event counting to either usermode or the kernel, respectively.  If
neither qualifier is given, events are counted in both.

Reviewed by: emaste
Sponsored by: University of Cambridge, Google, Inc.
Differential Revision: https://reviews.freebsd.org/D34527

2 years agoaarch64: Add constants for fields in the PMEVTYPERn_EL0 event registers.
John Baldwin [Fri, 11 Mar 2022 19:29:45 +0000 (11:29 -0800)]
aarch64: Add constants for fields in the PMEVTYPERn_EL0 event registers.

Reviewed by: andrew
Sponsored by: University of Cambridge, Google, Inc.
Differential Revision: https://reviews.freebsd.org/D34526

2 years agoloader: support numeric and named bright colors (8-15)
Ed Maste [Wed, 9 Mar 2022 21:08:04 +0000 (16:08 -0500)]
loader: support numeric and named bright colors (8-15)

Accept "bright" or "light" prefix for named colors.

For numeric colors, update error message to specify that values 0 to 15
are allowed, and verify that values are in that range.

Reviewed by: imp, tsoome (both earlier version)
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34512

2 years agoRevert "Add the PMCR_EL0.N arm64 register field"
Andrew Turner [Fri, 11 Mar 2022 17:51:27 +0000 (17:51 +0000)]
Revert "Add the PMCR_EL0.N arm64 register field"

This reverts commit b6fd96ed0b40e5a42eaea662b5461070c93a1c6c.

2 years agoratecheck: mininterval is const
Eric van Gyzen [Fri, 11 Mar 2022 17:35:41 +0000 (11:35 -0600)]
ratecheck: mininterval is const

Reflect this in the man page.

MFC after: 1 week
Sponsored by: Dell EMC Isilon

2 years agolindebugfs: Make single_release() NULL safe.
Hans Petter Selasky [Fri, 11 Mar 2022 16:39:44 +0000 (17:39 +0100)]
lindebugfs: Make single_release() NULL safe.

MFC after: 1 week
Sponsored by: NVIDIA Networking

2 years agolindebugfs: The Linux file operations use negative return values in the kernel.
Hans Petter Selasky [Fri, 11 Mar 2022 16:37:46 +0000 (17:37 +0100)]
lindebugfs: The Linux file operations use negative return values in the kernel.

Fix sign.

MFC after: 1 week
Sponsored by: NVIDIA Networking

2 years agolindebugfs: Zero the linux_file structure before use.
Hans Petter Selasky [Fri, 11 Mar 2022 16:29:54 +0000 (17:29 +0100)]
lindebugfs: Zero the linux_file structure before use.

This avoids clients using garbage values on the stack and makes
debugging easier.

MFC after: 1 week
Sponsored by: NVIDIA Networking

2 years agoAdd more arm64 register op* and CR* values
Andrew Turner [Fri, 11 Mar 2022 11:19:05 +0000 (11:19 +0000)]
Add more arm64 register op* and CR* values

These will be used by bhyve/arm64.

Sponsored by: Innovate UK

2 years agoAdd the PMCR_EL0.N arm64 register field
Andrew Turner [Fri, 11 Mar 2022 11:06:44 +0000 (11:06 +0000)]
Add the PMCR_EL0.N arm64 register field

Sponsored by: Innovate UK

2 years agoCorrect the location of the arm64 PMCR register
Andrew Turner [Fri, 11 Mar 2022 10:56:42 +0000 (10:56 +0000)]
Correct the location of the arm64 PMCR register

This was one of the last registers to not be in alphabetical order in
armreg.h. Fix this to make it easier to find.

Sponsored by: Innovate UK

2 years agoSort the M* and P* arm64 registers
Andrew Turner [Fri, 11 Mar 2022 10:31:05 +0000 (10:31 +0000)]
Sort the M* and P* arm64 registers

Sponsored by: Innovate UK

2 years agopci_vendors: update to 2022.03.06
Baptiste Daroussin [Fri, 11 Mar 2022 09:48:04 +0000 (10:48 +0100)]
pci_vendors: update to 2022.03.06

2 years agolibgeom(3): Use calloc instead of malloc and bzero.
Hans Petter Selasky [Thu, 10 Mar 2022 09:16:27 +0000 (10:16 +0100)]
libgeom(3): Use calloc instead of malloc and bzero.

Pull Request: https://github.com/freebsd/freebsd-src/pull/546
MFC after: 1 week
Sponsored by: NVIDIA Networking

2 years agops(1): Use calloc instead of malloc and memset.
Alfonso [Mon, 4 Oct 2021 16:46:57 +0000 (12:46 -0400)]
ps(1): Use calloc instead of malloc and memset.

Pull Request: https://github.com/freebsd/freebsd-src/pull/546
MFC after: 1 week
Sponsored by: NVIDIA Networking

2 years agonewfs(8): Fix a bug in initialization of sblock.fs_maxbsize .
Wuyang Chung [Tue, 8 Mar 2022 13:52:17 +0000 (21:52 +0800)]
newfs(8): Fix a bug in initialization of sblock.fs_maxbsize .

Fixes: 1c85e6a35d93195e896b030d9a55f7ac4ccee2c3 (SVN r98542)
Pull Request: https://github.com/freebsd/freebsd-src/pull/587
MFC after: 1 week
Sponsored by: NVIDIA Networking

2 years agodf: do not report a 100% full inode usage on fs without inodes
Baptiste Daroussin [Thu, 10 Mar 2022 14:28:50 +0000 (15:28 +0100)]
df: do not report a 100% full inode usage on fs without inodes

Before:
devfs    2        2         0   100%       0          0  100%   /dev

After:
devfs    2        2         0   100%       0          0     -   /dev

The previous behaviour was confusing for end users and many monitoring tools

Note the linux df tools is also using the same syntax '-' for such filesystem

MFC After: 2 weeks
Reviewed by: manu, emaste, imp
Differential Revision: https://reviews.freebsd.org/D34515

2 years agozfs: update zfs_config.h and zfs_gitrev.h
Martin Matuska [Fri, 11 Mar 2022 06:45:48 +0000 (07:45 +0100)]
zfs: update zfs_config.h and zfs_gitrev.h

Update zfs_config.h and zfs_gitrev.h as missed in c03c5b1c8

2 years agoicl_soft: Use PHYS_TO_DMAP instead of pmap_map_io_transient.
John Baldwin [Fri, 11 Mar 2022 02:20:28 +0000 (18:20 -0800)]
icl_soft: Use PHYS_TO_DMAP instead of pmap_map_io_transient.

The latter API is not actually MI but is only supported on amd64,
arm64, and RISC-V.

Sponsored by: Chelsio Communications

2 years agocxgbei: Support unmapped I/O requests.
John Baldwin [Thu, 10 Mar 2022 23:50:52 +0000 (15:50 -0800)]
cxgbei: Support unmapped I/O requests.

- Add icl_pdu_append_bio and icl_pdu_get_bio methods.

- Add new page pod routines for allocating and writing page pods for
  unmapped bio requests.  Use these new routines for setting up DDP
  for iSCSI tasks with a SCSI I/O CCB which uses CAM_DATA_BIO.

- When ICL_NOCOPY is used to append data from an unmapped I/O request
  to a PDU, construct unmapped mbufs from the relevant pages backing
  the struct bio.  This also requires changes in the t4_push_pdus path
  to support unmapped mbufs.

Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D34383

2 years agoiscsi: Support unmapped I/O requests in the default initiator.
John Baldwin [Thu, 10 Mar 2022 23:50:26 +0000 (15:50 -0800)]
iscsi: Support unmapped I/O requests in the default initiator.

- Add icl_pdu_append_bio and icl_pdu_get_bio methods.

- When ICL_NOCOPY is used to append data from an unmapped I/O request
  to a PDU, construct unmapped mbufs from the relevant pages backing
  the struct bio.

- Use m_apply with a helper to compute crc32 digests on mbuf chains
  to handle unmapped mbufs.  Since m_apply requires PMAP_HAS_DMAP
  for unmapped mbufs, only support unmapped requests when PMAP_HAS_DMAP
  is true.

Reviewed by: mav
Differential Revision: https://reviews.freebsd.org/D34406

2 years agoiscsi: Handle unmapped I/O requests.
John Baldwin [Thu, 10 Mar 2022 23:49:53 +0000 (15:49 -0800)]
iscsi: Handle unmapped I/O requests.

Don't assume that csio->data_ptr is pointer to a data buffer that can
be passed to icl_get_pdu_data and icl_append_data.  For unmapped I/O
requests, csio->data_ptr is instead a pointer to a struct bio as
indicated by CAM_DATA_BIO.  To support these requests, add
icl_pdu_append_bio and icl_pdu_get_bio methods which pass a pointer to
the bio and an offset and length relative to the bio's buffer.

Note that only backends supporting unmapped requests need to implement
these hooks.

Implement simple no-op hooks for the iser backend.

Reviewed by: mav
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D34382

2 years agoiser: Fix check for opcodes in iser_conn_pdu_append_data.
John Baldwin [Thu, 10 Mar 2022 23:49:37 +0000 (15:49 -0800)]
iser: Fix check for opcodes in iser_conn_pdu_append_data.

Reviewed by: mav
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D34487

2 years agoiscsi: Use ICL_NOCOPY for SCSI command immediate data and R2T.
John Baldwin [Thu, 10 Mar 2022 23:48:20 +0000 (15:48 -0800)]
iscsi: Use ICL_NOCOPY for SCSI command immediate data and R2T.

The associated csio ccb will not be completed via xpt_done() until
after the associated PDUs are transmitted to the other side and either
the original PDU is acked with a SCSI response, or a response is
received for a subsequent abort CCB (which means the earlier PDU has
also been sent since it would have been sent before the abort PDU).

This does assume that once an I/O request has been aborted, no further
PDUs with data payload are queued for that I/O request.

Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D34405

2 years agogcore: Use PT_GETREGSET to fetch NT_PRSTATUS and NT_FPREGSET.
John Baldwin [Thu, 10 Mar 2022 23:40:44 +0000 (15:40 -0800)]
gcore: Use PT_GETREGSET to fetch NT_PRSTATUS and NT_FPREGSET.

Add a elf_putregnote() helper to build the ELF note for a register
set.  Once nice result of this approach is that this reuses the
kernel's support for generating 32-bit register sets for 32-bit
processes avoiding the need to duplicate that logic in elf32core.c.

Reviewed by: markj
Sponsored by: University of Cambridge, Google, Inc.
Differential Revision: https://reviews.freebsd.org/D34447

2 years agoStore core dump notes for all valid register sets for FreeBSD processes.
John Baldwin [Thu, 10 Mar 2022 23:40:19 +0000 (15:40 -0800)]
Store core dump notes for all valid register sets for FreeBSD processes.

In particular, use a generic wrapper around struct regset rather than
requiring per-regset helpers.  This helper replaces the MI
__elfN(note_prstatus) and __elfN(note_fpregset) helpers.  It also
removes the need to explicitly dump NT_ARM_ADDR_MASK in the arm64
__elfN(dump_thread).

Reviewed by: markj, emaste
Sponsored by: University of Cambridge, Google, Inc.
Differential Revision: https://reviews.freebsd.org/D34446

2 years agolibpmcstat: Fix a few ARM-specific issues with function symbols.
John Baldwin [Thu, 10 Mar 2022 23:39:53 +0000 (15:39 -0800)]
libpmcstat: Fix a few ARM-specific issues with function symbols.

- Refine the checks for ARM mapping symbols and apply them on arm64 as
  well as 32-bit arm.  In particular, mapping symbols can have
  additional characters and are not strictly limited to just "$a" but
  can append additional characters (e.g. "$a.1").  Add "$x" to the
  list of mapping symbol prefixes.

- Clear the LSB of function symbol addresses.  Thumb function
  addresses set the LSB to enable Thumb mode.  However, the actual
  function starts at the aligned address with LSB clear.  Not clearing
  the LSB can cause pmcannotate to pass misaligned addresses to
  objdump when extracting disassembly.

Reviewed by: andrew
Obtained from: CheriBSD
Sponsored by: University of Cambridge, Google, Inc.
Differential Revision: https://reviews.freebsd.org/D34416

2 years agoddb: Add 'show gic <name>' and 'show all gics' commands.
John Baldwin [Thu, 10 Mar 2022 23:39:37 +0000 (15:39 -0800)]
ddb: Add 'show gic <name>' and 'show all gics' commands.

To handle the different register layouts for different versions, add a
GIC_DB_SHOW() method.  Currently this hook is only implemented for
versions 1 and 2.

Sponsored by: University of Cambridge, Google, Inc.
Differential Revision: https://reviews.freebsd.org/D34415

2 years agolinuxkpi: fix module build outside of kernel build environment
Eugene Grosbein [Thu, 10 Mar 2022 21:31:23 +0000 (04:31 +0700)]
linuxkpi: fix module build outside of kernel build environment

MFC after: 3 days

2 years agovt: clarify comments on kbd add/release
Ed Maste [Thu, 24 Feb 2022 15:38:16 +0000 (10:38 -0500)]
vt: clarify comments on kbd add/release

PR: 247498

2 years agofwcontrol: eliminate set but not used warning
Ed Maste [Sun, 27 Feb 2022 19:04:09 +0000 (14:04 -0500)]
fwcontrol: eliminate set but not used warning

The variable was used in an #if 0 block; just move the variable
definition and setting into the same block since Firewire is mainly of
historical interest and is unlikely to see ongoing development in
FreeBSD.

Sponsored by: The FreeBSD Foundation

2 years agoRemove an unneeded memset from the arm64 pmap
Andrew Turner [Thu, 10 Mar 2022 19:13:49 +0000 (19:13 +0000)]
Remove an unneeded memset from the arm64 pmap

There is no need to zero pagetable_dmap as we already did it when
creating the page tables in locore.S

Sponsored by: The FreeBSD Foundation

2 years agoSplit out creating the arm64 L2 dmap entries
Andrew Turner [Thu, 10 Mar 2022 18:00:40 +0000 (18:00 +0000)]
Split out creating the arm64 L2 dmap entries

When creating the DMAP region we may need to create level 2 page table
entries at the start and end of a block of memory. The code to do this
was almost identical so we can merge into a single function.

Sponsored by: The FreeBSD Foundation

2 years agoRemove l1ptfrom pmap_early_vtophys on arm64
Andrew Turner [Thu, 10 Mar 2022 18:10:40 +0000 (18:10 +0000)]
Remove l1ptfrom pmap_early_vtophys on arm64

The first argument was unused as we use an address translation
instruction to get the physical address.

Sponsored by: The FreeBSD Foundation

2 years agoscript: use %n at the end of default tstamp_fmt
Simon J. Gerraty [Thu, 10 Mar 2022 17:42:55 +0000 (09:42 -0800)]
script: use %n at the end of default tstamp_fmt

Since we are only outputting time-stamps when they differ
ending it with a newline, interferes with the output less.

2 years agopf: hoist the unlinked rules lock out of the mass rule removal loop
Mateusz Guzik [Mon, 28 Feb 2022 10:39:02 +0000 (11:39 +0100)]
pf: hoist the unlinked rules lock out of the mass rule removal loop

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agopf: add PF_UNLNKDRULES_ASSERT
Mateusz Guzik [Mon, 28 Feb 2022 10:37:30 +0000 (11:37 +0100)]
pf: add PF_UNLNKDRULES_ASSERT

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agopf: remove spurious zeroing from pf_ioctl_addrule
Mateusz Guzik [Fri, 25 Feb 2022 16:18:13 +0000 (17:18 +0100)]
pf: remove spurious zeroing from pf_ioctl_addrule

Newly allocated counters are guaranteed to be 0.

This removes 5 IPIs for each loaded rule.

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agobhyve.8: Fix a typo
Mateusz Piotrowski [Thu, 10 Mar 2022 16:43:39 +0000 (17:43 +0100)]
bhyve.8: Fix a typo

The Li macro is deprecated. Also, the Cm macro should be used here
instead for consistency with the rest of the manual and style.mdoc(5).

Fixes: e47fe3183e1f bhyve: add ROM emulation
MFC after: 1 month

2 years agodiff: Re-add void argument to usage
Tom Jones [Thu, 10 Mar 2022 16:24:02 +0000 (16:24 +0000)]
diff: Re-add void argument to usage

Previous commit (8cf449db88b2c7a505bc241a78f9736b43f2ede5)
unintentionally dropped the 'void' argument to usage, reinstate it.

Sponsored by: Klara Inc.

2 years agodiff: add support for --help and --version
Tom Jones [Thu, 10 Mar 2022 16:15:39 +0000 (16:15 +0000)]
diff: add support for --help and --version

Add support for --help and --version to be compatible with gnu diff.

gnu diff --help writes to stdout, do the same to be compatible

Reviewed by: bapt, pstef, debrup, Pau Amma
Sponsored by: Klara Inc.
Differential Revision: https://reviews.freebsd.org/D34508

2 years agopfdenied: support reporting on additional anchors
Matteo Riondato [Wed, 9 Mar 2022 14:02:11 +0000 (15:02 +0100)]
pfdenied: support reporting on additional anchors

The security/520-pfdenied script only reports blocked packets from the
main ruleset or any blocklistd(8) anchor.

Add an option to periodic.conf(5) to make it possible to specify
additional anchors to report.

PR: 262446
Reviewed by: kp

2 years agobhyve/usage: memory size is not in MB
Corvin Köhne [Thu, 10 Mar 2022 10:30:17 +0000 (11:30 +0100)]
bhyve/usage: memory size is not in MB

For backward compatibility, the memory size will be interpreted in MB if
it's smaller than1 MB and has no suffix. Nowadays, the -m switch accepts
more than just MB. Respect it in the usage message.

Differential Revision: https://reviews.freebsd.org/D34506
Reviewed by: grehan
Sponsored by:   Beckhoff Automation GmbH & Co. KG
MFC after:      1 month

2 years agobhyve: add ROM emulation
Corvin Köhne [Thu, 10 Mar 2022 10:28:06 +0000 (11:28 +0100)]
bhyve: add ROM emulation

Some PCI devices especially GPUs require a ROM to work properly.
The ROM is executed by boot firmware to initialize the device.
To add a ROM to a device use the new ROM option for passthru device
(e.g. -s passthru,0/2/0,rom=<path>/<to>/<rom>).

It's necessary that the ROM is executed by the boot firmware.
It won't be executed by any OS.
Additionally, the boot firmware should be configured to execute the
ROM file.
For that reason, it's only possible to use a ROM when using
OVMF with enabled bus enumeration.

Differential Revision: https://reviews.freebsd.org/D33129
Sponsored by:   Beckhoff Automation GmbH & Co. KG
MFC after:      1 month

2 years agobhyve: export funcs for read/write pci config
Corvin Köhne [Thu, 10 Mar 2022 10:26:19 +0000 (11:26 +0100)]
bhyve: export funcs for read/write pci config

Export functions for reading and writing the pci config space from passthru
device to be used by other devices.
This is required for lpc devices to set their vendor/device ids to their
physical values.
Otherwise, GPU passthrough for integrated Intel GPUs won't work properly.

Differential Revision: https://reviews.freebsd.org/D33769
Reviewed by: markj
Sponsored by: Beckhoff Automation GmbH & Co. KG
MFC after: 1 month

2 years agoExtend device_get_property API
Kornel Duleba [Fri, 28 Jan 2022 09:28:37 +0000 (10:28 +0100)]
Extend device_get_property API

In order to support various types of data stored in device
tree properties or ACPI _DSD packages, create a new enum so
the caller can specify the expected type of a property they
want to read, according to the binding. The bus logic will use
that information to process the underlying data.

For example in DT all integer properties are stored in BE format.
In order to get constant results across different platforms we
need to convert its endianness to match the host.

Another example are ACPI_TYPE_INTEGER properties stored
as uint64_t. Before this patch the ACPI logic would refuse
to read them if the provided buffer was smaller than 8 bytes.
Now this can be handled by using DEVICE_PROP_UINT32 type.

Modify the existing consumers of this API to reflect the changes
and update the man pages accordingly.

Reviewed by: mw
Obtained from: Semihalf
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D33457

2 years agobus_if: Add a default implementation of get_property
Kornel Duleba [Tue, 25 Jan 2022 10:10:55 +0000 (11:10 +0100)]
bus_if: Add a default implementation of get_property

There are multiple buses that pretend to be ofw compatible,
e.g ofw_pci, mii_fdt. We now need to provide an implementation
of BUS_GET_PROPERTY for every one of them. Instead of modifying
them one by one it's better to just provide a default
implementation that simply traverses up the device tree.
Remove the now unneeded BUS_GET_PROPERTY implementation in mii_fdt.

Reviewed by: andrew, bz
Obtained from: Semihalf
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D34031

2 years agoFix the arm64 DMAP start address in a comment
Andrew Turner [Thu, 10 Mar 2022 11:00:44 +0000 (11:00 +0000)]
Fix the arm64 DMAP start address in a comment

Sponsored by: The FreeBSD Foundation