|
|
495e37 |
From 636a09dbe361517ac2b8d810166676b5006a6ca2 Mon Sep 17 00:00:00 2001
|
|
|
495e37 |
From: Igor Mammedov <imammedo@redhat.com>
|
|
|
495e37 |
Date: Mon, 27 Dec 2021 14:31:17 -0500
|
|
|
495e37 |
Subject: [PATCH 05/14] acpi: fix QEMU crash when started with SLIC table
|
|
|
495e37 |
MIME-Version: 1.0
|
|
|
495e37 |
Content-Type: text/plain; charset=UTF-8
|
|
|
495e37 |
Content-Transfer-Encoding: 8bit
|
|
|
495e37 |
|
|
|
495e37 |
RH-Author: Igor Mammedov <imammedo@redhat.com>
|
|
|
495e37 |
RH-MergeRequest: 130: acpi: fix QEMU crash when started with SLIC table
|
|
|
495e37 |
RH-Commit: [1/10] 67c1d1d2358d0ba746f260dfc3c1cfc165357fd1
|
|
|
495e37 |
RH-Bugzilla: 2043531
|
|
|
495e37 |
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
495e37 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
495e37 |
RH-Acked-by: MST <None>
|
|
|
495e37 |
|
|
|
495e37 |
if QEMU is started with used provided SLIC table blob,
|
|
|
495e37 |
|
|
|
495e37 |
-acpitable sig=SLIC,oem_id='CRASH ',oem_table_id="ME",oem_rev=00002210,asl_compiler_id="",asl_compiler_rev=00000000,data=/dev/null
|
|
|
495e37 |
it will assert with:
|
|
|
495e37 |
|
|
|
495e37 |
hw/acpi/aml-build.c:61:build_append_padded_str: assertion failed: (len <= maxlen)
|
|
|
495e37 |
|
|
|
495e37 |
and following backtrace:
|
|
|
495e37 |
|
|
|
495e37 |
...
|
|
|
495e37 |
build_append_padded_str (array=0x555556afe320, str=0x555556afdb2e "CRASH ME", maxlen=0x6, pad=0x20) at hw/acpi/aml-build.c:61
|
|
|
495e37 |
acpi_table_begin (desc=0x7fffffffd1b0, array=0x555556afe320) at hw/acpi/aml-build.c:1727
|
|
|
495e37 |
build_fadt (tbl=0x555556afe320, linker=0x555557ca3830, f=0x7fffffffd318, oem_id=0x555556afdb2e "CRASH ME", oem_table_id=0x555556afdb34 "ME") at hw/acpi/aml-build.c:2064
|
|
|
495e37 |
...
|
|
|
495e37 |
|
|
|
495e37 |
which happens due to acpi_table_begin() expecting NULL terminated
|
|
|
495e37 |
oem_id and oem_table_id strings, which is normally the case, but
|
|
|
495e37 |
in case of user provided SLIC table, oem_id points to table's blob
|
|
|
495e37 |
directly and as result oem_id became longer than expected.
|
|
|
495e37 |
|
|
|
495e37 |
Fix issue by handling oem_id consistently and make acpi_get_slic_oem()
|
|
|
495e37 |
return NULL terminated strings.
|
|
|
495e37 |
|
|
|
495e37 |
PS:
|
|
|
495e37 |
After [1] refactoring, oem_id semantics became inconsistent, where
|
|
|
495e37 |
NULL terminated string was coming from machine and old way pointer
|
|
|
495e37 |
into byte array coming from -acpitable option. That used to work
|
|
|
495e37 |
since build_header() wasn't expecting NULL terminated string and
|
|
|
495e37 |
blindly copied the 1st 6 bytes only.
|
|
|
495e37 |
|
|
|
495e37 |
However commit [2] broke that by replacing build_header() with
|
|
|
495e37 |
acpi_table_begin(), which was expecting NULL terminated string
|
|
|
495e37 |
and was checking oem_id size.
|
|
|
495e37 |
|
|
|
495e37 |
1) 602b45820 ("acpi: Permit OEM ID and OEM table ID fields to be changed")
|
|
|
495e37 |
2)
|
|
|
495e37 |
Fixes: 4b56e1e4eb08 ("acpi: build_fadt: use acpi_table_begin()/acpi_table_end() instead of build_header()")
|
|
|
495e37 |
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/786
|
|
|
495e37 |
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
495e37 |
Message-Id: <20211227193120.1084176-2-imammedo@redhat.com>
|
|
|
495e37 |
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
495e37 |
Tested-by: Denis Lisov <dennis.lissov@gmail.com>
|
|
|
495e37 |
Tested-by: Alexander Tsoy <alexander@tsoy.me>
|
|
|
495e37 |
Cc: qemu-stable@nongnu.org
|
|
|
495e37 |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
495e37 |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
495e37 |
(cherry picked from commit 8cdb99af45365727ac17f45239a9b8c1d5155c6d)
|
|
|
495e37 |
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
495e37 |
---
|
|
|
495e37 |
hw/acpi/core.c | 4 ++--
|
|
|
495e37 |
hw/i386/acpi-build.c | 2 ++
|
|
|
495e37 |
2 files changed, 4 insertions(+), 2 deletions(-)
|
|
|
495e37 |
|
|
|
495e37 |
diff --git a/hw/acpi/core.c b/hw/acpi/core.c
|
|
|
495e37 |
index 1e004d0078..3e811bf03c 100644
|
|
|
495e37 |
--- a/hw/acpi/core.c
|
|
|
495e37 |
+++ b/hw/acpi/core.c
|
|
|
495e37 |
@@ -345,8 +345,8 @@ int acpi_get_slic_oem(AcpiSlicOem *oem)
|
|
|
495e37 |
struct acpi_table_header *hdr = (void *)(u - sizeof(hdr->_length));
|
|
|
495e37 |
|
|
|
495e37 |
if (memcmp(hdr->sig, "SLIC", 4) == 0) {
|
|
|
495e37 |
- oem->id = hdr->oem_id;
|
|
|
495e37 |
- oem->table_id = hdr->oem_table_id;
|
|
|
495e37 |
+ oem->id = g_strndup(hdr->oem_id, 6);
|
|
|
495e37 |
+ oem->table_id = g_strndup(hdr->oem_table_id, 8);
|
|
|
495e37 |
return 0;
|
|
|
495e37 |
}
|
|
|
495e37 |
}
|
|
|
495e37 |
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
|
|
|
495e37 |
index 8383b83ee3..0234fe7588 100644
|
|
|
495e37 |
--- a/hw/i386/acpi-build.c
|
|
|
495e37 |
+++ b/hw/i386/acpi-build.c
|
|
|
495e37 |
@@ -2723,6 +2723,8 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine)
|
|
|
495e37 |
|
|
|
495e37 |
/* Cleanup memory that's no longer used. */
|
|
|
495e37 |
g_array_free(table_offsets, true);
|
|
|
495e37 |
+ g_free(slic_oem.id);
|
|
|
495e37 |
+ g_free(slic_oem.table_id);
|
|
|
495e37 |
}
|
|
|
495e37 |
|
|
|
495e37 |
static void acpi_ram_update(MemoryRegion *mr, GArray *data)
|
|
|
495e37 |
--
|
|
|
495e37 |
2.31.1
|
|
|
495e37 |
|