]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
19 months agoheimdal: Handle other types of garbage data
Cy Schubert [Thu, 24 Nov 2022 15:07:43 +0000 (07:07 -0800)]
heimdal: Handle other types of garbage data

In addition to garbage realm data, also handle garbage dbname, acl_file,
stash_file, and invalid bitmask garbage data.

PR: 267912
Reported by: Robert Morris <rtm@lcs.mit.edu>
MFC after: 3 days

19 months agoheimdal: Fix NULL dereference when mangled realm message
Cy Schubert [Thu, 24 Nov 2022 14:22:13 +0000 (06:22 -0800)]
heimdal: Fix NULL dereference when mangled realm message

Fix a NULL dereference in _kadm5_s_init_context() when the client
sends a mangled realm message.

PR: 267912
Reported by: Robert Morris <rtm@lcs.mit.edu>
MFC after: 3 days

19 months agoheimdal: The version string must always contain a terminating NUL
Cy Schubert [Mon, 21 Nov 2022 15:33:08 +0000 (07:33 -0800)]
heimdal: The version string must always contain a terminating NUL

Should the sender send a string without a terminating NUL, ensure that
the NUL terminates the string regardless.

And while at it only process the version string when bytes are returned.

PR: 267884
Reported by: Robert Morris <rtm@lcs.mit.edu>
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D37471

19 months agoClarify what's normally not required.
Pau Amma [Wed, 23 Nov 2022 22:00:02 +0000 (22:00 +0000)]
Clarify what's normally not required.

Reported by: karels

Reviewed by: carlavilla, karels (informally)

Approved by: carlavilla (mentor)

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

19 months agopam.d: install hard link with same mode as target
Ed Maste [Wed, 23 Nov 2022 15:34:58 +0000 (10:34 -0500)]
pam.d: install hard link with same mode as target

Previously when using NO_ROOT we recorded a METALOG entry for the
pam.d/ftp hard link with a different file mode than the link target
pam.d/ftpd, which is not permitted.

This change is similar to 1dbb9994d4dd for .profile

Sponsored by: The FreeBSD Foundation

19 months ago<type_traits>: Avoid instantiating a pointer type in std::decay<>.
John Baldwin [Thu, 24 Nov 2022 00:10:05 +0000 (16:10 -0800)]
<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

19 months agoFix igor and mandoc -T lint low-hanging fruit in hier(7)
Pau Amma [Wed, 23 Nov 2022 01:41:04 +0000 (01:41 +0000)]
Fix igor and mandoc -T lint low-hanging fruit in hier(7)

Reviewed by: danfe, gjb (mentor)

Approved by: gjb (mentor)

MFC after: 3 days

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

19 months agoRemove disused /cdrom toplevel dir from hier(7).
Pau Amma [Tue, 22 Nov 2022 22:56:46 +0000 (22:56 +0000)]
Remove disused /cdrom toplevel dir from hier(7).

Reviewed by: gjb

Approved by: gjb (mentor)

MFC after: 3 days

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

19 months agodwatch: install hard links with same mode as target
Ed Maste [Wed, 23 Nov 2022 15:44:41 +0000 (10:44 -0500)]
dwatch: install hard links with same mode as target

Previoulsy when using NO_ROOT we recorded METALOG entries for dwatch
hard links with different file modes than their link targets, which is
not permitted.

Reviewed by: bapt
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37477

19 months agosh: install hard link with same mode as target
Ed Maste [Wed, 23 Nov 2022 15:20:49 +0000 (10:20 -0500)]
sh: install hard link with same mode as target

Previously when using NO_ROOT we recorded a METALOG entry for the
/.profile hard link with a different mode than the link target, which is
not permitted.

Reviewed by: bapt
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37476

19 months agomakefs: Ignore some sign comparison warnings from GCC.
John Baldwin [Wed, 23 Nov 2022 18:38:29 +0000 (10:38 -0800)]
makefs: Ignore some sign comparison warnings from GCC.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D37470

19 months agomakefs zfs: Disable -Wunused-function for GCC as well.
John Baldwin [Wed, 23 Nov 2022 18:35:30 +0000 (10:35 -0800)]
makefs zfs: Disable -Wunused-function for GCC as well.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D37469

19 months agomakefs zfs: Use signed values for both results of ?:.
John Baldwin [Wed, 23 Nov 2022 18:35:14 +0000 (10:35 -0800)]
makefs zfs: Use signed values for both results of ?:.

Reported by: GCC -Wsign-compare
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D37468

19 months agocompat32: retire now-unused MIPS support
Ed Maste [Wed, 23 Nov 2022 14:30:49 +0000 (09:30 -0500)]
compat32: retire now-unused MIPS support

This reverts commit a6d20bbaa2f4bb3684d2c396ef1f1411c8fb8499.

19 months agovmm: don't lock a mtx in the icr_low write handler
Corvin Köhne [Mon, 21 Nov 2022 14:00:04 +0000 (15:00 +0100)]
vmm: don't lock a mtx in the icr_low write handler

x2apic accesses are handled by a wrmsr exit. This handler is called in a
critical section. So, we can't lock a mtx in the icr_low handler.

