From nobody Mon Nov 21 08:31:44 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 4NG0ww4zBQz4j43G; Mon, 21 Nov 2022 08:31:44 +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 4NG0ww40NHz3Mm8; Mon, 21 Nov 2022 08:31:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669019504; 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=26nors3t+lg/ApcyOzRKfFAZPOMzPpwWImXJP4t+Eo8=; b=Hy1eyXc2pZuybQNYfVHyhAZh1wlM4TXYbsyeOPpYYo1SX19nqVf1WUelVB0Vn+NoQFskpO FXzK/WloIMz0Ti5t/+cRexOFQIOCIWzbvAoS+v+2ZBdg5oYmj5t0DdP2994tNFCMn6H4Ud 5xXIt29ovCCIEyQJpUtFLqsh374NFalp6YpEcHjLgd+12sJOzX9k8TohYmCCzwvd9+oJsY lGLCNAvl1fIr5dcu7aw3bjfx8papxGbeRmhOVaCsPHq/TFRY22Aq1is4CSV3xtQ+dovS26 VWD38+sGTZkNhq4OVonywpNFc6Shr3O4hgl+2DRRVzr755ZWTs3zyE3NLva5Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669019504; 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=26nors3t+lg/ApcyOzRKfFAZPOMzPpwWImXJP4t+Eo8=; b=GbBiDFN55+rhanwhbDNNkrwAJeb/Bi9M4eqsT85KJKPVND6YchoaEAF8R2WuTnDzmtRxHz HhKS1/5EepxdFExOiyXDR4vgOHf723mEC2oU+H0Eo++1VktnMBY/F6VckCgkKaxgZlAmo4 EgycHC0ENYZPbn1d+vsCMb6xRModKQH7Ldbfx5J/oI8fVGhH+1Q1BFYinFXubuJA07D6WJ 5vqVvPs9PLjcoNUhV8cSutpE8i/l3jpHJWOsQlolB2mgKmNV/NeeNOs+Uh3YGt7KKUzSNb fbucOVcuTSc9/kK0jKehSodO3thFtDKt3z7SxsmkzRlXimwFL6ne9N54BW/7Hw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1669019504; a=rsa-sha256; cv=none; b=mSo9NdS3IIGPOyIHLA0KZ41RZWK960iUqHA4OLSqU/hMSOz7hFt1lLHFMpMDtvqyNkLi+R LpAUCgaddaKL7y/zEjVzQXhsRLmzmEBL+OGv0q8dIYeesY+Q8HMlx1oaTd2x+5MIIy76pi sAM4INndu0yqJs2tHTDP7NPLneXNcQZxkMAJW9Td0Wl82ru9HLyDKjfJ0JsmKsF7xVH6XI ICGbDVarujVshu9qStkgbFnJQxjqV9Xzt7UP6sHfNGEGuf6vNAXH4qYpciK/XSD5gt9og5 qNRvDcqqCriupvVoPotvmF3F8UC46vPeEnnHOay3cn1d/bGUnOpO6KlXymhgFw== 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 4NG0ww30YCzwkm; Mon, 21 Nov 2022 08:31:44 +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 2AL8ViUs026798; Mon, 21 Nov 2022 08:31:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AL8Vi1Z026785; Mon, 21 Nov 2022 08:31:44 GMT (envelope-from git) Date: Mon, 21 Nov 2022 08:31:44 GMT Message-Id: <202211210831.2AL8Vi1Z026785@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: 03e7111fa606 - main - bhyve: build RSDP 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: 03e7111fa6061b886dc756802d2e91dcafbfc054 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=03e7111fa6061b886dc756802d2e91dcafbfc054 commit 03e7111fa6061b886dc756802d2e91dcafbfc054 Author: Corvin Köhne AuthorDate: 2022-04-06 09:10:43 +0000 Commit: Corvin Köhne CommitDate: 2022-11-21 08:28:00 +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 --- 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 13077f12168b..4f48986fd936 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));