git: fbf9519ab923 - stable/13 - bhyve: check for errors when writing device specific DSDT entries

From: Corvin Köhne <corvink_at_FreeBSD.org>
Date: Fri, 28 Apr 2023 10:40:19 UTC
The branch stable/13 has been updated by corvink:

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

commit fbf9519ab923313c25ddb766bd0f5d936a3488b2
Author:     Corvin Köhne <corvink@FreeBSD.org>
AuthorDate: 2023-04-05 06:45:22 +0000
Commit:     Corvin Köhne <corvink@FreeBSD.org>
CommitDate: 2023-04-28 07:28:33 +0000

    bhyve: check for errors when writing device specific DSDT entries
    
    At the moment, this function can't fail. This behaviour will change in
    the future. In preparation to that, convert the return type to int in
    order to be able to check for errors.
    
    Reviewed by:            markj
    MFC after:              1 week
    Sponsored by:           Beckhoff Automation GmbH & Co. KG
    Differential Revision:  https://reviews.freebsd.org/D39422
    
    (cherry picked from commit ab34ea4711b1001c416dc286380e54c118ff0c49)
---
 usr.sbin/bhyve/acpi.c        |  2 +-
 usr.sbin/bhyve/acpi_device.c | 15 +++++++++------
 usr.sbin/bhyve/acpi_device.h |  2 +-
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/usr.sbin/bhyve/acpi.c b/usr.sbin/bhyve/acpi.c
index 2346df5fd314..457575e395d8 100644
--- a/usr.sbin/bhyve/acpi.c
+++ b/usr.sbin/bhyve/acpi.c
@@ -245,7 +245,7 @@ basl_fwrite_dsdt(FILE *fp)
 
 	const struct acpi_device_list_entry *entry;
 	SLIST_FOREACH(entry, &acpi_devices, chain) {
-		acpi_device_write_dsdt(entry->dev);
+		BASL_EXEC(acpi_device_write_dsdt(entry->dev));
 	}
 
 	dsdt_line("}");
diff --git a/usr.sbin/bhyve/acpi_device.c b/usr.sbin/bhyve/acpi_device.c
index b183da3055b1..dffb73ba9023 100644
--- a/usr.sbin/bhyve/acpi_device.c
+++ b/usr.sbin/bhyve/acpi_device.c
@@ -17,6 +17,7 @@
 
 #include "acpi.h"
 #include "acpi_device.h"
+#include "basl.h"
 
 /**
  * List entry to enumerate all resources used by an ACPI device.
@@ -148,7 +149,7 @@ acpi_device_build_table(const struct acpi_device *const dev)
 	return (0);
 }
 
-static void
+static int
 acpi_device_write_dsdt_crs(const struct acpi_device *const dev)
 {
 	const struct acpi_resource_list_entry *res;
@@ -167,14 +168,14 @@ acpi_device_write_dsdt_crs(const struct acpi_device *const dev)
 			break;
 		}
 	}
+
+	return (0);
 }
 
-void
+int
 acpi_device_write_dsdt(const struct acpi_device *const dev)
 {
-	if (dev == NULL) {
-		return;
-	}
+	assert(dev != NULL);
 
 	dsdt_line("");
 	dsdt_line("  Scope (\\_SB)");
@@ -186,9 +187,11 @@ acpi_device_write_dsdt(const struct acpi_device *const dev)
 	dsdt_line("      Name (_CRS, ResourceTemplate ()");
 	dsdt_line("      {");
 	dsdt_indent(4);
-	acpi_device_write_dsdt_crs(dev);
+	BASL_EXEC(acpi_device_write_dsdt_crs(dev));
 	dsdt_unindent(4);
 	dsdt_line("      })");
 	dsdt_line("    }");
 	dsdt_line("  }");
+
+	return (0);
 }
diff --git a/usr.sbin/bhyve/acpi_device.h b/usr.sbin/bhyve/acpi_device.h
index 0306f19f47f0..de72ce1e5370 100644
--- a/usr.sbin/bhyve/acpi_device.h
+++ b/usr.sbin/bhyve/acpi_device.h
@@ -50,4 +50,4 @@ 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);
+int acpi_device_write_dsdt(const struct acpi_device *dev);