thebeanogamer / rpms / qemu-kvm

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