Reported by: kp, pho
Tested by: kp, pho
Approved by: manu (mentor)
Fixes: c0f35dbf19c3c8825bd2b321d8efd582807d1940 vmm: Use a cpuset_t for vCPUs waiting for STARTUP IPIs.
MFC after: 1 week
MFC with: c0f35dbf19c3c8825bd2b321d8efd582807d1940
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D37452

19 months agogitignore: whack dead architectures
Mateusz Guzik [Wed, 23 Nov 2022 01:18:03 +0000 (01:18 +0000)]
gitignore: whack dead architectures

19 months agotftpd: Disable -Wformat-nonliteral for GCC.
John Baldwin [Tue, 22 Nov 2022 19:12:06 +0000 (11:12 -0800)]
tftpd: Disable -Wformat-nonliteral for GCC.

GCC warns about the non-literal format string passed to strftime().  A
warning here seems a bit odd as strftime() does not take varargs so
there is not a risk of missing args.

19 months agosystat: Fix a bunch of use after frees in fetch_ifstat().
John Baldwin [Tue, 22 Nov 2022 19:11:42 +0000 (11:11 -0800)]
systat: Fix a bunch of use after frees in fetch_ifstat().

I think this was probably just a typo.  initifstat() continues around
a similar loop if the mib data fails to fetch, and fetch_ifstat() was
already using a FOREACH_SAFE loop here so expected to keep going.
Calling clearifstat() from the fetch routine also seems wrong, and the
sort_interface_list() call triggered by the existing needsort = 1 will
itself set needclear to trigger a future clearifstat().

Reported by: GCC 12 -Wuse-after-free
Differential Revision: https://reviews.freebsd.org/D36823

19 months agoiwlwifi: fix hang on unloading driver
Bjoern A. Zeeb [Tue, 22 Nov 2022 17:29:41 +0000 (17:29 +0000)]
iwlwifi: fix hang on unloading driver

f808c43ad9234670770601ba32a7426b00bbf528 introduced a FreeBSD specific
behaviour to wait for firmware load completion before returning from
loading the driver.  This does no longer allow iwl_drv_stop to detect
that startup has completed and it will wait indefinitely for a
completion event that will not happen.
We could change the complete() call to a complete_all() but to avoid
confusion, future side effects, and for simplicity daisy-chain two
complete events in FreeBSD.

PR: 267869
Reported by: Peter Much (pmc citylink.dinoex.sub.org)
Tested by: Peter Much (pmc citylink.dinoex.sub.org)
Sponsored by: The FreeBSD Foundation
MFC after: 3 days

19 months agotftp: Use printf0 attribute for options_set_request/reply.
John Baldwin [Tue, 22 Nov 2022 16:37:26 +0000 (08:37 -0800)]
tftp: Use printf0 attribute for options_set_request/reply.

These functions accept a NULL format argument so should use the printf0
attribute rather than plain printf.

Reported by: GCC -Wformat

19 months agolibicp: Link with -z noexecstack for ld.bfd.
John Baldwin [Tue, 22 Nov 2022 16:37:12 +0000 (08:37 -0800)]
libicp: Link with -z noexecstack for ld.bfd.

The assembly source files do not contain GNU-stack annotations, so
ld.bfd defaults to using an executable stack.

19 months agolibcrypto padlock.so: Link with -z noexecstack for ld.bfd.
John Baldwin [Tue, 22 Nov 2022 16:37:04 +0000 (08:37 -0800)]
libcrypto padlock.so: Link with -z noexecstack for ld.bfd.

The assembly source files do not contain GNU-stack annotations, so
ld.bfd defaults to using an executable stack.

19 months agolibsa: Add missing GNU-stack annotations to _setjmp.S.
John Baldwin [Tue, 22 Nov 2022 16:36:40 +0000 (08:36 -0800)]
libsa: Add missing GNU-stack annotations to _setjmp.S.

ld.bfd marks the stack as executable for the crt objects due to the
missing annotations which raises a fatal warning starting with version
2.39.

19 months agostand/libsa: Remove MIPS setjmp() and longjmp().
John Baldwin [Tue, 22 Nov 2022 16:36:28 +0000 (08:36 -0800)]
stand/libsa: Remove MIPS setjmp() and longjmp().

19 months agoUse __freebsd_kprintf__ with GCC 12+ similar to clang.
John Baldwin [Tue, 22 Nov 2022 16:36:12 +0000 (08:36 -0800)]
Use __freebsd_kprintf__ with GCC 12+ similar to clang.

19 months agoUpdate resolv.conf(5) "not necessary" language.
Pau Amma [Mon, 21 Nov 2022 00:19:55 +0000 (00:19 +0000)]
Update resolv.conf(5) "not necessary" language.

While there, fix mandoc -T lint warnings.

PR: 262492

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

MFC after: 1 week

Reviewed by: gjb

Approved by: gjb (mentor)

19 months agocrypto: move all zeroing into crypto_getreq
Mateusz Guzik [Tue, 22 Nov 2022 12:28:07 +0000 (12:28 +0000)]
crypto: move all zeroing into crypto_getreq

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

19 months agoipsec: add key_havesp_any
Mateusz Guzik [Wed, 7 Sep 2022 20:05:38 +0000 (22:05 +0200)]
ipsec: add key_havesp_any

