From nobody Wed Oct 4 16:53:55 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 4S11434pMpz4wGfl; Wed, 4 Oct 2023 16:53:55 +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 4S114347zxz3C8R; Wed, 4 Oct 2023 16:53:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696438435; 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=311YNNr5JVrROgeJDtyoEWQ2QG+sas09Wql6MpJsaVA=; b=D2d+c8QQiba14puM4PXeRBGHh8ln05hNe7yZDbJy06BvHBEIhjmoK6fOK0KeVi09VeAsKS i7m8TD3B2T7lhJYinfC9NkSf6lbLkyfFuZcPhsVa5jVOa1dBxR6hcEx9c/z8vbR0qm0C0p 8V3/hW9vQyZwO77YvaNxl+jW/FI4Vr0xXk/WMO1JMhKhsRNTFyCXH6Z1qSd5MoGUmBVTpN VadppSd6DJrqeUytjhE8a93Qbeg71jhlt3anmCifO2/WXb6Lz1N5MlF3Yf2SB8AbW1HEWB EEofS9tiQBCsm2sPXCu4ynuui/D/omIMgNd42wpEwcacS6qkSkKvXDHcViiO8Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1696438435; a=rsa-sha256; cv=none; b=e9pnHEa38zGhGaDSfwG9pq1se/RLfNYH/Io6JZJEu2QznmK7IfBCX7j25DRTChixaPJF+u JoiEbYzlF2pYtoNH6apxYcLjGmZguH09qA65Dko5F1SEoHPTPzmM0UR69FDuneE/qh5h4Y +J00EZJQM/xHxiGiWHjtUwpcBnBng4A7rl+BloEKx/sCljE5JOQBEHHXc8ZCp7niX3zx7w aKtaXMAy1xq619IpbKpRaJuDjJwsWmiCVWjfRcMt4I4NIPat1bevsN9cMU35XGp7OKSo+e KvfxIv0AX/drBpCF8C+h5OXhEl2X5vcTBuI94/qUrjzL3PpKcAbcfbMQmPjxcA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696438435; 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=311YNNr5JVrROgeJDtyoEWQ2QG+sas09Wql6MpJsaVA=; b=kgb9ByinqsKJSrZ52xwGB2S1WxMYgHQQPHHk9PpS6AscMG6vHpdTs6XdXrHkHjl30DOQ3p grvKFk/rvwHneeelEv6qMTOguzXOSwJxq5XN/2PTpnsZ3yyX95aQ8tqLtK/5Fsu+H+RSzC AqR63JVp4aPa5fWiIeUvkq/HhJUxQWKea7dWLgZmTd5nbet6iC+twMVJ4+jhtM9Qz/fNoD IyEC6+bKKohRb8amhADwQ54RaRfm5Efse/NYoELQYHF7BQKweWUb2+YbBTjME5cCGdDZ61 QGSIezHL71V7qEG4XX4/gRC3zridy7F3VzC/Ljf9C+FHKk7mzZ5+ZyvN8r3DVw== 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 4S1143341jzllx; Wed, 4 Oct 2023 16:53:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 394GrtuF037434; Wed, 4 Oct 2023 16:53:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 394GrtlA037431; Wed, 4 Oct 2023 16:53:55 GMT (envelope-from git) Date: Wed, 4 Oct 2023 16:53:55 GMT Message-Id: <202310041653.394GrtlA037431@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: 4f2bd4027b32 - main - bhyve: Start moving machine-dependent code into subdirectories 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: 4f2bd4027b3261d159f6d673dc9ee9e84b4a3538 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4f2bd4027b3261d159f6d673dc9ee9e84b4a3538 commit 4f2bd4027b3261d159f6d673dc9ee9e84b4a3538 Author: Mark Johnston AuthorDate: 2023-10-04 16:20:37 +0000 Commit: Mark Johnston CommitDate: 2023-10-04 16:53:16 +0000 bhyve: Start moving machine-dependent code into subdirectories In preparation for an arm64 port, make an easy change which puts some machine-dependent code in its own directory. Going forward, code which is only used on one platform should live in a MD directory. We should strive to layer modules in such a way as to avoid polluting shared code with lots of ifdefs. For some existing files this will take some effort. task_switch.c and fwctl.c are an easy place to start: the former is very x86-specific, and the latter provides an I/O port interface which can't be used on anything other than x86. (fwcfg as implemented has the same problem, but QEMU also supports a MMIO fwcfg interface.) So I propose that we start by simply making those files conditional. Reviewed by: corvink, jhb MFC after: 1 week Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D40501 --- usr.sbin/bhyve/Makefile | 16 +++++++++------- usr.sbin/bhyve/amd64/Makefile.inc | 6 ++++++ usr.sbin/bhyve/{ => amd64}/fwctl.c | 0 usr.sbin/bhyve/{ => amd64}/fwctl.h | 0 usr.sbin/bhyve/{ => amd64}/task_switch.c | 2 ++ usr.sbin/bhyve/bhyverun.c | 8 +++++++- usr.sbin/bhyve/bhyverun.h | 2 -- usr.sbin/bhyve/snapshot.c | 1 - 8 files changed, 24 insertions(+), 11 deletions(-) diff --git a/usr.sbin/bhyve/Makefile b/usr.sbin/bhyve/Makefile index a720c6b3c7a4..794bfbe4c8a3 100644 --- a/usr.sbin/bhyve/Makefile +++ b/usr.sbin/bhyve/Makefile @@ -2,9 +2,6 @@ # .include -CFLAGS+=-I${.CURDIR}/../../contrib/lib9p -CFLAGS+=-I${SRCTOP}/sys -.PATH: ${SRCTOP}/sys/libkern ${SRCTOP}/sys/cam/ctl PROG= bhyve PACKAGE= bhyve @@ -13,6 +10,10 @@ MAN= bhyve.8 bhyve_config.5 BHYVE_SYSDIR?=${SRCTOP} +.PATH: ${.CURDIR}/${MACHINE_CPUARCH} \ + ${SRCTOP}/sys/libkern \ + ${SRCTOP}/sys/cam/ctl + SRCS= \ acpi.c \ acpi_device.c \ @@ -29,7 +30,6 @@ SRCS= \ ctl_scsi_all.c \ ctl_util.c \ e820.c \ - fwctl.c \ gdb.c \ hda_codec.c \ inout.c \ @@ -73,7 +73,6 @@ SRCS= \ smbiostbl.c \ sockstream.c \ spinup_ap.c \ - task_switch.c \ tpm_device.c \ tpm_emul_passthru.c \ tpm_intf_crb.c \ @@ -90,10 +89,13 @@ SRCS= \ SRCS+= snapshot.c .endif +.include "${MACHINE_CPUARCH}/Makefile.inc" + CFLAGS.kernemu_dev.c+= -I${SRCTOP}/sys/amd64 -.PATH: ${BHYVE_SYSDIR}/sys/amd64/vmm -SRCS+= vmm_instruction_emul.c +CFLAGS+=-I${.CURDIR} \ + -I${.CURDIR}/../../contrib/lib9p \ + -I${SRCTOP}/sys LIBADD= vmmapi md nv pthread z util sbuf cam 9p diff --git a/usr.sbin/bhyve/amd64/Makefile.inc b/usr.sbin/bhyve/amd64/Makefile.inc new file mode 100644 index 000000000000..62de5f211a23 --- /dev/null +++ b/usr.sbin/bhyve/amd64/Makefile.inc @@ -0,0 +1,6 @@ +SRCS+= \ + fwctl.c \ + task_switch.c + +.PATH: ${BHYVE_SYSDIR}/sys/amd64/vmm +SRCS+= vmm_instruction_emul.c diff --git a/usr.sbin/bhyve/fwctl.c b/usr.sbin/bhyve/amd64/fwctl.c similarity index 100% rename from usr.sbin/bhyve/fwctl.c rename to usr.sbin/bhyve/amd64/fwctl.c diff --git a/usr.sbin/bhyve/fwctl.h b/usr.sbin/bhyve/amd64/fwctl.h similarity index 100% rename from usr.sbin/bhyve/fwctl.h rename to usr.sbin/bhyve/amd64/fwctl.h diff --git a/usr.sbin/bhyve/task_switch.c b/usr.sbin/bhyve/amd64/task_switch.c similarity index 99% rename from usr.sbin/bhyve/task_switch.c rename to usr.sbin/bhyve/amd64/task_switch.c index 351df7fb738b..c316d18142a7 100644 --- a/usr.sbin/bhyve/task_switch.c +++ b/usr.sbin/bhyve/amd64/task_switch.c @@ -700,6 +700,8 @@ push_errcode(struct vcpu *vcpu, struct vm_guest_paging *paging, return (VMEXIT_CONTINUE); \ } while (0) +int vmexit_task_switch(struct vmctx *, struct vcpu *, struct vm_run *); + int vmexit_task_switch(struct vmctx *ctx, struct vcpu *vcpu, struct vm_run *vmrun) { diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c index 1d4cf048b59b..4e2d5467cfaf 100644 --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -88,7 +88,9 @@ #include "inout.h" #include "debug.h" #include "e820.h" -#include "fwctl.h" +#ifdef __amd64__ +#include "amd64/fwctl.h" +#endif #include "gdb.h" #include "ioapic.h" #include "kernemu_dev.h" @@ -921,6 +923,8 @@ vmexit_ipi(struct vmctx *ctx __unused, struct vcpu *vcpu __unused, return (error); } +int vmexit_task_switch(struct vmctx *, struct vcpu *, struct vm_run *); + static const vmexit_handler_t handler[VM_EXITCODE_MAX] = { [VM_EXITCODE_INOUT] = vmexit_inout, [VM_EXITCODE_INOUT_STR] = vmexit_inout, @@ -1576,9 +1580,11 @@ main(int argc, char *argv[]) } free(e820_fwcfg_item); +#ifdef __amd64__ if (lpc_bootrom() && strcmp(lpc_fwcfg(), "bhyve") == 0) { fwctl_init(); } +#endif /* * Change the proc title to include the VM name. diff --git a/usr.sbin/bhyve/bhyverun.h b/usr.sbin/bhyve/bhyverun.h index 1131e18baed2..fc0d2595e66b 100644 --- a/usr.sbin/bhyve/bhyverun.h +++ b/usr.sbin/bhyve/bhyverun.h @@ -46,6 +46,4 @@ uintptr_t paddr_host2guest(struct vmctx *ctx, void *addr); int fbsdrun_virtio_msix(void); -int vmexit_task_switch(struct vmctx *, struct vcpu *, struct vm_run *); - #endif diff --git a/usr.sbin/bhyve/snapshot.c b/usr.sbin/bhyve/snapshot.c index ec56bd0fed9a..7d8959756757 100644 --- a/usr.sbin/bhyve/snapshot.c +++ b/usr.sbin/bhyve/snapshot.c @@ -79,7 +79,6 @@ #include "debug.h" #include "inout.h" #include "ipc.h" -#include "fwctl.h" #include "ioapic.h" #include "mem.h" #include "mevent.h"