From nobody Mon Dec 05 07:42:03 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 4NQb9729Q5z4jfCf; Mon, 5 Dec 2022 07:42:03 +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 4NQb971mKNz4G9K; Mon, 5 Dec 2022 07:42:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670226123; 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=ZDNWMYTa2Yt4ddsRrvWQUrPvUq8wmXxLNgG+jgy8STk=; b=Sniy+LFHeCCmbXBTMyBsVkExPB/q5IPmZH0SJ9E5DqXR9ennjGnLVaWJ3nEmKnR3g6C72a Ta8Fy9ru6JJ32F5M49yE2NyW49MSJdxMOXKan/slpkP+p6INoNgwIto72SKUdfo2adjFMM /vHoT+1pIagltjezbQyLvfGTLZ30OP21XK19SyJnOmCqQ/R1VvmNW8/NDYBQETYbGHqIHX foX6+nwb9LG7neWTtec+WaaGBSDr2pBBAlgb67XdVgEjHLVfUOwY/DEbbuim3CzxaKDXjH OHOJbP0s/R4FdBi80z0XmaK94YuEaGaO7bxGp3jMSkvEMujCguvXb9uqvKuIDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670226123; 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=ZDNWMYTa2Yt4ddsRrvWQUrPvUq8wmXxLNgG+jgy8STk=; b=b9Fno6jki6JXON1LnN6tgtXOOn/CdK5C+HuoKC7/6azLXaGzWq+SiFW7eOo/THKjgPCfTv Ayi6y7gN6ud97IMNR49pl9t/4Xo3bo+XoKWPr/i5idz8OP+L5NS58fK2bxwp4YVNqqjULb 1OC3ElIm1cwDY8Jy7Nk7TW/c4FFV3q0G3oyBdnY9ZKJBTsGl0q1hbC7nb26mATryMu2vXM dxJlm06pOO9bNFlPFnU1/gAoiBpXUvXUQ058KN9eV5rHs60xPr/ntyorJmgXtks72eA9av KaUUcHslxf8iTpscihhTlfPqAwHLA+4OZ8aNUty2UNeRXvM3cvL+DR/1tJRaPg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1670226123; a=rsa-sha256; cv=none; b=SXGib2OExgvwC/wetPzS0bglQx4RHIE7xZuBVWshHZsnh550+mbbfebUnLli+tKA1Yeuwe PtaNZEvgniTXUPBWcWEzVQUQ6DY/g5riunCvBy5qkR7noHZ461bphlSXxxjF49PnxoBHas EDnY8PE0HTFDnkiHEPmzl5lc3FQiUaLv7uXyCSckKhsLmKgEBYDFDR3BJSxcKMNVB8XuqS bP2uC58Md8oppCoLWV+pCbZEQ0tm7nfwT7hdpC2G50J1E3eTQAYHVldWdcWkftPlLkN4Gb Z68yzoeextpEc6r5jdZatlquWmXkGwAJTLi8slOVVgiXk0esAgrEjqqFX9KTdg== 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 4NQb970rGnzqNl; Mon, 5 Dec 2022 07:42:03 +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 2B57g310082917; Mon, 5 Dec 2022 07:42:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2B57g3eQ082916; Mon, 5 Dec 2022 07:42:03 GMT (envelope-from git) Date: Mon, 5 Dec 2022 07:42:03 GMT Message-Id: <202212050742.2B57g3eQ082916@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: 34520ce30b3c - stable/13 - bhyve: build HPET 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: 34520ce30b3c4fe4bfbb12fb1f263b2cb23ba020 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=34520ce30b3c4fe4bfbb12fb1f263b2cb23ba020 commit 34520ce30b3c4fe4bfbb12fb1f263b2cb23ba020 Author: Corvin Köhne AuthorDate: 2022-04-06 09:10:41 +0000 Commit: Corvin Köhne CommitDate: 2022-12-05 07:39:37 +0000 bhyve: build HPET table by basl Building the HPET 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/D36996 (cherry picked from commit d61d71229902f4963e269a394b36ce67ba910cab) --- usr.sbin/bhyve/acpi.c | 69 +++++++++++++++++---------------------------------- 1 file changed, 23 insertions(+), 46 deletions(-) diff --git a/usr.sbin/bhyve/acpi.c b/usr.sbin/bhyve/acpi.c index 683fc0ef00e5..82a7e0b90748 100644 --- a/usr.sbin/bhyve/acpi.c +++ b/usr.sbin/bhyve/acpi.c @@ -109,6 +109,8 @@ __FBSDID("$FreeBSD$"); #define BHYVE_ASL_SUFFIX ".aml" #define BHYVE_ASL_COMPILER "/usr/sbin/iasl" +#define BHYVE_ADDRESS_HPET 0xFED00000 + static int basl_keep_temps; static int basl_verbose_iasl; static int basl_ncpu; @@ -544,51 +546,6 @@ err_exit: return (errno); } -static int -basl_fwrite_hpet(FILE *fp) -{ - EFPRINTF(fp, "/*\n"); - EFPRINTF(fp, " * bhyve HPET template\n"); - EFPRINTF(fp, " */\n"); - EFPRINTF(fp, "[0004]\t\tSignature : \"HPET\"\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 : \"BVHPET \"\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"); - - EFPRINTF(fp, "[0004]\t\tHardware Block ID : %08X\n", hpet_capabilities); - EFPRINTF(fp, - "[0012]\t\tTimer Block Register : [Generic Address Structure]\n"); - EFPRINTF(fp, "[0001]\t\tSpace ID : 00 [SystemMemory]\n"); - EFPRINTF(fp, "[0001]\t\tBit Width : 00\n"); - EFPRINTF(fp, "[0001]\t\tBit Offset : 00\n"); - EFPRINTF(fp, - "[0001]\t\tEncoded Access Width : 00 [Undefined/Legacy]\n"); - EFPRINTF(fp, "[0008]\t\tAddress : 00000000FED00000\n"); - EFPRINTF(fp, "\n"); - - EFPRINTF(fp, "[0001]\t\tSequence Number : 00\n"); - EFPRINTF(fp, "[0002]\t\tMinimum Clock Ticks : 0000\n"); - EFPRINTF(fp, "[0004]\t\tFlags (decoded below) : 00000001\n"); - EFPRINTF(fp, "\t\t\t4K Page Protect : 1\n"); - EFPRINTF(fp, "\t\t\t64K Page Protect : 0\n"); - EFPRINTF(fp, "\n"); - - EFFLUSH(fp); - - return (0); - -err_exit: - return (errno); -} - /* * Helper routines for writing to the DSDT from other modules. */ @@ -919,6 +876,26 @@ build_facs(struct vmctx *const ctx) return (0); } +static int +build_hpet(struct vmctx *const ctx) +{ + ACPI_TABLE_HPET hpet; + struct basl_table *table; + + BASL_EXEC(basl_table_create(&table, ctx, ACPI_SIG_HPET, + BASL_TABLE_ALIGNMENT, HPET_OFFSET)); + + memset(&hpet, 0, sizeof(hpet)); + BASL_EXEC(basl_table_append_header(table, ACPI_SIG_HPET, 1, 1)); + hpet.Id = htole32(hpet_capabilities); + basl_fill_gas(&hpet.Address, ACPI_ADR_SPACE_SYSTEM_MEMORY, 0, 0, + ACPI_GAS_ACCESS_WIDTH_LEGACY, BHYVE_ADDRESS_HPET); + hpet.Flags = ACPI_HPET_PAGE_PROTECT4; + BASL_EXEC(basl_table_append_content(table, &hpet, sizeof(hpet))); + + return (0); +} + static int build_mcfg(struct vmctx *const ctx) { @@ -980,7 +957,7 @@ acpi_build(struct vmctx *ctx, int ncpu) BASL_EXEC(basl_compile(ctx, basl_fwrite_xsdt, XSDT_OFFSET)); 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(build_hpet(ctx)); BASL_EXEC(build_mcfg(ctx)); BASL_EXEC(build_facs(ctx)); BASL_EXEC(build_dsdt(ctx));