From nobody Wed Apr 12 07:04:16 2023 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 4PxDGS49ssz45QHP; Wed, 12 Apr 2023 07:04:16 +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 4PxDGS3JQSz3nJB; Wed, 12 Apr 2023 07:04:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681283056; 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=HrImAVhzR3Ezk5H1IihiiKLhTgY33od5G15jsKH8ZXw=; b=R+nDqljHmF/LExEkbgKjt8Nuh36ruh/d564hOX+vu4/y7CcAWVR9tTm4DnxTFGBdQq/obS vAlz7gvQoQAOGUpLX1pH6CzhZEOU7vSP7Fbn4eq5fuEXVzXd5XjzL7nvBcnv+i5LWZTFF2 yKsUqSjLNVIrJLVev8LSfizgfkrY86mM8x8apMhxGA/qB6V6b+iMvJiQef2XJeaogpiHRX BjuT1XoNLv2TAvkIq2pbxkth0eQBG6JMK53l99A3B7aTmovK6ces1ktCU8cg+JkU+EObGg HcQfqTsxgMxnmzpJ0E8pmNPgxrjF8AvLZueTPBTa6VdfveDhH674ewE4ZQPGSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681283056; 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=HrImAVhzR3Ezk5H1IihiiKLhTgY33od5G15jsKH8ZXw=; b=dV5pUMASJa/kDk3Vj2FFPXrkIIrn2iw5p2enLAEmkV7LFAxEqXGqISCLsT9xN8PTBopWBE 6xqoli+IdKxY1lC7bDZHhC9dfm9GdYP8vutE8rTCrykIzA9TchV91/ONTdGA1wPLmvvSvd 06nZdKdLDgxmDsoba/V6VB26u0xWd1KFPVg5Ghqx+01cdk4ij4+y2CX3IUFhYINS4gPVmr wU0cNVfT5eglX0Anh8mu6aob4NR4b77s3E5PDOJl8x+D/OJffv3T8hVkEKlH4rvO1r6tPM ql6a8TZUkcLRAbp6e/Asu6r4j2M2WRad51mWqcnxERVoAgxNfffjId5XqEl5hQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1681283056; a=rsa-sha256; cv=none; b=c1wscM5M79LizIvKZ9zhyvSBaXZh5j18QdXydXkH0ioCpqbMe7BQWaIXAkQfuED39oEePj 03zHX9KkSA5GpsCcAo/dU1feCHQtmr41e3v5L9O2lgj3SH3TfZ+t2yQW0Yt28XVySk6erj siVitbI6MV+lV3itU5UP29tNyNrmvXKqU/NmW04VxfjhXBfD5Q7xZaWBNqPzjO7PYobyq1 rFfGcXmnC/5xUQ+b34YXU+Au4XEXdv05oImnlhXCZSSTvFyQZx18zrleiP+XVxL/ZCND+V j4+Xj8kVwia2XpCfGAPzl6+ltOtgerzFSN/9BO4H+JGfltRktx4fkbOhsG1rbw== 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 4PxDGS24cdzqWc; Wed, 12 Apr 2023 07:04:16 +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 33C74GPF062554; Wed, 12 Apr 2023 07:04:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33C74GqA062553; Wed, 12 Apr 2023 07:04:16 GMT (envelope-from git) Date: Wed, 12 Apr 2023 07:04:16 GMT Message-Id: <202304120704.33C74GqA062553@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: 0926566f6f9c - main - bhyve: allow building device specific 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: 0926566f6f9cc1dba0d7b5d7e0b45484dd901b20 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=0926566f6f9cc1dba0d7b5d7e0b45484dd901b20 commit 0926566f6f9cc1dba0d7b5d7e0b45484dd901b20 Author: Corvin Köhne AuthorDate: 2022-07-22 08:09:01 +0000 Commit: Corvin Köhne CommitDate: 2023-04-12 06:27:04 +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 --- 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 d53785c4bfba..614aa8b476b1 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);