diff mbox series

acpi: phat: fix the device path for the health data record

Message ID 20230714082913.43050-1-ivan.hu@canonical.com
State Accepted
Headers show
Series acpi: phat: fix the device path for the health data record | expand

Commit Message

Ivan Hu July 14, 2023, 8:29 a.m. UTC
BugLink: https://bugs.launchpad.net/fwts/+bug/2027782

From ACPI spec. the device path should not be the general string, should be
"The UEFI Device Path associated with the record producer. See
the UEFI specification for the EFI_DEVICE_PATH_PROTOCOL
definition."

Firmware Health Data Record (Type 1):
    Type: 0x0001
    Record Length: 0x007d
    Revision: 0x01
    Reserved: 0x0000
    AmHealthy: 0x01
    Device Signature: A30DFF09-56BF-4622-A9E7-399B0A79E7C7
    Device-specific Data Offset: 0x00000074
    Device Path: V
    Vendor Data: 0x01
    Vendor Data: 0x01
    Vendor Data: 0x05
    Vendor Data: 0x00
    Vendor Data: 0x00
    Vendor Data: 0x00
    Vendor Data: 0x00
    Vendor Data: 0x01
    Vendor Data: 0x00

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 src/acpi/phat/phat.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/src/acpi/phat/phat.c b/src/acpi/phat/phat.c
index 02fb17c9..9a72e732 100644
--- a/src/acpi/phat/phat.c
+++ b/src/acpi/phat/phat.c
@@ -23,6 +23,8 @@ 
 #include <inttypes.h>
 #include <stdbool.h>
 
+#include "fwts_uefi.h"
+
 static fwts_acpi_table_info *table;
 acpi_table_init(PHAT, &table)
 
@@ -81,11 +83,13 @@  static void phat_health_test(
 	uint32_t offset,
 	bool *passed)
 {
-	char *device_path;
+	uint16_t *device_path;
+
 	char guid[37];
+	char buffer[2048];
 
 	fwts_guid_buf_to_str(entry->data_signature, guid, sizeof(guid));
-	device_path = (char *)entry + sizeof(fwts_acpi_table_phat_health);
+	device_path = (uint16_t *)((char *)entry + sizeof(fwts_acpi_table_phat_health));
 
 	fwts_log_info_verbatim(fw, " Firmware Health Data Record (Type 1):");
 	print_record_header(fw, &entry->header);
@@ -93,9 +97,11 @@  static void phat_health_test(
 	fwts_log_info_simp_int(fw, "    AmHealthy:                      ", entry->healthy);
 	fwts_log_info_verbatim(fw, "    Device Signature:               %s", guid);
 	fwts_log_info_simp_int(fw, "    Device-specific Data Offset:    ", entry->data_offset);
-	fwts_log_info_verbatim(fw, "    Device Path:                    %s", device_path);
 
-	offset = offset + sizeof(fwts_acpi_table_phat_health) + strlen(device_path);
+	fwts_uefi_str16_to_str(buffer, sizeof(buffer), device_path);
+	fwts_log_info_verbatim(fw, "    Device Path:                    %s", buffer);
+
+	offset = offset + sizeof(fwts_acpi_table_phat_health) + (fwts_uefi_str16len(device_path) + 1) * 2;
 
 	if (entry->data_offset != 0) {
 		uint16_t i;