Saves on work in a common case of checking both directions.

Note further work in the area is impending to elide these in the common
case to begin with.

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

19 months agoipsec: prohibit unknown directions in key_havesp
Mateusz Guzik [Wed, 7 Sep 2022 20:27:15 +0000 (22:27 +0200)]
ipsec: prohibit unknown directions in key_havesp

Eliminates a branch checking for its validity.

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

19 months agoAdd dnctl rc.d service
Goran Mekic [Tue, 22 Nov 2022 09:46:19 +0000 (10:46 +0100)]
Add dnctl rc.d service

As PF now also supports dummynet but can not configure it on its own,
the service which configures pipes, queues and schedulers is needed.

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D37451

19 months agoipfw: Fix ipfw/dnctl detection
Goran Mekic [Tue, 22 Nov 2022 08:53:20 +0000 (09:53 +0100)]
ipfw: Fix ipfw/dnctl detection

Running "dnctl" vs "/sbin/dnctl" gave different results, because we
looked at the entire argv[0] string, rather than the basename.

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D37431

19 months agoAdd support for _CR3 critical standby (S3) threshold.
Cyrus Rahman [Fri, 18 Nov 2022 18:30:30 +0000 (10:30 -0800)]
Add support for _CR3 critical standby (S3) threshold.

Along with _PSV, _HOT, and _CRT, ACPI supports the _CR3 threshold
which specifies a temperature above which a system should transition
to the S3 standby state.

On FreeBSD, this is more useful than _HOT, which specifies the S4
transition threshold temperature (since FreeBSD does not generally
support the S4 state), or, in many cases, _CRT, since after
transitioning to S3 the system can cool and then be resumed.

Reviewed by: jhb, bcr (manpages)
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D35980

19 months agoRetire CLANG_IS_CC option
Ed Maste [Thu, 29 Sep 2022 18:15:39 +0000 (14:15 -0400)]
Retire CLANG_IS_CC option

A small reduction in build infrastructure complexity; when we had both
Clang and GCC in the tree it was useful to have both built, and choose
one or the other to install as /usr/bin/cc.  Now only Clang is in the
tree, and there is no point in building and installing base Clang but
not providing it as cc (and c++, cpp).

Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37075

19 months agobhyve: use dynamic ACPI table offsets
Corvin Köhne [Wed, 6 Apr 2022 09:10:44 +0000 (11:10 +0200)]
bhyve: use dynamic ACPI table offsets

Now that all ACPI tables are build by basl, basl can dynamically
calculate the offset for each table.

Reviewed by: jhb, markj (older version)
Approved by: manu (mentor)
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D37002

19 months agobhyve: build RSDP table by basl
Corvin Köhne [Wed, 6 Apr 2022 09:10:43 +0000 (11:10 +0200)]
bhyve: build RSDP table by basl

Building the RSDP table by basl will allow it to be loaded by qemu's
ACPI table loader in the future.

Reviewed by: jhb, markj (older version)
Approved by: manu (mentor)
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D37001

19 months agobhyve: build RSDT table by basl
Corvin Köhne [Wed, 6 Apr 2022 09:10:43 +0000 (11:10 +0200)]
bhyve: build RSDT table by basl

Building the RSDT table by basl will allow it to be loaded by qemu's
ACPI table loader in the future.

Reviewed by: jhb, markj (older version)
Approved by: manu (mentor)
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D37000

19 months agobhyve: build XSDT table by basl
Corvin Köhne [Wed, 6 Apr 2022 09:10:42 +0000 (11:10 +0200)]
bhyve: build XSDT table by basl

Building the XSDT table by basl will allow it to be loaded by qemu's
ACPI table loader in the future.

Reviewed by: jhb, markj (older version)
Approved by: manu (mentor)
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D36999

19 months agobhyve: build FADT table by basl
Corvin Köhne [Wed, 6 Apr 2022 09:10:42 +0000 (11:10 +0200)]
bhyve: build FADT table by basl

Building the FADT table by basl will allow it to be loaded by qemu's
ACPI table loader in the future.

Reviewed by: jhb, markj (older version)
Approved by: manu (mentor)
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D36998

19 months agobhyve: build MADT table by basl
Corvin Köhne [Wed, 6 Apr 2022 09:10:42 +0000 (11:10 +0200)]
bhyve: build MADT table by basl

Building the MADT table by basl will allow it to be loaded by qemu's
ACPI table loader in the future.

Reviewed by: jhb, markj (older version)
Approved by: manu (mentor)
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D36997

19 months agobhyve: build HPET table by basl
Corvin Köhne [Wed, 6 Apr 2022 09:10:41 +0000 (11:10 +0200)]
bhyve: build HPET table by basl

Building the HPET table by basl will allow it to be loaded by qemu's
ACPI table loader in the future.

Reviewed by: jhb, markj (older version)
Approved by: manu (mentor)
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D36996

19 months agobhyve: add helper to fill a ACPI_GENERIC_ADDRESS
Corvin Köhne [Wed, 16 Nov 2022 09:45:17 +0000 (10:45 +0100)]
bhyve: add helper to fill a ACPI_GENERIC_ADDRESS

Reviewed by: jhb
Approved by: manu (mentor)
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D37407

