495e37
From 473b05bbdad50dc3877ab6da4ac52b5a4fc7d5e1 Mon Sep 17 00:00:00 2001
495e37
From: Igor Mammedov <imammedo@redhat.com>
495e37
Date: Wed, 12 Jan 2022 08:03:31 -0500
495e37
Subject: [PATCH 11/14] acpi: fix OEM ID/OEM Table ID padding
495e37
495e37
RH-Author: Igor Mammedov <imammedo@redhat.com>
495e37
RH-MergeRequest: 130: acpi: fix QEMU crash when started with SLIC table
495e37
RH-Commit: [7/10] 276af1aa7650e79f146c75ef4ec19f792e7e163c
495e37
RH-Bugzilla: 2043531
495e37
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
495e37
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
495e37
RH-Acked-by: MST <None>
495e37
495e37
Commit [2] broke original '\0' padding of OEM ID and OEM Table ID
495e37
fields in headers of ACPI tables. While it doesn't have impact on
495e37
default values since QEMU uses 6 and 8 characters long values
495e37
respectively, it broke usecase where IDs are provided on QEMU CLI.
495e37
It shouldn't affect guest (but may cause licensing verification
495e37
issues in guest OS).
495e37
One of the broken usecases is user supplied SLIC table with IDs
495e37
shorter than max possible length, where [2] mangles IDs with extra
495e37
spaces in RSDT and FADT tables whereas guest OS expects those to
495e37
mirror the respective values of the used SLIC table.
495e37
495e37
Fix it by replacing whitespace padding with '\0' padding in
495e37
accordance with [1] and expectations of guest OS
495e37
495e37
1) ACPI spec, v2.0b
495e37
       17.2 AML Grammar Definition
495e37
       ...
495e37
       //OEM ID of up to 6 characters. If the OEM ID is
495e37
       //shorter than 6 characters, it can be terminated
495e37
       //with a NULL character.
495e37
495e37
2)
495e37
Fixes: 602b458201 ("acpi: Permit OEM ID and OEM table ID fields to be changed")
495e37
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/707
495e37
Reported-by: Dmitry V. Orekhov <dima.orekhov@gmail.com>
495e37
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
495e37
Cc: qemu-stable@nongnu.org
495e37
Message-Id: <20220112130332.1648664-4-imammedo@redhat.com>
495e37
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
495e37
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
495e37
Reviewed-by: Ani Sinha <ani@anisinha.ca>
495e37
Tested-by: Dmitry V. Orekhov dima.orekhov@gmail.com
495e37
(cherry picked from commit 748c030f360a940fe0c9382c8ca1649096c3a80d)
495e37
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
495e37
---
495e37
 hw/acpi/aml-build.c | 4 ++--
495e37
 1 file changed, 2 insertions(+), 2 deletions(-)
495e37
495e37
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
495e37
index b3b3310df3..65148d5b9d 100644
495e37
--- a/hw/acpi/aml-build.c
495e37
+++ b/hw/acpi/aml-build.c
495e37
@@ -1724,9 +1724,9 @@ void acpi_table_begin(AcpiTable *desc, GArray *array)
495e37
     build_append_int_noprefix(array, 0, 4); /* Length */
495e37
     build_append_int_noprefix(array, desc->rev, 1); /* Revision */
495e37
     build_append_int_noprefix(array, 0, 1); /* Checksum */
495e37
-    build_append_padded_str(array, desc->oem_id, 6, ' '); /* OEMID */
495e37
+    build_append_padded_str(array, desc->oem_id, 6, '\0'); /* OEMID */
495e37
     /* OEM Table ID */
495e37
-    build_append_padded_str(array, desc->oem_table_id, 8, ' ');
495e37
+    build_append_padded_str(array, desc->oem_table_id, 8, '\0');
495e37
     build_append_int_noprefix(array, 1, 4); /* OEM Revision */
495e37
     g_array_append_vals(array, ACPI_BUILD_APPNAME8, 4); /* Creator ID */
495e37
     build_append_int_noprefix(array, 1, 4); /* Creator Revision */
495e37
-- 
495e37
2.31.1
495e37