34b321
From b36e60614f9c4a6eb3f417422c3cb99402b82963 Mon Sep 17 00:00:00 2001
34b321
From: Laszlo Ersek <lersek@redhat.com>
34b321
Date: Wed, 11 May 2016 12:33:44 +0200
34b321
Subject: [PATCH 05/10] acpi: support specified oem table id for build_header
34b321
34b321
RH-Author: Laszlo Ersek <lersek@redhat.com>
34b321
Message-id: <1462970028-10959-4-git-send-email-lersek@redhat.com>
34b321
Patchwork-id: 70380
34b321
O-Subject: [RHEL-7.3 qemu-kvm PATCH v2 3/7] acpi: support specified oem table id for build_header
34b321
Bugzilla: 1330969
34b321
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
34b321
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
34b321
RH-Acked-by: Thomas Huth <thuth@redhat.com>
34b321
34b321
From: Xiao Guangrong <guangrong.xiao@linux.intel.com>
34b321
34b321
Let build_header() support specified OEM table id so that we can build
34b321
multiple SSDT later
34b321
34b321
If the oem table id is not specified (aka, NULL), we use the default id
34b321
instead as the previous behavior
34b321
34b321
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
34b321
Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
34b321
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
34b321
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
34b321
(cherry picked from commit 8870ca0e94f2524644812dd759863c0851ffb870)
34b321
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
34b321
34b321
Conflicts:
34b321
	hw/acpi/aml-build.c
34b321
	hw/arm/virt-acpi-build.c
34b321
	hw/i386/acpi-build.c
34b321
	include/hw/acpi/aml-build.h
34b321
34b321
RHEL-7 backport note: this is actually a manual reimplementation of the
34b321
upstream patch, which is mostly mechanic. A clean cherry-pick would depend
34b321
on a lot of reorganizatorial upstream patches (e.g., 658c27181bf3
34b321
("hw/i386/acpi-build: move generic acpi building helpers into dedictated
34b321
file")), and many new features that overlap with ACPI generation (e.g.,
34b321
the "virt" machtype of the arm/aarch64 targets).
34b321
34b321
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
34b321
---
34b321
 hw/i386/acpi-build.c | 29 ++++++++++++++++++-----------
34b321
 1 file changed, 18 insertions(+), 11 deletions(-)
34b321
---
34b321
 hw/i386/acpi-build.c | 29 ++++++++++++++++++-----------
34b321
 1 file changed, 18 insertions(+), 11 deletions(-)
34b321
34b321
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
34b321
index be32bc3..a9d9f97 100644
34b321
--- a/hw/i386/acpi-build.c
34b321
+++ b/hw/i386/acpi-build.c
34b321
@@ -243,14 +243,21 @@ static void acpi_get_pci_info(PcPciInfo *info)
34b321
 
34b321
 static void
34b321
 build_header(GArray *linker, GArray *table_data,
34b321
-             AcpiTableHeader *h, const char *sig, int len, uint8_t rev)
34b321
+             AcpiTableHeader *h, const char *sig, int len, uint8_t rev,
34b321
+             const char *oem_table_id)
34b321
 {
34b321
     memcpy(&h->signature, sig, 4);
34b321
     h->length = cpu_to_le32(len);
34b321
     h->revision = rev;
34b321
     memcpy(h->oem_id, ACPI_BUILD_APPNAME6, 6);
34b321
-    memcpy(h->oem_table_id, ACPI_BUILD_APPNAME4, 4);
34b321
-    memcpy(h->oem_table_id + 4, sig, 4);
34b321
+
34b321
+    if (oem_table_id) {
34b321
+        strncpy((char *)h->oem_table_id, oem_table_id, sizeof(h->oem_table_id));
34b321
+    } else {
34b321
+        memcpy(h->oem_table_id, ACPI_BUILD_APPNAME4, 4);
34b321
+        memcpy(h->oem_table_id + 4, sig, 4);
34b321
+    }
34b321
+
34b321
     h->oem_revision = cpu_to_le32(1);
34b321
     memcpy(h->asl_compiler_id, ACPI_BUILD_APPNAME4, 4);
34b321
     h->asl_compiler_revision = cpu_to_le32(1);
34b321
@@ -520,7 +527,7 @@ build_fadt(GArray *table_data, GArray *linker, AcpiPmInfo *pm,
34b321
     fadt_setup(fadt, pm);
34b321
 
34b321
     build_header(linker, table_data,
34b321
-                 (void *)fadt, "FACP", sizeof(*fadt), 1);
34b321
+                 (void *)fadt, "FACP", sizeof(*fadt), 1, NULL);
34b321
 }