19 months agobhyve: build MCFG table by basl
Corvin Köhne [Wed, 6 Apr 2022 09:10:41 +0000 (11:10 +0200)]
bhyve: build MCFG table by basl

Building the MCFG table by basl will allow it to be loaded by qemu's
ACPI table loader in the future.

Reviewed by: jhb, markj (older version)
Approved by: manu (mentor)
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D36995

19 months agobhyve: add helper to append a basl table without a header
Corvin Köhne [Wed, 16 Nov 2022 08:31:29 +0000 (09:31 +0100)]
bhyve: add helper to append a basl table without a header

The common style for build an ACPI table will be:

1. basl_table_create
2. basl_table_append_header
3. setup an ACPI_TABLE_* struct
4. basl_table_append_bytes (without header)

Add a helper for the last step.

Reviewed by: jhb, markj
Approved by: manu (mentor)
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D37406

19 months agobhyve: make basl_table_add_* functions public
Corvin Köhne [Wed, 16 Nov 2022 08:15:12 +0000 (09:15 +0100)]
bhyve: make basl_table_add_* functions public

The code will be more readable if we use struct definitions from ACPI-CA
to build ACPI tables. We can fill out the struct and append it to the
basl_table by using basl_table_append_bytes. After that, we have to
declare which checksums, length and pointers should be patched by basl.
That's done by the add_* functions.

Reviewed by: jhb, markj
Approved by: manu (mentor)
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D37405

19 months agobhyve: build FACS table by basl
Corvin Köhne [Wed, 6 Apr 2022 09:10:41 +0000 (11:10 +0200)]
bhyve: build FACS table by basl

Building the FACS table by basl will allow it to be loaded by qemu's
ACPI table loader in the future.

Reviewed by: jhb, markj (older version)
Approved by: manu (mentor)
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D36994

19 months agovmm: remove unneccessary rendezvous assertion
Corvin Köhne [Thu, 17 Nov 2022 06:51:51 +0000 (07:51 +0100)]
vmm: remove unneccessary rendezvous assertion

When a vcpu sees that a rendezvous is in progress, it exits and tries to
handle the rendezvous. The vcpu doesn't check if it's part of the
rendezvous or not. If the vcpu isn't part of the rendezvous, the
rendezvous could be done before it reaches the assertion. This will
cause a panic.

The assertion isn't needed at all because vm_handle_rendezvous properly
handles a spurious rendezvous. So, we can just remove it.

PR: 267779
Reviewed by: jhb, markj
Tested by: bz
Approved by: manu (mentor)
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D37417

19 months agopowerpc/dtrace: Guard fuword64 usage for powerpc64 only
Justin Hibbits [Mon, 21 Nov 2022 00:47:19 +0000 (19:47 -0500)]
powerpc/dtrace: Guard fuword64 usage for powerpc64 only

32-bit powerpc doesn't have a fuword64, so only use it on powerpc64.
This could also be done elsewhere that splits 32-bit and 64-bit
accesses, but adding ifdefs everywhere would just clutter up the source
for little benefit.  This is the only usage of fuword64 directly; other
archs have a dtrace_fuword64_nocheck(), but powerpc does not, and I
don't see a need to add it currently.

MFC after: 1 week

19 months agoorders.7: Sync with NetBSD after CGPM
Gordon Bergling [Sun, 20 Nov 2022 18:24:57 +0000 (19:24 +0100)]
orders.7: Sync with NetBSD after CGPM

Extend orders(7) with prefixes from Resolution 3 of
the 27th meeting of CGPM.

Obtained from: NetBSD
MFC ater: 1 week

19 months agoMake devd shared now that libc++ is in /lib
Ed Maste [Thu, 25 Nov 2021 22:41:50 +0000 (17:41 -0500)]
Make devd shared now that libc++ is in /lib

Commit 5e6a2d6eb220 moved libc++ from /usr/lib to /lib, so we no longer
have an interval during boot when it is not available (before /usr is
mounted).  We no longer need to force devd to be statically linked.

Reviewed by: jhb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37409

19 months agovmm: Fix build w/o KDTRACE_HOOKS.
Dmitry Chagin [Sun, 20 Nov 2022 15:00:55 +0000 (18:00 +0300)]
vmm: Fix build w/o KDTRACE_HOOKS.

Reviewed by: imp
Differential revision: https://reviews.freebsd.org/D37446

19 months agoDocument that cmake files were omitted in previous import.
Xin LI [Sun, 20 Nov 2022 04:17:59 +0000 (20:17 -0800)]
Document that cmake files were omitted in previous import.

19 months agonvmecontrol: Fix IEEE OUI Identifier output
Wanpeng Qian [Sun, 20 Nov 2022 03:06:36 +0000 (19:06 -0800)]
nvmecontrol: Fix IEEE OUI Identifier output

Current sequence of IEEE OUI Identifier output is wrong.

For Intel, current output is e4 d2 5c, specification is 5CD2E4h
For Samsung, current output is 38 25 00, specification is 002538h
also check with Linux nvme-cli.

Reviewed by: imp, chuck
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D33856

