cryptospore / rpms / qemu-kvm

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