]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
14 months agopw: do not call system()
Baptiste Daroussin [Mon, 15 May 2023 06:55:08 +0000 (08:55 +0200)]
pw: do not call system()

Calling system makes pw(8) spawn a shell, which can then be abused.

MFC After: 3 days

(cherry picked from commit ef7d0eb9489f39169a1ae83c576fe74e40d126ad)

14 months agosh(1): fix history file write checking
Daniel Kolesa [Mon, 20 Mar 2023 16:42:59 +0000 (17:42 +0100)]
sh(1): fix history file write checking

We cannot just compare histsizeval() against 0, since that returns
a string pointer, which is always non-zero (non-null). The logic
in sethistsize() initializes the history size to 100 with values
that are non-number, and an empty string counts as that. Therefore,
the only time we want to not write into history with HISTSIZE val
set is when it's explicitly 0.

MFC after: 2 weeks

(cherry picked from commit 3ce64010f8ce3accc64eff312f31dc0d3c0fc9d1)

14 months agosvc_rpcsec_gss.c: Separate out the non-vnet initialization
Rick Macklem [Wed, 1 Mar 2023 23:29:25 +0000 (15:29 -0800)]
svc_rpcsec_gss.c: Separate out the non-vnet initialization

Without this patch, a single initialization function was
used to initialize both the vnet'd and non-vnet'd data.
This patch separates out the non-vnet'd initializations
into a separate function invoked by SYSINIT().
This avoids use of IS_DEFAULT_VNET() in the initialization
functions and also configures the non-vnet'd initialization
function to be called first, although ordering is not
currently needed.

(cherry picked from commit 57ff348804f98d956f2e203b665de5a8989dbf8c)

14 months agonfsd: Fix a use after free when vnet prisons are deleted
Rick Macklem [Fri, 24 Feb 2023 15:36:28 +0000 (07:36 -0800)]
nfsd: Fix a use after free when vnet prisons are deleted

The Kasan tests show the nfsrvd_cleancache() results
in a modify after free. I think this occurs because the
nfsrv_cleanup() function gets executed after nfs_cleanup()
which free's the nfsstatsv1_p.

This patch makes them use the same subsystem and sets
SI_ORDER_FIRST for nfs_cleanup(), so that it will be called
after nfsrv_cleanup() via VNET_SYSUNINIT().

The patch also sets nfsstatsv1_p NULL after free'ng it,
so that a crash will result if it is used after free'ng.

(cherry picked from commit 4036fcb8053adf3ac54c8428eef0dd076dfc1718)

14 months agonfscommon: Use IS_DEFAULT_VNET() in the vnet initialization
Rick Macklem [Tue, 21 Feb 2023 03:43:37 +0000 (19:43 -0800)]
nfscommon: Use IS_DEFAULT_VNET() in the vnet initialization

Another oopsie.  The vnet initialization function in
nfs_commonport.c for initializing prison0 by testing
curthread->td_ucred->cr_prison == &prison0. This is bogus
and always true.  Replace it with IS_DEFAULT_VNET(curvnet).

(cherry picked from commit ef4e8f0cf91f7009745d5a7a90d3bdd2d9e25780)

14 months agonfsd: Add VNET_SYSUNINIT() macros for vnet cleanup
Rick Macklem [Mon, 20 Feb 2023 21:11:22 +0000 (13:11 -0800)]
nfsd: Add VNET_SYSUNINIT() macros for vnet cleanup

Commit ed03776ca7f4 enabled the vnet front end macros.
As such, for kernels built with the VIMAGE option will malloc
data and initialize locks on a per-vnet basis, typically
via a VNET_SYSINIT().

This patch adds VNET_SYSUNINIT() macros to do the frees
of the per-vnet malloc'd data and destroys of per-vnet
locks.  It also removes the mtx_lock/mtx_unlock calls
from nfsrvd_cleancache(), since they are not needed.

(cherry picked from commit ef6fcc5e2b0714c859d2e4ba23a55b1fd12f8a4e)

14 months agonfsd: Enable the NFSD_VNET vnet front end macros
Rick Macklem [Sat, 18 Feb 2023 22:59:36 +0000 (14:59 -0800)]
nfsd: Enable the NFSD_VNET vnet front end macros

Several commits have added front end macros for the vnet
macros to the NFS server, krpc and kgssapi.  These macros
are now null, but this patch changes them to front end
the vnet macros.

With this commit, many global variables in the code become
vnet'd, so that nfsd(8), nfsuserd(8), rpc.tlsservd(8) and
gssd(8) can run in a vnet prison, once enabled.
To run the NFS server in a vnet prison still requires a
couple of patches (in D37741 and D38371) that allow mountd(8)
to export file systems from within a vnet prison.  Once
these are committed to main, a small patch to kern_jail.c
allowing "allow.nfsd" without VNET_NFSD defined will allow
the NFS server to run in a vnet prison.

One area that still needs to be settled is cleanup when a
prison is removed.  Without this, everything should work
except there will be a leak of malloc'd data and mutex locks
when a vnet prison is removed.

(cherry picked from commit ed03776ca7f43de8275da80cfa89a9ecc4732f82)

14 months agoUPDATING: Update release name and handbook link
Graham Perrin [Thu, 18 May 2023 14:13:04 +0000 (08:13 -0600)]
UPDATING: Update release name and handbook link

Pull-Request: https://github.com/freebsd/freebsd-src/pull/714
Reviewed-by: imp
14 months agoMFV: less v632.
Xin LI [Tue, 2 May 2023 03:43:57 +0000 (20:43 -0700)]
MFV: less v632.

(cherry picked from commit d713e0891ff9ab8246245c3206851d486ecfdd37)

14 months agokrpc: Remove VNET_NFSD #ifdefs
Rick Macklem [Tue, 14 Feb 2023 21:53:39 +0000 (13:53 -0800)]
krpc: Remove VNET_NFSD #ifdefs

The consensus is that the VNET_NFSD kernel option is not
needed, so this commit removes its use from the kernel RPC.

(cherry picked from commit 364391a9bb5eb85af5f711a952ba40a4b1f768da)

14 months agonfscommon: Revert use of nfsstatsv1_p in nfs_commonkrpc.c
Rick Macklem [Fri, 17 Feb 2023 01:44:19 +0000 (17:44 -0800)]
nfscommon: Revert use of nfsstatsv1_p in nfs_commonkrpc.c

Commit 9d329bbc9aea converted a lot of accesses to nfsstatsv1
to use nfsstatsv1_p instead.  However, the accesses in
nfs_commonkrpc.c are for client side and should not be
converted.  This patch puts them back in the correct
pre-commit 9d329bbc9aea form.

(cherry picked from commit a63b5d488badce9298e4272da2d5344e9f83a13d)

14 months agonfscl: Add NFSD_CURVNET macros to nfsclient syscall
Rick Macklem [Tue, 21 Feb 2023 00:40:07 +0000 (16:40 -0800)]
nfscl: Add NFSD_CURVNET macros to nfsclient syscall

