From nobody Mon Jun 19 19:54:36 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QlL7x12Brz4fcvC; Mon, 19 Jun 2023 19:54:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QlL7w52QZz3vTq; Mon, 19 Jun 2023 19:54:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687204476; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/GWKzFcVy5kLjApWAsLApHCtTtw2z0gRw/Nikf1hn7I=; b=NJDn6M/c2RyUpBItj6xoVZfqV3bmgbDqTolYcePN/pnERuy8x5eU8fYiW8e08Fpo4C29MB eB3yShncNJ3q1Lvr5NUCwwQUDpCF0EvV/FCaLSrCibom7Zw+eJ3H7d8tOdUAacBDoTalOu HZ9P/q1OWVT7zPgK94NH0pJyko0WxEk2YHJUrZpmLI6aMnwTv7EFB/dfWieqRjK36Ngyqx uatke8k3Y4DUR9pculOoJIJ9LypL3ysErxzr2JE9XIY5FIB0UxQpvwKpePQivsKqGVJUCr FS44KXVS6m+W9pLWaDMIWjQ74DKePA6ixkH5Bar1ZynVLjT2deRYaxVDC7K2/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687204476; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/GWKzFcVy5kLjApWAsLApHCtTtw2z0gRw/Nikf1hn7I=; b=PEAprgSBKkuR7vgIGAEaELpoUCrcVMNLGxfRtfXRPtihNyTXRvZfaPSTynGYQlv/JF8CAc NcwRi/gUaOen7drZ1PEHPSpfpxZ9S+p1YMSHfR3YdIe0Lc4qJsa9NJaYlVAx6O7GbnL+Zf 5Vr6kpZR33/H0qDAAkrCbP0+hwlMyn+VaMf8+7Qw9RfCJK9btYULHsMi6TMdrZ9A+C4Rju /5wxVAAddrU508UA3b4C+eKY7EYa52pu17FdUuIWnhYtyY7drKnGb0rjQkSgYCytkcTVv8 GL+Pnh0cT0xY7nj2HLz/qmTgttYHdbSSk4zoTXD/yIEqteuBmjAWWfPwU9435A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1687204476; a=rsa-sha256; cv=none; b=ShPNO5afOVbLTOtWfmUCjixS5ONXkiV48U4ywii0cM2N7SsCVOus0XFCWikQPnh0zp6CZk zhalGox5icjYkLaBFRbVligUDPY6w/MPPycIS6CU0H+8aaKAnE74n8E45xEah1UDlOfqqS SF4Y3+QpyPQO+GBQ5JkwAs96UtliXnPZ1qzMPJBO6RTzlNePxErRkjNP5xnkGbBpETJqlH LrRSMKy2DYkr0ZOs1QGfL+2pAwKshC1zdoh/SPX2lCi6jwpmWJjgTAwIdx/Sr1zJaMQOfz HzWVuDukvfr78/qDqVdthEFDpIepADy6V5hB5SOSuAdXil5R8/+NY3vdHm1+uw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QlL7w3zrDzVh6; Mon, 19 Jun 2023 19:54:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 35JJsaUb012938; Mon, 19 Jun 2023 19:54:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35JJsasK012937; Mon, 19 Jun 2023 19:54:36 GMT (envelope-from git) Date: Mon, 19 Jun 2023 19:54:36 GMT Message-Id: <202306191954.35JJsasK012937@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 15c1f0cc2c1f - main - bhyve: Register hlt and pause vmexit handlers unconditionally List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 15c1f0cc2c1f991fc3895d2a96f48705604d1987 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=15c1f0cc2c1f991fc3895d2a96f48705604d1987 commit 15c1f0cc2c1f991fc3895d2a96f48705604d1987 Author: Mark Johnston AuthorDate: 2023-06-19 19:46:02 +0000 Commit: Mark Johnston CommitDate: 2023-06-19 19:46:02 +0000 bhyve: Register hlt and pause vmexit handlers unconditionally These exit handlers might not be used if the corresponding VM capabilities are not set, but there is no harm in putting them into the handler table regardless. Doing so simplifies initialization code, makes it easier to split vmexit handlers into a separate file, and lets us declare the handler table as const. Reviewed by: corvink, jhb MFC after: 2 weeks Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D40572 --- usr.sbin/bhyve/bhyverun.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c index f5365a352d07..888fbe1cd8fc 100644 --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -930,7 +930,7 @@ vmexit_ipi(struct vmctx *ctx __unused, struct vcpu *vcpu __unused, return (error); } -static vmexit_handler_t handler[VM_EXITCODE_MAX] = { +static const vmexit_handler_t handler[VM_EXITCODE_MAX] = { [VM_EXITCODE_INOUT] = vmexit_inout, [VM_EXITCODE_INOUT_STR] = vmexit_inout, [VM_EXITCODE_VMX] = vmexit_vmx, @@ -946,6 +946,8 @@ static vmexit_handler_t handler[VM_EXITCODE_MAX] = { [VM_EXITCODE_DEBUG] = vmexit_debug, [VM_EXITCODE_BPT] = vmexit_breakpoint, [VM_EXITCODE_IPI] = vmexit_ipi, + [VM_EXITCODE_HLT] = vmexit_hlt, + [VM_EXITCODE_PAUSE] = vmexit_pause, }; static void @@ -1012,7 +1014,7 @@ num_vcpus_allowed(struct vmctx *ctx, struct vcpu *vcpu) } static void -fbsdrun_set_capabilities(struct vcpu *vcpu, bool bsp) +fbsdrun_set_capabilities(struct vcpu *vcpu) { int err, tmp; @@ -1023,8 +1025,6 @@ fbsdrun_set_capabilities(struct vcpu *vcpu, bool bsp) exit(4); } vm_set_capability(vcpu, VM_CAP_HALT_EXIT, 1); - if (bsp) - handler[VM_EXITCODE_HLT] = vmexit_hlt; } if (get_config_bool_default("x86.vmexit_on_pause", false)) { @@ -1038,8 +1038,6 @@ fbsdrun_set_capabilities(struct vcpu *vcpu, bool bsp) exit(4); } vm_set_capability(vcpu, VM_CAP_PAUSE_EXIT, 1); - if (bsp) - handler[VM_EXITCODE_PAUSE] = vmexit_pause; } if (get_config_bool_default("x86.x2apic", false)) @@ -1130,7 +1128,7 @@ spinup_vcpu(struct vcpu_info *vi, bool bsp) int error; if (!bsp) { - fbsdrun_set_capabilities(vi->vcpu, false); + fbsdrun_set_capabilities(vi->vcpu); /* * Enable the 'unrestricted guest' mode for APs. @@ -1432,7 +1430,7 @@ main(int argc, char *argv[]) exit(4); } - fbsdrun_set_capabilities(bsp, true); + fbsdrun_set_capabilities(bsp); /* Allocate per-VCPU resources. */ vcpu_info = calloc(guest_ncpus, sizeof(*vcpu_info));