From nobody Mon Nov 21 08:31:36 2022 X-Original-To: dev-commits-src-all@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 4NG0wm5tjpz4j40v; Mon, 21 Nov 2022 08:31:36 +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 4NG0wm5GZLz3LgY; Mon, 21 Nov 2022 08:31:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669019496; 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=/sbp2T4rECulsK2JBbIwzAcFdLyh06r859y6gWhKJXk=; b=U8ozjyG/XrrpK10uypZJ0/mXCjhBjTxSCZo3lB/DejvVpaksH7itpp50lwPM/koXMcF0pM 58sSACju2vgkQb8lkfBOwcP58VvEC1Xgiy/ZFa1e6kZZeSqmVw4VLtN21V1I7rg/PVGVmJ sFatI5Wpn4EDmhFkEFXM/OcTgwYKu6c1u20E7JgILYRV3kibdsYsKv4f+0rfWArldekqg2 78Qwb3KzTa8dr8WO2vX59oG4wscMcQOjwa9JmaPRVrxbYA8W/zWNt0MlQPH6ONW/J2psxL 7LTF/RA6UZ7P0LmQ7GSx4U7++8FgsDfkdzPD741mZvngejj89rt4BoBHBhB6Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669019496; 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=/sbp2T4rECulsK2JBbIwzAcFdLyh06r859y6gWhKJXk=; b=Bk2CLYxcqhGhjPBTmjYirb8Xlfq6r9oHnmggjEpT/XxWHqPzKuJ3ioKSSN7HhkrP5GOZl8 53NrAvazUUVEFzlsIe/P1N1BdwGEpPlnGJ27SGlYO8QZvZDoR3pqTSSVG92sL0ODRExYud brU0iVkTZZv/6CKpKJY3QNzGuCQgGTYh1ZXzF4fvJXxBB5cfBqujoEkS8bTvTc4npUyRSC 0xkX2/CBZmaohQrqvFOb9eWXhJGSPSQe1OgtxZCO6Aow7veCTznqSk+8aUwEQyv6fkUHXc eCZTcrj7q484mf+3Ax93M9CkNJaw6t/emjDDNvrOlWN9x+yJi6ACKpU3sNxO0g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1669019496; a=rsa-sha256; cv=none; b=JXI3H+BFP2RgM54nPkPxLF+eVROqsRxQNTjZB7A7TCHDKMnJEn6wbP9LQvT2dNF41ELAOO XPKesgAfZihbTCkAA24OCNka5R3H3QHR2hiLAIgbVAe/ZEoaoHbqdQSwK+SE7xVhwpmWxG DXh7sCtBNh7VKHLjJ2YinjjNedSE86fxs/CsN0vPrGilxaK8oTwgn03RR6X1F/lW/hlEan 6omOaA4NaVenPGBXqd+X2w7nf3V1KZQc+L3+K+nIpUyK6y3yPoUpYyrIoRk1nXKFL42w6t BNDesmU7CaHZbEcT4FaDo6cGTByrHZjvmQzc0dHii+MvtrXYSYPb8RSqU4ZE+A== 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 4NG0wm4LTvzwkf; Mon, 21 Nov 2022 08:31: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 2AL8Vaf1026423; Mon, 21 Nov 2022 08:31:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AL8VabQ026422; Mon, 21 Nov 2022 08:31:36 GMT (envelope-from git) Date: Mon, 21 Nov 2022 08:31:36 GMT Message-Id: <202211210831.2AL8VabQ026422@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Corvin=20K=C3=B6hne?= Subject: git: 2c2bd1553218 - main - bhyve: build MCFG table by basl List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: corvink X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2c2bd1553218248aab0ed9267d6b7d22cf96c1c5 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=2c2bd1553218248aab0ed9267d6b7d22cf96c1c5 commit 2c2bd1553218248aab0ed9267d6b7d22cf96c1c5 Author: Corvin Köhne AuthorDate: 2022-04-06 09:10:41 +0000 Commit: Corvin Köhne CommitDate: 2022-11-21 08:27:53 +0000 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 --- usr.sbin/bhyve/acpi.c | 56 ++++++++++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/usr.sbin/bhyve/acpi.c b/usr.sbin/bhyve/acpi.c index f5b37e78c1d5..04ee843075c1 100644 --- a/usr.sbin/bhyve/acpi.c +++ b/usr.sbin/bhyve/acpi.c @@ -589,37 +589,6 @@ err_exit: return (errno); } -static int -basl_fwrite_mcfg(FILE *fp) -{ - EFPRINTF(fp, "/*\n"); - EFPRINTF(fp, " * bhyve MCFG template\n"); - EFPRINTF(fp, " */\n"); - EFPRINTF(fp, "[0004]\t\tSignature : \"MCFG\"\n"); - EFPRINTF(fp, "[0004]\t\tTable Length : 00000000\n"); - EFPRINTF(fp, "[0001]\t\tRevision : 01\n"); - EFPRINTF(fp, "[0001]\t\tChecksum : 00\n"); - EFPRINTF(fp, "[0006]\t\tOem ID : \"BHYVE \"\n"); - EFPRINTF(fp, "[0008]\t\tOem Table ID : \"BVMCFG \"\n"); - EFPRINTF(fp, "[0004]\t\tOem Revision : 00000001\n"); - - /* iasl will fill in the compiler ID/revision fields */ - EFPRINTF(fp, "[0004]\t\tAsl Compiler ID : \"xxxx\"\n"); - EFPRINTF(fp, "[0004]\t\tAsl Compiler Revision : 00000000\n"); - EFPRINTF(fp, "[0008]\t\tReserved : 0\n"); - EFPRINTF(fp, "\n"); - - EFPRINTF(fp, "[0008]\t\tBase Address : %016lX\n", pci_ecfg_base()); - EFPRINTF(fp, "[0002]\t\tSegment Group Number : 0000\n"); - EFPRINTF(fp, "[0001]\t\tStart Bus Number : 00\n"); - EFPRINTF(fp, "[0001]\t\tEnd Bus Number : FF\n"); - EFPRINTF(fp, "[0004]\t\tReserved : 0\n"); - EFFLUSH(fp); - return (0); -err_exit: - return (errno); -} - /* * Helper routines for writing to the DSDT from other modules. */ @@ -950,6 +919,29 @@ build_facs(struct vmctx *const ctx) return (0); } +static int +build_mcfg(struct vmctx *const ctx) +{ + ACPI_TABLE_MCFG mcfg; + ACPI_MCFG_ALLOCATION mcfg_allocation; + struct basl_table *table; + + BASL_EXEC(basl_table_create(&table, ctx, ACPI_SIG_MCFG, + BASL_TABLE_ALIGNMENT, MCFG_OFFSET)); + + memset(&mcfg, 0, sizeof(mcfg)); + BASL_EXEC(basl_table_append_header(table, ACPI_SIG_MCFG, 1, 1)); + BASL_EXEC(basl_table_append_content(table, &mcfg, sizeof(mcfg))); + + memset(&mcfg_allocation, 0, sizeof(mcfg_allocation)); + mcfg_allocation.Address = htole64(pci_ecfg_base()); + mcfg_allocation.EndBusNumber = 0xFF; + BASL_EXEC(basl_table_append_bytes(table, &mcfg_allocation, + sizeof(mcfg_allocation))); + + return (0); +} + int acpi_build(struct vmctx *ctx, int ncpu) { @@ -989,7 +981,7 @@ acpi_build(struct vmctx *ctx, int ncpu) BASL_EXEC(basl_compile(ctx, basl_fwrite_madt, MADT_OFFSET)); BASL_EXEC(basl_compile(ctx, basl_fwrite_fadt, FADT_OFFSET)); BASL_EXEC(basl_compile(ctx, basl_fwrite_hpet, HPET_OFFSET)); - BASL_EXEC(basl_compile(ctx, basl_fwrite_mcfg, MCFG_OFFSET)); + BASL_EXEC(build_mcfg(ctx)); BASL_EXEC(build_facs(ctx)); BASL_EXEC(build_dsdt(ctx));