]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
16 months agospeaker: ansify
Mateusz Guzik [Mon, 13 Feb 2023 18:28:09 +0000 (18:28 +0000)]
speaker: ansify

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

16 months agontptime: ansify
Mateusz Guzik [Mon, 13 Feb 2023 18:24:13 +0000 (18:24 +0000)]
ntptime: ansify

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

16 months agovm: ansify
Mateusz Guzik [Mon, 13 Feb 2023 18:23:21 +0000 (18:23 +0000)]
vm: ansify

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

16 months agouipc: ansify
Mateusz Guzik [Mon, 13 Feb 2023 18:20:29 +0000 (18:20 +0000)]
uipc: ansify

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

16 months agosctp: ansify
Mateusz Guzik [Mon, 13 Feb 2023 18:16:28 +0000 (18:16 +0000)]
sctp: ansify

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

16 months agointr_event(9): fixup Nm field
Mitchell Horne [Sun, 12 Feb 2023 18:58:25 +0000 (14:58 -0400)]
intr_event(9): fixup Nm field

16 months agoipfilter: ansify
Mateusz Guzik [Mon, 13 Feb 2023 18:05:57 +0000 (18:05 +0000)]
ipfilter: ansify

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

16 months agoofwbus: only allow unit number zero
Mitchell Horne [Mon, 13 Feb 2023 17:44:03 +0000 (13:44 -0400)]
ofwbus: only allow unit number zero

ofwbus has always been the root of attachment for OFW/FDT platforms. It
may have simplebus children, but we expect only one instance of the
ofwbus driver, added directly by nexus. We may as well ensure this
remains the case.

Reviewed by: jhb
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D38493

16 months agoofwbus: remove arm64 ifdefs
Mitchell Horne [Mon, 13 Feb 2023 17:43:25 +0000 (13:43 -0400)]
ofwbus: remove arm64 ifdefs

Rather than using the DEVICE_IDENTIFY method, let's have other
ofwbus-using platforms add ofwbus0 explicitly in nexus, like arm64. This
gives them the same flexibility, e.g. if riscv starts supporting ACPI,
and cleans up the #ifdefs.

We were doing this already on riscv, but adjust the 'order' parameters.

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

16 months agoofwbus: trim includes
Mitchell Horne [Mon, 13 Feb 2023 17:42:56 +0000 (13:42 -0400)]
ofwbus: trim includes

Nothing in the file today relies on these.

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

16 months agozlib: Use NO_WDEPRECATED_NON_PROTOTYPE
Warner Losh [Mon, 13 Feb 2023 16:15:58 +0000 (09:15 -0700)]
zlib: Use NO_WDEPRECATED_NON_PROTOTYPE

Also add it to kern.mk so it's available for module builds.

Sponsored by: Netflix
Noticed by: mjg
Fixes: b9f235ba3178
Differential Revision: https://reviews.freebsd.org/D38550

16 months agoChange "ctlstat -P"'s schema
Alan Somers [Wed, 25 Jan 2023 18:00:49 +0000 (11:00 -0700)]
Change "ctlstat -P"'s schema

It now reports stats separately for both ports and luns.

Also, prohibit using both "-p" and "-P" at the same time.

MFC after: 1 week
Sponsored by: Axcient
Reviewed by: mav
Differential Revision: https://reviews.freebsd.org/D38500

16 months agoComplete removal of opt_compat.h
Dmitry Chagin [Mon, 13 Feb 2023 16:07:38 +0000 (19:07 +0300)]
Complete removal of opt_compat.h

Since Linux emulation layer build options was removed there is no reason
to keep opt_compat.h.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D38548
MFC after: 2 weeks

16 months agosesutil: don't malloc in a tight loop
Alan Somers [Thu, 9 Feb 2023 22:23:51 +0000 (15:23 -0700)]
sesutil: don't malloc in a tight loop

Reported by: mav
MFC after: 1 week
Sponsored by: Axcient
Reviwed by: mav
Differential Revision: https://reviews.freebsd.org/D38473

16 months agobearssl: Suppress warnings from functions that have no args
Warner Losh [Mon, 13 Feb 2023 15:19:40 +0000 (08:19 -0700)]
bearssl: Suppress warnings from functions that have no args

clag15 is much pickier than others, so suppress the warning until
upstream can be updated.

Sponsored by: Netflix

16 months agoProperly conditionalize clang 15-only flags
Warner Losh [Mon, 13 Feb 2023 15:19:00 +0000 (08:19 -0700)]
Properly conditionalize clang 15-only flags

Sponsored by: Netflix
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D38550

16 months agoprof: Remove sysctl docs for sysctls that are now gone.
Warner Losh [Mon, 13 Feb 2023 15:18:50 +0000 (08:18 -0700)]
prof: Remove sysctl docs for sysctls that are now gone.

GRPOF based kernel profiling was removed in aa3ea612be36. However, the
docs for the sysctls were not. Remove them belatedly.

Sponsored by: Netflix

16 months agoCirrus-CI: use llvm15 toolchain packages
Ed Maste [Mon, 13 Feb 2023 14:28:35 +0000 (09:28 -0500)]
Cirrus-CI: use llvm15 toolchain packages

As of commit 50d7464c3fe6 we use llvm15 as the system toolchain, and
commit eca005d8531f added compiler options incompatible with earlier
versions.  Switch to llvm15 packages.

Sponsored by: The FreeBSD Foundation

16 months agotop: fix sorting by pid (-o pid)
Kyle Evans [Mon, 13 Feb 2023 06:39:04 +0000 (00:39 -0600)]
top: fix sorting by pid (-o pid)

The 'pid' order was added, but the equivalent comparator was not back in
8b800d3af2d8c ("Add the PID column to the list of sort keys.").
`ordernames` indices need to match `compares` indices in order for this
to work.

A future commit will restructure all of this to make it less error prone
going forward (see D37083).

MFC after: 3 days
Reviewed by: pstef (D37083)

16 months agolibc: popen: slightly simplify cloexec logic
Kyle Evans [Mon, 13 Feb 2023 06:33:52 +0000 (00:33 -0600)]
libc: popen: slightly simplify cloexec logic

No need to check the mode again here; we know that `iop` wraps the
correct fd.

Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D37987

16 months agomd5: fix *sum -c with missing files
Kyle Evans [Mon, 13 Feb 2023 06:32:38 +0000 (00:32 -0600)]
md5: fix *sum -c with missing files

