Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Apr 2023 10:40:18 GMT
From:      =?utf-8?Q?Corvin=20K=C3=B6hne?= <corvink@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 76f744cf2d08 - stable/13 - bhyve: allow building device specific ACPI tables
Message-ID:  <202304281040.33SAeI5c092510@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by corvink:

URL: https://cgit.FreeBSD.org/src/commit/?id=76f744cf2d088a31ba4f9875f3f67d310ba29605

commit 76f744cf2d088a31ba4f9875f3f67d310ba29605
Author:     Corvin Köhne <corvink@FreeBSD.org>
AuthorDate: 2022-07-22 08:09:01 +0000
Commit:     Corvin Köhne <corvink@FreeBSD.org>
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202304281040.33SAeI5c092510>