Although the nfsclient syscall is used for client side,
it does set up server side krpc for callbacks.  As such,
it needs to have the vnet set.  This patch does this.
Without this patch, the system would crash when the
nfscbd(8) daemon was killed.

(cherry picked from commit 357492c99597d13bc966441f30bb44f6ef659f08)

14 months agokrpc: Replace !jailed() with IS_DEFAULT_VNET()
Rick Macklem [Thu, 16 Feb 2023 22:32:50 +0000 (14:32 -0800)]
krpc: Replace !jailed() with IS_DEFAULT_VNET()

Since svcpool_create() is now called from an initialization function,
!jailed() no longer works.  Replace it with IS_DEFAULT_VNET().

(cherry picked from commit 780bae23b8e6c386e4b2f971eb27fa3bd1a6edd1)

14 months agokrpc: Allow mountd/nfsd to optionally run in a jail
Rick Macklem [Sun, 18 Dec 2022 20:40:48 +0000 (12:40 -0800)]
krpc: Allow mountd/nfsd to optionally run in a jail

This patch modifies the kernel RPC so that it will allow
mountd/nfsd to run inside of a vnet jail.  Running mountd/nfsd
inside a vnet jail will be enabled via a new kernel build
option called VNET_NFSD, which will be implemented in future
commits.

Although I suspect cr_prison can be set from the credentials
of the current thread unconditionally, I #ifdef'd the code
VNET_NFSD and only did this for the jailed case mainly to
document that it is only needed for use in a jail.

The TLS support code has not yet been modified to work in
a jail.  That is planned as future development after the
basic VNET_NFSD support is in the kernel.

This patch should not result in any semantics change until
VNET_NFSD is implemented and used in a kernel configuration.

(cherry picked from commit 6a76d35cac8e1549f74bd4cdceccc2ee52c8e556)

14 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.

(cherry picked from commit ab0440af75ba0c2dbf263c5441ccbe4058515fff)

14 months agokgssapi: Add macros so that gssd(8) can run in vnet prison
Rick Macklem [Wed, 15 Feb 2023 23:18:46 +0000 (15:18 -0800)]
kgssapi: Add macros so that gssd(8) can run in 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 similar macros named KGSS_VNETxxx so that
the gssd(8) daemon can run in a vnet prison, once the
macros front end the vnet ones.  For now, they are null macros.

This is the last commit that adds macros.  The next step is
to change the macros to front end the vnet ones.

(cherry picked from commit 2894c8c96b9b94f35aaa27ee5ef3ac11c276fe3f)

14 months agokrpc: Add macros so that rpc.tlsservd can run in vnet prison
Rick Macklem [Wed, 15 Feb 2023 13:58:21 +0000 (05:58 -0800)]
krpc: Add macros so that rpc.tlsservd can run in 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 similar macros named KRPC_VNETxxx so that
the rpc.tlsservd(8) daemon can run in a vnet prison, once the
macros front end the vnet ones.  For now, they are null macros.

(cherry picked from commit 6444662a563ba714fed8563645764262c6f5e90f)

14 months agoprison_check_nfsd: Add check for enforce_statfs != 0
Rick Macklem [Thu, 2 Feb 2023 00:02:20 +0000 (16:02 -0800)]
prison_check_nfsd: Add check for enforce_statfs != 0

Since mountd(8) will not be able to do exports
when running in a vnet prison if enforce_statfs is
set to 0, add a check for this to prison_check_nfsd().

(cherry picked from commit 99187c3a44c2c3e168e462a30d45af075748195f)

14 months agokern_jail.c: Allow mountd/nfsd to optionally run in a jail
Rick Macklem [Sat, 17 Dec 2022 21:43:49 +0000 (13:43 -0800)]
kern_jail.c: Allow mountd/nfsd to optionally run in a jail

This patch adds "allow.nfsd" to the jail code based on a
new kernel build option VNET_NFSD.  This will not work
until future patches fix nmount(2) to allow mountd to
run in a vnet prison and the NFS server code is patched
so that global variables are in a vnet.

The jail(8) man page will be patched in a future commit.

(cherry picked from commit bba7a2e89602e6745bb2ec474f5ab714aef49f42)

14 months agomrsas: Fix a typo in a source code comment
Zhenlei Huang [Fri, 28 Apr 2023 10:01:58 +0000 (18:01 +0800)]
mrsas: Fix a typo in a source code comment

- s/feild/field/

MFC after: 3 days

(cherry picked from commit bbfb244724e25933d7c7cf68b943e0c2a7d6e381)

14 months agomps: Fix a typo in a source code comment
Zhenlei Huang [Fri, 28 Apr 2023 10:01:58 +0000 (18:01 +0800)]
mps: Fix a typo in a source code comment

- s/feild/field/

MFC after: 3 days

(cherry picked from commit 5bcbdb0b2eb4c14ef0a8671c996337acdefb7f72)

14 months agoixgbe: Fix typos in source code comments
Ian Moffett [Fri, 28 Apr 2023 10:01:58 +0000 (18:01 +0800)]
ixgbe: Fix typos in source code comments

- s/feilds/fields/

Reviewed by: zlei
MFC after: 3 days
Pull Request: https://github.com/freebsd/freebsd-src/pull/707

(cherry picked from commit 99cb088f1a2513ad71225b9691e0aed09ba8fafe)

14 months agoelf.5: Fix conjugation of holds
Zhenlei Huang [Tue, 25 Apr 2023 10:21:52 +0000 (18:21 +0800)]
elf.5: Fix conjugation of holds

MFC after: 1 week

(cherry picked from commit 6f96b5487f4359199ceb8339d2d7063e2249f538)

14 months agoip_mroute: Delete unreachable code
Zhenlei Huang [Sun, 23 Apr 2023 04:47:57 +0000 (12:47 +0800)]
ip_mroute: Delete unreachable code

As the flag M_WAITOK is passed to ip_encap_attach(), then the function
will never return NULL, and the following code within NULL check branch
will be unreachable.

No functional change intended.

Reviewed by: kp
Fixes: 6d8fdfa9d5e7d Rework IP encapsulation handling code
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D39746

(cherry picked from commit b658c0fce10a06493dc468fc9f6699120473e17b)

14 months agoif_stf: Delete unreachable code
Zhenlei Huang [Sun, 23 Apr 2023 04:47:57 +0000 (12:47 +0800)]
if_stf: Delete unreachable code

As the flag M_WAITOK is passed to ip_encap_attach(), then the function
will never return NULL, and the following code within NULL check branch
will be unreachable.

No functional change intended.

Reviewed by: kp
Fixes: 6d8fdfa9d5e7d Rework IP encapsulation handling code
MFC after: 1 week
Differential Revision:  https://reviews.freebsd.org/D39746

(cherry picked from commit c373e1d6adbc3785e8f1072cdc4a062733baa514)

14 months agonfs_fha_new: Fix nfs_fha_new so that sysctls work in prisons
Rick Macklem [Wed, 1 Mar 2023 23:25:35 +0000 (15:25 -0800)]
nfs_fha_new: Fix nfs_fha_new so that sysctls work in prisons

