From nobody Mon Nov 21 08:31:42 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 4NG0wt4jSVz4j4DP; Mon, 21 Nov 2022 08:31:42 +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 4NG0wt2pbKz3MPx; Mon, 21 Nov 2022 08:31:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669019502; 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=xPgBXVL9u/BO1Ma5ORjU9vdnF4Qmon0FHzcxBwaeNPI=; b=sUdfqRExjKhanwqkdntqP9dRy4/G4u2s7CVK3U23QV2P0QyYx+yzhQR1VlTFHR26+Eh5gi au7F5kVH0q5rpqKK+SqtmpcoydFDTRAZZ1XE0L64c5fAN/1e/+Wf/slNNvVT4EMlrucl+X 4CzJkly8iHS9DHhJ1L3xe5nRwMM1PA7u773PMeA+jaMY8n7fp2TPCmsPjiByuUtVm+Gsh+ AxQLpTlzjsSOWBwnKerf//03/3fCBX8o36g0EmpKfjgtmqSqyyfpIhddJR7qnKW/3SlBsK Bz4ciox6OM6UlWMRrvdKA1r3Rsyk1dTsEGNfb1QZrxT8KDjwIQRSbNOL9Zz2ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669019502; 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=xPgBXVL9u/BO1Ma5ORjU9vdnF4Qmon0FHzcxBwaeNPI=; b=pTTjkr25I72DnGMLKCNzduD6SkDQ1pR+BAz1OOHtG89Khuw8unAEtBj7tJvKe6bghfdwDd 9oJfB1UGTEaB/7mliV5PwRaUP2pLWzaeTkKsx57HzfOxECnoGoMF1oZDeUj2G5MLgbZwpw 3DWOJNFKoufRLSI2AFnYr4adkkIGtTVTRkctbs7v0MhwLzHcVEHRqCfVS8EOOI31C8vSqw bwlI3fSVwxhqg1EzMbNrIsOD/9PpeApJmHFRrzs7VURsJZuf+4INsXAGh3TrIal04c5Q1T 99mYPTzgFiC/IMQNzQeisn90ggosXx31gwjiq0kqYMuOBH3EDGVm78MIIZv4WQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1669019502; a=rsa-sha256; cv=none; b=Xyw/YMqKH2CRBgR+LybUzP9c7TI6wUVBxglWQD7UH9JxlauS4VvVzZSqF926Lvp4le9GrX iUR0mR2PcH9oB+F8uI6XlK4qntcpxKYBTIMAg1WuQkIFYOWvAwmrlpScwMmPRfkZxzN1zE Xq8jNmULE2K/q0ihWfd28eyXl7y4nZH5zoMHgooojlr6cCvdpIbPLJE4MogCB9q0gPWjC/ 7tRgK4cpypMWQgVDlLqSpiJWkwf7ojNijBicxQXtg5CkMPjES27sACZJ+yYgASGaaG++rC AVNt05tUOr3CCx9hCuHS1tGYUtq2w4X4PqeaJS37Wh5PM+E44/IQPKaY3Myzkw== 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 4NG0wt1vwHzx1j; Mon, 21 Nov 2022 08:31:42 +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 2AL8VgIP026585; Mon, 21 Nov 2022 08:31:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AL8Vg0J026584; Mon, 21 Nov 2022 08:31:42 GMT (envelope-from git) Date: Mon, 21 Nov 2022 08:31:42 GMT Message-Id: <202211210831.2AL8Vg0J026584@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: 4a60470f053d - main - bhyve: build XSDT 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: 4a60470f053dd035df6023457c153d3d86bc7123 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=4a60470f053dd035df6023457c153d3d86bc7123 commit 4a60470f053dd035df6023457c153d3d86bc7123 Author: Corvin Köhne AuthorDate: 2022-04-06 09:10:42 +0000 Commit: Corvin Köhne CommitDate: 2022-11-21 08:27:58 +0000 bhyve: build XSDT table by basl Building the XSDT 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/D36999 --- usr.sbin/bhyve/acpi.c | 65 ++++++++++++++++++++++----------------------------- 1 file changed, 28 insertions(+), 37 deletions(-) diff --git a/usr.sbin/bhyve/acpi.c b/usr.sbin/bhyve/acpi.c index 182ec290675c..8cc3b56a199d 100644 --- a/usr.sbin/bhyve/acpi.c +++ b/usr.sbin/bhyve/acpi.c @@ -134,6 +134,8 @@ static FILE *dsdt_fp; static int dsdt_indent_level; static int dsdt_error; +static struct basl_table *xsdt; + struct basl_fio { int fd; FILE *fp; @@ -208,42 +210,6 @@ err_exit: return (errno); } -static int -basl_fwrite_xsdt(FILE *fp) -{ - EFPRINTF(fp, "/*\n"); - EFPRINTF(fp, " * bhyve XSDT template\n"); - EFPRINTF(fp, " */\n"); - EFPRINTF(fp, "[0004]\t\tSignature : \"XSDT\"\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 : \"BVXSDT \"\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, "\n"); - - /* Add in pointers to the MADT, FADT and HPET */ - EFPRINTF(fp, "[0004]\t\tACPI Table Address 0 : 00000000%08X\n", - basl_acpi_base + MADT_OFFSET); - EFPRINTF(fp, "[0004]\t\tACPI Table Address 1 : 00000000%08X\n", - basl_acpi_base + FADT_OFFSET); - EFPRINTF(fp, "[0004]\t\tACPI Table Address 2 : 00000000%08X\n", - basl_acpi_base + HPET_OFFSET); - EFPRINTF(fp, "[0004]\t\tACPI Table Address 3 : 00000000%08X\n", - basl_acpi_base + MCFG_OFFSET); - - EFFLUSH(fp); - - return (0); - -err_exit: - return (errno); -} - /* * Helper routines for writing to the DSDT from other modules. */ @@ -642,6 +608,9 @@ build_fadt(struct vmctx *const ctx) BASL_EXEC(basl_table_add_pointer(table, ACPI_SIG_DSDT, offsetof(ACPI_TABLE_FADT, XDsdt), sizeof(fadt.XDsdt))); + BASL_EXEC(basl_table_append_pointer(xsdt, ACPI_SIG_FADT, + ACPI_XSDT_ENTRY_SIZE)); + return (0); } @@ -662,6 +631,9 @@ build_hpet(struct vmctx *const ctx) hpet.Flags = ACPI_HPET_PAGE_PROTECT4; BASL_EXEC(basl_table_append_content(table, &hpet, sizeof(hpet))); + BASL_EXEC(basl_table_append_pointer(xsdt, ACPI_SIG_HPET, + ACPI_XSDT_ENTRY_SIZE)); + return (0); } @@ -735,6 +707,9 @@ build_madt(struct vmctx *const ctx) BASL_EXEC(basl_table_append_bytes(table, &madt_lapic_nmi, sizeof(madt_lapic_nmi))); + BASL_EXEC(basl_table_append_pointer(xsdt, ACPI_SIG_MADT, + ACPI_XSDT_ENTRY_SIZE)); + return (0); } @@ -758,6 +733,22 @@ build_mcfg(struct vmctx *const ctx) BASL_EXEC(basl_table_append_bytes(table, &mcfg_allocation, sizeof(mcfg_allocation))); + BASL_EXEC(basl_table_append_pointer(xsdt, ACPI_SIG_MCFG, + ACPI_XSDT_ENTRY_SIZE)); + + return (0); +} + +static int +build_xsdt(struct vmctx *const ctx) +{ + BASL_EXEC(basl_table_create(&xsdt, ctx, ACPI_SIG_XSDT, + BASL_TABLE_ALIGNMENT, XSDT_OFFSET)); + + /* Header */ + BASL_EXEC(basl_table_append_header(xsdt, ACPI_SIG_XSDT, 1, 1)); + /* Pointers (added by other build_XXX funcs) */ + return (0); } @@ -800,7 +791,7 @@ acpi_build(struct vmctx *ctx, int ncpu) */ BASL_EXEC(basl_compile(ctx, basl_fwrite_rsdp, 0)); BASL_EXEC(basl_compile(ctx, basl_fwrite_rsdt, RSDT_OFFSET)); - BASL_EXEC(basl_compile(ctx, basl_fwrite_xsdt, XSDT_OFFSET)); + BASL_EXEC(build_xsdt(ctx)); BASL_EXEC(build_fadt(ctx)); BASL_EXEC(build_madt(ctx)); BASL_EXEC(build_hpet(ctx));