From nobody Wed Oct 11 13:25:04 2023 X-Original-To: dev-commits-src-branches@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 4S5D5r33lsz4xNy0; Wed, 11 Oct 2023 13:25:04 +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 4S5D5r2Wfxz3GMc; Wed, 11 Oct 2023 13:25:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697030704; 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=KpImpOaOivpEbeGu51CFlmdvDNOFJZOTnyneWbeWTV4=; b=wTYUbW4VhaQkc2UaJN7v5yx6u1MnnCAH3mKsXwr6+2xM4WBaNsnV657pvedyN73UjQ0CvD sXffZwkWfRSB9HB5OPlwSTpfkiqrVP1eQ6ANU/Xyr/DDnYdhL0c6X4G2erpuetmQlmq9Ad QEbie9yBlZYFDWDyMrwF/KODZZgriJqC01HsgN3f8OAAK8wyZ5CC50JUTnUneH5ZjegCXn CZ1twxFSwM1kku2pBS5TgKANb9Q8FcsyhLGbMKJnjg/HAM0UWU5Li8qPgdbesOwCMZH3f9 F6YiZacbQRubLA5MJVxRCgfMGyChfdJJ2emjy8sKey64l2NSAiQxJTmD1YlgiQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1697030704; a=rsa-sha256; cv=none; b=qHi6Nyl8yN3bewS55Bp/PqcIMqbZu221razh3PYjPcICZlTa5je3UyRtE5q8wOqplF5dTy Vu9zwQ7ADLZ7LCOLVo3W2AVdOA9m0D+I1oF0s4mMMAocVXOE50HQF8aF5CzDSbZG1CM0Oq ZPPiSTMuX7UCWMNAM+HN7YJTpe2LAY9PfVcQ+hBKp7/MJj12zrNj0UPZebNS+uOM8kjXWa ZFqX5TLboddcO9HsYdGZFYqe9A5t6HPf6YVCcqtrY04ddZtzcLq7JNLCKUA2YUYMLdd1Kq QhZH1uKtnKvbq2CeoMPb+674iqnHmbrPS1JW7b/yH8OO6bJwK470bVV6tOX05w== 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=1697030704; 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=KpImpOaOivpEbeGu51CFlmdvDNOFJZOTnyneWbeWTV4=; b=yuKtJpyTAP2GFhEqVPBRp2CiOqYQM+bacs5hYSiKHZ6UnATXwr6wv4iHkcsJ+SR2mb6i5O Q39kZQB1rMkKYUARo1/26qG4xIEv7I5FiNEY4OvSkgNWW5t/0o5FjiDMwk1HZEphQQu5yT CamIBb/Kmr0/5aKEmGeeHY47hwcDRi2xww3os1Hmf5A6waMwpwj2MGvZgfpCUO83qACGdf N58vahnBq0ZyvmeTbdmY4x61pQM3fYkckI2l/zFZeAMslzjXddtSTVjJLXLYjzBVGh/2hW RSgaLX7eZFMPjoPEDc6T8zNrf6ok/2JL8/JeTmB0RA0KPwBH0Q4ZGH5h5sXRfw== 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 4S5D5r1HXyz7cv; Wed, 11 Oct 2023 13:25:04 +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 39BDP4Y2089913; Wed, 11 Oct 2023 13:25:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39BDP4iA089910; Wed, 11 Oct 2023 13:25:04 GMT (envelope-from git) Date: Wed, 11 Oct 2023 13:25:04 GMT Message-Id: <202310111325.39BDP4iA089910@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: aeb52e2ff677 - stable/14 - bhyve: Move more amd64-specific code under amd64/ List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/14 X-Git-Reftype: branch X-Git-Commit: aeb52e2ff67769b2f01582b4a26c3887b45d964b Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=aeb52e2ff67769b2f01582b4a26c3887b45d964b commit aeb52e2ff67769b2f01582b4a26c3887b45d964b Author: Mark Johnston AuthorDate: 2023-10-04 16:21:20 +0000 Commit: Mark Johnston CommitDate: 2023-10-11 13:21:53 +0000 bhyve: Move more amd64-specific code under amd64/ mptable and the e820 are both rather amd64-specific and can be moved easily. In the case of e820, move the registration with qemu_fwcfg into e820.c, as it simplifies bhyverun.c a bit and I can't see any downsides. No functional change intended. Reviewed by: corvink, jhb, emaste MFC after: 1 week Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D40552 (cherry picked from commit 4fe5b70cae6761b9205ff35b72ccfe60d7326301) --- usr.sbin/bhyve/Makefile | 2 -- usr.sbin/bhyve/amd64/Makefile.inc | 2 ++ usr.sbin/bhyve/{ => amd64}/e820.c | 24 +++++++++++++++++++++++- usr.sbin/bhyve/{ => amd64}/e820.h | 2 +- usr.sbin/bhyve/{ => amd64}/mptbl.c | 0 usr.sbin/bhyve/{ => amd64}/mptbl.h | 0 usr.sbin/bhyve/bhyverun.c | 30 ++++++++++++++---------------- usr.sbin/bhyve/pci_gvt-d.c | 2 +- usr.sbin/bhyve/snapshot.c | 1 - 9 files changed, 41 insertions(+), 22 deletions(-) diff --git a/usr.sbin/bhyve/Makefile b/usr.sbin/bhyve/Makefile index 86039a8c45da..499c0d1bb89d 100644 --- a/usr.sbin/bhyve/Makefile +++ b/usr.sbin/bhyve/Makefile @@ -28,7 +28,6 @@ SRCS= \ crc16.c \ ctl_scsi_all.c \ ctl_util.c \ - e820.c \ gdb.c \ hda_codec.c \ inout.c \ @@ -37,7 +36,6 @@ SRCS= \ kernemu_dev.c \ mem.c \ mevent.c \ - mptbl.c \ net_backends.c \ net_utils.c \ pci_ahci.c \ diff --git a/usr.sbin/bhyve/amd64/Makefile.inc b/usr.sbin/bhyve/amd64/Makefile.inc index c52219cb8dd1..e0cb84e32b85 100644 --- a/usr.sbin/bhyve/amd64/Makefile.inc +++ b/usr.sbin/bhyve/amd64/Makefile.inc @@ -1,6 +1,8 @@ SRCS+= \ atkbdc.c \ + e820.c \ fwctl.c \ + mptbl.c \ post.c \ ps2kbd.c \ ps2mouse.c \ diff --git a/usr.sbin/bhyve/e820.c b/usr.sbin/bhyve/amd64/e820.c similarity index 95% rename from usr.sbin/bhyve/e820.c rename to usr.sbin/bhyve/amd64/e820.c index 99a66645f70f..545878aad39f 100644 --- a/usr.sbin/bhyve/e820.c +++ b/usr.sbin/bhyve/amd64/e820.c @@ -105,7 +105,7 @@ e820_dump_table(void) } } -struct qemu_fwcfg_item * +static struct qemu_fwcfg_item * e820_get_fwcfg_item(void) { struct qemu_fwcfg_item *fwcfg_item; @@ -466,3 +466,25 @@ e820_init(struct vmctx *const ctx) return (0); } + +int +e820_finalize(void) +{ + struct qemu_fwcfg_item *e820_fwcfg_item; + int error; + + e820_fwcfg_item = e820_get_fwcfg_item(); + if (e820_fwcfg_item == NULL) { + warnx("invalid e820 table"); + return (ENOMEM); + } + error = qemu_fwcfg_add_file("etc/e820", + e820_fwcfg_item->size, e820_fwcfg_item->data); + if (error != 0) { + warnx("could not add qemu fwcfg etc/e820"); + return (error); + } + free(e820_fwcfg_item); + + return (0); +} diff --git a/usr.sbin/bhyve/e820.h b/usr.sbin/bhyve/amd64/e820.h similarity index 95% rename from usr.sbin/bhyve/e820.h rename to usr.sbin/bhyve/amd64/e820.h index 8703a55115cd..ae68fe9040a9 100644 --- a/usr.sbin/bhyve/e820.h +++ b/usr.sbin/bhyve/amd64/e820.h @@ -41,5 +41,5 @@ uint64_t e820_alloc(const uint64_t address, const uint64_t length, const uint64_t alignment, const enum e820_memory_type type, const enum e820_allocation_strategy strategy); void e820_dump_table(void); -struct qemu_fwcfg_item *e820_get_fwcfg_item(void); int e820_init(struct vmctx *const ctx); +int e820_finalize(void); diff --git a/usr.sbin/bhyve/mptbl.c b/usr.sbin/bhyve/amd64/mptbl.c similarity index 100% rename from usr.sbin/bhyve/mptbl.c rename to usr.sbin/bhyve/amd64/mptbl.c diff --git a/usr.sbin/bhyve/mptbl.h b/usr.sbin/bhyve/amd64/mptbl.h similarity index 100% rename from usr.sbin/bhyve/mptbl.h rename to usr.sbin/bhyve/amd64/mptbl.h diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c index 6bebfddc3985..a61ebcda0003 100644 --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -89,8 +89,8 @@ #include "config.h" #include "inout.h" #include "debug.h" -#include "e820.h" #ifdef __amd64__ +#include "amd64/e820.h" #include "amd64/fwctl.h" #endif #include "gdb.h" @@ -98,7 +98,9 @@ #include "kernemu_dev.h" #include "mem.h" #include "mevent.h" -#include "mptbl.h" +#ifdef __amd64__ +#include "amd64/mptbl.h" +#endif #include "pci_emul.h" #include "pci_irq.h" #include "pci_lpc.h" @@ -1221,7 +1223,6 @@ main(int argc, char *argv[]) int max_vcpus, memflags; struct vcpu *bsp; struct vmctx *ctx; - struct qemu_fwcfg_item *e820_fwcfg_item; size_t memsize; const char *optstr, *value, *vmname; #ifdef BHYVE_SNAPSHOT @@ -1345,9 +1346,11 @@ main(int argc, char *argv[]) case 'x': set_config_bool("x86.x2apic", true); break; +#ifdef __amd64__ case 'Y': set_config_bool("x86.mptable", false); break; +#endif case 'h': usage(0); default: @@ -1472,10 +1475,12 @@ main(int argc, char *argv[]) exit(4); } +#ifdef __amd64__ if (e820_init(ctx) != 0) { fprintf(stderr, "Unable to setup E820"); exit(4); } +#endif /* * Exit if a device emulation finds an error in its initialization @@ -1548,9 +1553,7 @@ main(int argc, char *argv[]) } #endif - /* - * build the guest tables, MP etc. - */ +#ifdef __amd64__ if (get_config_bool_default("x86.mptable", true)) { error = mptable_build(ctx, guest_ncpus); if (error) { @@ -1558,6 +1561,7 @@ main(int argc, char *argv[]) exit(4); } } +#endif error = smbios_build(ctx); if (error != 0) @@ -1568,17 +1572,11 @@ main(int argc, char *argv[]) assert(error == 0); } - e820_fwcfg_item = e820_get_fwcfg_item(); - if (e820_fwcfg_item == NULL) { - fprintf(stderr, "invalid e820 table"); - exit(4); - } - if (qemu_fwcfg_add_file("etc/e820", e820_fwcfg_item->size, - e820_fwcfg_item->data) != 0) { - fprintf(stderr, "could not add qemu fwcfg etc/e820"); +#ifdef __amd64__ + error = e820_finalize(); + if (error != 0) exit(4); - } - free(e820_fwcfg_item); +#endif #ifdef __amd64__ if (lpc_bootrom() && strcmp(lpc_fwcfg(), "bhyve") == 0) { diff --git a/usr.sbin/bhyve/pci_gvt-d.c b/usr.sbin/bhyve/pci_gvt-d.c index 78fa9878358e..f64cc5984352 100644 --- a/usr.sbin/bhyve/pci_gvt-d.c +++ b/usr.sbin/bhyve/pci_gvt-d.c @@ -17,7 +17,7 @@ #include #include -#include "e820.h" +#include "amd64/e820.h" #include "pci_gvt-d-opregion.h" #include "pci_passthru.h" diff --git a/usr.sbin/bhyve/snapshot.c b/usr.sbin/bhyve/snapshot.c index 593930c7f8a3..2daef0ef74f0 100644 --- a/usr.sbin/bhyve/snapshot.c +++ b/usr.sbin/bhyve/snapshot.c @@ -84,7 +84,6 @@ #include "ioapic.h" #include "mem.h" #include "mevent.h" -#include "mptbl.h" #include "pci_emul.h" #include "pci_irq.h" #include "pci_lpc.h"