From nobody Wed Mar 09 23:57:32 2022 X-Original-To: dev-commits-src-main@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 DB4571A1235E; Wed, 9 Mar 2022 23:57:32 +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 4KDTdm59Qcz4c8p; Wed, 9 Mar 2022 23:57:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646870252; 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=w5xgApXdw81IzqSSbDZmZeIU/Bu145ACJ/DJygKHjk8=; b=CVYcNJCxrYM7qsjHn4WhrKdrOB3F5CifXHDNRxNSlE/CNt2QHUoVHqXpGFc5r5RLHyKiq1 xQ9PKFilCyZ/wU+wfycTWsXj8Zyih1fMHHgR0IDKYg/X4ZzYRfjNW5ijo2Yrsea/Go9p9r QGEXDjxyGTNmXS/m2XMxf19ggJ/serGOhfrjXtKi37lOoysyB2Qmg9cVYGkcSuqzOintI9 3V0yhrjdmxbtW+LHumvVV1Pnkvb0w9pXTFyelIli4UoEDMsrE+VwVTJiQNDZ/ebosmqJeo y+mm7bX9jaf0Gi3Z/nmfTwk4HrGraa7rA/5S7EWR2+tx4MtFHxdm2Bvthm4deg== 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 85C371A72C; Wed, 9 Mar 2022 23:57:32 +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 229NvWVA004742; Wed, 9 Mar 2022 23:57:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 229NvWTF004741; Wed, 9 Mar 2022 23:57:32 GMT (envelope-from git) Date: Wed, 9 Mar 2022 23:57:32 GMT Message-Id: <202203092357.229NvWTF004741@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 340a293f9147 - main - bhyve: Make the MADT dynamically sized. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 340a293f9147a37bb71c80a767e37794ca277a28 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646870252; 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=w5xgApXdw81IzqSSbDZmZeIU/Bu145ACJ/DJygKHjk8=; b=sWcWLxPNxRvZaE5WR7JTA4M4129uRCAP6EJajwInuzlgLuF86IATfL7oiFwSidU9sBvw5b IiTzkwmobnzkfGZeWyGN8JO1qstSTjV4OESzGQ+/tJDE4LU50IoUhhG3o5iLRYUYpSraNS 1ZFjskWhgnTiHLfQRBZD02pcfV20ycsUXDIc6chFwaiOQblL1i7oATleDqshGZxgdzNFYG y6sBckL9XOkdiKaPzgDdftUREhEpf7FVKJMGiGjayCzJrYN7ZLg0p1nb9vWHq++7ZcKsog jarFSwVVIGzW6e6d65VwquhCKeq14xzUp4BjbVxK2iRLYQ/8QZq5s5GjE7k3uw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646870252; a=rsa-sha256; cv=none; b=Q8J/Sn0r+xxFME5ihb9oHugbSTn8WSpgexCZM6rz7ZfiR1k4/LL5JaLWjfS7aaQFTyBEvi 1wQiuRfDljtl26Ks097uwSBJElxHj13Ys8DRSME+U0k1cyt+rCe/QGEEJqOpzhtBcl8Gj4 Bw+qERF4JZCwAF/FmmVJuIJ4YraWmLyYU5iRGr6FrtAHQDaUGNhrni9Uc14C69BKSGrAUz YljPyxaq/U2fvod2SV2QtdnOgV9DZHTC5O5MtlpI2z5IFmfteLZVbcmmvVUy2O+9V04you xqtnm4j8zPKgOnDvxBdzQ2QOaU8p66oqMQ2zZBAgIsczeNJwQYANbGOuwh18FQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=340a293f9147a37bb71c80a767e37794ca277a28 commit 340a293f9147a37bb71c80a767e37794ca277a28 Author: John Baldwin AuthorDate: 2022-03-09 23:38:58 +0000 Commit: John Baldwin CommitDate: 2022-03-09 23:38:58 +0000 bhyve: Make the MADT dynamically sized. Use basl_ncpu instead of VM_MAXCPU in MADT_SIZE. Since several of the offsets are no longer compile time constants, unroll the loop generating ACPI tables. Reviewed by: grehan Differential Revision: https://reviews.freebsd.org/D34490 --- usr.sbin/bhyve/acpi.c | 46 ++++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/usr.sbin/bhyve/acpi.c b/usr.sbin/bhyve/acpi.c index 95c65ecc15d2..35dbf4704aab 100644 --- a/usr.sbin/bhyve/acpi.c +++ b/usr.sbin/bhyve/acpi.c @@ -89,10 +89,10 @@ __FBSDID("$FreeBSD$"); * 44 Fixed Header * 8 * maxcpu Processor Local APIC entries * 12 I/O APIC entry - * 2 * 10 Interrupt Source Override entires + * 2 * 10 Interrupt Source Override entries * 6 Local APIC NMI entry */ -#define MADT_SIZE (44 + VM_MAXCPU*8 + 12 + 2*10 + 6) +#define MADT_SIZE roundup2((44 + basl_ncpu*8 + 12 + 2*10 + 6), 0x100) #define FADT_OFFSET (MADT_OFFSET + MADT_SIZE) #define FADT_SIZE 0x140 #define HPET_OFFSET (FADT_OFFSET + FADT_SIZE) @@ -943,28 +943,10 @@ basl_make_templates(void) return (err); } -static struct { - int (*wsect)(FILE *fp); - uint64_t offset; -} basl_ftables[] = -{ - { basl_fwrite_rsdp, 0}, - { basl_fwrite_rsdt, RSDT_OFFSET }, - { basl_fwrite_xsdt, XSDT_OFFSET }, - { basl_fwrite_madt, MADT_OFFSET }, - { basl_fwrite_fadt, FADT_OFFSET }, - { basl_fwrite_hpet, HPET_OFFSET }, - { basl_fwrite_mcfg, MCFG_OFFSET }, - { basl_fwrite_facs, FACS_OFFSET }, - { basl_fwrite_dsdt, DSDT_OFFSET }, - { NULL } -}; - int acpi_build(struct vmctx *ctx, int ncpu) { int err; - int i; basl_ncpu = ncpu; @@ -986,18 +968,30 @@ acpi_build(struct vmctx *ctx, int ncpu) if (getenv("BHYVE_ACPI_KEEPTMPS")) basl_keep_temps = 1; - i = 0; err = basl_make_templates(); /* * Run through all the ASL files, compiling them and * copying them into guest memory */ - while (!err && basl_ftables[i].wsect != NULL) { - err = basl_compile(ctx, basl_ftables[i].wsect, - basl_ftables[i].offset); - i++; - } + 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); return (err); }