The sysctls were in "struct fha_params", making it impractical
to vnet them.  This patch moves the sysctls out of "struct fha_params"
and vnet's them, so that they are available in vnet prisons
running nfsd(8).  It also avoids the IS_DEFAULT_VNET() macros
in the VNET_SYSINIT() function.

(cherry picked from commit a90b47abcbdbd48c68fbf7c407546293479056de)

14 months agonfsd: Add NFSD_VNET() macros to nfs_fha_new.c
Rick Macklem [Sat, 18 Feb 2023 15:45:38 +0000 (07:45 -0800)]
nfsd: Add NFSD_VNET() macros to nfs_fha_new.c

Although it is not 100% obvious if the affinity threads
lists need to be vnet'd when nfsd runs in a prison, I
think it is necessary for the unusual case where the
same file system is exported in multiple prisons.
For this case, the affinity code might try to assign
the RPC to a svc thread that runs in a different prison.
Also, it makes sense to vnet them, since there are
separate svc threads for each prison running nfsd(8).

This patch adds the macros for vnet'ng to nfs_fha_new.c.
The macros are still null, so the only semantics change
is malloc'ng the fha_param structure.

(cherry picked from commit cd406ac94d8beae7f184adb14a3c94e058366b9a)

14 months agonfsd: Get rid of useless "pool" field in nfs_fha_new.c
Rick Macklem [Fri, 17 Feb 2023 15:34:40 +0000 (07:34 -0800)]
nfsd: Get rid of useless "pool" field in nfs_fha_new.c

Since svcpool_create() is now called from an initialization function,
the pool field of fha_params is always non-NULL, so just get
rid of it and the useless check for it being NULL.

(cherry picked from commit b99c419587db2ac75b929637f61ec3b845d7b5f6)

14 months agofreebsd-update: Fix merging already-updated files
Colin Percival [Fri, 5 May 2023 03:00:58 +0000 (20:00 -0700)]
freebsd-update: Fix merging already-updated files

When performing an "upgrade" (moving between FreeBSD releases, as
opposed to "update" which merely applies security/errata updates
to the installed release) FreeBSD Update:

1. Generates a list of "files needing to be merged", namely those
files which don't match the version installed in the "old" release
and have paths matching the MergeChanges configuration directive
(by default, /boot/device.hints and everything under /etc/).

and later on,

2. Compares the currently-installed files to the versions in the
"new" release, removing index entries for files which "don't need
to be updated because they're not changing".

Unfortunately if a file falls into both of these categories -- that
is to say, if a file in /etc/ is the same as the version in the new
release and not the same as the version in the old release -- the
resulting "merge" step saw that the file was no longer listed as
being part of the new release, resulting in the file being deleted.

For the first 18 years of FreeBSD Update's existence, this never
happened, since $FreeBSD$ tags resulted in "new release" files
always being different from any files systems would already have
installed.

This commit fixes this behaviour by only placing a file into the
"files needing to be merged" list if it does not match the version
in the old release *or* the version in the new release.

Reported by: des
Reviewed by: delphij (earlier version), des, emaste
MFC after: 7 days
X-EN-Candidate: yes
Differential Revision: https://reviews.freebsd.org/D39973

(cherry picked from commit c55b7e522629cb78adeb54bd9964304481d55eab)

