|
|
9ae3a8 |
From 87f01cd69488bf39e80c422b92717029fed0bef6 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Date: Wed, 11 May 2016 12:33:43 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 04/10] acpi: fix endian-ness for table ids
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1462970028-10959-3-git-send-email-lersek@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 70379
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.3 qemu-kvm PATCH v2 2/7] acpi: fix endian-ness for table ids
|
|
|
9ae3a8 |
Bugzilla: 1330969
|
|
|
9ae3a8 |
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: "Michael S. Tsirkin" <mst@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
when using signature for table ID, we forgot to byte-swap it.
|
|
|
9ae3a8 |
signatures are really ASCII strings, let's treat them as such.
|
|
|
9ae3a8 |
While at it, get rid of most of _SIGNATURE macros.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 821e3227863ea8db057190e578efa0f1f57ed9de)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RHEL-7 backport notes: this patch is being backported only to decrease the
|
|
|
9ae3a8 |
number of conflicts in the upcoming patches; we only support x86_64 hosts,
|
|
|
9ae3a8 |
which is unaffected by the endianness issue described in the upstream
|
|
|
9ae3a8 |
commit message.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/i386/acpi-defs.h | 14 --------------
|
|
|
9ae3a8 |
hw/i386/acpi-build.c | 31 ++++++++++++++++---------------
|
|
|
9ae3a8 |
2 files changed, 16 insertions(+), 29 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/i386/acpi-build.c | 31 ++++++++++++++++---------------
|
|
|
9ae3a8 |
hw/i386/acpi-defs.h | 14 --------------
|
|
|
9ae3a8 |
2 files changed, 16 insertions(+), 29 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
|
|
|
9ae3a8 |
index a3a4c3b..be32bc3 100644
|
|
|
9ae3a8 |
--- a/hw/i386/acpi-build.c
|
|
|
9ae3a8 |
+++ b/hw/i386/acpi-build.c
|
|
|
9ae3a8 |
@@ -243,14 +243,14 @@ static void acpi_get_pci_info(PcPciInfo *info)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static void
|
|
|
9ae3a8 |
build_header(GArray *linker, GArray *table_data,
|
|
|
9ae3a8 |
- AcpiTableHeader *h, uint32_t sig, int len, uint8_t rev)
|
|
|
9ae3a8 |
+ AcpiTableHeader *h, const char *sig, int len, uint8_t rev)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- h->signature = cpu_to_le32(sig);
|
|
|
9ae3a8 |
+ memcpy(&h->signature, sig, 4);
|
|
|
9ae3a8 |
h->length = cpu_to_le32(len);
|
|
|
9ae3a8 |
h->revision = rev;
|
|
|
9ae3a8 |
memcpy(h->oem_id, ACPI_BUILD_APPNAME6, 6);
|
|
|
9ae3a8 |
memcpy(h->oem_table_id, ACPI_BUILD_APPNAME4, 4);
|
|
|
9ae3a8 |
- memcpy(h->oem_table_id + 4, (void *)&sig, 4);
|
|
|
9ae3a8 |
+ memcpy(h->oem_table_id + 4, sig, 4);
|
|
|
9ae3a8 |
h->oem_revision = cpu_to_le32(1);
|
|
|
9ae3a8 |
memcpy(h->asl_compiler_id, ACPI_BUILD_APPNAME4, 4);
|
|
|
9ae3a8 |
h->asl_compiler_revision = cpu_to_le32(1);
|
|
|
9ae3a8 |
@@ -463,7 +463,7 @@ static void
|
|
|
9ae3a8 |
build_facs(GArray *table_data, GArray *linker, PcGuestInfo *guest_info)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
AcpiFacsDescriptorRev1 *facs = acpi_data_push(table_data, sizeof *facs);
|
|
|
9ae3a8 |
- facs->signature = cpu_to_le32(ACPI_FACS_SIGNATURE);
|
|
|
9ae3a8 |
+ memcpy(&facs->signature, "FACS", 4);
|
|
|
9ae3a8 |
facs->length = cpu_to_le32(sizeof(*facs));
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -520,7 +520,7 @@ build_fadt(GArray *table_data, GArray *linker, AcpiPmInfo *pm,
|
|
|
9ae3a8 |
fadt_setup(fadt, pm);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
build_header(linker, table_data,
|
|
|
9ae3a8 |
- (void *)fadt, ACPI_FACP_SIGNATURE, sizeof(*fadt), 1);
|
|
|
9ae3a8 |
+ (void *)fadt, "FACP", sizeof(*fadt), 1);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static void
|
|
|
9ae3a8 |
@@ -589,7 +589,7 @@ build_madt(GArray *table_data, GArray *linker, AcpiCpuInfo *cpu,
|
|
|
9ae3a8 |
local_nmi->lint = 1; /* ACPI_LINT1 */
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
build_header(linker, table_data,
|
|
|
9ae3a8 |
- (void *)(table_data->data + madt_start), ACPI_APIC_SIGNATURE,
|
|
|
9ae3a8 |
+ (void *)(table_data->data + madt_start), "APIC",
|
|
|
9ae3a8 |
table_data->len - madt_start, 1);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -782,7 +782,7 @@ build_ssdt(GArray *table_data, GArray *linker,
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
build_header(linker, table_data,
|
|
|
9ae3a8 |
(void *)(table_data->data + ssdt_start),
|
|
|
9ae3a8 |
- ACPI_SSDT_SIGNATURE, table_data->len - ssdt_start, 1);
|
|
|
9ae3a8 |
+ "SSDT", table_data->len - ssdt_start, 1);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static void
|
|
|
9ae3a8 |
@@ -797,7 +797,7 @@ build_hpet(GArray *table_data, GArray *linker)
|
|
|
9ae3a8 |
hpet->timer_block_id = cpu_to_le32(0x8086a201);
|
|
|
9ae3a8 |
hpet->addr.address = cpu_to_le64(HPET_BASE);
|
|
|
9ae3a8 |
build_header(linker, table_data,
|
|
|
9ae3a8 |
- (void *)hpet, ACPI_HPET_SIGNATURE, sizeof(*hpet), 1);
|
|
|
9ae3a8 |
+ (void *)hpet, "HPET", sizeof(*hpet), 1);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static void
|
|
|
9ae3a8 |
@@ -889,7 +889,7 @@ build_srat(GArray *table_data, GArray *linker,
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
build_header(linker, table_data,
|
|
|
9ae3a8 |
(void *)(table_data->data + srat_start),
|
|
|
9ae3a8 |
- ACPI_SRAT_SIGNATURE,
|
|
|
9ae3a8 |
+ "SRAT",
|
|
|
9ae3a8 |
table_data->len - srat_start, 1);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -897,7 +897,7 @@ static void
|
|
|
9ae3a8 |
build_mcfg_q35(GArray *table_data, GArray *linker, AcpiMcfgInfo *info)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
AcpiTableMcfg *mcfg;
|
|
|
9ae3a8 |
- uint32_t sig;
|
|
|
9ae3a8 |
+ const char *sig;
|
|
|
9ae3a8 |
int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
mcfg = acpi_data_push(table_data, len);
|
|
|
9ae3a8 |
@@ -914,9 +914,10 @@ build_mcfg_q35(GArray *table_data, GArray *linker, AcpiMcfgInfo *info)
|
|
|
9ae3a8 |
* ACPI spec requires OSPMs to ignore such tables.
|
|
|
9ae3a8 |
*/
|
|
|
9ae3a8 |
if (info->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
|
|
|
9ae3a8 |
- sig = ACPI_RSRV_SIGNATURE;
|
|
|
9ae3a8 |
+ /* Reserved signature: ignored by OSPM */
|
|
|
9ae3a8 |
+ sig = "QEMU";
|
|
|
9ae3a8 |
} else {
|
|
|
9ae3a8 |
- sig = ACPI_MCFG_SIGNATURE;
|
|
|
9ae3a8 |
+ sig = "MCFG";
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
build_header(linker, table_data, (void *)mcfg, sig, len, 1);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -932,7 +933,7 @@ build_dsdt(GArray *table_data, GArray *linker, AcpiMiscInfo *misc)
|
|
|
9ae3a8 |
memcpy(dsdt, misc->dsdt_code, misc->dsdt_size);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
memset(dsdt, 0, sizeof *dsdt);
|
|
|
9ae3a8 |
- build_header(linker, table_data, dsdt, ACPI_DSDT_SIGNATURE,
|
|
|
9ae3a8 |
+ build_header(linker, table_data, dsdt, "DSDT",
|
|
|
9ae3a8 |
misc->dsdt_size, 1);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -957,7 +958,7 @@ build_rsdt(GArray *table_data, GArray *linker, GArray *table_offsets)
|
|
|
9ae3a8 |
sizeof(uint32_t));
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
build_header(linker, table_data,
|
|
|
9ae3a8 |
- (void *)rsdt, ACPI_RSDT_SIGNATURE, rsdt_len, 1);
|
|
|
9ae3a8 |
+ (void *)rsdt, "RSDT", rsdt_len, 1);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static GArray *
|
|
|
9ae3a8 |
@@ -968,7 +969,7 @@ build_rsdp(GArray *rsdp_table, GArray *linker, unsigned rsdt)
|
|
|
9ae3a8 |
bios_linker_loader_alloc(linker, ACPI_BUILD_RSDP_FILE, 1,
|
|
|
9ae3a8 |
true /* fseg memory */);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- rsdp->signature = cpu_to_le64(ACPI_RSDP_SIGNATURE);
|
|
|
9ae3a8 |
+ memcpy(&rsdp->signature, "RSD PTR ", 8);
|
|
|
9ae3a8 |
memcpy(rsdp->oem_id, ACPI_BUILD_APPNAME6, 6);
|
|
|
9ae3a8 |
rsdp->rsdt_physical_address = cpu_to_le32(rsdt);
|
|
|
9ae3a8 |
/* Address to be filled by Guest linker */
|
|
|
9ae3a8 |
diff --git a/hw/i386/acpi-defs.h b/hw/i386/acpi-defs.h
|
|
|
9ae3a8 |
index 78ca204..e93babb 100644
|
|
|
9ae3a8 |
--- a/hw/i386/acpi-defs.h
|
|
|
9ae3a8 |
+++ b/hw/i386/acpi-defs.h
|
|
|
9ae3a8 |
@@ -52,8 +52,6 @@ struct Acpi20GenericAddress {
|
|
|
9ae3a8 |
} QEMU_PACKED;
|
|
|
9ae3a8 |
typedef struct Acpi20GenericAddress Acpi20GenericAddress;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-#define ACPI_RSDP_SIGNATURE 0x2052545020445352LL // "RSD PTR "
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
struct AcpiRsdpDescriptor { /* Root System Descriptor Pointer */
|
|
|
9ae3a8 |
uint64_t signature; /* ACPI signature, contains "RSD PTR " */
|
|
|
9ae3a8 |
uint8_t checksum; /* To make sum of struct == 0 */
|
|
|
9ae3a8 |
@@ -92,7 +90,6 @@ typedef struct AcpiTableHeader AcpiTableHeader;
|
|
|
9ae3a8 |
/*
|
|
|
9ae3a8 |
* ACPI 1.0 Fixed ACPI Description Table (FADT)
|
|
|
9ae3a8 |
*/
|
|
|
9ae3a8 |
-#define ACPI_FACP_SIGNATURE 0x50434146 // FACP
|
|
|
9ae3a8 |
struct AcpiFadtDescriptorRev1
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
ACPI_TABLE_HEADER_DEF /* ACPI common table header */
|
|
|
9ae3a8 |
@@ -141,7 +138,6 @@ typedef struct AcpiFadtDescriptorRev1 AcpiFadtDescriptorRev1;
|
|
|
9ae3a8 |
/*
|
|
|
9ae3a8 |
* ACPI 1.0 Root System Description Table (RSDT)
|
|
|
9ae3a8 |
*/
|
|
|
9ae3a8 |
-#define ACPI_RSDT_SIGNATURE 0x54445352 // RSDT
|
|
|
9ae3a8 |
struct AcpiRsdtDescriptorRev1
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
ACPI_TABLE_HEADER_DEF /* ACPI common table header */
|
|
|
9ae3a8 |
@@ -153,7 +149,6 @@ typedef struct AcpiRsdtDescriptorRev1 AcpiRsdtDescriptorRev1;
|
|
|
9ae3a8 |
/*
|
|
|
9ae3a8 |
* ACPI 1.0 Firmware ACPI Control Structure (FACS)
|
|
|
9ae3a8 |
*/
|
|
|
9ae3a8 |
-#define ACPI_FACS_SIGNATURE 0x53434146 // FACS
|
|
|
9ae3a8 |
struct AcpiFacsDescriptorRev1
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
uint32_t signature; /* ACPI Signature */
|
|
|
9ae3a8 |
@@ -169,7 +164,6 @@ typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescriptorRev1;
|
|
|
9ae3a8 |
/*
|
|
|
9ae3a8 |
* Differentiated System Description Table (DSDT)
|
|
|
9ae3a8 |
*/
|
|
|
9ae3a8 |
-#define ACPI_DSDT_SIGNATURE 0x54445344 // DSDT
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/*
|
|
|
9ae3a8 |
* MADT values and structures
|
|
|
9ae3a8 |
@@ -182,7 +176,6 @@ typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescriptorRev1;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* Master MADT */
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-#define ACPI_APIC_SIGNATURE 0x43495041 // APIC
|
|
|
9ae3a8 |
struct AcpiMultipleApicTable
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
ACPI_TABLE_HEADER_DEF /* ACPI common table header */
|
|
|
9ae3a8 |
@@ -253,7 +246,6 @@ typedef struct AcpiMadtLocalNmi AcpiMadtLocalNmi;
|
|
|
9ae3a8 |
/*
|
|
|
9ae3a8 |
* HPET Description Table
|
|
|
9ae3a8 |
*/
|
|
|
9ae3a8 |
-#define ACPI_HPET_SIGNATURE 0x54455048 // HPET
|
|
|
9ae3a8 |
struct Acpi20Hpet {
|
|
|
9ae3a8 |
ACPI_TABLE_HEADER_DEF /* ACPI common table header */
|
|
|
9ae3a8 |
uint32_t timer_block_id;
|
|
|
9ae3a8 |
@@ -268,7 +260,6 @@ typedef struct Acpi20Hpet Acpi20Hpet;
|
|
|
9ae3a8 |
* SRAT (NUMA topology description) table
|
|
|
9ae3a8 |
*/
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-#define ACPI_SRAT_SIGNATURE 0x54415253 // SRAT
|
|
|
9ae3a8 |
struct AcpiSystemResourceAffinityTable
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
ACPI_TABLE_HEADER_DEF
|
|
|
9ae3a8 |
@@ -316,11 +307,6 @@ struct AcpiMcfgAllocation {
|
|
|
9ae3a8 |
} QEMU_PACKED;
|
|
|
9ae3a8 |
typedef struct AcpiMcfgAllocation AcpiMcfgAllocation;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-#define ACPI_MCFG_SIGNATURE 0x4746434d // MCFG
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
-/* Reserved signature: ignored by OSPM */
|
|
|
9ae3a8 |
-#define ACPI_RSRV_SIGNATURE 0x554d4551 // QEMU
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
struct AcpiTableMcfg {
|
|
|
9ae3a8 |
ACPI_TABLE_HEADER_DEF;
|
|
|
9ae3a8 |
uint8_t reserved[8];
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|