thebeanogamer / rpms / qemu-kvm

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