If we fail to open one of the files in the file listing, we still need
to advance `rec` along with `argv` so that the checksum we're checking
against lines up with the file we're hashing.

Tests added both for the -c flag, as well as the -b and -t modes of
the *sum programs.

PR: 267722
Reviewed by: emaste (earlier version)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D37374

16 months agopatch: omit filename if the prompt was ignored
Kyle Evans [Tue, 24 Jan 2023 16:46:01 +0000 (10:46 -0600)]
patch: omit filename if the prompt was ignored

When a file is missing, patch(1) will prompt for a filename to try and
patch it.  If we're doing a dry-run, we'll output that the patch to the
source file was either ignored/failed.  If you ignore the prompt in a
dry-run (i.e. just hit enter), we'll output:

X out of X hunks ignored while patching (null)

Let's improve the aesthetics a bit and just omit the last part if the
prompt was ignored:

X out of X hunks ignored

Unfortunately we can't really test this without expect(1) because both
force and batch mode will use the first best guess, which is wiped out
by the "File to patch:" prompt.  We could record the initially derived
bestguess there and use *that*, but given that this is only possible in
an interactive session I think it's fine to just omit the filename
rather than adding a fair amount of complexity (which could also break
other scenarios I haven't considered yet)..

Reviewed by: des
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D38179

16 months agowg: tests: remove an obsolete workaround
Kyle Evans [Mon, 13 Feb 2023 05:59:21 +0000 (23:59 -0600)]
wg: tests: remove an obsolete workaround

PR 254212 was resolved to avoid issues with not having IPv6 addresses
present in the jail, so we can safely drop this workaround now...

Reviewed by: jhb, markj
Differential Revision: https://reviews.freebsd.org/D37755

16 months agowg: add a test for the home jail socket feature
Kyle Evans [Mon, 13 Feb 2023 05:59:20 +0000 (23:59 -0600)]
wg: add a test for the home jail socket feature

This adds a test for a semantic that we added to mirror a feature of
the Linux implementation w/ netns: if a wg interface is moved into a
jail, we still create the socket in the context of the home vnet.  With
this added, one can actually create vnet jails that only have a wg
tunnel to the outside world providing network connectivity without any
epairs in the setup.

Reviewed by: jhb, markj (both earlier version)
Differential Revision: https://reviews.freebsd.org/D37755

16 months agorpc: ansify
Mateusz Guzik [Mon, 13 Feb 2023 05:39:10 +0000 (05:39 +0000)]
rpc: ansify

Reported by: clang 15
Sponsored by: Rubicon Communications, LLC ("Netgate")

16 months agocleanvar: Be more careful when cleaning up /var.
Xin LI [Mon, 13 Feb 2023 04:56:17 +0000 (20:56 -0800)]
cleanvar: Be more careful when cleaning up /var.

The cleanvar script uses find -delete to remove stale files under /var,
which could lead to unwanted removal of files in some unusual scenarios.
For example, when a mounted fdescfs(5) is present under /var/run/samba/fd,
find(1) could descend into a directory that is out of /var/run and remove
files that should not be removed.

To mitigate this, modify the script to use find -x, which restricts the
find scope to one file system only instead of descending into mounted
file systems.

PR: 269213
MFC after: 1 week

16 months agoman5/rc.conf.5: document utx_enable variable.
Ceri Davies [Sun, 12 Feb 2023 22:17:46 +0000 (22:17 +0000)]
man5/rc.conf.5: document utx_enable variable.

16 months agonfsd: Continue adding macros so nfsd can run in a vnet prison
Rick Macklem [Sun, 12 Feb 2023 21:52:13 +0000 (13:52 -0800)]
nfsd: Continue adding macros so nfsd can run in a vnet prison

Commit 7344856e3a6d added a lot of macros that will front end
vnet macros so that nfsd(8) can run in vnet prison.
This patch adds some more of them.

MFC after: 3 months

16 months agolge: ansify
Mateusz Guzik [Sun, 12 Feb 2023 21:37:24 +0000 (21:37 +0000)]
lge: ansify

Reported by: clang 15
Sponsored by: Rubicon Communications, LLC ("Netgate")

16 months agoARM release build: enable IPv6 SLAAC by default
Joerg Wunsch [Sun, 12 Feb 2023 21:26:52 +0000 (22:26 +0100)]
ARM release build: enable IPv6 SLAAC by default

When building ARM release images, enable IPv6 SLAAC by default in
addition to IPv4 DHCP.

Unlike amd64 (and other desktop/server) releases, ARM releases on SoC
setups are usually deployed by just using the installation image, so
there is no interactive network configuration. Not having IPv6
included by default is kind of an anachronism these days, given that
FreeBSD with the KAME project once pioneered IPv6 technology.

MFC after: 2 weeks

16 months agozlib: silence K&R warns
Mateusz Guzik [Sun, 12 Feb 2023 21:12:34 +0000 (21:12 +0000)]
zlib: silence K&R warns

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

16 months agolinux(4): Get rid of the opt_compat.h include.
Dmitry Chagin [Sun, 12 Feb 2023 17:24:32 +0000 (20:24 +0300)]
linux(4): Get rid of the opt_compat.h include.

Since e013e369 COMPAT_LINUX, COMPAT_LINUX32 build options are removed,
so include of opt_compat.h is no more needed.

MFC after: 2 weeks

16 months agonfsd: Fix initialization broken by 7344856e3a6d
Rick Macklem [Sun, 12 Feb 2023 17:16:56 +0000 (09:16 -0800)]
nfsd: Fix initialization broken by 7344856e3a6d

Oops, although the vneting macros do not do anything yet,
commit 7344856e3a6d did change where things are initialized
and one of the initialization functions was not being called
early enough.  This patch moves nfsrvd_init(0) to the
function called via (VNET_)SYSINIT() to fix this.

Reported by: olivier
MFC after: 3 months

16 months agoRevert "netlink: make netlink_snl(3) c++ friendly."
Alexander V. Chernikov [Sun, 12 Feb 2023 12:16:58 +0000 (12:16 +0000)]
Revert "netlink: make netlink_snl(3) c++ friendly."

Was pushed accidentally.

This reverts commit 629d9219d931e63dc49ef046332b2a360e42a5f6.

16 months agofibs: restrict jail_attach(2) if process fibnum >= numfibs in the jail.
Alexander V. Chernikov [Sat, 11 Feb 2023 15:43:23 +0000 (15:43 +0000)]
fibs: restrict jail_attach(2) if process fibnum >= numfibs in the jail.

Reported by: olivier
Tested by: olivier
Reviewed by: kp, glebius
Differential Revision: https://reviews.freebsd.org/D38505
MFC after: 1 week

16 months agonetlink: make netlink_snl(3) c++ friendly.
Alexander V. Chernikov [Fri, 10 Feb 2023 20:19:09 +0000 (20:19 +0000)]
netlink: make netlink_snl(3) c++ friendly.

16 months agonfsd: Delete nfsrv_prison_cleanup() until vneting enabled
Rick Macklem [Sun, 12 Feb 2023 02:27:59 +0000 (18:27 -0800)]
nfsd: Delete nfsrv_prison_cleanup() until vneting enabled

Oops, although the vneting macros do not do anything yet,
commit 7344856e3a6d enabled the prison cleanup function, that
would get called and crash the system when a jail was terminated.

This patch gets rid of nfsrv_prison_cleanup() for now.
It can go in when the vnet macros are enabled as
front ends to the vnet macros.

MFC after: 3 months

16 months agonfsd: Prepare the NFS server code to run in a vnet prison
Rick Macklem [Sat, 11 Feb 2023 23:51:19 +0000 (15:51 -0800)]
nfsd: Prepare the NFS server code to run in a vnet prison

This patch defines null macros that can be used to apply
the vnet macros for global variables and SYSCTL flags.
It also applies these macros to many of the global variables
and some of the SYSCTLs.  Since the macros do nothing, these
changes should not result in semantics changes, although the
changes are large in number.

The patch does change several global variables that were
arrays or structures to pointers to same.  For these variables,
modified initialization and cleanup code malloc's and free's
the arrays/structures.  This was done so that the vnet footprint
would be about 300bytes when the macros are defined as vnet macros,
allowing nfsd.ko to load dynamically.

I believe the comments in D37519 have been addressed, although
it has never been reviewed, due in part to the large size of the patch.
This is the first of a series of patches that will put D37519 in main.

Once everything is in main, the macros will be defined as front
end macros to the vnet ones.

MFC after: 3 months
Differential Revision: https://reviews.freebsd.org/D37519

16 months agoman: some typesetting and style fixes for recent additions
Konstantin Belousov [Sat, 11 Feb 2023 00:46:34 +0000 (02:46 +0200)]
man: some typesetting and style fixes for recent additions

Mostly start each sentence from a new line.  Also add more pretty
typesetting to cdce(4).

Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D38501

16 months agonfsd: Add a KASSERT in nfsvno_open
Rick Macklem [Sat, 11 Feb 2023 15:14:08 +0000 (07:14 -0800)]
nfsd: Add a KASSERT in nfsvno_open

Commit ded5f2954e1a defined done_namei to indicate that
nd_repstat was set after a successful nfsvno_namei(),
so that a cleanup needs to be done in nfsvno_open().
This only happens when nfsvno_namei() is done with CREATE.

This patch adds a KASSERT() to check for that.

PR: 268971

16 months agoFix pjfstest issue tests/rename/09.t
Fedor Uporov [Thu, 2 Feb 2023 10:13:02 +0000 (13:13 +0300)]
Fix pjfstest issue tests/rename/09.t

Fix rename when renamed directory not owned by user,
but when user owns the sticky parent directory.

Reviewed by:    kib
MFC after:      2 week
Differential revision:  https://reviews.freebsd.org/D38245

16 months agostress2: Fix compiler warning about unused variables
Peter Holm [Sat, 11 Feb 2023 05:36:39 +0000 (06:36 +0100)]
stress2: Fix compiler warning about unused variables

16 months agogetopt_long(3): note an inconsistency with getopt(3) in BUGS
Kyle Evans [Sat, 11 Feb 2023 05:31:13 +0000 (23:31 -0600)]
getopt_long(3): note an inconsistency with getopt(3) in BUGS

getopt_long(3) will not allow an `optind` setting of 0 to be bug-for-bug
compatible with the GNU implementation, as some software does rely on
it.  Document it as a BUG, since it affects previous declarations of
compatibility with getopt(3).

Reviewed by: pauamma (markup)
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37867

16 months agonfsd: Fix handling of the error case for nfsvno_open some more
Rick Macklem [Sat, 11 Feb 2023 03:34:57 +0000 (19:34 -0800)]
nfsd: Fix handling of the error case for nfsvno_open some more

Commit ded5f2954e1a defined done_namei to indicate that
nd_repstat was set after a successful nfsvno_namei(),
so that a cleanup needs to be done in nfsvno_open().
However, it missed the case where a call to
nfsrv_opencheck() in nfsvno_open() sets nd_repstat non-zero.

This would cause panics due to a dangling locked vnode
when nfsrv_opencheck() set nd_repstat, such as during grace
just after a server boot.

This patch fixes the problem.

PR: 268971

16 months agoUPDATING: add UPDATING section for HUAWEI 3G/4G Devices change
Michael Paepcke [Fri, 10 Feb 2023 19:26:13 +0000 (19:26 +0000)]
UPDATING: add UPDATING section for HUAWEI 3G/4G Devices change

help users to migrate existing devices

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/645

16 months agou3g: add huawei device id
Michael Paepcke [Fri, 10 Feb 2023 19:06:39 +0000 (19:06 +0000)]
u3g: add huawei device id

Add missing entry for E3372h Model already in NCM mode

Noticed by: David BOYER
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/645

16 months agocdce: add to cdce.4 information about NCM network mode
Michael Paepcke [Fri, 10 Feb 2023 19:43:09 +0000 (19:43 +0000)]
cdce: add to cdce.4 information about NCM network mode

add a new section how to use NCM network mode and specify the required
kernel modules

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/646

16 months agoAdd libclang_rt files for powerpc64le to ObsoleteFiles.inc
Dimitry Andric [Fri, 10 Feb 2023 19:10:31 +0000 (20:10 +0100)]
Add libclang_rt files for powerpc64le to ObsoleteFiles.inc

Since f5024381ac16 we have also built and installed several clang
runtime support libraries (for sanitizers) on powerpc64le, so add
entries to properly clean these up when upgrading.

Reported by: pkubaj
PR: 269423
MFC after: 2 weeks

16 months agocxgbe: fix module loading
Jung-uk Kim [Fri, 10 Feb 2023 18:27:20 +0000 (13:27 -0500)]
cxgbe: fix module loading

After c03414326909, if_cxgbe.ko fails to load if crypto is not compiled
in kernel, e.g., MINIMAL.

link_elf_obj: symbol hmac_init_ipad undefined
linker_load_file: /boot/kernel/if_cxgbe.ko - unsupported file type
kldload: an error occurred while loading module if_cxgbe. Please check dmesg(8) for more details.

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

16 months agotarfs: Fix deadlock between descent and ascent in tarfs_lookup().
Dag-Erling Smørgrav [Fri, 10 Feb 2023 17:19:45 +0000 (17:19 +0000)]
tarfs: Fix deadlock between descent and ascent in tarfs_lookup().

Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D38486

16 months agoahci: increase timout
Mariusz Zaborski [Fri, 10 Feb 2023 15:56:04 +0000 (16:56 +0100)]
ahci: increase timout

For some devices, like Marvell 88SE9230, it takes more time
to connect to the device. This patch introduces a special flag
that extends the timeout from around 100ms to around 500ms.

This change is based on the work of: Peter Eriksson <pen@lysator.liu.se>

PR: 243401
Reviewed by: imp
Tested by: dch
MFC after: 3 days
Sponsored by: Equinix
Sponsored by: SkunkWerks, GmbH
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D38413

16 months agodaemon: add long_opts
Ihor Antonov [Fri, 10 Feb 2023 04:36:07 +0000 (22:36 -0600)]
daemon: add long_opts

Long options improve readability of scripts, makes code comprehension
easier.  This patch adds long options while preserving the existing CLI
interface.

Also --help/-h option is added.

Reviewed by: allanjude, pauamma (both earlier versions), kevans
Differential Revision: https://reviews.freebsd.org/D38244

16 months agolibc: ssp: remove some GCC 4.2 remnants
Kyle Evans [Fri, 10 Feb 2023 04:08:07 +0000 (22:08 -0600)]
libc: ssp: remove some GCC 4.2 remnants

With GCC 4.2 out of the tree for a while now and no sign of it
returning, we don't really need to support older versions that don't
allow us to specify a ctor priority anymore.

Noticed by: mjg

16 months agoMerge bmake-20230208
Simon J. Gerraty [Fri, 10 Feb 2023 01:21:33 +0000 (17:21 -0800)]
Merge bmake-20230208

Merge commit 'f4d51098686d961fc03dc5aa327619d0af3c9dcd'

16 months agoImport bmake-20230208
Simon J. Gerraty [Fri, 10 Feb 2023 01:20:05 +0000 (17:20 -0800)]
Import bmake-20230208

ChangeLog since bmake-20230126

        * VERSION (_MAKE_VERSION): 20230208
        Merge with NetBSD make, pick up
        o var.c: always use SCOPE_GLOBAL for :_ to avoid problems
        when it has been used within conditional expressions

        * install-sh: if making directories ensure umask is set
        to match mode.

        * Makefile: use DIRMODE for directories and
        NONBINMODE for man pages and mk files

16 months agoAdd ck.h userspace shims for CK_SLIST_
Elliott Mitchell [Thu, 9 Feb 2023 23:27:12 +0000 (16:27 -0700)]
Add ck.h userspace shims for CK_SLIST_

MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D38471

16 months agosesutil: plug memory leaks
Alan Somers [Wed, 19 Jan 2022 21:57:27 +0000 (14:57 -0700)]
sesutil: plug memory leaks

MFC after: 1 week
Sponsored by: Axcient
Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D33955

16 months agoinpcb: Split in_pcblookup_hash_locked() and clean up a bit
Mark Johnston [Thu, 9 Feb 2023 20:59:27 +0000 (15:59 -0500)]
inpcb: Split in_pcblookup_hash_locked() and clean up a bit

Split the in_pcblookup_hash_locked() function into several independent
subroutine calls, each of which does some kind of hash table lookup.
This refactoring makes it easier to introduce variants of the lookup
algorithm that behave differently depending on whether they are
synchronized by SMR or the PCB database hash lock.

While here, do some related cleanup:
- Remove an unused ifnet parameter from internal functions.  Keep it in
  external functions so that it can be used in the future to derive a v6
  scopeid.
- Reorder the parameters to in_pcblookup_lbgroup() to be consistent with
  the other lookup functions.
- Remove an always-true check from in_pcblookup_lbgroup(): we can assume
  that we're performing a wildcard match.

No functional change intended.

Reviewed by: glebius
Differential Revision: https://reviews.freebsd.org/D38364

16 months agovmm: Fix AP startup compatibility for old bhyve executables
Mark Johnston [Thu, 9 Feb 2023 20:52:35 +0000 (15:52 -0500)]
vmm: Fix AP startup compatibility for old bhyve executables

These changes unbreak AP startup when using a 13.1-RELEASE bhyve
executable with a newer kernel:
- Correct the destination mask for the VM_EXITCODE_IPI message generated
  by an INIT or STARTUP IPI in vlapic_icrlo_write_handler().
- Only initialize vlapics on active vCPUs.  13.1-RELEASE bhyve activates
  AP vCPUs only after the BSP starts them with an IPI, and vmm now
  allocates vcpu structures lazily, so the STARTUP handling in
  vm_handle_ipi() could trigger a page fault.
- Fix an off-by-one setting the vcpuid in a VM_EXITCODE_SPINUP_AP
  message.

Fixes: 7c326ab5bb9a ("vmm: don't lock a mtx in the icr_low write handler")
Reviewed by: jhb, corvink
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38446

16 months agovmm: Remove an unneeded initialization of "retu"
Mark Johnston [Thu, 9 Feb 2023 20:51:11 +0000 (15:51 -0500)]
vmm: Remove an unneeded initialization of "retu"

vm_handle_ipi() unconditionally initializes "retu".  No functional
change intended.

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

16 months agovmm: Collapse identical case statements in vlapic_icrlo_write_handler()
Mark Johnston [Thu, 9 Feb 2023 20:49:40 +0000 (15:49 -0500)]
vmm: Collapse identical case statements in vlapic_icrlo_write_handler()

No functional change intended.

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

16 months agokern_poll: include sys/sched.h
Mitchell Horne [Thu, 9 Feb 2023 21:08:33 +0000 (17:08 -0400)]
kern_poll: include sys/sched.h

For sched_relinquish(). This fixes the build for some kernel configs.

Reported by: Jenkins
Fixes: 1029dab63457 ("mi_switch(): clean up switch types and their usage")

16 months ago.github: Restrict permissions on cross-build jobs.
Alex [Thu, 9 Feb 2023 20:12:17 +0000 (12:12 -0800)]
.github: Restrict permissions on cross-build jobs.

16 months agoktls: Fix comments & whitespace issues with c0e4090e3d43
Andrew Gallatin [Thu, 9 Feb 2023 19:09:05 +0000 (14:09 -0500)]
ktls: Fix comments & whitespace issues with c0e4090e3d43

Address some last minute review feedback on c0e4090e3d43
by fixing spacing around comments, and clarifying that the
newly added destroy_task is not related to tls 1.0.
No functional change intended.

Pointed out by: jhb
Sponsored by: Netflix

16 months agolua: Export loaded modules env vars via environment
Warner Losh [Thu, 9 Feb 2023 16:49:43 +0000 (09:49 -0700)]
lua: Export loaded modules env vars via environment

To make auditing and debugging easier, export foo_load=XXX foo_name=yyy
etc to the loader env that we export to the kernel.

Original by: dhw
Sponsored by: Netflix
Discussed with: kevans
Differential Revsion: https://reviews.freebsd.org/D38466

16 months agotzcode: Resurrect tzsetwall(3) with a deprecation warning.
Dag-Erling Smørgrav [Thu, 9 Feb 2023 18:35:34 +0000 (19:35 +0100)]
tzcode: Resurrect tzsetwall(3) with a deprecation warning.

This function has been around since 4.4BSD but was dropped upstream in 2020.  This went unnoticed when tzcode was updated.  Bring it back, but prepare for removing it before 14.0 is released.

PR: 269445
MFC after: 3 days
Reported by: val@packett.cool
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D38445

16 months agoktls: Accurately track if ifnet ktls is enabled
Andrew Gallatin [Wed, 8 Feb 2023 20:37:08 +0000 (15:37 -0500)]
ktls: Accurately track if ifnet ktls is enabled

This allows us to avoid spurious calls to ktls_disable_ifnet()

When we implemented ifnet kTLSe, we set a flag in the tx socket
buffer (SB_TLS_IFNET) to indicate ifnet kTLS.  This flag meant that
now, or in the past, ifnet ktls was active on a socket.  Later,
I added code to switch ifnet ktls sessions to software in the case
of lossy TCP connections that have a high retransmit rate.
Because TCP was using SB_TLS_IFNET to know if it needed to do math
to calculate the retransmit ratio and potentially call into
ktls_disable_ifnet(), it was doing unneeded work long after
a session was moved to software.

This patch carefully tracks whether or not ifnet ktls is still enabled
on a TCP connection.  Because the inp is now embedded in the tcpcb, and
because TCP is the most frequent accessor of this state, it made sense to
move this from the socket buffer flags to the tcpcb. Because we now need
reliable access to the tcbcb, we take a ref on the inp when creating a tx
ktls session.

While here, I noticed that rack/bbr were incorrectly implementing
tfb_hwtls_change(), and applying the change to all pending sends,
when it should apply only to future sends.

This change reduces spurious calls to  ktls_disable_ifnet() by 95% or so
in a Netflix CDN environment.

Reviewed by: markj, rrs
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D38380

16 months agotarfs: Fix issues revealed by static analysis and testing.
Dag-Erling Smørgrav [Thu, 9 Feb 2023 17:35:28 +0000 (17:35 +0000)]
tarfs: Fix issues revealed by static analysis and testing.

* tarfs_alloc_mount(): Remove an unnecessary null check (CID 1504505) and an unused variable.

* tarfs_alloc_one(): Verify that the file size is not negative (CID 1504506).  While there, also validate the mode, owner and group.

* tarfs_vget(), tarfs_zio_init(): Explicitly ignore return value from getnewvnode(), which cannot fail (CID 1504508)

* tarfs_lookup_path(): Fix a case where a specially-crafted tarball could trigger a null pointer dereference by first descending into, and then backing out of, a previously unknown directory. (CID 1504515)

* mktar: Construct a tarball that triggers the aforementioned null pointer dereference.

Reported by: Coverity
Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Reviewed by: imp, kib
Differential Revision: https://reviews.freebsd.org/D38463

16 months agoMINIMAL: Update and clean up.
Dag-Erling Smørgrav [Thu, 9 Feb 2023 17:24:08 +0000 (18:24 +0100)]
MINIMAL: Update and clean up.

* Add GEOM_LABEL, required to boot a default UEFI install.

* Add enough of virtio to boot in bhyve.

* Reduce diff between amd64 and i386.

* Reduce diff to GENERIC.

MFC after: 1 week
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D38468

16 months agoReapply: <type_traits>: Avoid instantiating a pointer type in std::decay<>
Dimitry Andric [Thu, 9 Feb 2023 09:33:42 +0000 (10:33 +0100)]
Reapply: <type_traits>: Avoid instantiating a pointer type in std::decay<>

  GCC expands the pointer type in this conditional expression even for
  template types _Up that are not arrays.  This raises an error when
  std::decay<> is used with reference types (as is done in LLVM's
  sources).  Using add_pointer<> causes GCC to only instantiate a
  pointer type for array types.

  A similar change to this commit (albeit reworked due to upstream
  changes) has been merged to libc++ in commit
  26068c6e60324ed866a1ca2afb5cb5eb0aaf015b.

  In file included from /usr/obj/usr/src/amd64.amd64/tmp/usr/include/c++/v1/__compare/ordering.h:13,
                   from /usr/obj/usr/src/amd64.amd64/tmp/usr/include/c++/v1/__compare/common_comparison_category.h:12,
                   from /usr/obj/usr/src/amd64.amd64/tmp/usr/include/c++/v1/tuple:168,
                   from /usr/src/contrib/llvm-project/llvm/include/llvm/ADT/DenseMapInfo.h:20,
                   from /usr/src/contrib/llvm-project/llvm/include/llvm/ADT/DenseMap.h:17,
                   from /usr/src/contrib/llvm-project/llvm/lib/Transforms/Scalar/GVNHoist.cpp:36:
  /usr/obj/usr/src/amd64.amd64/tmp/usr/include/c++/v1/type_traits: In instantiation of 'struct std::__1::__decay<llvm::CHIArg&, true>':
  /usr/obj/usr/src/amd64.amd64/tmp/usr/include/c++/v1/type_traits:1591:89:   required from 'struct std::__1::decay<llvm::CHIArg&&>'
  /usr/obj/usr/src/amd64.amd64/tmp/usr/include/c++/v1/__utility/pair.h:132:16:   required by substitution of 'template<class _Tuple, typename std::__1::enable_if<typename std::__1::conditional<(std::__1::__tuple_like_with_size<_Tuple, 2, typename std::__1::__uncvref<_Tp>::type>::value && (! std::__1::is_same<typename std::__1::decay<_Tp>::type, std::__1::pair<llvm::BasicBlock*, llvm::SmallVector<llvm::CHIArg, 2> > >::value)), std::__1::pair<llvm::BasicBlock*, llvm::SmallVector<llvm::CHIArg, 2> >::_CheckTupleLikeConstructor, std::__1::__check_tuple_constructor_fail>::type::__enable_implicit<_Tuple>(), void>::type* <anonymous> > constexpr std::__1::pair<llvm::BasicBlock*, llvm::SmallVector<llvm::CHIArg, 2> >::pair(_Tuple&&) [with _Tuple = llvm::CHIArg&&; typename std::__1::enable_if<typename std::__1::conditional<(std::__1::__tuple_like_with_size<_Tuple, 2, typename std::__1::__uncvref<_Tp>::type>::value && (! std::__1::is_same<typename std::__1::decay<_Tp>::type, std::__1::pair<llvm::BasicBlock*, llvm::SmallVector<llvm::CHIArg, 2> > >::value)), std::__1::pair<llvm::BasicBlock*, llvm::SmallVector<llvm::CHIArg, 2> >::_CheckTupleLikeConstructor, std::__1::__check_tuple_constructor_fail>::type::__enable_implicit<_Tuple>(), void>::type* <anonymous> = <missing>]'
  /usr/src/contrib/llvm-project/llvm/lib/Transforms/Scalar/GVNHoist.cpp:892:51:   required from here
  /usr/obj/usr/src/amd64.amd64/tmp/usr/include/c++/v1/type_traits:1582:30: error: forming pointer to reference type 'std::__1::remove_extent<llvm::CHIArg&>::type' {aka 'llvm::CHIArg&'}
   1582 |                      >::type type;
        |                              ^~~~

  Reviewed by:    dim
  Differential Revision:  https://reviews.freebsd.org/D36898

This reapplies commit c36de97088a2b9141cdaf2fae2a7f41bf820ffa0, which I
accidentally overwrote in the llvm 15 merge. (It turns out upstream did
not merge this to their 15.x branch.)

MFC after: 2 weeks

16 months agomi_switch(9): update to current day
Mitchell Horne [Thu, 9 Feb 2023 15:41:14 +0000 (11:41 -0400)]
mi_switch(9): update to current day

The function itself and much of the information in this page remains
relevant, but many details need to be fixed.
 - Update function signatures
 - Update the list of major uses of mi_switch() (it is not exhaustive)
 - Document 'flags' argument and its possible values
 - Document thread lock requirement for callers
 - Thread runtime limits are out of scope now, no need to describe them
 - Remove outdated information w.r.t. KSE, runqueue, non-preemptible
   kernel, etc
 - Update the description of cpu_switch() and its responsibilities

PR: 149574
Reviewed by: kib
Discussed with: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38185

16 months agomi_switch(): clean up switch types and their usage
Mitchell Horne [Thu, 9 Feb 2023 15:40:29 +0000 (11:40 -0400)]
mi_switch(): clean up switch types and their usage

Overall, this is a non-functional change, except for kernels built with
SCHED_STATS. However, the switch types are useful for communicating the
intent of the caller.

1. Ensure that every caller provides a type. In most cases, we upgrade
   the basic yield to sched_relinquish() aka SWT_RELINQUISH.
2. The case of sched_bind() is distinct, so add a new switch type SWT_BIND.
3. Remove the two unused types, SWT_PREEMPT and SWT_SLEEPQTIMO.
4. Remove SWT_NONE altogether and assert that callers always provide
   a type flag.
5. Reference the mi_switch(9) man page in the comments, as these flags
   will be documented there.

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

16 months agosched_4bsd: use the same switch flags as ULE
Mitchell Horne [Thu, 9 Feb 2023 15:39:12 +0000 (11:39 -0400)]
sched_4bsd: use the same switch flags as ULE

ULE uses the more specific SWT_REMOTEPREEMPT and SWT_REMOTEWAKEIDLE
switch types, let's do that here as well. SWT_PREEMPT is somewhat
redundant when we also have the SW_PREEMPT flag.

This only has an effect for kernels built with SCHED_STATS.

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

16 months agoman9: Add man page for kern_yield() and friends
Mitchell Horne [Thu, 9 Feb 2023 15:35:39 +0000 (11:35 -0400)]
man9: Add man page for kern_yield() and friends

The page is fairly simple and will be referenced by mi_switch(9).
Provide some usage notes so that the broader implications of how/when to
use these functions are understood.

Reviewed by: kib, markj
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38182

16 months agoUse maybe_yield() in a few more places
Mitchell Horne [Thu, 9 Feb 2023 15:42:53 +0000 (11:42 -0400)]
Use maybe_yield() in a few more places

Reviewed by: kib, markj
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38186

16 months agoBoolify should_yield()
Mitchell Horne [Thu, 9 Feb 2023 15:35:11 +0000 (11:35 -0400)]
Boolify should_yield()

Do this ahead of adding a man page that describes the function. No
functional change.

Reviewed by: kib, markj
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38181

16 months agoUpdate comments referencing create_thread()
Mitchell Horne [Thu, 9 Feb 2023 15:34:38 +0000 (11:34 -0400)]
Update comments referencing create_thread()

The equivalent function is now named thread_create(). Mention
kthread_add() where it is also relevant.

Reviewed by: kib, markj
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38180

16 months agonetlink: return optional metadata with the operation result.
Alexander V. Chernikov [Thu, 9 Feb 2023 14:53:44 +0000 (14:53 +0000)]
netlink: return optional metadata with the operation result.

Some operations like interface creation may need to return metadata
 - in this case, interface name - back to the caller if the operation
 is successful.
This change implements attaching an `NLMSGERR_ATTR_COOKIE` nla to the
operation reply message via `nlmsg_report_cookie()`.
Additionally, on successful interface creation, interface index and
 interface name are returned in the `IFLA_NEW_IFINDEX` and `IFLA_IFNAME
 TLVs, encapsulated in the `NLMSGERR_ATTR_COOKIE`.

Reviewed By: pauamma
Differential Revision: https://reviews.freebsd.org/D38283
MFC after: 1 week

16 months agoatomic: Fix the atomic_load_ptr() *SAN interceptor
Mark Johnston [Thu, 9 Feb 2023 14:54:52 +0000 (09:54 -0500)]
atomic: Fix the atomic_load_ptr() *SAN interceptor

The interceptor didn't handle a pointer of type "foo * const *" and in
that case we'd get compiler errors 1) an invalid cast to volatile
uintptr_t, and 2) an assignment to a variable of type "foo * const"
(__retptr).

Reported by: mjg
MFC after: 1 week

16 months agotesting: handling non-root users with VNETs in pytest-based tests.
Alexander V. Chernikov [Thu, 9 Feb 2023 14:31:34 +0000 (14:31 +0000)]
testing: handling non-root users with VNETs in pytest-based tests.

Currently isolation and resource requirements are handled directly
 by the kyua runner, based on the requirements specified by the test.
It works well for simple tests, but may cause discrepancy with tests
 doing complex pre-setups. For example, all tests that perform
 VNET setups require root access to properly function.

This change adds additional handling of the "require_user" property
 within the python testing framework. Specifically, it requests
 root access if the test class signals its root requirements and
 drops privileges to the desired user after performing the pre-setup.

Differential Revision: https://reviews.freebsd.org/D37923
MFC after: 2 weeks

16 months agonetlink: do not require elevated privileges when reading arp/ndp state.
Alexander V. Chernikov [Thu, 9 Feb 2023 14:12:33 +0000 (14:12 +0000)]
netlink: do not require elevated privileges when reading arp/ndp state.

MFC after: 1 day

16 months agoAdd libclang_rt files for powerpc64 to ObsoleteFiles.inc
Dimitry Andric [Thu, 9 Feb 2023 08:59:54 +0000 (09:59 +0100)]
Add libclang_rt files for powerpc64 to ObsoleteFiles.inc

Since f5024381ac16 we have also built and installed several clang
runtime support libraries (for sanitizers) on powerpc64, so add entries
to properly clean these up when upgrading.

Reported by: pkubaj
PR: 269423
MFC after: 2 weeks

16 months agobuildworld: drop config(8) dependencies from bootstrap
Kyle Evans [Thu, 9 Feb 2023 04:56:12 +0000 (22:56 -0600)]
buildworld: drop config(8) dependencies from bootstrap

We may still need them for other parts, so just remove the dependency
relationship for now and simplify config's place in bootstrap-tools.

Reviewed by: imp
Sponsored by: Klara, Inc.
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D38277

16 months agotools: cleanup stale dependencies from further config(8) C++ification
Kyle Evans [Thu, 9 Feb 2023 04:56:11 +0000 (22:56 -0600)]
tools: cleanup stale dependencies from further config(8) C++ification

Sponsored by: Klara, Inc.
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D38276

16 months agoconfig: drop dependency on libsbuf
Kyle Evans [Thu, 9 Feb 2023 04:56:10 +0000 (22:56 -0600)]
config: drop dependency on libsbuf

Use an std::stringstream instead.  get_word() and get_quoted_word() both
return a buffer that's presumed to not need release, so solve this by
returning a new special configword type that holds a string or eof/eol
state.  This cleans up caller checking for EOF/EOL to make it more
explicit what they're doing, at least in the EOL cases which previously
checked for NULL.

Sponsored by: Klara, Inc.
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D38276

16 months agoamd64 ia32 vdso: always define some __vdso_ symbols
Konstantin Belousov [Sun, 5 Feb 2023 21:41:25 +0000 (23:41 +0200)]
amd64 ia32 vdso: always define some __vdso_ symbols

... regardless of the kernel config options.
It is reported that llvm16 ld.lld warns about undefined symbols
referenced by the VERSION script.

Reviewed by: emaste, val_packett.cool
Discussed with: jrtc27
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D38392

16 months agoamd64: record a dependency of vdso on its linker script
Konstantin Belousov [Sun, 5 Feb 2023 21:40:31 +0000 (23:40 +0200)]
amd64: record a dependency of vdso on its linker script

Reviewed by: emaste, val_packett.cool
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D38392

16 months agoe1000: Add support for future client platforms
Kevin Bowling [Thu, 9 Feb 2023 01:14:41 +0000 (18:14 -0700)]
e1000: Add support for future client platforms

MFC after: 2 weeks
Sponsored by: BBOX.io

16 months agoe1000: Fix packet loss on 11th gen and later
Kevin Bowling [Thu, 9 Feb 2023 00:32:54 +0000 (17:32 -0700)]
e1000: Fix packet loss on 11th gen and later

Ungate DMA clock on TGP and later to avoid packet loss.

A similar fix appears in Linux 639e298f432fb058a9496ea16863f53b1ce935fe

This may be needed as far back as SPT but no confirmation from intel or
other OS yet.

Obtained from: OpenBSD (if_em_hw.c 1.116)
MFC after: 2 weeks
Sponsored by: BBOX.io

16 months agoe1000: Remove redundant disable_ulp for ich8lan
Kevin Bowling [Wed, 8 Feb 2023 23:17:03 +0000 (16:17 -0700)]
e1000: Remove redundant disable_ulp for ich8lan

This call only makes sense for ich8lan, and the shared code does it in
e1000_setup_init_funcs() above this deletion.

Obtained from: DPDK
MFC after: 2 weeks
Sponsored by: BBOX.io
Pull Request: https://github.com/freebsd/freebsd-src/pull/539

16 months agossh: fix SIZEOF_TIME_T #define on i386
Ed Maste [Wed, 8 Feb 2023 18:31:44 +0000 (13:31 -0500)]
ssh: fix SIZEOF_TIME_T #define on i386

Reported by: imp
Reviewed by: imp
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38443

16 months agoheimdal: Resolve hdb_free_entry() SIGSEGV/SIGILL
Cy Schubert [Tue, 7 Feb 2023 15:46:59 +0000 (07:46 -0800)]
heimdal: Resolve hdb_free_entry() SIGSEGV/SIGILL

When the client sends kadmind a create principal (kadm_create) request
kadm_s_create_principal() returns an error before zeroing out ent (an
hdb entry structure wrapper -- hdb_entry_ex), resulting in a NULL
reference.

Fix obtained from upstream commit 35ea4955a.

PR: 268059
Reported by: Robert Morris <rtm@lcs.mit.edu>
Obtained from: Heimdal commit 35ea4955a
MFC after: 3 days

16 months agodepend-cleanup.sh: Simplify the logic, and clean bootstrap tools.
Dag-Erling Smørgrav [Wed, 8 Feb 2023 22:58:51 +0000 (23:58 +0100)]
depend-cleanup.sh: Simplify the logic, and clean bootstrap tools.

* There's no need to check if the file exists before grepping it; if it does not exist, grep will fail, which is what we want.  Just redirect the error message to /dev/null.
* There's no need to split the .o and .pico cases; the bodies are identical, so combine the conditions.  Use a glob to avoid a false negative if one exists but not the other.
* Also run depend-cleanup.sh on the bootstrap build tree.  This unbreaks the build after 29c5f8bf9a01.

Sponsored by: Klara, Inc.
Sponsored by: NetApp, Inc.
Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D38447

16 months agonfscl: Fix interaction between mmap'd and VOP_WRITE file updates
Rick Macklem [Wed, 8 Feb 2023 22:25:01 +0000 (14:25 -0800)]
nfscl: Fix interaction between mmap'd and VOP_WRITE file updates

asomers@ found a problem with the NFS client, where a write to
an NFS mounted file done via mmap(2) was lost when fspacectl(2)
was done before it.  This turned out to be caused by clearing the
dirty bit on pages when the client was doing commit RPCs,
due to the second argument to vfs_busy_pages() being set to 1.
Commit RPCs tell the server to commit previously written data to
stable storage.  However, Commit RPCs do not write data from the
client to the server.  As such, if the dirty bit on the page has
been set by a mmap'd write to an address in the page, it should
not be cleared.  Clearing it causes the mmap'd write to by lost.

This patch fixes the problem by changing the 2nd argument to
vfs_busy_pages() to 0 for this case.

I doubt this bug has affected many, since it was inherited from
the old NFS client and was in 4.3 FreeBSD twenty years ago.
Although fspacectl(2) is FreeBSD 14 specific, a write(2) would
cause the same failure.

Reviewed by: kib
Tested by: asomers
PR: 269328
MFC after: 1 week

16 months agonfsd: Fix handling of the error case for nfsvno_open
Rick Macklem [Wed, 8 Feb 2023 21:06:07 +0000 (13:06 -0800)]
nfsd: Fix handling of the error case for nfsvno_open

Using done_namei instead of ni_startdir did not
fix the crashes reported in the PR. Upon looking
more closely at the code, the only case where the
code near the end of nfsvno_open() needs to be
executed is when nfsvno_namei() has succeeded,
but a subsequent error was detected.

This patch uses done_namei to indicate this case.

Also, nfsvno_relpathbuf() should only be called for
this case and not whenever nfsvno_open() is called
with nd_repstat != 0. A bug was introduced here when
the HASBUF flag was deleted.

Reviewed by: mjg
PR: 268971
Tested by: ish@amail.plala.or.jp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D38430

16 months agonetmap: drop redundant if_mtu assignment
Vincenzo Maffione [Wed, 8 Feb 2023 21:05:32 +0000 (21:05 +0000)]
netmap: drop redundant if_mtu assignment

Reported by: zlei
MFC after 3 days

16 months agophysmem: add ram0 pseudo-driver
Mitchell Horne [Thu, 27 May 2021 14:27:40 +0000 (11:27 -0300)]
physmem: add ram0 pseudo-driver

Its purpose is to reserve all I/O space belonging to physical memory
from nexus, preventing it from being handed out by bus_alloc_resource()
to callers such as xenpv_alloc_physmem(), which looks for the first
available free range it can get. This mimics the existing pseudo-driver
on x86.

If needed, the device can be disabled with hint.ram.0.disabled="1" in
/boot/device.hints.

Reviewed by: imp
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D32343

16 months agoofwbus: remove handling of resources from ofwbus
Elliott Mitchell [Wed, 8 Feb 2023 20:17:03 +0000 (16:17 -0400)]
ofwbus: remove handling of resources from ofwbus

The architecture nexus should handle allocation and release of memory and
interrupts. This is to ensure that system-wide resources such as these
are available to all devices, not just children of ofwbus0.

On powerpc this moves the ownership of these resources up one level,
from ofwbus0 to nexus0. Other architectures already have the required
logic in their nexus implementation, so this eliminates the duplication
of resources. An implementation of nexus_adjust_resource() is added for
arm, arm64, and riscv.

As noted by ian@ in the review, resource handling was the main bit of
logic distinguishing ofwbus from simplebus. With some attention to
detail, it should be possible to merge the two in the future.

Co-authored by: mhorne
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D30554

16 months agoarm: add an interrupt rman to nexus
Mitchell Horne [Sun, 5 Dec 2021 15:27:50 +0000 (11:27 -0400)]
arm: add an interrupt rman to nexus

Allow the nexus bus to own and manage interrupt resources. Currently,
interrupt resources on this architecture are managed completely by
ofwbus, but it is desirable that system-wide memory and interrupt
resources be managed by the top-level bus.

This is a pre-requisite to moving this resource management out of
ofwbus.

Reviewed By: ian, Elliott Mitchell <ehem+freebsd@m5p.com>
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D32357

16 months agoAdd nproc(1)
Mateusz Guzik [Sat, 4 Feb 2023 23:33:48 +0000 (23:33 +0000)]
Add nproc(1)

This program prints the number of CPU threads it can run on, while
respecting cpusets (or not, depending on switches).

It aims to be compatible with nproc as found in GNU coreutils.

Reviewed by: des
Reviewed by: pstef
Differential Revision: https://reviews.freebsd.org/D38386