19 months agoman9: remove vm_map_unwire from ObsoleteFiles.inc
Mateusz Guzik [Sat, 19 Nov 2022 14:00:58 +0000 (14:00 +0000)]
man9: remove vm_map_unwire from ObsoleteFiles.inc

Fixes: b8121324553079ba ("man9: add vm_map_unwire link")
Reported by: yuri

19 months agosrc.opts.mk: Require C++20 for C++ support.
John Baldwin [Sat, 19 Nov 2022 04:12:28 +0000 (20:12 -0800)]
src.opts.mk: Require C++20 for C++ support.

libc++ requires C++20, so mark C++ (MK_CXX) as broken if the compiler
does not support C++20.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D36893

19 months agobsd.compiler.mk: Add a c++20 compiler feature.
John Baldwin [Sat, 19 Nov 2022 04:11:59 +0000 (20:11 -0800)]
bsd.compiler.mk: Add a c++20 compiler feature.

This is enabled for clang versions 10+ and GCC versions 10+.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D36892

19 months agoDon't omit bsd.compiler.mk for the nested delete-old in buildworld.
John Baldwin [Sat, 19 Nov 2022 04:11:07 +0000 (20:11 -0800)]
Don't omit bsd.compiler.mk for the nested delete-old in buildworld.

src.opts.mk will need bsd.compiler.mk to determine if CXX is
supported.  Without this, src.opts.mk always marks CXX as broken and
attempts to delete all dependencies of MK_CXX from WORLDTMP.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D36890

19 months agoevdev: Extend EVIOCGRAB ioctl scope to cover kbd interface
Vladimir Kondratyev [Fri, 18 Nov 2022 23:54:46 +0000 (02:54 +0300)]
evdev: Extend EVIOCGRAB ioctl scope to cover kbd interface

of various keyboard drivers.
EVIOCGRAB ioctl execution on /dev/input/event# device node gains
exclusive access to this device to caller. It is used mostly for
development purposes and remote control software. See e.g.
https://reviews.freebsd.org/D30020 which is the reason of creation
of this change.
Keyboard grabbing is disabled in KDB and during panics.

MFC with: 4a0db5e2920c
Tested by: corvink
Differential revision: https://reviews.freebsd.org/D30542

19 months agovmm: Fix non-INVARIANTS build
Cy Schubert [Fri, 18 Nov 2022 21:20:13 +0000 (13:20 -0800)]
vmm: Fix non-INVARIANTS build

Reported by: O. Hartmann <freebsd@walstatt-de.de>
Reviewed by: jhb
Fixes: 58eefc67a1cf
Differential Revision: https://reviews.freebsd.org/D37444

19 months agocsu: Add missing GNU-stack annotations to note object files.
John Baldwin [Fri, 18 Nov 2022 20:20:14 +0000 (12:20 -0800)]
csu: Add missing GNU-stack annotations to note object files.

ld.bfd marks the stack as executable for the crt objects due to the
missing annotations which raises a fatal warning starting with version
2.39.

19 months agoUpdate pkgbase metalog tool README to match installed filename
Ed Maste [Wed, 16 Nov 2022 19:31:26 +0000 (14:31 -0500)]
Update pkgbase metalog tool README to match installed filename

The pkgbase metalog tool is named metalog_reader.lua.  (One may argue
that a better name could be chosen, but the README should match in any
case.)

Sponsored by: The FreeBSD Foundation

19 months agobhyve: Enable the default compiler warnings
Mark Johnston [Fri, 18 Nov 2022 19:10:33 +0000 (14:10 -0500)]
bhyve: Enable the default compiler warnings

Disable -Wcast-align for now since we have many instances of that
warning (I fixed some but not most of them) and platforms on which bhyve
runs don't particularly care about unaligned accesses.

Reviewed by: corvink
Differential Revision: https://reviews.freebsd.org/D37296

19 months agobhyve: Avoid using a packed struct for xhci port registers
Mark Johnston [Fri, 18 Nov 2022 19:07:38 +0000 (14:07 -0500)]
bhyve: Avoid using a packed struct for xhci port registers

I believe the __packed annotation is there only because
pci_xhci_portregs_read() is treating the register set as an array of
uint32_t.  clang warns about taking the address of portregs->portsc
because it is a packed member and thus might not have expected
alignment.

Fix the problem by simply selecting the field to read with a switch
statement.  This mimics pci_xhci_portregs_write().  While here, switch
to using some symbolic constants.

There is a small semantic change here in that pci_xhci_portregs_read()
would silently truncate unaligned offsets.  For consistency with
pci_xhci_portregs_write(), which does not do that, return all ones for
unaligned reads instead.

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

19 months agobhyve: Let BASL compile with raised warnings
Mark Johnston [Fri, 18 Nov 2022 19:07:20 +0000 (14:07 -0500)]
bhyve: Let BASL compile with raised warnings

- Make basl_dump() as unused.
- Avoid arithmetic on a void pointer.
- Avoid a signed/unsigned comparison with
  BASL_TABLE_CHECKSUM_LEN_FULL_TABLE.
- Ignore warnings about unused parameters from stuff pulled in by
  acpi.h.  In particular, any prototype wrapped by
  ACPI_DBG_DEPENDENT_RETURN_VOID() will raise such parameters unless
  ACPI_DEBUG_OUTPUT is defined.

