From nobody Mon Dec 05 07:42:08 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 4NQb9D6w2Jz4jfCq; 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 4NQb9D693Tz4GVM; 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=rttOVWzeFL20Ua+6991l5KlAoJsz8EONhj7E8DNr/70=; b=f9YfCvZiBesnlRPkWW95hdds23Mxms7steku6BiWzPgGfHsZJVKSVRurl8/EB3YOYYa1Yd 4Rs2D74Er9gGii0UPZG8i1Yzcb91XTQI0PEWH1y9AyPazi7RVX1Wow1jKHQs6BkvbDDfRD a81PjvMeAB572GaPdlaW5xKcvMPqOExM0xgJOHl3+u+RTm8G97ie8TUNmpbmX0vm/lzcxM 4c3t5hmlMNSplrvYfmixLlAg9VznptrSDdehoqI4USG+te9wse9ERctK+ha6+SLOINkW8D RLMuEf7ZYmzeYtMQHl63449guahTNacPGNBmcjY3SJlnmHeML3HjP+QXPEedWQ== 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=rttOVWzeFL20Ua+6991l5KlAoJsz8EONhj7E8DNr/70=; b=IKa6885Vp8KXoG/VjPyAqkjXdcZ0WqxcjcOWOWiYNza61fU0sm1XqqdTjinmIkNhV99CLM 8SZACNTikWl/zuoiyk7+y9azYf3wwR5Ll18U0FpXnA1UIhrOKO02+bvX7Ct11f+1KMmDkR /bGRblDvI21KNiLWUQC3uUMPFdFWW34o8PPzN71XZKPtdN7lE9BO/6R1BHOVVqlqwdm/7k 9/SAY76SSJ7e2/8EF+GnH6nooNeqZ1NmL13NELai6nyxkLg6e8z/3y9ynEXqCCijynWPvw TWiExxZAhGbvh9aDyLYY2s634wX3ELslnJZdkmpDYmbjPtb5t3BGh5L8WFR/4g== 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=h93Ukq7Yxkw2PDEYQdl6JIG9LZqVM2mW6xELwEC0wUI4cSNVKagTyqLwBqxKvoBn3sCOaR 6S725NcLF9CJ6kkVQgx+0JcLMD5mbblf4urslG1QYrsM5gRJb02poryopxqhogXjJhIrtk X1QuSEfm5WzSMHy4Fk3x0TRnnUznN0TSR6ssaTzkdyhPoe2DRmNXVk9pFVyiypyJyqo96H i8k495/Yu5VY1SL4IONxNdsE7DXUc4ByMrHh9Wf/niV8qeLc/wdAGTSyLSAIN6tgtAEBBk +AC+YUdJsZHGwD9gOmeLb6h0tXJ0+xmfegQ/gbJL/V8wKJN6OISU6PpXrbZ/7Q== 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 4NQb9D57Pgzpsp; Mon, 5 Dec 2022 07:42:08 +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 2B57g8ZO084150; Mon, 5 Dec 2022 07:42:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2B57g86x084149; Mon, 5 Dec 2022 07:42:08 GMT (envelope-from git) Date: Mon, 5 Dec 2022 07:42:08 GMT Message-Id: <202212050742.2B57g86x084149@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: 6c5f461fe9d9 - stable/13 - bhyve: build RSDP 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: 6c5f461fe9d9a499d7aa16d51b49549fb934bcd3 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=6c5f461fe9d9a499d7aa16d51b49549fb934bcd3 commit 6c5f461fe9d9a499d7aa16d51b49549fb934bcd3 Author: Corvin Köhne AuthorDate: 2022-04-06 09:10:43 +0000 Commit: Corvin Köhne CommitDate: 2022-12-05 07:39:43 +0000 bhyve: build RSDP table by basl Building the RSDP 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/D37001 (cherry picked from commit 03e7111fa6061b886dc756802d2e91dcafbfc054) --- usr.sbin/bhyve/acpi.c | 75 ++++++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/usr.sbin/bhyve/acpi.c b/usr.sbin/bhyve/acpi.c index f4b39c66ca84..0f215d3f508a 100644 --- a/usr.sbin/bhyve/acpi.c +++ b/usr.sbin/bhyve/acpi.c @@ -32,11 +32,9 @@ * bhyve ACPI table generator. * * Create the minimal set of ACPI tables required to boot FreeBSD (and - * hopefully other o/s's) by writing out ASL template files for each of - * the tables and the compiling them to AML with the Intel iasl compiler. - * The AML files are then read into guest memory. + * hopefully other o/s's). * - * The tables are placed in the guest's ROM area just below 1MB physical, + * The tables are placed in the guest's ROM area just below 1MB physical, * above the MPTable. * * Layout (No longer correct at FADT and beyond due to properly @@ -117,7 +115,6 @@ __FBSDID("$FreeBSD$"); static int basl_keep_temps; static int basl_verbose_iasl; static int basl_ncpu; -static uint32_t basl_acpi_base = BHYVE_ACPI_BASE; static uint32_t hpet_capabilities; /* @@ -149,32 +146,6 @@ struct basl_fio { #define EFFLUSH(x) \ if (fflush(x) != 0) goto err_exit; -static int -basl_fwrite_rsdp(FILE *fp) -{ - EFPRINTF(fp, "/*\n"); - EFPRINTF(fp, " * bhyve RSDP template\n"); - EFPRINTF(fp, " */\n"); - EFPRINTF(fp, "[0008]\t\tSignature : \"RSD PTR \"\n"); - EFPRINTF(fp, "[0001]\t\tChecksum : 43\n"); - EFPRINTF(fp, "[0006]\t\tOem ID : \"BHYVE \"\n"); - EFPRINTF(fp, "[0001]\t\tRevision : 02\n"); - EFPRINTF(fp, "[0004]\t\tRSDT Address : %08X\n", - basl_acpi_base + RSDT_OFFSET); - EFPRINTF(fp, "[0004]\t\tLength : 00000024\n"); - EFPRINTF(fp, "[0008]\t\tXSDT Address : 00000000%08X\n", - basl_acpi_base + XSDT_OFFSET); - EFPRINTF(fp, "[0001]\t\tExtended Checksum : 00\n"); - EFPRINTF(fp, "[0003]\t\tReserved : 000000\n"); - - EFFLUSH(fp); - - return (0); - -err_exit: - return (errno); -} - /* * Helper routines for writing to the DSDT from other modules. */ @@ -712,6 +683,43 @@ build_mcfg(struct vmctx *const ctx) return (0); } +static int +build_rsdp(struct vmctx *const ctx) +{ + ACPI_TABLE_RSDP rsdp; + struct basl_table *table; + + BASL_EXEC(basl_table_create(&table, ctx, ACPI_RSDP_NAME, + BASL_TABLE_ALIGNMENT, 0)); + + memset(&rsdp, 0, sizeof(rsdp)); + memcpy(rsdp.Signature, ACPI_SIG_RSDP, 8); + rsdp.Checksum = 0; /* patched by basl */ + memcpy(rsdp.OemId, "BHYVE ", ACPI_OEM_ID_SIZE); + rsdp.Revision = 2; + rsdp.RsdtPhysicalAddress = htole32(0); /* patched by basl */ + rsdp.Length = htole32(0); /* patched by basl */ + rsdp.XsdtPhysicalAddress = htole64(0); /* patched by basl */ + rsdp.ExtendedChecksum = 0; /* patched by basl */ + BASL_EXEC(basl_table_append_bytes(table, &rsdp, sizeof(rsdp))); + + BASL_EXEC(basl_table_add_checksum(table, + offsetof(ACPI_TABLE_RSDP, Checksum), 0, 20)); + BASL_EXEC(basl_table_add_pointer(table, ACPI_SIG_RSDT, + offsetof(ACPI_TABLE_RSDP, RsdtPhysicalAddress), + sizeof(rsdp.RsdtPhysicalAddress))); + BASL_EXEC(basl_table_add_length(table, + offsetof(ACPI_TABLE_RSDP, Length), sizeof(rsdp.Length))); + BASL_EXEC(basl_table_add_pointer(table, ACPI_SIG_XSDT, + offsetof(ACPI_TABLE_RSDP, XsdtPhysicalAddress), + sizeof(rsdp.XsdtPhysicalAddress))); + BASL_EXEC(basl_table_add_checksum(table, + offsetof(ACPI_TABLE_RSDP, ExtendedChecksum), 0, + BASL_TABLE_CHECKSUM_LEN_FULL_TABLE)); + + return (0); +} + static int build_rsdt(struct vmctx *const ctx) { @@ -768,14 +776,13 @@ acpi_build(struct vmctx *ctx, int ncpu) BASL_EXEC(basl_make_templates()); /* - * Run through all the ASL files, compiling them and - * copying them into guest memory + * Generate ACPI tables and copy them into guest memory. * * According to UEFI Specification v6.3 chapter 5.1 the FADT should be * the first table pointed to by XSDT. For that reason, build it as the * first table after XSDT. */ - BASL_EXEC(basl_compile(ctx, basl_fwrite_rsdp, 0)); + BASL_EXEC(build_rsdp(ctx)); BASL_EXEC(build_rsdt(ctx)); BASL_EXEC(build_xsdt(ctx)); BASL_EXEC(build_fadt(ctx));