34b321
 
34b321
 static void
34b321
@@ -590,7 +597,7 @@ build_madt(GArray *table_data, GArray *linker, AcpiCpuInfo *cpu,
34b321
 
34b321
     build_header(linker, table_data,
34b321
                  (void *)(table_data->data + madt_start), "APIC",
34b321
-                 table_data->len - madt_start, 1);
34b321
+                 table_data->len - madt_start, 1, NULL);
34b321
 }
34b321
 
34b321
 /* Encode a hex value */
34b321
@@ -782,7 +789,7 @@ build_ssdt(GArray *table_data, GArray *linker,
34b321
 
34b321
     build_header(linker, table_data,
34b321
                  (void *)(table_data->data + ssdt_start),
34b321
-                 "SSDT", table_data->len - ssdt_start, 1);
34b321
+                 "SSDT", table_data->len - ssdt_start, 1, NULL);
34b321
 }
34b321
 
34b321
 static void
34b321
@@ -797,7 +804,7 @@ build_hpet(GArray *table_data, GArray *linker)
34b321
     hpet->timer_block_id = cpu_to_le32(0x8086a201);
34b321
     hpet->addr.address = cpu_to_le64(HPET_BASE);
34b321
     build_header(linker, table_data,
34b321
-                 (void *)hpet, "HPET", sizeof(*hpet), 1);
34b321
+                 (void *)hpet, "HPET", sizeof(*hpet), 1, NULL);
34b321
 }
34b321
 
34b321
 static void
34b321
@@ -890,7 +897,7 @@ build_srat(GArray *table_data, GArray *linker,
34b321
     build_header(linker, table_data,
34b321
                  (void *)(table_data->data + srat_start),
34b321
                  "SRAT",
34b321
-                 table_data->len - srat_start, 1);
34b321
+                 table_data->len - srat_start, 1, NULL);
34b321
 }
34b321
 
34b321
 static void
34b321
@@ -919,7 +926,7 @@ build_mcfg_q35(GArray *table_data, GArray *linker, AcpiMcfgInfo *info)
34b321
     } else {
34b321
         sig = "MCFG";
34b321
     }
34b321
-    build_header(linker, table_data, (void *)mcfg, sig, len, 1);
34b321
+    build_header(linker, table_data, (void *)mcfg, sig, len, 1, NULL);
34b321
 }
34b321
 
34b321
 static void
34b321
@@ -934,7 +941,7 @@ build_dsdt(GArray *table_data, GArray *linker, AcpiMiscInfo *misc)
34b321
 
34b321
     memset(dsdt, 0, sizeof *dsdt);
34b321
     build_header(linker, table_data, dsdt, "DSDT",
34b321
-                 misc->dsdt_size, 1);
34b321
+                 misc->dsdt_size, 1, NULL);
34b321
 }
34b321
 
34b321
 /* Build final rsdt table */
34b321
@@ -958,7 +965,7 @@ build_rsdt(GArray *table_data, GArray *linker, GArray *table_offsets)
34b321
                                        sizeof(uint32_t));
34b321
     }
34b321
     build_header(linker, table_data,
34b321
-                 (void *)rsdt, "RSDT", rsdt_len, 1);
34b321
+                 (void *)rsdt, "RSDT", rsdt_len, 1, NULL);
34b321
 }
34b321
 
34b321
 static GArray *
34b321
-- 
34b321
1.8.3.1
34b321