Reviewed by: corvink, jhb
Differential Revision: https://reviews.freebsd.org/D37397

19 months agobhyve: Address an unused parameter warning in the smbios code
Mark Johnston [Fri, 18 Nov 2022 19:06:44 +0000 (14:06 -0500)]
bhyve: Address an unused parameter warning in the smbios code

The compiler was warning that the "size" parameter to
smbios_generic_initializer() was unused.  This parameter is apparently
used to populate the "maximum structure size" field in the SMBIOS entry
point, but we were always setting it to zero.

Implement it instead in the main loop of the smbios table builder.

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

19 months agobhyve: Disable thread safety analysis
Mark Johnston [Fri, 18 Nov 2022 19:04:19 +0000 (14:04 -0500)]
bhyve: Disable thread safety analysis

The warnings that arise are bogus and have to be muted with
__no_lock_analysis in most cases.  As a step towards enabling the
default warning level for bhyve, just disable them.

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

19 months agovmm: Restore the correct vm_inject_*() prototypes
Mark Johnston [Fri, 18 Nov 2022 19:11:21 +0000 (14:11 -0500)]
vmm: Restore the correct vm_inject_*() prototypes

Fixes: 80cb5d845b8f ("vmm: Pass vcpu instead of vm and vcpuid...")
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D37443

19 months agovmm: Trim some pointless #ifdef KTR.
John Baldwin [Fri, 18 Nov 2022 18:06:20 +0000 (10:06 -0800)]
vmm: Trim some pointless #ifdef KTR.

Reported by: markj
Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37272

19 months agovmm: Convert VM_MAXCPU into a loader tunable hw.vmm.maxcpu.
John Baldwin [Fri, 18 Nov 2022 18:06:08 +0000 (10:06 -0800)]
vmm: Convert VM_MAXCPU into a loader tunable hw.vmm.maxcpu.

The default is now the number of physical CPUs in the system rather
than 16.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37175

19 months agovmm: Allocate vCPUs on first use of a vCPU.
John Baldwin [Fri, 18 Nov 2022 18:05:35 +0000 (10:05 -0800)]
vmm: Allocate vCPUs on first use of a vCPU.

Convert the vcpu[] array in struct vm to an array of pointers and
allocate vCPUs on first use.  This avoids always allocating VM_MAXCPU
vCPUs for each VM, but instead only allocates the vCPUs in use.  A new
per-VM sx lock is added to serialize attempts to allocate vCPUs on
first use.  However, a given vCPU is never freed while the VM is
active, so the pointer is read via an unlocked read first to avoid the
need for the lock in the common case once the vCPU has been created.

Some ioctls need to lock all vCPUs.  To prevent races with ioctls that
want to allocate a new vCPU, these ioctls also lock the sx lock that
protects vCPU creation.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37174

19 months agovmm: Use a cpuset_t for vCPUs waiting for STARTUP IPIs.
John Baldwin [Fri, 18 Nov 2022 18:05:10 +0000 (10:05 -0800)]
vmm: Use a cpuset_t for vCPUs waiting for STARTUP IPIs.

Retire the boot_state member of struct vlapic and instead use a cpuset
in the VM to track vCPUs waiting for STARTUP IPIs.  INIT IPIs add
vCPUs to this set, and STARTUP IPIs remove vCPUs from the set.
STARTUP IPIs are only reported to userland for vCPUs that were removed
from the set.

In particular, this permits a subsequent change to allocate vCPUs on
demand when the vCPU may not be allocated until after a STARTUP IPI is
reported to userland.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37173

19 months agovmm devmem_mmap_single: Bump object reference under memsegs lock.
John Baldwin [Fri, 18 Nov 2022 18:04:58 +0000 (10:04 -0800)]
vmm devmem_mmap_single: Bump object reference under memsegs lock.

Reported by: markj
Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37273

19 months agovmm: Use an sx lock to protect the memory map.
John Baldwin [Fri, 18 Nov 2022 18:04:37 +0000 (10:04 -0800)]
vmm: Use an sx lock to protect the memory map.

Previously bhyve obtained a "read lock" on the memory map for ioctls
needing to read the map by locking the last vCPU.  This is now
replaced by a new per-VM sx lock.  Modifying the map requires
exclusively locking the sx lock as well as locking all existing vCPUs.
Reading the map requires either locking one vCPU or the sx lock.

This permits safely modifying or querying the memory map while some
vCPUs do not exist which will be true in a future commit.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37172

19 months agovmm: Destroy mutexes.
John Baldwin [Fri, 18 Nov 2022 18:04:30 +0000 (10:04 -0800)]
vmm: Destroy mutexes.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37171

19 months agovmm stat: Add a special nelems constant for arrays sized by vCPU count.
John Baldwin [Fri, 18 Nov 2022 18:04:23 +0000 (10:04 -0800)]
vmm stat: Add a special nelems constant for arrays sized by vCPU count.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37170

19 months agovmm vmx: Allocate vpids on demand as each vCPU is initialized.
John Baldwin [Fri, 18 Nov 2022 18:04:11 +0000 (10:04 -0800)]
vmm vmx: Allocate vpids on demand as each vCPU is initialized.

