From nobody Tue Nov 15 07:28:05 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 4NBHpF6DPBz4hBft; Tue, 15 Nov 2022 07:28:05 +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 4NBHpF59zlz3jgM; Tue, 15 Nov 2022 07:28:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668497285; 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=cUYql1GruAVf/TB5MdaqgmXaHJ+i8gd0anSYjTpLK/U=; b=M/p+l5TeTPRT65yrY0kCpyZXY9qZMGEJzQFJRcC+wI0WscmZx5txONO3tVPwoj4dmy7TiV hKMnBrDcbVceFZPTomBGdEZBjOdRWyawnYcQpvAAge1TG0pL9VOm3DWOUX6T03NGmWSYDI 3XzqU8eDEObc6LoCiE9V8ptK2HgGdNsaQOzRBBlRmqqy0md/zrPyL/DlHxL+tuTFAAJQAl IO9UGuD87QS6NugkJylkcU0uPe+5OMA+QptmaIpAOK5Y6aYKORaaHBwjk238vn83kfw+cZ n7j27HpG+B9bql5ZDkVvBk80Kv4u1kSS/hPs85FvnKtW3Fd400UvhR4bgwt7Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668497285; 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=cUYql1GruAVf/TB5MdaqgmXaHJ+i8gd0anSYjTpLK/U=; b=V0/EJeHPrTkFHrbVgtDw3wdboy1+Z8svH2Rv8cXrc8vE23QZ06PV4pxbf1vZQ33pYOZFPi 9jfPL5o9uanH1+q469VUVFnUdKy4wuGm/15s8xBMeCOVnBgGbeV+XzJqjffCMdUvqSIymm 9j3wvYPmzj9oqjoTADCcQcyBKPODs4PuuQ2Kx5eYOCTa0r6M+atnEhDJ9ZdVx07vlZk+gW kOt30Y8eOxYxbjx9Xym+LPsW3IINOF3BKY74c0Jdha0q/0iI6A7T79eP+cvJ8+Kw5jODhn mkekCrK94bK7hxlHp7WL812GW+hLMz+MZmCBTiMrPEl2s7396eGDYuhalUZh1A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1668497285; a=rsa-sha256; cv=none; b=vYKqHdrd4s9Qk86TVGOEcCJtnG5NA0u2clomIrU8qGzE8vmPi4D/EohFYBoUIGGMTU+Nyh sFdSA+kJHLa2JIagGmBmODVaEqsjpcVSHf5OjlCzEX8X3pnLm4qNnyqz4QRpgtqSMjp21Y nmrfSo6DJv9e2MN09qTe7HFinn4k7Jq0Y8PkjUwr/615eupmO6r3EKN5/gdU7Jf2r41Rrx dbAvjB9gFmq+TmUXE/JGFw6Jo6gwmWWma/gNC2f/PmxScV4ynr8ZuGskqmyrYmoKnWrpSe IVAAhd/4LbPHUAzfByXoBdypCdFB9KYdVwqxGuM2BLG36Rq2neCGPV020MsloA== 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 4NBHpF36DLz1Cfv; Tue, 15 Nov 2022 07:28:05 +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 2AF7S5QX046692; Tue, 15 Nov 2022 07:28:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AF7S58t046691; Tue, 15 Nov 2022 07:28:05 GMT (envelope-from git) Date: Tue, 15 Nov 2022 07:28:05 GMT Message-Id: <202211150728.2AF7S58t046691@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: 22a2e94f3805 - main - bhyve: use basl to load ACPI tables 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: 22a2e94f3805195bf8195c81f7fda4157ebae372 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=22a2e94f3805195bf8195c81f7fda4157ebae372 commit 22a2e94f3805195bf8195c81f7fda4157ebae372 Author: Corvin Köhne AuthorDate: 2022-11-04 11:30:37 +0000 Commit: Corvin Köhne CommitDate: 2022-11-15 07:27:06 +0000 bhyve: use basl to load ACPI tables Load the blobs compiled by iasl into a basl_table. The basl_table is a temporary buffer which copies the ACPI tables into guest memory for us. This allows us in the future to pass the blobs over the qemu fwcfg interface to the guest. Reviewed by: jhb, markj Approved by: manu (mentor) MFC after: 2 weeks Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D36986 --- usr.sbin/bhyve/acpi.c | 52 +++++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/usr.sbin/bhyve/acpi.c b/usr.sbin/bhyve/acpi.c index 55c8c9cb35fc..e823d2d41357 100644 --- a/usr.sbin/bhyve/acpi.c +++ b/usr.sbin/bhyve/acpi.c @@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -838,18 +839,26 @@ static int basl_load(struct vmctx *ctx, int fd, uint64_t off) { struct stat sb; - void *gaddr; + void *addr; if (fstat(fd, &sb) < 0) return (errno); - gaddr = paddr_guest2host(ctx, basl_acpi_base + off, sb.st_size); - if (gaddr == NULL) + addr = calloc(1, sb.st_size); + if (addr == NULL) return (EFAULT); - if (read(fd, gaddr, sb.st_size) < 0) + if (read(fd, addr, sb.st_size) < 0) return (errno); + struct basl_table *table; + + uint8_t name[ACPI_NAMESEG_SIZE + 1] = { 0 }; + memcpy(name, addr, sizeof(name) - 1 /* last char is '\0' */); + BASL_EXEC( + basl_table_create(&table, ctx, name, BASL_TABLE_ALIGNMENT, off)); + BASL_EXEC(basl_table_append_bytes(table, addr, sb.st_size)); + return (0); } @@ -968,30 +977,25 @@ acpi_build(struct vmctx *ctx, int ncpu) if (getenv("BHYVE_ACPI_KEEPTMPS")) basl_keep_temps = 1; - err = basl_make_templates(); + BASL_EXEC(basl_init()); + + BASL_EXEC(basl_make_templates()); /* * Run through all the ASL files, compiling them and * copying them into guest memory */ - if (err == 0) - err = basl_compile(ctx, basl_fwrite_rsdp, 0); - if (err == 0) - err = basl_compile(ctx, basl_fwrite_rsdt, RSDT_OFFSET); - if (err == 0) - err = basl_compile(ctx, basl_fwrite_xsdt, XSDT_OFFSET); - if (err == 0) - err = basl_compile(ctx, basl_fwrite_madt, MADT_OFFSET); - if (err == 0) - err = basl_compile(ctx, basl_fwrite_fadt, FADT_OFFSET); - if (err == 0) - err = basl_compile(ctx, basl_fwrite_hpet, HPET_OFFSET); - if (err == 0) - err = basl_compile(ctx, basl_fwrite_mcfg, MCFG_OFFSET); - if (err == 0) - err = basl_compile(ctx, basl_fwrite_facs, FACS_OFFSET); - if (err == 0) - err = basl_compile(ctx, basl_fwrite_dsdt, DSDT_OFFSET); + 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(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(basl_compile(ctx, basl_fwrite_mcfg, MCFG_OFFSET)); + BASL_EXEC(basl_compile(ctx, basl_fwrite_facs, FACS_OFFSET)); + BASL_EXEC(basl_compile(ctx, basl_fwrite_dsdt, DSDT_OFFSET)); + + BASL_EXEC(basl_finish()); - return (err); + return (0); }