From nobody Fri Apr 28 10:40:18 2023 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 4Q78JL563Tz48Jn3; Fri, 28 Apr 2023 10:40:18 +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 4Q78JL4GwJz3Ggd; Fri, 28 Apr 2023 10:40:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682678418; 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=1+no0fGEZvhJNqjItTbtMCP5o5BQpQn8wMBlCWeACfA=; b=lXnMQNeh9Vpxf49ZcAjq2aoHzD6FNC1/x3+wghPVkjElNMCHwEb35nkska98StgvLNzxm4 +WIvpYp/eqka4dsqKz6o+AZrbzI58k6694JOh/5HenW4XF9D6g2p4pdJ8G7RKNUarIMfbE jgSfFRBpryNIuZUoClHKlROAEulXHle/T3npTAok+mhvsQnt5jVZ72oaEjjbxbrQi4iZFB QJ/J71BhenSj1RslNeP+b/3WSttvl+nnjPls/PnjdgqGNRiz6b3ighvEuc+G45AZ+NMQ+J 4ZSLyRDJrXVv+GS8+rQ5ugqLBymWDdLtbtAKhXT8gA1F5J9Eel2OJIn5Gma2mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682678418; 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=1+no0fGEZvhJNqjItTbtMCP5o5BQpQn8wMBlCWeACfA=; b=fZx4LpDxvA8NlwezdqMPmAfAQISf/laNr5XL1xm80CeXy7P+l59rjWbJ7i7NiL6kBzM+QC YnVBhBn6BiJUzdqE4ztfvxSt20Q0xzNmOTGaSWYmPQH/wZs68upD+89/961Y2XeAx+Mhma bo8vmWcfOmR4/HQRLz0FTBlS4BqLnqXOXWDMu/ioqkrzJkDjkQ5EXAXWe5fID0aAUWFmyy l4mpTgCefA+LlBmgo3PCoo71wwDdK/H8eyvJEmwgiffsigULuzW09VMYN4SXAUtD6vibwj mKnsRMmKsV1PNVhRT5nec9OmMJ723j34QVqzlgFvzt8iQncX4BLh2yQ8TQB7CA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1682678418; a=rsa-sha256; cv=none; b=CrlRmWeK48XlgrpzABSYUuly+ZM7R+XWFOgbwxe6JFT6yObFRd2QhAjyj5KnljRGzPrgVw aDRN6R6lX0XJ6J9EpDLd5/5IiY8DJAZFP4bzC/p9ebDNWma4wPNygD3/srTu4Cj/PDU6M1 0KJ7sO9tqzacLRas2oUguVBN7SA633ImvM1FK2Ad4SMptoq9uH0nJ7CjeWX9wDU4Lh8185 I0eOlMULcjEGYplgMDIyfaOiPHPLNA+25NAIE5Dw2BTHpp1UN3EHfaiVMmwM5FEw6jyk+9 Za8Fh0dJQmZaOlYrzgVq9bzxVvHpFn0MZPSiI6/AcA0IvORUaSvNx9HUz2zP0g== 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 4Q78JL3JVqzwLb; Fri, 28 Apr 2023 10:40:18 +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 33SAeIJh092511; Fri, 28 Apr 2023 10:40:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33SAeI5c092510; Fri, 28 Apr 2023 10:40:18 GMT (envelope-from git) Date: Fri, 28 Apr 2023 10:40:18 GMT Message-Id: <202304281040.33SAeI5c092510@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: 76f744cf2d08 - stable/13 - bhyve: allow building device specific ACPI tables 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: 76f744cf2d088a31ba4f9875f3f67d310ba29605 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=76f744cf2d088a31ba4f9875f3f67d310ba29605 commit 76f744cf2d088a31ba4f9875f3f67d310ba29605 Author: Corvin Köhne AuthorDate: 2022-07-22 08:09:01 +0000 Commit: Corvin Köhne CommitDate: 2023-04-28 07:28:33 +0000 bhyve: allow building device specific ACPI tables Some ACPI devices require a device specific acpi table. E.g. a TPM2 device requires a TPM2 table. Use the acpi_device_emul struct to define such a device specific table. Reviewed by: markj MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D39320 (cherry picked from commit 0926566f6f9cc1dba0d7b5d7e0b45484dd901b20) --- usr.sbin/bhyve/acpi.c | 7 +++++++ usr.sbin/bhyve/acpi_device.c | 13 +++++++++++++ usr.sbin/bhyve/acpi_device.h | 11 +++++++++++ 3 files changed, 31 insertions(+) diff --git a/usr.sbin/bhyve/acpi.c b/usr.sbin/bhyve/acpi.c index 84a54cc485c5..2346df5fd314 100644 --- a/usr.sbin/bhyve/acpi.c +++ b/usr.sbin/bhyve/acpi.c @@ -810,6 +810,13 @@ acpi_build(struct vmctx *ctx, int ncpu) BASL_EXEC(build_mcfg(ctx)); BASL_EXEC(build_facs(ctx)); BASL_EXEC(build_spcr(ctx)); + + /* Build ACPI device-specific tables such as a TPM2 table. */ + const struct acpi_device_list_entry *entry; + SLIST_FOREACH(entry, &acpi_devices, chain) { + BASL_EXEC(acpi_device_build_table(entry->dev)); + } + BASL_EXEC(build_dsdt(ctx)); BASL_EXEC(basl_finish()); diff --git a/usr.sbin/bhyve/acpi_device.c b/usr.sbin/bhyve/acpi_device.c index a1155ecb44b6..b183da3055b1 100644 --- a/usr.sbin/bhyve/acpi_device.c +++ b/usr.sbin/bhyve/acpi_device.c @@ -135,6 +135,19 @@ acpi_device_add_res_fixed_memory32(struct acpi_device *const dev, return (0); } +int +acpi_device_build_table(const struct acpi_device *const dev) +{ + assert(dev != NULL); + assert(dev->emul != NULL); + + if (dev->emul->build_table != NULL) { + return (dev->emul->build_table(dev)); + } + + return (0); +} + static void acpi_device_write_dsdt_crs(const struct acpi_device *const dev) { diff --git a/usr.sbin/bhyve/acpi_device.h b/usr.sbin/bhyve/acpi_device.h index 45e36a8ae771..0306f19f47f0 100644 --- a/usr.sbin/bhyve/acpi_device.h +++ b/usr.sbin/bhyve/acpi_device.h @@ -16,9 +16,19 @@ struct vmctx; struct acpi_device; +/** + * Device specific information and emulation. + * + * @param name Used as device name in the DSDT. + * @param hid Used as _HID in the DSDT. + * @param build_table Called to build a device specific ACPI table like the TPM2 + * table. + */ struct acpi_device_emul { const char *name; const char *hid; + + int (*build_table)(const struct acpi_device *dev); }; /** @@ -39,4 +49,5 @@ int acpi_device_add_res_fixed_ioport(struct acpi_device *dev, UINT16 port, int acpi_device_add_res_fixed_memory32(struct acpi_device *dev, UINT8 write_protected, UINT32 address, UINT32 length); +int acpi_device_build_table(const struct acpi_device *dev); void acpi_device_write_dsdt(const struct acpi_device *dev);