Compared to the previous version this does mean that if the system as
a whole runs out of dedicated vPIDs you might end up with some vCPUs
within a single VM using dedicated vPIDs and others using shared
vPIDs, but this should not break anything.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37169

19 months agovmm: Lookup vcpu pointers in vmmdev_ioctl.
John Baldwin [Fri, 18 Nov 2022 18:03:52 +0000 (10:03 -0800)]
vmm: Lookup vcpu pointers in vmmdev_ioctl.

Centralize mapping vCPU IDs to struct vcpu objects in vmmdev_ioctl and
pass vcpu pointers to the routines in vmm.c.  For operations that want
to perform an action on all vCPUs or on a single vCPU, pass pointers
to both the VM and the vCPU using a NULL vCPU pointer to request
global actions.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37168

19 months agovmm ppt: Remove unused vcpu arg from MSI setup handlers.
John Baldwin [Fri, 18 Nov 2022 18:03:46 +0000 (10:03 -0800)]
vmm ppt: Remove unused vcpu arg from MSI setup handlers.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37167

19 months agovmm: Remove unused vcpuid argument from vioapic_process_eoi.
John Baldwin [Fri, 18 Nov 2022 18:03:39 +0000 (10:03 -0800)]
vmm: Remove unused vcpuid argument from vioapic_process_eoi.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37166

19 months agovmm: Use struct vcpu in the rendezvous code.
John Baldwin [Fri, 18 Nov 2022 18:03:34 +0000 (10:03 -0800)]
vmm: Use struct vcpu in the rendezvous code.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37165

19 months agovmm: Remove support for vm_rendezvous with a cpuid of -1.
John Baldwin [Fri, 18 Nov 2022 18:03:23 +0000 (10:03 -0800)]
vmm: Remove support for vm_rendezvous with a cpuid of -1.

This is not currently used.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37164

19 months agovmm: Remove vcpuid from I/O port handlers.
John Baldwin [Fri, 18 Nov 2022 18:03:14 +0000 (10:03 -0800)]
vmm: Remove vcpuid from I/O port handlers.

No I/O ports are vCPU-specific (unlike memory which does have
vCPU-specific ranges such as the local APIC).

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37163

19 months agovmm: Pass vcpu instead of vm and vcpuid to APIs used from CPU backends.
John Baldwin [Fri, 18 Nov 2022 18:03:05 +0000 (10:03 -0800)]
vmm: Pass vcpu instead of vm and vcpuid to APIs used from CPU backends.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37162

19 months agovmm: Use struct vcpu in the instruction emulation code.
John Baldwin [Fri, 18 Nov 2022 18:02:09 +0000 (10:02 -0800)]
vmm: Use struct vcpu in the instruction emulation code.

This passes struct vcpu down in place of struct vm and and integer
vcpu index through the in-kernel instruction emulation code.  To
minimize userland disruption, helper macros are used for the vCPU
arguments passed into and through the shared instruction emulation
code.

A few other APIs used by the instruction emulation code have also been
updated to accept struct vcpu in the kernel including
vm_get/set_register and vm_inject_fault.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37161

19 months agovmm: Add vm_gpa_hold_global wrapper function.
John Baldwin [Fri, 18 Nov 2022 18:01:57 +0000 (10:01 -0800)]
vmm: Add vm_gpa_hold_global wrapper function.

This handles the case that guest pages are being held not on behalf of
a virtual CPU but globally.  Previously this was handled by passing a
vcpuid of -1 to vm_gpa_hold, but that will not work in the future when
vm_gpa_hold is changed to accept a struct vcpu pointer.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37160

19 months agovmm: Add _KERNEL guards for io headers shared with userspace.
John Baldwin [Fri, 18 Nov 2022 18:01:51 +0000 (10:01 -0800)]
vmm: Add _KERNEL guards for io headers shared with userspace.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37159

19 months agobhyve: Remove unused vm and vcpu arguments from vm_copy routines.
John Baldwin [Fri, 18 Nov 2022 18:01:44 +0000 (10:01 -0800)]
bhyve: Remove unused vm and vcpu arguments from vm_copy routines.

The arguments identifying the VM and vCPU are only needed for
vm_copy_setup.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37158

19 months agovmm: Use struct vcpu with the vmm_stat API.
John Baldwin [Fri, 18 Nov 2022 18:01:18 +0000 (10:01 -0800)]
vmm: Use struct vcpu with the vmm_stat API.

The function callbacks still use struct vm and and vCPU index.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37157

19 months agovmm: Expose struct vcpu as an opaque type.
John Baldwin [Fri, 18 Nov 2022 18:01:05 +0000 (10:01 -0800)]
vmm: Expose struct vcpu as an opaque type.

Pass a pointer to the current struct vcpu to the vcpu_init callback
and save this pointer in the CPU-specific vcpu structures.

Add routines to fetch a struct vcpu by index from a VM and to query
the VM and vcpuid from a struct vcpu.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37156

19 months agovmm: Use VLAPIC_CTR* in more places.
John Baldwin [Fri, 18 Nov 2022 18:00:59 +0000 (10:00 -0800)]
vmm: Use VLAPIC_CTR* in more places.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37155

