From nobody Mon Dec 5 07:42:07 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 4NQb9D0xswz4jf9n; Mon, 5 Dec 2022 07:42:08 +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 4NQb9D0Ksdz4Ggc; Mon, 5 Dec 2022 07:42:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670226128; 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=GTWCjt3R9r1KDW6gXQdNi9xHoTDRehhirBXMfnTjMaY=; b=V1vepep1V2Jr4LvSK+fznszw3OSkq1Ij29xaNGxDUEmZat5+mLfXDxlNuifFP8038SGcg/ OW5+VUDSK1JrRD+ehv3aWVjbdzdekS06lnLSuVY0nGYilS/jBymJZXPGAbvZGe9UpUjj+l vwTQChIq7PuslkqfAug55U8Qt/oBlgn2Wz/gRrpaQd610fgUtfrsFK20JO+THbsgQIPPuf ouDHXs2sNP4T+puLtTEObY2iRJC6FPKegUVw7pSmWVeIEKtYA5jEyn+PZPFzKYgP336jU5 v+aZyAb6cgrb7e919khRdxkuoM5Nup3FlcMItCWrA3exyogYwMmI/TU45ZdDAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670226128; 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=GTWCjt3R9r1KDW6gXQdNi9xHoTDRehhirBXMfnTjMaY=; b=sqt+h1984G6z3JCLgbVlyPB2f/IyLuMCXqy/zEopLQiklK+q+TnC4fiWIGx6oaHYwMKSw8 5LVjXcVPxOEcR4rUdPXPn91I7wsZ/CKmYWYrUCb7vx+yt/BL2Fkn1LnJOiVc3g1cD9rpud em7muxpAWV+1sIpPEp8Gbdvjrie5oLcq1tFkgkn7k27eMs2qItSyHUw+pqlfebzADO6tnB MS0oiQBrWw2m3LsrKUVpigjvN7ys8eyCoo5KIAhoBvtv/MUn3hcnI0xY768urizSLVhg8g PiMGYZoaD4x1guob7ZnStLVKL0FByEXXjX/1PvN1wbG1I08D5HdhJ4Xn6YCSzA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1670226128; a=rsa-sha256; cv=none; b=FKMKQ6hxczAECJtWKEHhz6Qu4p4Es8UNNZesb9ovCxQ/ZBdeT2oiotifF3tldJNT2DoNuC xwPvJiK7xBxtOwC53Wp36KvNrZz5oElirJgKOJ47dCE3SIFr8W8NFTziVUnn+rvkRNsOKh 7CrQAZa+1DH2prkjqm2PVJ6dkT9oklsGhxyMcwfZj5pkzYHx7sMhkcpoVk4v91EkTshepN C1U6zeD1Y2t8nkftL06yZG5JlWF91qCRowk91Awzd3iTAW+Pa88qWESgeKOFU2Pp0MDyqA uPOaqJfyDoyDMtFaY9WQugnuJqyDv5l/ITBsmOfXOdlBYZXbOBn/7NHEanV23w== 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 4NQb9C48BMzq28; Mon, 5 Dec 2022 07:42:07 +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 2B57g7qH084121; Mon, 5 Dec 2022 07:42:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2B57g766084120; Mon, 5 Dec 2022 07:42:07 GMT (envelope-from git) Date: Mon, 5 Dec 2022 07:42:07 GMT Message-Id: <202212050742.2B57g766084120@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: 29d288f36e8f - stable/13 - bhyve: build RSDT 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: 29d288f36e8f90b2682a42faacede067a7786b5f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=29d288f36e8f90b2682a42faacede067a7786b5f commit 29d288f36e8f90b2682a42faacede067a7786b5f Author: Corvin Köhne AuthorDate: 2022-04-06 09:10:43 +0000 Commit: Corvin Köhne CommitDate: 2022-12-05 07:39:42 +0000 bhyve: build RSDT table by basl Building the RSDT 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/D37000 (cherry picked from commit f3dcdf8be4cc1cd6878f6e962a749dca372d5982) --- usr.sbin/bhyve/acpi.c | 60 ++++++++++++++++++++------------------------------- 1 file changed, 23 insertions(+), 37 deletions(-) diff --git a/usr.sbin/bhyve/acpi.c b/usr.sbin/bhyve/acpi.c index b38e167ccf49..f4b39c66ca84 100644 --- a/usr.sbin/bhyve/acpi.c +++ b/usr.sbin/bhyve/acpi.c @@ -134,6 +134,7 @@ static FILE *dsdt_fp; static int dsdt_indent_level; static int dsdt_error; +static struct basl_table *rsdt; static struct basl_table *xsdt; struct basl_fio { @@ -174,42 +175,6 @@ err_exit: return (errno); } -static int -basl_fwrite_rsdt(FILE *fp) -{ - EFPRINTF(fp, "/*\n"); - EFPRINTF(fp, " * bhyve RSDT template\n"); - EFPRINTF(fp, " */\n"); - EFPRINTF(fp, "[0004]\t\tSignature : \"RSDT\"\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 : \"BVRSDT \"\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 : %08X\n", - basl_acpi_base + MADT_OFFSET); - EFPRINTF(fp, "[0004]\t\tACPI Table Address 1 : %08X\n", - basl_acpi_base + FADT_OFFSET); - EFPRINTF(fp, "[0004]\t\tACPI Table Address 2 : %08X\n", - basl_acpi_base + HPET_OFFSET); - EFPRINTF(fp, "[0004]\t\tACPI Table Address 3 : %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. */ @@ -608,6 +573,8 @@ 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(rsdt, ACPI_SIG_FADT, + ACPI_RSDT_ENTRY_SIZE)); BASL_EXEC(basl_table_append_pointer(xsdt, ACPI_SIG_FADT, ACPI_XSDT_ENTRY_SIZE)); @@ -631,6 +598,8 @@ 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(rsdt, ACPI_SIG_HPET, + ACPI_RSDT_ENTRY_SIZE)); BASL_EXEC(basl_table_append_pointer(xsdt, ACPI_SIG_HPET, ACPI_XSDT_ENTRY_SIZE)); @@ -707,6 +676,8 @@ 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(rsdt, ACPI_SIG_MADT, + ACPI_RSDT_ENTRY_SIZE)); BASL_EXEC(basl_table_append_pointer(xsdt, ACPI_SIG_MADT, ACPI_XSDT_ENTRY_SIZE)); @@ -733,12 +704,27 @@ build_mcfg(struct vmctx *const ctx) BASL_EXEC(basl_table_append_bytes(table, &mcfg_allocation, sizeof(mcfg_allocation))); + BASL_EXEC(basl_table_append_pointer(rsdt, ACPI_SIG_MCFG, + ACPI_RSDT_ENTRY_SIZE)); BASL_EXEC(basl_table_append_pointer(xsdt, ACPI_SIG_MCFG, ACPI_XSDT_ENTRY_SIZE)); return (0); } +static int +build_rsdt(struct vmctx *const ctx) +{ + BASL_EXEC(basl_table_create(&rsdt, ctx, ACPI_SIG_RSDT, + BASL_TABLE_ALIGNMENT, RSDT_OFFSET)); + + /* Header */ + BASL_EXEC(basl_table_append_header(rsdt, ACPI_SIG_RSDT, 1, 1)); + /* Pointers (added by other build_XXX funcs) */ + + return (0); +} + static int build_xsdt(struct vmctx *const ctx) { @@ -790,7 +776,7 @@ acpi_build(struct vmctx *ctx, int ncpu) * first table after XSDT. */ BASL_EXEC(basl_compile(ctx, basl_fwrite_rsdp, 0)); - BASL_EXEC(basl_compile(ctx, basl_fwrite_rsdt, RSDT_OFFSET)); + BASL_EXEC(build_rsdt(ctx)); BASL_EXEC(build_xsdt(ctx)); BASL_EXEC(build_fadt(ctx)); BASL_EXEC(build_madt(ctx));