From nobody Mon Dec 5 07:42:00 2022 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 4NQb950LXBz4jf9f; Mon, 5 Dec 2022 07:42:01 +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 4NQb946vNHz4Ft5; Mon, 5 Dec 2022 07:42:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670226121; 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=Y7X3L+1U+juvICmYiCO44U5Jw4BGFZM5yCxuhcH1np4=; b=MNU4EwD+U93fdhVgSTqI5ndDbviGtEzojq/r3p3wB/eMHXpdSwKGwoSdHM9ZXkJi0zPyWA xAjTYmD3A90hxobXpsVJD7wWfi9jORM0poNf29mXyjCGoNJM5m8tmEZklAFCJXS1B6M/ll BDVKPcMkBXqxWq+h5kGwg0MKNaAUjTr8NE/E8l13DUfzpLPt4EsL55Usbnf172URQrIf8l rz2g4JBBMzPi+ltszUaHLSieKafj6YyoLSoZBatvKca5/uMBSvAqQejsxMWZpTA1S+32Mc yj3EEAfHBA6AuvbWYAOaLjshSxf2URpQ+GGawhvujI6vPdWZArHyUN4AL1pkHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670226121; 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=Y7X3L+1U+juvICmYiCO44U5Jw4BGFZM5yCxuhcH1np4=; b=wMe/mQOxIli3XS2WkMCMOtaKjmskxVmJ7WH+KcP/y4wZykGQdXvdbTiZgE+bpbfRZt8TcX qWsbKVrfSsTKJCNlX4ExBWyUyN7cygMQu8Qt+yYCvlZ5tn4M5D+AFTUN46Rw6gTmx1cN5i xxf5fZL8rKDsS79uFTOC1h1HplN6rMuErSnkVRsIAjXpA2KSPzhDw/ralEUv65GrduS6Jt dDel01gfBkb8/GtovAkukX/tNgqxPJxAMk/NwDbKHZtzFLDs7RuRPTxfH2LXENlxRfHuJM Iu3cSr6RXyFZ810kJQmRq7iFesMVK8V5K0iWq+Q0N92tTIDZk/7dbm2lS/zlwQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1670226121; a=rsa-sha256; cv=none; b=EgAhOi4HqVaqHG/oq1t1NnOQGrMBELbTv5aTsFGzP8iU97y29ow99RXbSVRV0RENkC9cjI KXs6qXbXTLgdrdk3FluJ7RigH+8cuOK4E1UNQsmX91xS8NhEB1Gl1u7IpkNOF88cmPqUZ9 0CSdK4wtKhT2Mn50Ue8A1tBJ1pV26DwUXuGvyEl/KrWMjqJ78/c87b/CKWeN75FbCDPjRJ UAgR3+o8Wd//+bXLcKa2VLKJEORbA/Xaj7sPUbqn6oKUlomObvQ/E4BCkmYMoPbKLBbZHk c4odna12uSTQ74tHxc5nEm29M8KTYIKX1Gecgmby3ez610WrIrEGYmdHSA1QAQ== 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 4NQb94607kzpVJ; Mon, 5 Dec 2022 07:42:00 +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 2B57g0wZ082856; Mon, 5 Dec 2022 07:42:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2B57g0ZI082855; Mon, 5 Dec 2022 07:42:00 GMT (envelope-from git) Date: Mon, 5 Dec 2022 07:42:00 GMT Message-Id: <202212050742.2B57g0ZI082855@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: =?utf-8?Q?Corvin=20K=C3=B6hne?= Subject: git: 9de8b7319a70 - stable/13 - bhyve: build MCFG table by basl 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: corvink X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9de8b7319a705a950da9ef60e9d87c8b6c1355d6 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=9de8b7319a705a950da9ef60e9d87c8b6c1355d6 commit 9de8b7319a705a950da9ef60e9d87c8b6c1355d6 Author: Corvin Köhne AuthorDate: 2022-04-06 09:10:41 +0000 Commit: Corvin Köhne CommitDate: 2022-12-05 07:39:35 +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 (cherry picked from commit 2c2bd1553218248aab0ed9267d6b7d22cf96c1c5) --- 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 c1318b42030c..683fc0ef00e5 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));