14 months agonfsd: Continue adding macros so nfsd can run in a vnet prison
Rick Macklem [Tue, 14 Feb 2023 21:33:35 +0000 (13:33 -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, to allow the nfsuserd(8) daemon to
run in vnet prison, once the macros map to vnet ones.
This is the last commit for NFSD_VNET_xxx macros, but there are
still some for KRPC_VNET_xxx and KGSS_VNET_xx to allow the
rpc.tlsservd(8) and gssd(8) daemons to run in a vnet prison.

(cherry picked from commit f0db2b6022dfa15f375f5fcdd278b9df21cb88f5)

14 months agonfsd: Wrap nfsstatsv1_p in the NFSD_VNET() macro
Rick Macklem [Thu, 16 Feb 2023 01:39:07 +0000 (17:39 -0800)]
nfsd: Wrap nfsstatsv1_p in the NFSD_VNET() macro

Commit 7344856e3a6d added a lot of macros that will front end
vnet macros so that nfsd(8) can run in vnet prison.
The nfsstatsv1_p variable got missed.  This patch wraps all
uses of nfsstatsv1_p with the NFSD_VNET() macro.
The NFSD_VNET() macro is still a null macro.

(cherry picked from commit b039ca0776774036a9e33aa45f50296a7f6ba547)

14 months agonfsd: Continue adding macros so nfsd can run in a vnet prison
Rick Macklem [Mon, 13 Feb 2023 23:07:17 +0000 (15:07 -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 and also a lot of uses of
nfsstatsv1_p instead of nfsstatsv1. nfsstatsv1_p points to
nfsstatsv1 for prison0, but will point to a malloc'd structure
for other prisons.

It also puts nfsstatsv1_p in nfscommon.ko instead of nfsd.ko.

(cherry picked from commit 9d329bbc9aea6b8f47df251072bc65403ac3e43e)

14 months agoacpi_ged: New driver to ACPI generic event device
Takanori Watanabe [Tue, 18 Oct 2022 05:41:53 +0000 (14:41 +0900)]
acpi_ged:  New driver to ACPI generic event device

New driver to ACPI generic event device, defined in ACPI spec.
Some ACPI power button may not work without this.

In qemu arm64 with "virt" machine, with ACPI firmware,
enable devd check devd message by
and invoke following command in qemu monitor
(qemu) system_powerdown
and make sure some power button input event appear.
(setting sysctl hw.acpi.power_button_state=S5 is not work,
because ACPI tree does not have \_S5 object.)

Reviewed by: andrew, hrs
Differential Revision: https://reviews.freebsd.org/D37032
(cherry-picked from a9880bfe1181b7a32d026339bae113f24300e5e1)

acpi_ged: fix build, as module and non INTRNG case.

Reviewed-by: cy
Differential Revision: https://reviews.freebsd.org/D37104
(cherry-picked from 9cf5db63698b3c73edd632412bf68735d3c20d37)
acpi_ged: fix build with ACPI_DEBUG
(cherry-picked from ba23f762ece54a86f64b8ef62bbfc9c73c98762c)

Make it compile for 13-stable.

14 months agosmp_topo(): correct allocation sizes for trivial topologies
Konstantin Belousov [Tue, 9 May 2023 15:08:22 +0000 (18:08 +0300)]
smp_topo(): correct allocation sizes for trivial topologies

(cherry picked from commit 361c8f75a61832d9aa3dd4c589a0220f3467466f)

14 months agosmp_topo(): make it idempotent
Konstantin Belousov [Sun, 7 May 2023 18:37:42 +0000 (21:37 +0300)]
smp_topo(): make it idempotent

(cherry picked from commit d0f67f97579f7b2febf29264b1874a95056dec06)

14 months agosmp_topo: dynamically allocate group array
Konstantin Belousov [Fri, 5 May 2023 20:24:22 +0000 (23:24 +0300)]
smp_topo: dynamically allocate group array

(cherry picked from commit 9801e7c275f6ec42a44b98a2e2e1a8ac4674a096)

14 months agoquiesce_cpus(): do not overallocate generation array
Konstantin Belousov [Fri, 5 May 2023 20:21:38 +0000 (23:21 +0300)]
quiesce_cpus(): do not overallocate generation array

(cherry picked from commit ccc6b87b3825a235991d978e43d29431e012461f)

14 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.

(cherry picked from commit fcfdb76e12fb3cdf584e6f06e56e7c48ec475cc6)

14 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.

(cherry picked from commit 4d68605f31fb536722529dc90f16cc47d964882e)

14 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.

(cherry picked from commit 7e44856e3a6deb194c2c376e886854b256360c40)

14 months agoMake SMCCC usable by device drivers
Andrew Turner [Sat, 4 Jun 2022 11:13:51 +0000 (12:13 +0100)]
Make SMCCC usable by device drivers

To allow device drivers to call into SMCCC we need to initialise it
earlier. As it depends on PSCI, and that is detected via ACPI or FDT
move the call to smccc_init to the PSCI driver.

Add a function for drivers to read the smccc version, or 0 if smccc
is not present.

(cherry picked from commit 0600af1ff16041f15633b2263a8ad9525eecd2f1)
(cherry picked from commit 7ca55fcc541b375c83eaf75f0658b79f250c82fd)

14 months agoAdd the fixed memory type to the pci ecam driver
Andrew Turner [Wed, 18 Jan 2023 09:30:46 +0000 (09:30 +0000)]
Add the fixed memory type to the pci ecam driver

Add ACPI_RESOURCE_TYPE_FIXED_MEMORY32 to the PCI ECAM driver. This is
used on the Microsoft Dev Kit 2023 and reportedly the Lenovo x13s.

Reviewed by: Robert Clausecker <fuz@fuz.su> (Earlier version)
Tested by: Robert Clausecker <fuz@fuz.su> (Earlier version)
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D38031

(cherry picked from commit 896f556205c8d87ef842dc844752daa7d2385336)

14 months agoReduce an arm64 VFP critical section
Andrew Turner [Wed, 18 Jan 2023 09:30:36 +0000 (09:30 +0000)]
Reduce an arm64 VFP critical section

In set_fpcontext we only need a critical section around vfp_discard.
The remainder of the code can run without it.

While here add an assert to check the passed in thread is the
current thread as the code already this.

Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D38000

(cherry picked from commit a85cf421d1bfec7e753bfee781355785b00d89d4)

14 months agoAlways store the arm64 VFP context
Andrew Turner [Wed, 18 Jan 2023 09:30:32 +0000 (09:30 +0000)]
Always store the arm64 VFP context

If a thread enters a kernel FP context the PCB_FP_STARTED may be
unset when calling get_fpcontext even if the VFP unit has been used
by the current thread.

Reduce the use of this flag to just decide when to store the VFP state.

While here add an assert to check the assumption that the passed in
thread is the current thread and remove the unneeded critical section.
The latter is unneeded as the only place we would need it is in
vfp_save_state and this already has a critical section when needed.

Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D37998

(cherry picked from commit 61f5462fde6c38c1f4f5c34a05fab506b6869375)

14 months agoAlways read the VFP regs in the arm64 fill_fpregs
Andrew Turner [Wed, 18 Jan 2023 09:30:20 +0000 (09:30 +0000)]
Always read the VFP regs in the arm64 fill_fpregs

The PCB_FP_STARTED is used to indicate that the current VFP context
has been used since either 1. the start of the thread, or 2. exiting
a kernel FP context.

When case 2 was added to the kernel this could cause incorrect results
to be returned when a thread exits the kernel FP context and fill_fpregs
is called before it has restored the VFP state, e.g. by trappin on a
userspace VFP instruction.

In both of the cases the base save area is still valid so reduce the
use of the PCB_FP_STARTED flag check to help decide if we need to
store the current threads VFP state.

Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D37994

(cherry picked from commit 95dd6974b591ce76bf8d29adcc0dd01b4b281ffd)

14 months agoStop using the rid as an index in the arm timer
Andrew Turner [Wed, 15 Mar 2023 13:35:04 +0000 (13:35 +0000)]
Stop using the rid as an index in the arm timer

The order of the interrupt array doesn't matter. Store the described
interrupts at the start of the array to simplify iterating over them.

Reviewed by: imp, kevans
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D39094

(cherry picked from commit 5c4bd8756fbc23a48ddd8976df0b8429311fba83)

14 months agoKeep per-timer interrupt data together
Andrew Turner [Tue, 14 Mar 2023 09:27:23 +0000 (09:27 +0000)]
Keep per-timer interrupt data together

Eliminate a redundant resource array allow possible use by bhyve later.

Reviewed by: kevans
Sponsored by: Arm Ltd
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37424

(cherry picked from commit b71ef90ec28fdb731733afde495ac74ae59d6196)

14 months agoAlways enable the virtual timer for userspace
Andrew Turner [Fri, 10 Mar 2023 12:43:59 +0000 (12:43 +0000)]
Always enable the virtual timer for userspace

We always have it, some languages assume it's present, e.g. go
before 1.20. Enable it by default on arm and arm64.

PR: 269070
Reviewed by: kevans
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D39059

(cherry picked from commit 93d574ea957decec1c95dea9bfa8bc72457cc60d)

14 months agoarm: generic_timer: use interrupt-names when available
Kyle Evans [Sun, 5 Mar 2023 00:49:04 +0000 (18:49 -0600)]
arm: generic_timer: use interrupt-names when available

Offsets for all of thse can be a bit complicated as not all interrupts
will be present, only phys and virt are actually required, and sec-phys
could optionally be specified before phys.  Push idx/name pairs into
a new config struct and maintain the old indices while still getting the
correct timers.

Split fdt/acpi attach out independently and allocate interrupts before
we head into the common attach().  The secure physical timer is also
optional there, so mark it so to avoid erroring out if we run into
problems.

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D38911

(cherry picked from commit 91b2da13702fb3cfb40a3219feed6e5af651039d)

14 months agoLimit where we disable the Arm generic timer
Andrew Turner [Thu, 2 Feb 2023 16:26:25 +0000 (16:26 +0000)]
Limit where we disable the Arm generic timer

Only disable the Arm generic timer on arm64 when entering the kernel
through EL2. There is no guarantee it will be enabled if we are running
under a hypervisor.

Sponsored by: Arm Ltd

(cherry picked from commit 22e4897422a055b7a15be5984fbc4bb97f432e79)

14 months agoDisable the arm physical timer when an irq exists
Andrew Turner [Sat, 28 Jan 2023 17:36:24 +0000 (17:36 +0000)]
Disable the arm physical timer when an irq exists

Some firmware leaves the timers enabled. Ensure they are disabled if
there are any physical timer interrupt resources to ensure we don't
receive any unexpected interrupts from them.

(cherry picked from commit c57694ce94712ce1fe0341ae51d70446a7dbbfa2)

14 months agoarm64: Fix a typo in a source code comment
Gordon Bergling [Fri, 12 May 2023 08:45:46 +0000 (10:45 +0200)]
arm64: Fix a typo in a source code comment

- s/inferface/interface/

(cherry picked from commit cbe88c6f3c47e3d7731b6ec30bfc201970b20602)

14 months agoe1000: fix VLAN 0
Kristof Provost [Wed, 10 May 2023 16:26:29 +0000 (18:26 +0200)]
e1000: fix VLAN 0

VLAN 0 essentially means "Treat as untagged, but with priority bits",
and is used by some ISPs.

On igb/em interfaces we did not receive packets with VLAN tag 0 unless
vlanhwfilter was disabled.

This can be fixed by explicitly listing VLAN 0 in the hardware VLAN
filter (VFTA). Do this from em_setup_vlan_hw_support(), where we already
(re-)write the VFTA.

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

(cherry picked from commit 0229fab2fe0eed843ebec98fd31b7d49bb2e8438)

14 months agoamd64 MINIMAL: SysV IPC syscalls are loadable
Konstantin Belousov [Sat, 6 May 2023 20:03:07 +0000 (23:03 +0300)]
amd64 MINIMAL: SysV IPC syscalls are loadable

(cherry picked from commit bf864c3ed5830785cbc4dcc8b832c14fdc7110e4)

14 months agoamd64 MINIMAL: remove UFS from compiled-in list
Konstantin Belousov [Sat, 6 May 2023 20:02:34 +0000 (23:02 +0300)]
amd64 MINIMAL: remove UFS from compiled-in list

(cherry picked from commit 0c1c5e36ebbb7e30a5e57a044a20ea2c4f7cf793)

14 months agoamd64 MINIMAL config: remove statements about UFS module
Konstantin Belousov [Sat, 6 May 2023 20:01:45 +0000 (23:01 +0300)]
amd64 MINIMAL config: remove statements about UFS module

(cherry picked from commit bba6249ae9848b97d351ce04061c06d5e8ad8f9d)

14 months agoamd64: add MINIMALUP config
Konstantin Belousov [Sat, 6 May 2023 11:22:58 +0000 (14:22 +0300)]
amd64: add MINIMALUP config

(cherry picked from commit 38843fe0f27cb93dc50a3b0d7ba9a958c0581de7)

14 months agoamd64 MINIMAL config: remove sentence about acpi
Konstantin Belousov [Sat, 6 May 2023 11:21:13 +0000 (14:21 +0300)]
amd64 MINIMAL config: remove sentence about acpi

(cherry picked from commit 3a8c69c1ff56b8f55a3ca87b1cb2513b5072a150)

14 months agonet/pfkeyv2.h: fix typo, meNber
Konstantin Belousov [Wed, 10 May 2023 23:52:39 +0000 (02:52 +0300)]
net/pfkeyv2.h: fix typo, meNber

(cherry picked from commit b6d3a9644d5c73a1903dc39f79fe306b42b86b35)

14 months agoktls.4: Mention mb_use_ext_pgs in the "sysctl nodes" section
Mark Johnston [Wed, 26 May 2021 14:20:37 +0000 (10:20 -0400)]
ktls.4: Mention mb_use_ext_pgs in the "sysctl nodes" section

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

(cherry picked from commit 27130028a583273071a14a3256f8ea0a131f2dd4)

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

The default mb_use_ext_pgs value was toggled in commit 52cd25eb1aa.

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

(cherry picked from commit c235059bb7e600b7bb88234836102fa9911addc2)

14 months agogeom.8: Fix typos and wordsmith
Mateusz Piotrowski [Tue, 9 May 2023 13:46:00 +0000 (15:46 +0200)]
geom.8: Fix typos and wordsmith

MFC after: 3 days

(cherry picked from commit 794f5122bb0c9bad1c3dfedbf373a728b6689297)

14 months agovmm: Fix casts around kmem_malloc/free() calls
Mark Johnston [Thu, 11 May 2023 15:00:53 +0000 (11:00 -0400)]
vmm: Fix casts around kmem_malloc/free() calls

This is a direct commit to stable/13.

Reported by: Jenkins

14 months agocap_net tests: Skip tests if there is no connectivity
Mark Johnston [Thu, 11 May 2023 13:31:30 +0000 (09:31 -0400)]
cap_net tests: Skip tests if there is no connectivity

When testing cap_connect() and name/addr lookup functions, skip tests if
we fail and the error is not ENOTCAPABLE.  This makes the tests amenable
to running in CI without Internet connectivity.

Reviewed by: oshogbo
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D39242

(cherry picked from commit 7ee4066db1295fe3660964c2561bef87da7431f8)

14 months agobuf: Dynamically allocate per-CPU buffer queues
Mark Johnston [Wed, 10 May 2023 14:05:32 +0000 (10:05 -0400)]
buf: Dynamically allocate per-CPU buffer queues

To reduce static bloat.  No functional change intended.

PR: 269572
Reviewed by: mjg, kib, emaste
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39808

(cherry picked from commit e72f7ed43eefaf305c33c232bc2c33d997427f58)

14 months agovmm: don't free unallocated memory
Corvin Köhne [Wed, 10 May 2023 13:19:25 +0000 (09:19 -0400)]
vmm: don't free unallocated memory

If vmx or svm is disabled in BIOS or the device isn't supported by vmm,
modinit won't allocate these state save areas. As kmem_free panics when
passing a NULL pointer to it, loading the vmm kernel module causes a
panic too.

PR: 271251
Reviewed by: markj
Fixes: 74ac712f72cfd6d7b3db3c9d3b72ccf2824aa183 ("vmm: Dynamically allocate a couple of per-CPU state save areas")
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D39974

(cherry picked from commit b10e100d1696782cfebef09b5870dfc6d1b3217b)

14 months agovmm: Dynamically allocate a couple of per-CPU state save areas
Mark Johnston [Wed, 10 May 2023 13:19:09 +0000 (09:19 -0400)]
vmm: Dynamically allocate a couple of per-CPU state save areas

This avoids bloating the BSS when MAXCPU is large.

No functional change intended.

PR: 269572
Reviewed by: corvink, rew
Tested by: rew
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39805

(cherry picked from commit 74ac712f72cfd6d7b3db3c9d3b72ccf2824aa183)

14 months agounix: Fix locking in uipc_peeraddr()
Mark Johnston [Wed, 10 May 2023 13:18:16 +0000 (09:18 -0400)]
unix: Fix locking in uipc_peeraddr()

After the locking protocol changed in commit 75a67bf3d00d ("AF_UNIX:
make unix socket locking finer grained"), uipc_peeraddr() was not
updated accordingly.

The link lock now only protects global socket lists.  The PCB lock is
used to protect the link between connected PCBs, so use that.  Remove an
old comment which appears to be noting that unp_conn is not set for
connected SOCK_DGRAM sockets (in one direction anyway).

Reviewed by: glebius
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D39855

(cherry picked from commit e8f6e5b2d969fdf7e8f0a9a0a87eede357618fe9)

14 months agotwe: Add deprecation notice
Warner Losh [Thu, 11 May 2023 04:09:10 +0000 (22:09 -0600)]
twe: Add deprecation notice

This was flagged for removal in 14 over a year ago. Add deprecation to
man page.

MFC After: 3 days

(cherry picked from commit f710a4de92c142fddde636e3610d525bc237ff6d)

14 months agonetmap: pkt-gen: sync with upstream
Vincenzo Maffione [Wed, 26 Apr 2023 20:32:24 +0000 (20:32 +0000)]
netmap: pkt-gen: sync with upstream

Keep in sync with the recent upstream changes:

Fix compilation on 32-bit architectures
Update IP length, UDP length/checksum when size changes
Man page fixes

Submitted by: jlduran@gmail.com
MFC after: 7 days
Differential Revision: https://reviews.freebsd.org/D39760

(cherry picked from commit 8c3b8c838674239538682b914bc1d7059255f116)

14 months agoRevert "uart(4): add Sunrise Point UART controllers"
Kyle Evans [Tue, 9 May 2023 06:38:32 +0000 (01:38 -0500)]
Revert "uart(4): add Sunrise Point UART controllers"

This reverts commit d1b6271118188dd25a18f2372ab1d3004335ea3c.

I've received multiple reports of machines failing to boot with
this hardware; back it out for now until we can fix it.

PR: 271147

(cherry picked from commit 20d8d9809a8c0a3ddd1d0156e77ec53a1ed95747)

14 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

(cherry picked from commit 67fca20eb2cea55fb2eaacc22807ee4741894796)

14 months agoCirrus-CI: switch GCC job to GCC 12
Ed Maste [Fri, 27 Jan 2023 17:15:01 +0000 (12:15 -0500)]
Cirrus-CI: switch GCC job to GCC 12

We need a C++20 or later compiler.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit e7f9bdb4a6fb976770c0d2bbe31d34e964dc167f)

14 months agoCirrus-CI: Switch to llvm14 toolchain package
Ed Maste [Tue, 24 May 2022 20:12:48 +0000 (16:12 -0400)]
Cirrus-CI: Switch to llvm14 toolchain package

Follow base system update to LLVM 14

Sponsored by: The FreeBSD Foundation

(cherry picked from commit daed785d6fe0a6cfdbfab92af9ee9afd7451c7aa)

14 months agovmrun.sh: mention new edk2 package
Christos Margiolis [Tue, 2 May 2023 19:19:08 +0000 (19:19 +0000)]
vmrun.sh: mention new edk2 package

uefi-edk2-bhyve no longer exists.

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

(cherry picked from commit 0ebc92bf3db1685fbcd023e42b683f4b10464095)

14 months agodtrace: Sync dis_tables.c with illumos
Mark Johnston [Tue, 21 Mar 2023 13:36:58 +0000 (09:36 -0400)]
dtrace: Sync dis_tables.c with illumos

This brings in the following commits:

    commit 584b574a3b16c6772c8204ec1d1c957c56f22a87
    12174 i86pc: variable may be used uninitialized
    Author: Toomas Soome <tsoome@me.com>
    Reviewed by: John Levon <john.levon@joyent.com>
    Reviewed by: Andrew Stormont <astormont@racktopsystems.com>
    Approved by: Dan McDonald <danmcd@joyent.com>

    commit a25e615d76804404e5fc63897a9196d4f92c3f5e
    12371 dis x86 EVEX prefix mishandled
    12372 dis EVEX encoding SIB mishandled
    12373 dis support for EVEX vaes instructions
    12374 dis support for EVEX vpclmulqdq instructions
    12375 dis support for gfni instructions
    Author: Robert Mustacchi <rm@fingolfin.org>
    Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
    Approved by: Joshua M. Clulow <josh@sysmgr.org>

    commit c1e9bf00765d7ac9cf1986575e4489dd8710d9b1
    12369 dis WBNOINVD support
    Author: Robert Mustacchi <rm@joyent.com>
    Reviewed by: Hans Rosenfeld <hans.rosenfeld@joyent.com>
    Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
    Reviewed by: Andy Fiddaman <andy@omniosce.org>
    Reviewed by: Toomas Soome <tsoome@me.com>
    Approved by: Dan McDonald <danmcd@joyent.com>

    commit e4f6ce7088a7dd335b9edf4774325f888692e5fb
    10893 Need support for new Cascade Lake Instructions
    Author: Robert Mustacchi <rm@joyent.com>
    Reviewed by: Hans Rosenfeld <hans.rosenfeld@joyent.com>
    Reviewed by: Dan McDonald <danmcd@joyent.com>
    Reviewed by: Richard Lowe <richlowe@richlowe.net>
    Approved by: Gordon Ross <gwr@nexenta.com>

    commit cff040f3ef42d16ae655969398f5a5e6e700b85e
    10226 Need support for new EPYC ISA extensions
    Author: Robert Mustacchi <rm@joyent.com>
    Reviewed by: Hans Rosenfeld <hans.rosenfeld@joyent.com>
    Reviewed by: Jason King <jason.king@joyent.com>
    Reviewed by: Richard Lowe <richlowe@richlowe.net>
    Approved by: Dan McDonald <danmcd@joyent.com>

    commit d242cdf5288b86d9070d88791c8ee696612becdc
    8492 AVX512 dis - legacy logical instructions
    Author: Jerry Jelinek <jerry.jelinek@joyent.com>
    Reviewed by: Robert Mustacchi <rm@joyent.com>
    Reviewed by: Gordon Ross <gordon.w.ross@gmail.com>
    Approved by: Richard Lowe <richlowe@richlowe.net>

    commit 81b505b772ab015c588c56bb116239ee549b6eee
    8384 AVX512 dis - EVEX prefix support
    8385 32-bit avx dis test mishandles EVEX prefix
    8386 32-bit bound dis is incorrect
    Author: Jerry Jelinek <jerry.jelinek@joyent.com>
    Reviewed by: Robert Mustacchi <rm@joyent.com>
    Reviewed by: Gordon Ross <gordon.w.ross@gmail.com>
    Approved by: Richard Lowe <richlowe@richlowe.net>

    commit 92381362ae635a3bea638d87b7119f1623b6212e
    8319 dis support for new xsave instructions
    Author: Jerry Jelinek <jerry.jelinek@joyent.com>
    Reviewed by: Robert Mustacchi <rm@joyent.com>
    Reviewed by: Gordon Ross <gordon.w.ross@gmail.com>
    Approved by: Richard Lowe <richlowe@richlowe.net>

    commit a4e73d5d60e566669c550027fae2b1d87b4be2b4
    8240 AVX512 dis - opmask instruction support
    Author: Jerry Jelinek <jerry.jelinek@joyent.com>
    Reviewed by: Robert Mustacchi <rm@joyent.com>
    Reviewed by: Toomas Soome <tsoome@me.com>
    Approved by: Gordon Ross <gordon.w.ross@gmail.com>

    959b2dfd39979fe8a9a315a52741d009eb168822
    7825 want avx dis tests
    7826 PCLMULQDQ psuedo-ops aren't properly described in dis
    7827 dis tests for f16c, movbe, cpuid, msr, tsc, fence instrs
    7828 sysenter and sysexit dis should be allowed in 64-bit x86
    Author: Robert Mustacchi <rm@joyent.com>
    Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
    Approved by: Richard Lowe <richlowe@richlowe.net>

MFC after: 2 weeks

(cherry picked from commit 722b2e2f9aa64e6ff4dec346951bd4b56cd27a8d)

14 months agovmm: Expose some more AVX512 CPUID bits to guests
Mark Johnston [Tue, 25 Apr 2023 17:33:08 +0000 (13:33 -0400)]
vmm: Expose some more AVX512 CPUID bits to guests

This is required to announce support for some accelerated AES
operations.  AVX512BW indicates support for the AVX512-FP16 extension
and AVX512VL indicates support for the use of AVX512 instructions with
vector lengths smaller than 512 bits.

VAES and VPCLMULQDQ extensions indicate that VEX-prefixed AES-NI and
pclmulqdq instructions are supported.

All of these bits are needed for OpenSSL to use VAES to accelerate
AES-GCM transforms.

Reviewed by: corvink, kib, jhb
MFC after: 2 weeks
Sponsored by: Stormshield
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D39781

(cherry picked from commit 47cf1b37f42d2acb24fa3a1e6106374dddb3edbf)

14 months agohwpmc: Fix a typo
Mark Johnston [Mon, 1 May 2023 15:19:25 +0000 (11:19 -0400)]
hwpmc: Fix a typo

MFC after: 1 week

(cherry picked from commit 56da525b535f8537205bccd1f4b25b3ce354ca62)

14 months agofbt: get rid of redundant defines
Christos Margiolis [Mon, 1 May 2023 15:20:34 +0000 (15:20 +0000)]
fbt: get rid of redundant defines

No functional change intended.

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

(cherry picked from commit aad1685066fc2430d6ee9b3025369ba6bd513333)

14 months agofsck_ffs: fix the previous change that skipped pass 5 in some cases
Chuck Silvers [Wed, 3 May 2023 20:21:19 +0000 (13:21 -0700)]
fsck_ffs: fix the previous change that skipped pass 5 in some cases

The previous change involved calling check_cgmagic() twice in a row
for the same CG in order to differentiate when the CG was already ok vs.
when the CG was rebuilt, but that doesn't work because the second call
(which was supposed to rebuild the CG) returns 0 (indicating that
the CG was not rebuilt) due to the prevfailcg check causing an early
failure return.  Fix this by moving the rebuild part of check_cgmagic()
out into a separate function which is called by pass1() when it wants to
rebuild a CG.

Fixes: da86e7a20dc4a4b17e8d9e7630ed9b675cf71702
Reported by: pho
Discussed with: mckusick
Sponsored by: Netflix

(cherry picked from commit 406475581246360faa7af9891dc8ad2423284e18)

14 months agontpd: Support IPv6-only hosts
Mina Galic [Fri, 5 May 2023 04:33:18 +0000 (21:33 -0700)]
ntpd: Support IPv6-only hosts

0.pool.* returns only IPv4 addresses.
2.pool.* returns both, IPv6 and IPv4 addresses.

conservatively extend our IPv4 only pool configuration by adding a
second pool, which also returns IPv6 addresses.

PR: 270536
Reported by: Lapo Luchini <lapo@lapo.it>
Pull Request: https://github.com/freebsd/freebsd-src/pull/731
Differential Revision: https://reviews.freebsd.org/D39954

(cherry picked from commit fff1551c0357cc43f6138fecfad1d79d8d8baa15)

14 months agoApply libc++ fix for compiling <type_traits> with gcc 13
Dimitry Andric [Fri, 5 May 2023 16:19:40 +0000 (18:19 +0200)]
Apply libc++ fix for compiling <type_traits> with gcc 13

Merge commit 484e64f7e7b2 from llvm-project (by Roland McGrath):

  [libc++] Use __is_convertible built-in when available

  https://github.com/llvm/llvm-project/issues/62396 reports that
  GCC 13 barfs on parsing <type_traits> because of the declarations
  of `struct __is_convertible`.  In GCC 13, `__is_convertible` is a
  built-in, but `__is_convertible_to` is not.  Clang has both, so
  using either should be fine.

  Reviewed By: #libc, philnik

  Differential Revision: https://reviews.llvm.org/D149313

Reported by: Mark Millard <marklmi@yahoo.com>
MFC after: 3 days

(cherry picked from commit 2df58f190731634be67e90b7c453dee587b4ea27)

14 months agoriscv: remove unused string from swtch.S
Mitchell Horne [Mon, 23 Jan 2023 17:11:16 +0000 (13:11 -0400)]
riscv: remove unused string from swtch.S

MFC after: 3 days
Sponsored by: The FreeBSD Foundation

(cherry picked from commit f5d39047b094d5164b85ae7e2a6a9a8342269815)

14 months agovmm: fix HLT loop while vcpu has requested virtual interrupts
Vitaliy Gusev [Wed, 26 Apr 2023 08:17:50 +0000 (10:17 +0200)]
vmm: fix HLT loop while vcpu has requested virtual interrupts

This fixes the detection of pending interrupts when pirval is 0 and the
pending bit is set

More information how this situation occurs, can be found here:
https://github.com/freebsd/freebsd-src/blob/c5b5f2d8086f540fefe4826da013dd31d4e45fe8/sys/amd64/vmm/intel/vmx.c#L4016-L4031

Reviewed by: corvink, markj
Fixes: 02cc877968bbcd57695035c67114a67427f54549 ("Recognize a pending virtual interrupt while emulating the halt instruction.")
MFC after: 1 week
Sponsored by: vStack
Differential Revision: https://reviews.freebsd.org/D39620

(cherry picked from commit 0912408a281f203c43d0b3f73c38117336588342)

14 months agobhyve: pass E820 table to guest
Corvin Köhne [Thu, 9 Sep 2021 09:37:04 +0000 (11:37 +0200)]
bhyve: pass E820 table to guest

E820 table will be used to report valid RAM ranges and reserve special
memory areas like graphics memory for GPU passthrough.

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

(cherry picked from commit 16f23f75432915e64a34357e7d5f26bca82f8219)

14 months agobhyve: add E820 dump function
Corvin Köhne [Thu, 9 Sep 2021 09:37:03 +0000 (11:37 +0200)]
bhyve: add E820 dump function

For debugging purposes it is helpful to dump the E820 table.

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

(cherry picked from commit a8a8e9af574c63fbecf4719e3bf184795dc98c51)

14 months agobhyve: add allocation function to E820
Corvin Köhne [Thu, 9 Sep 2021 09:37:03 +0000 (11:37 +0200)]
bhyve: add allocation function to E820

This function makes it easy to allocate new E820 entries. It will be
used to allocate graphics memory for Intel integrated graphic devices.

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

(cherry picked from commit 5597f564870e94d56111dec638b8859423c936a9)

14 months agobhyve: add common memory holes to E820 table
Corvin Köhne [Thu, 9 Sep 2021 09:37:03 +0000 (11:37 +0200)]
bhyve: add common memory holes to E820 table

The VGA and the ROM memory ranges can't be used as system memory. For
that reason, remove them from the E820 table.

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

(cherry picked from commit 059af92a300f76653048c042559f7d7d8fd8f99c)

14 months agobhyve: add basic E820 implementation
Corvin Köhne [Thu, 9 Sep 2021 09:37:03 +0000 (11:37 +0200)]
bhyve: add basic E820 implementation

There are some use cases where bhyve has to prepare some special memory
regions. E.g. GPU passthrough for Intel integrated graphic devices needs
to reserve some memory for the graphic device. So, bhyve has to inform
the guest about those memory regions. This information can be passed by
the qemu fwcfg interface. As qemu creates an E820 table, we can reuse
the existing fwcfg item "etc/e820".

This commit is the first one of a series. It only adds a basic
implementation for the creation of the E820 table. Some subsequent
commits will add more items to the E820 table and register it as fwcfg
item.

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

(cherry picked from commit 9180daa1e34577aaccf3ff64cc63a5179c4f09d8)

14 months agobhyve: make use of qemus acpi table loader
Corvin Köhne [Wed, 6 Apr 2022 09:10:37 +0000 (11:10 +0200)]
bhyve: make use of qemus acpi table loader

Add all acpi tables to qemus acpi table loader. This passes the acpi
tables by fwcfg to the guest.

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

(cherry picked from commit 7959d80d99ae06ba06cbe7a206ef9bc513e4109b)

14 months agobhyve: add helper struct for qemus acpi table loader
Corvin Köhne [Wed, 6 Apr 2022 09:10:36 +0000 (11:10 +0200)]
bhyve: add helper struct for qemus acpi table loader

The hypervisor is aware of all system properties. For the guest bios
it's hard and complex to detect all system properties. For that reason,
it would be better if the hypervisor creates acpi tables instead of the
guest. Therefore, the hypervisor has to send the acpi tables to the
guest. At the moment, bhyve just copies the acpi tables into the guest
memory. This approach has some restrictions. You have to keep sure that
the guest doesn't overwrite them accidentally. Additionally, the size of
acpi tables is limited.

Providing a plain copy of all acpi tables by fwcfg isn't possible. Acpi
tables have to point to each other. So, if the guest copies the acpi
tables into memory by it's own, it has to patch the tables. Due to
different layouts for different acpi tables, there's no generic way to
do that.  For that reason, qemu created a table loader interface. It
contains commands for the guest for loading specific blobs into guest
memory and patching those blobs.

This commit adds a qemu_loader class which handles the creation of qemu
loader commands. At the moment, the WRITE_POINTER command isn't
implement. It won't be required by bhyve's acpi table generation yet.

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

(cherry picked from commit f565b4d6303f4798a2cb0dc51ef88de9e4a24047)

14 months agoObsoleteFiles: Complete 20201025: Remove cal data files
Li-Wen Hsu [Thu, 4 May 2023 04:28:52 +0000 (12:28 +0800)]
ObsoleteFiles: Complete 20201025: Remove cal data files

Fixes: d20d6550187a calendar: remove all datafiles except freebsd one
MFC after: 3 days

(cherry picked from commit 5282ada06bbc6727b467d6f6530fa19114143c61)

14 months agoshare/mk/bsd.cpu.mk: add AltiVec / VSX to powerpc*'s MACHINE_CPU
Piotr Kubaj [Fri, 5 May 2023 14:19:19 +0000 (16:19 +0200)]
share/mk/bsd.cpu.mk: add AltiVec / VSX to powerpc*'s MACHINE_CPU

MFC after: 3 days
Approved by: jhibbits
Differential revision: https://reviews.freebsd.org/D39240

(cherry picked from commit 448045e4a7873f4733cebda56df002acabb2aef1)

14 months agotests: Add ATF_REQUIRE_SYSCTL_BOOL
Mark Johnston [Tue, 25 Apr 2023 13:54:23 +0000 (09:54 -0400)]
tests: Add ATF_REQUIRE_SYSCTL_BOOL

Modify a capability mode test to use it for kern.trap_enotcap, to avoid
false positives.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 8a271827e7b5d5310e06df1f9f49ba0ef9efd263)

14 months agoriscv: Implement bus_describe_intr() for nexus
Mark Johnston [Sun, 23 Apr 2023 17:31:01 +0000 (13:31 -0400)]
riscv: Implement bus_describe_intr() for nexus

Reviewed by: mhorne
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D39750

(cherry picked from commit ff13b924751489efed1c6a42dbca8f236902d6fb)

14 months agoarm64: Implement bus_describe_intr() for nexus
Mark Johnston [Sun, 23 Apr 2023 17:30:44 +0000 (13:30 -0400)]
arm64: Implement bus_describe_intr() for nexus

Prompted by a compiler warning introduced by
e582d4a2b09e ("arm64: nexus code tidy-up").

Reviewed by: mhorne, andrew
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D39749

(cherry picked from commit 7623cc8f65ab1b28690d4a6580ae87b7926ed008)

14 months agoriscv: Compile instr_size.c into the kernel when DTrace is configured
Mark Johnston [Fri, 21 Apr 2023 13:26:17 +0000 (09:26 -0400)]
riscv: Compile instr_size.c into the kernel when DTrace is configured

Reported by: Jenkins
Fixes: 080e56a6c98c ("dtrace: expose dtrace_instr_size() to userland and implement it for riscv")

(cherry picked from commit 92fa22c6a5c41303e3ad98096c9ebe8202418d81)

14 months agodtrace: add register bindings for RISC-V
Christos Margiolis [Thu, 20 Apr 2023 16:25:37 +0000 (16:25 +0000)]
dtrace: add register bindings for RISC-V

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

(cherry picked from commit 1fef7abdc76bd6f0c93775bd0c1b62b523abd20d)

14 months agodtrace: use dtrace_instr_size() in the riscv dtrace_subr.c
Christos Margiolis [Thu, 20 Apr 2023 16:24:03 +0000 (16:24 +0000)]
dtrace: use dtrace_instr_size() in the riscv dtrace_subr.c

No functional change intended.

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

(cherry picked from commit 75081b9ed8e67c8443551828f1b5ccf3d449b41b)

14 months agodtrace: expose dtrace_instr_size() to userland and implement it for riscv
Christos Margiolis [Thu, 20 Apr 2023 16:21:46 +0000 (16:21 +0000)]
dtrace: expose dtrace_instr_size() to userland and implement it for riscv

dtrace_instr_size() is needed by the forthcoming RISC-V port of kinst,
as well as by libdtrace in D38825 for both amd64 and RISC-V.

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

(cherry picked from commit 080e56a6c98c7e7a241a4260d4c19d3cad5b22af)