19 months agovmm vmx: Add VMX_CTR* wrapper macros.
John Baldwin [Fri, 18 Nov 2022 18:00:49 +0000 (10:00 -0800)]
vmm vmx: Add VMX_CTR* wrapper macros.

These macros are similar to VCPU_CTR* but accept a single vmx_vcpu
pointer as the first argument instead of separate vm and vcpuid.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37154

19 months agovmm svm: Add SVM_CTR* wrapper macros.
John Baldwin [Fri, 18 Nov 2022 18:00:38 +0000 (10:00 -0800)]
vmm svm: Add SVM_CTR* wrapper macros.

These macros are similar to VCPU_CTR* but accept a single svm_vcpu
pointer as the first argument instead of separate vm and vcpuid.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37153

19 months agovmm: Remove the per-vm cookie argument from vmmops taking a vcpu.
John Baldwin [Fri, 18 Nov 2022 18:00:00 +0000 (10:00 -0800)]
vmm: Remove the per-vm cookie argument from vmmops taking a vcpu.

This requires storing a reference to the per-vm cookie in the
CPU-specific vCPU structure.  Take advantage of this new field to
remove no-longer-needed function arguments in the CPU-specific
backends.  In particular, stop passing the per-vm cookie to functions
that either don't use it or only use it for KTR traces.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37152

19 months agovmm: Refactor storage of CPU-dependent per-vCPU data.
John Baldwin [Fri, 18 Nov 2022 17:59:21 +0000 (09:59 -0800)]
vmm: Refactor storage of CPU-dependent per-vCPU data.

Rather than storing static arrays of per-vCPU data in the CPU-specific
per-VM structure, adopt a more dynamic model similar to that used to
manage CPU-specific per-VM data.

That is, add new vmmops methods to init and cleanup a single vCPU.
The init method returns a pointer that is stored in 'struct vcpu' as a
cookie pointer.  This cookie pointer is now passed to other vmmops
callbacks in place of the integer index.  The index is now only used
in KTR traces and when calling back into the CPU-independent layer.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37151

19 months agovmm vmx: Add a global bool to indicate if the host has the TSC_AUX MSR.
John Baldwin [Fri, 18 Nov 2022 17:58:56 +0000 (09:58 -0800)]
vmm vmx: Add a global bool to indicate if the host has the TSC_AUX MSR.

A future commit will remove direct access to vCPU structures from
struct vmx, so add a dedicated boolean for this rather than checking
the capabilities for vCPU 0.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37269

19 months agovmm: Rework snapshotting of CPU-specific per-vCPU data.
John Baldwin [Fri, 18 Nov 2022 17:58:41 +0000 (09:58 -0800)]
vmm: Rework snapshotting of CPU-specific per-vCPU data.

Previously some per-vCPU state was saved in vmmops_snapshot and other
state was saved in vmmops_vcmx_snapshot.  Consolidate all per-vCPU
state into the latter routine and rename the hook to the more generic
'vcpu_snapshot'.  Note that the CPU-independent per-vCPU data is still
stored in a separate blob as well as the per-vCPU local APIC data.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37150

19 months agovmm svm: Mark all VMCB state caches dirty on vCPU restore.
John Baldwin [Fri, 18 Nov 2022 17:58:22 +0000 (09:58 -0800)]
vmm svm: Mark all VMCB state caches dirty on vCPU restore.

Mark Johnston noticed that this was missing VMCB_CACHE_LBR.  Just set
all the bits as is done in svm_run() rather than trying to clear
individual bits.

Reported by: markj
Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37259

19 months agovmm vmx: Refactor per-vCPU data.
John Baldwin [Fri, 18 Nov 2022 17:58:08 +0000 (09:58 -0800)]
vmm vmx: Refactor per-vCPU data.

Add a struct vmx_vcpu to hold per-vCPU data specific to VT-x and
move parallel arrays out of struct vmx into a single array of
this structure.

While here, dynamically allocate the VMCS, APIC page and PIR
descriptors for each vCPU rather than embedding them.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37149

19 months agovmm svm: Refactor per-vCPU data.
John Baldwin [Fri, 18 Nov 2022 17:57:48 +0000 (09:57 -0800)]
vmm svm: Refactor per-vCPU data.

- Allocate VMCBs separately to avoid excessive padding in struct
  svm_vcpu.

- Allocate APIC pages dynamically directly in struct vlapic.

- Move vm_mtrr into struct svm_vcpu rather than using a separate
  parallel array.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37148

19 months agovmm: Use vm_get_maxcpus() instead of VM_MAXCPU in various places.
John Baldwin [Fri, 18 Nov 2022 17:57:38 +0000 (09:57 -0800)]
vmm: Use vm_get_maxcpus() instead of VM_MAXCPU in various places.

Mostly these are loops that iterate over all possible vCPU IDs for a
specific virtual machine.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37147

19 months agovmm: Simplify saving of absolute TSC values in snapshots.
John Baldwin [Fri, 18 Nov 2022 17:57:29 +0000 (09:57 -0800)]
vmm: Simplify saving of absolute TSC values in snapshots.

Read the current "now" TSC value and use it to compute absolute time
saved value in vm_snapshot_vcpus rather than iterating over vCPUs
multiple times in vm_snapshot_vm.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D37146