From nobody Tue Feb 14 07:29:10 2023 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 4PGCWW1xqmz3rLGT; Tue, 14 Feb 2023 07:29:11 +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 4PGCWW1Wcdz4P2K; Tue, 14 Feb 2023 07:29:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676359751; 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=X76R6DzsUWcTUm5nSr10CPAtMzGmKxBod6vxTHkxC1M=; b=IS0ubexkMazLsqTnOOiVbnL1it1d1rwPCbaElMurRBW52mWf084C2pJBXeLs9g4W89Ac9o jPwFheQTXaB8bXLP+eRmnjWekpx+e6YrGmCz+KAoHpbl4wpy8Ur3ACDNdcXM/LNXTYgHz2 pWo4Ata2FBpKQWPjpB5j0NqstSDq7PuG0xNnocLiqpmmvq3JJvNHSo6zwyNbjh5vhxHTuS 911AQ9sMIMRxX50uFquc1O2Aw1qwzxLbdyTxMyiy/5wb30k9lZSN7p4Bexx6Z99o1ciAv7 ozWuo/qIRDwM/3JqMDcx3sJRDt7j62MDXY5fkR0MWVH1Nq7BpA9edSsMiMh6RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676359751; 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=X76R6DzsUWcTUm5nSr10CPAtMzGmKxBod6vxTHkxC1M=; b=yRYDrVPDPe/VabaTuImCHI7wLBYcB4vqakkuNEgB6utk0reDb9pLLeDp4RGmlefwHMHv1k JFfE6efXAwjtvQi3pODhOvDZEQHaiZnj9evsaQIEEePVeAJZ2BJ7bfB3WDP122LUIHaeRV 6qg2v2g0ZWG6ZvORKbAMDhI3ma1RANsA/Gadw4KiuFaKlwj1FRv30YYZZMQQ3QnVq2n0o+ DtKgTUDTpdU4r64cvYl6PPZ9/8u/IjhRYxYHGRNzHYlvl/bg1ASA9vLUpCsbxmUk2IRiYt bNVxneZKCrrHfME8EdJIjWLrlGpKd7n0N9M4XptRhS/FL+YW6YT7bZJQZCF18A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676359751; a=rsa-sha256; cv=none; b=fPcNCSdM6br7JUKIDYx/fd7BanXO+EKJDReLft07Qm3e4q+N6vlwXG6LGGXMxkRWdapC4y U1tOuLrTWLYJWblVxeACTyGkKZi7WU76x3z0sbP/Al1R2yJT1xudZqxQJYoeqmNg6ZTZ1F bPLX1zhnc9qQC6wkaxCpFdMFwO5QC1VlmpX5DcD+aiw4G5hlfWixTiophRE4kUvE6dkqxM uX6uKTcQbtu7nxEGMQDhjx5tEKxWiJyj7MFSF89z9pI+/6k1iGyYMGp8cHvpsWzXmPTyaR 85kABasMFSzpalkd5LsaAwjTHhCNRtyxISYFtmPx4JwAxyGxJuf7IZeLFkzM5w== 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 4PGCWW0Fv0zqnW; Tue, 14 Feb 2023 07:29:11 +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 31E7TAbK044037; Tue, 14 Feb 2023 07:29:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31E7TAJj044036; Tue, 14 Feb 2023 07:29:10 GMT (envelope-from git) Date: Tue, 14 Feb 2023 07:29:10 GMT Message-Id: <202302140729.31E7TAJj044036@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: fbd045021d9f - main - bhyve: maintain a list of acpi devices 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: corvink X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fbd045021d9ffdae5e5bb20e1d1890fd4b46498e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=fbd045021d9ffdae5e5bb20e1d1890fd4b46498e commit fbd045021d9ffdae5e5bb20e1d1890fd4b46498e Author: Corvin Köhne AuthorDate: 2021-10-07 14:14:31 +0000 Commit: Corvin Köhne CommitDate: 2023-02-14 07:28:31 +0000 bhyve: maintain a list of acpi devices The list is used to generate the dsdt entry for every acpi device. Reviewed by: markj MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D3830 --- usr.sbin/bhyve/acpi.c | 29 +++++++++++++++++++++++++++++ usr.sbin/bhyve/acpi.h | 3 +++ usr.sbin/bhyve/acpi_device.c | 6 ++++++ 3 files changed, 38 insertions(+) diff --git a/usr.sbin/bhyve/acpi.c b/usr.sbin/bhyve/acpi.c index bdb0e97076ad..84a54cc485c5 100644 --- a/usr.sbin/bhyve/acpi.c +++ b/usr.sbin/bhyve/acpi.c @@ -106,6 +106,30 @@ struct basl_fio { #define EFFLUSH(x) \ if (fflush(x) != 0) goto err_exit; +/* + * A list for additional ACPI devices like a TPM. + */ +struct acpi_device_list_entry { + SLIST_ENTRY(acpi_device_list_entry) chain; + const struct acpi_device *dev; +}; +static SLIST_HEAD(acpi_device_list, + acpi_device_list_entry) acpi_devices = SLIST_HEAD_INITIALIZER(acpi_devices); + +int +acpi_tables_add_device(const struct acpi_device *const dev) +{ + struct acpi_device_list_entry *const entry = calloc(1, sizeof(*entry)); + if (entry == NULL) { + return (ENOMEM); + } + + entry->dev = dev; + SLIST_INSERT_HEAD(&acpi_devices, entry, chain); + + return (0); +} + /* * Helper routines for writing to the DSDT from other modules. */ @@ -219,6 +243,11 @@ basl_fwrite_dsdt(FILE *fp) vmgenc_write_dsdt(); + const struct acpi_device_list_entry *entry; + SLIST_FOREACH(entry, &acpi_devices, chain) { + acpi_device_write_dsdt(entry->dev); + } + dsdt_line("}"); if (dsdt_error != 0) diff --git a/usr.sbin/bhyve/acpi.h b/usr.sbin/bhyve/acpi.h index 50e5337f332a..98479913732c 100644 --- a/usr.sbin/bhyve/acpi.h +++ b/usr.sbin/bhyve/acpi.h @@ -31,6 +31,8 @@ #ifndef _ACPI_H_ #define _ACPI_H_ +#include "acpi_device.h" + #define SCI_INT 9 #define SMI_CMD 0xb2 @@ -55,6 +57,7 @@ struct vmctx; int acpi_build(struct vmctx *ctx, int ncpu); void acpi_raise_gpe(struct vmctx *ctx, unsigned bit); +int acpi_tables_add_device(const struct acpi_device *const dev); void dsdt_line(const char *fmt, ...); void dsdt_fixed_ioport(uint16_t iobase, uint16_t length); void dsdt_fixed_irq(uint8_t irq); diff --git a/usr.sbin/bhyve/acpi_device.c b/usr.sbin/bhyve/acpi_device.c index 10259006c619..047d411deec2 100644 --- a/usr.sbin/bhyve/acpi_device.c +++ b/usr.sbin/bhyve/acpi_device.c @@ -68,6 +68,12 @@ acpi_device_create(struct acpi_device **const new_dev, return (ENOMEM); } + const int error = acpi_tables_add_device(dev); + if (error) { + acpi_device_destroy(dev); + return (error); + } + *new_dev = dev; return (0);