thebeanogamer / rpms / qemu-kvm

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