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