acpi: move common parts of the SSDT to the DSDT (and preview of things to come)
cover acpi: move common parts of the SSDT to the DSDT (and preview of things to come)
Right now, the SSDT/DSDT is split in three parts:
- code that doesn't need patching goes in the DSDT. Furthermore, code in this category that is shared between PIIX4 and Q35 is handled via #include. There was one exception, the SMC._STA method is patched and is in the DSDT.
- shared code that needs patching goes in the SSDT
- template-based code that comes from command line arguments goes in the SSDT as well
This series changes things to:
- code that is chipset-specific goes in the DSDT first. Right now none of this needs patching
- code that is not chipset-specific, some of which needs patching, goes in the DSDT second
- template-based code that comes from command line arguments goes in the SSDT
Patch 1 moves ssdt-misc ("common code that needs patching") to the DSDT. Patches 2-4 stop using the C preprocessor in the DSDTs.
Patches 5-7 show why this could be useful. They add padding in fw_cfg after the DSDT, and in exchange stop padding the ACPI tables to 128K. This fixes migration problems (ROM sizes, RSDP) because the ACPI tables are split in two:
1) fixed tables and the DSDT can be changed freely;
2) tables that vary depending on the command-line arguments (SSDT, MADT, ...) are versioned and, given a machine type, they have to be byte-equivalent across QEMU versions >= 2.3.
Patches 5 and 6 introduce a new sizing algorithm. Patch 7 use it to fix the migration problems.
Only the first 4 or 6 patches are meant for inclusion. Patch 7 should only be committed after Igor's series that rewrites the templating mechanism in C. That makes it much simpler to track changes to the ACPI tables, and removes dependencies on the IASL version that could cause some head-scratching.
The conflicts with Igor's series are nontrivial but overall not complicated to solve. Igor rewrote ssdt-misc in C, but those parts can be easily removed from his series. He has plans to build the DSDT from C, and if that materializes it can apply to acpi-dsdt-common.dsl too.
Paolo
Paolo Bonzini (7):
pc: append ssdt-misc.dsl to the DSDT
pc: rename ssdt-misc to dsdt-common
pc: move common parts of the DSDT to dsdt-common
pc: merge DSDT common parts into acpi-dsdt-common.dsl
pc: introduce new ACPI table sizing algorithm
pc: clean up pre-2.1 compatibility code
pc: go back to smaller ACPI tables
hw/i386/Makefile.objs | 2 +-
hw/i386/acpi-build.c | 107 +++--
hw/i386/acpi-dsdt-common.dsl | 467 +++++++++++++++++++++
...ex.generated => acpi-dsdt-common.hex.generated} | 4 +-
hw/i386/acpi-dsdt-dbug.dsl | 41 --
hw/i386/acpi-dsdt-hpet.dsl | 48 ---
hw/i386/acpi-dsdt-isa.dsl | 128 ------
hw/i386/acpi-dsdt-mem-hotplug.dsl | 176 --------
hw/i386/acpi-dsdt.dsl | 12 +-
hw/i386/pc_piix.c | 9 +-
hw/i386/pc_q35.c | 6 +-
hw/i386/q35-acpi-dsdt.dsl | 9 +-
hw/i386/ssdt-misc.dsl | 122 ------
include/hw/i386/pc.h | 2 +
14 files changed, 550 insertions(+), 583 deletions(-)
create mode 100644 hw/i386/acpi-dsdt-common.dsl
rename hw/i386/{ssdt-misc.hex.generated => acpi-dsdt-common.hex.generated} (96%)
delete mode 100644 hw/i386/acpi-dsdt-dbug.dsl
delete mode 100644 hw/i386/acpi-dsdt-hpet.dsl
delete mode 100644 hw/i386/acpi-dsdt-isa.dsl
delete mode 100644 hw/i386/acpi-dsdt-mem-hotplug.dsl
delete mode 100644 hw/i386/ssdt-misc.dslSignature · 1 line
1.8.3.1
PATCH 1/4 pc: append ssdt-misc.dsl to the DSDT
This part of the ACPI tables can vary in size across machine types, but does not depend on the command-line. It is an SSDT just because it is the same for i440fx and Q35, and making it an SSDT made the code a bit simpler. However, it also complicates backwards compatibility, so merge it with the DSDT.
--- hw/i386/acpi-build.c | 54 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 19 deletions(-)
hw/i386/acpi-build.c +35 -19
@@ -1061,26 +1061,17 @@ static void patch_pci_windows(PcPciInfo *pci, uint8_t *start, unsigned size) } } -static void -build_ssdt (GArray *table_data,GArray *linker, -AcpiCpuInfo *cpu,AcpiPmInfo *pm,AcpiMiscInfo *misc, -PcPciInfo *pci,PcGuestInfo *guest_info) +static size_t +append_ssdt_misc (GArray *table_data,AcpiPmInfo *pm,AcpiMiscInfo *misc, +PcPciInfo *pci) {MachineState *machine =MACHINE (qdev_get_machine ());uint32_t nr_mem = machine->ram_slots; -unsigned acpi_cpus = guest_info->apic_id_limit; -int ssdt_start = table_data->len; +size_t size =sizeof (ssdp_misc_aml) -sizeof (AcpiTableHeader);uint8_t *ssdt_ptr; -int i; - -/* The current AML generator can cover the APIC ID range [0..255], -* inclusive, for VCPU hotplug. */ -QEMU_BUILD_BUG_ON (ACPI_CPU_HOTPLUG_ID_LIMIT >256 ); -g_assert (acpi_cpus <=ACPI_CPU_HOTPLUG_ID_LIMIT );/* Copy header and patch values in the S3_ / S4_ / S5_ packages */ - ssdt_ptr =acpi_data_push (table_data,sizeof (ssdp_misc_aml)); -memcpy (ssdt_ptr, ssdp_misc_aml,sizeof (ssdp_misc_aml)); + ssdt_ptr =g_memdup (ssdp_misc_aml,sizeof (ssdp_misc_aml));if (pm->s3_disabled) { ssdt_ptr[acpi_s3_name[0 ]] ='X' ; }
@@ -1099,6 +1090,29 @@ build_ssdt(GArray *table_data, GArray *linker,ACPI_BUILD_SET_LE (ssdt_ptr,sizeof (ssdp_misc_aml), ssdt_mctrl_nr_slots[0 ],32 , nr_mem); +memcpy (acpi_data_push (table_data, size), + ssdt_ptr +sizeof (AcpiTableHeader), size); +g_free (ssdt_ptr); +return size; +} + +static void +build_ssdt (GArray *table_data,GArray *linker, +AcpiCpuInfo *cpu,AcpiPmInfo *pm,PcGuestInfo *guest_info) +{ +MachineState *machine =MACHINE (qdev_get_machine ()); +uint32_t nr_mem = machine->ram_slots; +unsigned acpi_cpus = guest_info->apic_id_limit; +int ssdt_start = table_data->len; +int i; + +acpi_data_push (table_data,sizeof (AcpiTableHeader)); + +/* The current AML generator can cover the APIC ID range [0..255], +* inclusive, for VCPU hotplug. */ +QEMU_BUILD_BUG_ON (ACPI_CPU_HOTPLUG_ID_LIMIT >256 ); +g_assert (acpi_cpus <=ACPI_CPU_HOTPLUG_ID_LIMIT ); + {GArray *sb_scope =build_alloc_array ();uint8_t op =0x10 ;/* ScopeOp */
@@ -1423,18 +1437,21 @@ build_dmar_q35(GArray *table_data, GArray *linker) }static void -build_dsdt (GArray *table_data,GArray *linker,AcpiMiscInfo *misc) +build_dsdt (GArray *table_data,GArray *linker,AcpiPmInfo *pm, +AcpiMiscInfo *misc,PcPciInfo *pci) {AcpiTableHeader *dsdt; +size_t ssdt_misc_size;assert (misc->dsdt_code && misc->dsdt_size); dsdt =acpi_data_push (table_data, misc->dsdt_size);memcpy (dsdt, misc->dsdt_code, misc->dsdt_size); + ssdt_misc_size =append_ssdt_misc (table_data, pm, misc, pci);memset (dsdt,0 ,sizeof *dsdt);build_header (linker, table_data, dsdt,"DSDT" , - misc->dsdt_size,1 ); + misc->dsdt_size + ssdt_misc_size,1 ); }/* Build final rsdt table */
@@ -1591,7 +1608,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)/* DSDT is pointed to by FADT */ dsdt = tables->table_data->len; -build_dsdt (tables->table_data, tables->linker, &misc); +build_dsdt (tables->table_data, tables->linker, &pm, &misc, &pci);/* Count the size of the DSDT and SSDT, we will need it for legacy * sizing of ACPI tables.
@@ -1604,8 +1621,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables) ssdt = tables->table_data->len;acpi_add_table (table_offsets, tables->table_data); -build_ssdt (tables->table_data, tables->linker, &cpu, &pm, &misc, &pci, - guest_info); +build_ssdt (tables->table_data, tables->linker, &cpu, &pm, guest_info); aml_len += tables->table_data->len - ssdt;acpi_add_table (table_offsets, tables->table_data);
Signature · 1 line
1.8.3.1
PATCH 2/4 pc: rename ssdt-misc to dsdt-common
In reply to Paolo Bonzini---
hw/i386/Makefile.objs | 2 +-
hw/i386/acpi-build.c | 38 +++++++++++-----------
hw/i386/{ssdt-misc.dsl => acpi-dsdt-common.dsl} | 8 ++---
...ex.generated => acpi-dsdt-common.hex.generated} | 4 +--
hw/i386/acpi-dsdt.dsl | 2 +-
5 files changed, 27 insertions(+), 27 deletions(-)
rename hw/i386/{ssdt-misc.dsl => acpi-dsdt-common.dsl} (94%)
rename hw/i386/{ssdt-misc.hex.generated => acpi-dsdt-common.hex.generated} (96%)hw/i386/Makefile.objs +1 -1
@@ -9,7 +9,7 @@ obj-y += kvmvapic.o obj-y += acpi-build.o obj-y += bios-linker-loader.o hw/i386/acpi-build.o: hw/i386/acpi-build.c hw/i386/acpi-dsdt.hex \ - hw/i386/ssdt-proc.hex hw/i386/ssdt-pcihp.hex hw/i386/ssdt-misc.hex \ + hw/i386/ssdt-proc.hex hw/i386/ssdt-pcihp.hex hw/i386/acpi-dsdt-common.hex \ hw/i386/acpi-dsdt.hex hw/i386/q35-acpi-dsdt.hex \ hw/i386/q35-acpi-dsdt.hex hw/i386/ssdt-mem.hex \ hw/i386/ssdt-tpm.hex
hw/i386/acpi-build.c +19 -19
@@ -715,7 +715,7 @@ static inline char acpi_get_hex(uint32_t val)#define ACPI_SSDT_SIGNATURE 0x54445353/* SSDT */ #define ACPI_SSDT_HEADER_LENGTH 36 -#include "hw/i386/ssdt-misc.hex" +#include "hw/i386/acpi-dsdt-common.hex" #include "hw/i386/ssdt-pcihp.hex" #include "hw/i386/ssdt-tpm.hex"
@@ -1062,37 +1062,37 @@ static void patch_pci_windows(PcPciInfo *pci, uint8_t *start, unsigned size) }static size_t -append_ssdt_misc (GArray *table_data,AcpiPmInfo *pm,AcpiMiscInfo *misc, -PcPciInfo *pci) +append_dsdt_common (GArray *table_data,AcpiPmInfo *pm,AcpiMiscInfo *misc, +PcPciInfo *pci) {MachineState *machine =MACHINE (qdev_get_machine ());uint32_t nr_mem = machine->ram_slots; -size_t size =sizeof (ssdp_misc_aml) -sizeof (AcpiTableHeader); -uint8_t *ssdt_ptr; +size_t size =sizeof (dsdt_common_aml) -sizeof (AcpiTableHeader); +uint8_t *dsdt_ptr;/* Copy header and patch values in the S3_ / S4_ / S5_ packages */ - ssdt_ptr =g_memdup (ssdp_misc_aml,sizeof (ssdp_misc_aml)); + dsdt_ptr =g_memdup (dsdt_common_aml,sizeof (dsdt_common_aml));if (pm->s3_disabled) { - ssdt_ptr[acpi_s3_name[0 ]] ='X' ; + dsdt_ptr[acpi_s3_name[0 ]] ='X' ; }if (pm->s4_disabled) { - ssdt_ptr[acpi_s4_name[0 ]] ='X' ; + dsdt_ptr[acpi_s4_name[0 ]] ='X' ; }else { - ssdt_ptr[acpi_s4_pkg[0 ] +1 ] = ssdt_ptr[acpi_s4_pkg[0 ] +3 ] = + dsdt_ptr[acpi_s4_pkg[0 ] +1 ] = dsdt_ptr[acpi_s4_pkg[0 ] +3 ] = pm->s4_val; } -patch_pci_windows (pci, ssdt_ptr,sizeof (ssdp_misc_aml)); +patch_pci_windows (pci, dsdt_ptr,sizeof (dsdt_common_aml)); -ACPI_BUILD_SET_LE (ssdt_ptr,sizeof (ssdp_misc_aml), - ssdt_isa_pest[0 ],16 , misc->pvpanic_port); +ACPI_BUILD_SET_LE (dsdt_ptr,sizeof (dsdt_common_aml), + dsdt_isa_pest[0 ],16 , misc->pvpanic_port); -ACPI_BUILD_SET_LE (ssdt_ptr,sizeof (ssdp_misc_aml), - ssdt_mctrl_nr_slots[0 ],32 , nr_mem); +ACPI_BUILD_SET_LE (dsdt_ptr,sizeof (dsdt_common_aml), + dsdt_mctrl_nr_slots[0 ],32 , nr_mem);memcpy (acpi_data_push (table_data, size), - ssdt_ptr +sizeof (AcpiTableHeader), size); -g_free (ssdt_ptr); + dsdt_ptr +sizeof (AcpiTableHeader), size); +g_free (dsdt_ptr);return size; }
@@ -1441,17 +1441,17 @@ build_dsdt(GArray *table_data, GArray *linker, AcpiPmInfo *pm, AcpiMiscInfo *misc, PcPciInfo *pci) {AcpiTableHeader *dsdt; -size_t ssdt_misc_size; +size_t dsdt_common_size;assert (misc->dsdt_code && misc->dsdt_size); dsdt =acpi_data_push (table_data, misc->dsdt_size);memcpy (dsdt, misc->dsdt_code, misc->dsdt_size); - ssdt_misc_size =append_ssdt_misc (table_data, pm, misc, pci); + dsdt_common_size =append_dsdt_common (table_data, pm, misc, pci);memset (dsdt,0 ,sizeof *dsdt);build_header (linker, table_data, dsdt,"DSDT" , - misc->dsdt_size + ssdt_misc_size,1 ); + misc->dsdt_size + dsdt_common_size,1 ); }/* Build final rsdt table */
hw/i386/acpi-dsdt-common.dsl renamed from hw/i386/ssdt-misc.dsl +4 -4
@@ -14,9 +14,9 @@ */ #include "hw/acpi/pc-hotplug.h" -ACPI_EXTRACT_ALL_CODE ssdp_misc_aml +ACPI_EXTRACT_ALL_CODE dsdt_common_aml -DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) +DefinitionBlock ("acpi-dsdt-common.aml", "SSDT", 0x01, "BXPC", "BXSSDTCOMM", 0x1) { /****************************************************************
@@ -36,7 +36,7 @@ DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) Name(P1E, Buffer() { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }) ACPI_EXTRACT_NAME_BUFFER8 acpi_pci64_length Name(P1L, Buffer() { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }) - ACPI_EXTRACT_NAME_DWORD_CONST ssdt_mctrl_nr_slots + ACPI_EXTRACT_NAME_DWORD_CONST dsdt_mctrl_nr_slots Name(MEMORY_SLOTS_NUMBER, 0x12345678) }
@@ -81,7 +81,7 @@ DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) Device(PEVT) { Name(_HID, "QEMU0001") /* PEST will be patched to be Zero if no such device */ - ACPI_EXTRACT_NAME_WORD_CONST ssdt_isa_pest + ACPI_EXTRACT_NAME_WORD_CONST dsdt_isa_pest Name(PEST, 0xFFFF) OperationRegion(PEOR, SystemIO, PEST, 0x01) Field(PEOR, ByteAcc, NoLock, Preserve) {
hw/i386/acpi-dsdt-common.hex.generated renamed from hw/i386/ssdt-misc.hex.generated +2 -2
@@ -16,7 +16,7 @@ static unsigned char acpi_pci32_start[] = { static unsigned char acpi_pci64_valid[] = { 0x43 }; -static unsigned char ssdp_misc_aml[] = { +static unsigned char dsdt_common_aml[] = { 0x53, 0x53, 0x44,
@@ -382,7 +382,7 @@ static unsigned char ssdp_misc_aml[] = { 0x4d, 0x58 }; -static unsigned char ssdt_isa_pest[] = { +static unsigned char dsdt_isa_pest[] = { 0xda }; static unsigned char acpi_s4_name[] = {
hw/i386/acpi-dsdt.dsl +1 -1
@@ -170,7 +170,7 @@ DefinitionBlock ( Return (0x0) } - /* Hotplug notification method supplied by SSDT */ + /* Hotplug notification method in acpi-dsdt-common.dsl */ External(\_SB.PCI0.PCNT, MethodObj) }
Signature · 1 line
1.8.3.1
PATCH 3/4 pc: move common parts of the DSDT to dsdt-common
In reply to Paolo Bonzini--- hw/i386/acpi-build.c | 7 ++----- hw/i386/acpi-dsdt-common.dsl | 14 +++++++++++--- hw/i386/acpi-dsdt-isa.dsl | 6 +++++- hw/i386/acpi-dsdt.dsl | 10 ++-------- hw/i386/q35-acpi-dsdt.dsl | 9 ++------- 5 files changed, 22 insertions(+), 24 deletions(-)
hw/i386/acpi-build.c +2 -5
@@ -53,6 +53,7 @@#include "hw/i386/q35-acpi-dsdt.hex" #include "hw/i386/acpi-dsdt.hex" +#include "hw/i386/acpi-dsdt-common.hex" #include "qapi/qmp/qint.h" #include "qom/qom-qobject.h"
@@ -116,7 +117,6 @@ typedef struct AcpiBuildPciBusHotplugState {static void acpi_get_dsdt (AcpiMiscInfo *info) { -uint16_t *applesmc_sta;Object *piix =piix4_pm_find ();Object *lpc =ich9_lpc_find ();assert (!!piix != !!lpc);
@@ -124,16 +124,14 @@ static void acpi_get_dsdt(AcpiMiscInfo *info)if (piix) { info->dsdt_code = AcpiDsdtAmlCode; info->dsdt_size =sizeof AcpiDsdtAmlCode; - applesmc_sta = piix_dsdt_applesmc_sta; }if (lpc) { info->dsdt_code = Q35AcpiDsdtAmlCode; info->dsdt_size =sizeof Q35AcpiDsdtAmlCode; - applesmc_sta = q35_dsdt_applesmc_sta; }/* Patch in appropriate value for AppleSMC _STA */ - *(uint8_t *)(info->dsdt_code + *applesmc_sta) = + *(uint8_t *)(info->dsdt_code + dsdt_applesmc_sta[0 ]) =applesmc_find () ?0x0b :0x00 ; }
@@ -715,7 +713,6 @@ static inline char acpi_get_hex(uint32_t val)#define ACPI_SSDT_SIGNATURE 0x54445353/* SSDT */ #define ACPI_SSDT_HEADER_LENGTH 36 -#include "hw/i386/acpi-dsdt-common.hex" #include "hw/i386/ssdt-pcihp.hex" #include "hw/i386/ssdt-tpm.hex"
hw/i386/acpi-dsdt-common.dsl +11 -3
@@ -19,6 +19,17 @@ ACPI_EXTRACT_ALL_CODE dsdt_common_aml DefinitionBlock ("acpi-dsdt-common.aml", "SSDT", 0x01, "BXPC", "BXSSDTCOMM", 0x1) { + External(\_SB.PCI0, DeviceObj) + External(\_SB.PCI0.ISA, DeviceObj) + External(\_SB.PCI0.PCI, DeviceObj) + +#include "hw/acpi/pc-hotplug.h" +#include "acpi-dsdt-dbug.dsl" +#include "acpi-dsdt-hpet.dsl" +#include "acpi-dsdt-isa.dsl" +#include "acpi-dsdt-mem-hotplug.dsl" + + /**************************************************************** * PCI memory ranges ****************************************************************/
@@ -74,9 +85,6 @@ DefinitionBlock ("acpi-dsdt-common.aml", "SSDT", 0x01, "BXPC", "BXSSDTCOMM", 0x1 }) } - External(\_SB.PCI0, DeviceObj) - External(\_SB.PCI0.ISA, DeviceObj) - Scope(\_SB.PCI0.ISA) { Device(PEVT) { Name(_HID, "QEMU0001")
hw/i386/acpi-dsdt-isa.dsl +5 -1
@@ -19,7 +19,7 @@ Scope(\_SB.PCI0.ISA) { Device (SMC) { Name(_HID, EisaId("APP0001")) /* _STA will be patched to 0x0B if AppleSMC is present */ - ACPI_EXTRACT_NAME_BYTE_CONST DSDT_APPLESMC_STA + ACPI_EXTRACT_NAME_BYTE_CONST dsdt_applesmc_sta Name(_STA, 0xF0) Name(_CRS, ResourceTemplate () { IO (Decode16, 0x0300, 0x0300, 0x01, 0x20)
@@ -58,6 +58,7 @@ Scope(\_SB.PCI0.ISA) { }) } + External(FDEN) Device(FDC0) { Name(_HID, EisaId("PNP0700")) Method(_STA, 0, NotSerialized) {
@@ -76,6 +77,7 @@ Scope(\_SB.PCI0.ISA) { }) } + External(LPEN) Device(LPT) { Name(_HID, EisaId("PNP0400")) Method(_STA, 0, NotSerialized) {
@@ -92,6 +94,7 @@ Scope(\_SB.PCI0.ISA) { }) } + External(CAEN) Device(COM1) { Name(_HID, EisaId("PNP0501")) Name(_UID, 0x01)
@@ -109,6 +112,7 @@ Scope(\_SB.PCI0.ISA) { }) } + External(CBEN) Device(COM2) { Name(_HID, EisaId("PNP0501")) Name(_UID, 0x02)
hw/i386/acpi-dsdt.dsl +2 -8
@@ -29,9 +29,6 @@ DefinitionBlock ( ) { -#include "acpi-dsdt-dbug.dsl" - - /**************************************************************** * PCI Bus definition ****************************************************************/
@@ -86,7 +83,6 @@ DefinitionBlock ( } #include "acpi-dsdt-pci-crs.dsl" -#include "acpi-dsdt-hpet.dsl" /****************************************************************
@@ -130,9 +126,6 @@ DefinitionBlock ( } } -#define DSDT_APPLESMC_STA piix_dsdt_applesmc_sta -#include "acpi-dsdt-isa.dsl" - /**************************************************************** * PCI hotplug
@@ -297,7 +290,6 @@ DefinitionBlock ( #include "hw/acpi/pc-hotplug.h" #define CPU_STATUS_BASE PIIX4_CPU_HOTPLUG_IO_BASE #include "acpi-dsdt-cpu-hotplug.dsl" -#include "acpi-dsdt-mem-hotplug.dsl" /****************************************************************
@@ -318,6 +310,8 @@ DefinitionBlock ( // CPU hotplug event \_SB.PRSC() } + External(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE, DeviceObj) + External(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_SCAN_METHOD, MethodObj) Method(_E03) { // Memory hotplug event \_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_SCAN_METHOD()
hw/i386/q35-acpi-dsdt.dsl +2 -7
@@ -34,7 +34,6 @@ DefinitionBlock ( ) { -#include "acpi-dsdt-dbug.dsl" Scope(\_SB) { OperationRegion(PCST, SystemIO, 0xae00, 0x0c)
@@ -132,8 +131,6 @@ DefinitionBlock ( } #include "acpi-dsdt-pci-crs.dsl" -#include "acpi-dsdt-hpet.dsl" - /**************************************************************** * LPC ISA bridge
@@ -168,9 +165,6 @@ DefinitionBlock ( } } -#define DSDT_APPLESMC_STA q35_dsdt_applesmc_sta -#include "acpi-dsdt-isa.dsl" - /**************************************************************** * PCI IRQs
@@ -405,7 +399,6 @@ DefinitionBlock ( #include "hw/acpi/pc-hotplug.h" #define CPU_STATUS_BASE ICH9_CPU_HOTPLUG_IO_BASE #include "acpi-dsdt-cpu-hotplug.dsl" -#include "acpi-dsdt-mem-hotplug.dsl" /****************************************************************
@@ -422,6 +415,8 @@ DefinitionBlock ( // CPU hotplug event \_SB.PRSC() } + External(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE, DeviceObj) + External(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_SCAN_METHOD, MethodObj) Method(_E03) { // Memory hotplug event \_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_SCAN_METHOD()
Signature · 1 line
1.8.3.1
[Qemu-devel] [PATCH 5/4] pc: introduce new ACPI table sizing algorithm
In reply to Paolo BonziniAdd padding after the DSDT. Tables that vary depending on the command-line arguments will have to be byte-equivalent across QEMU versions >= 2.2, while fixed tables (including the DSDT) can be changed freely.
--- hw/i386/acpi-build.c | 19 +++++++++++-------- hw/i386/pc_piix.c | 5 +++++ include/hw/i386/pc.h | 2 ++ 3 files changed, 18 insertions(+), 8 deletions(-)
hw/i386/acpi-build.c +11 -8
@@ -67,8 +67,6 @@#define ACPI_BUILD_LEGACY_CPU_AML_SIZE 97#define ACPI_BUILD_ALIGN_SIZE 0x1000 -#define ACPI_BUILD_TABLE_SIZE 0x20000 -/* #define DEBUG_ACPI_BUILD */ #ifdef DEBUG_ACPI_BUILD #define ACPI_BUILD_DPRINTF (fmt, ...) \
@@ -1616,6 +1614,10 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)acpi_add_table (table_offsets, tables->table_data);build_fadt (tables->table_data, tables->linker, &pm, facs, dsdt); +if (guest_info->fixed_table_align) { +acpi_align_size (tables->table_data, guest_info->fixed_table_align); + } + ssdt = tables->table_data->len;acpi_add_table (table_offsets, tables->table_data);build_ssdt (tables->table_data, tables->linker, &cpu, &pm, guest_info);
@@ -1698,15 +1700,16 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables) }g_array_set_size (tables->table_data, legacy_table_size); }else { -/* Make sure we have a buffer in case we need to resize the tables. */ -if (tables->table_data->len >ACPI_BUILD_TABLE_SIZE /2 ) { -/* As of QEMU 2.1, this fires with 160 VCPUs and 255 memory slots. */ +/* Suggest upgrading to the newer algorithm if close to the limit. +* As of QEMU 2.1, this fired with 160 VCPUs and 255 memory slots. +*/ +if (!guest_info->fixed_table_align && + tables->table_data->len > guest_info->acpi_table_align /2 ) {error_report ("Warning: ACPI tables are larger than 64k." );error_report ("Warning: migration may not work." ); -error_report ("Warning: please remove CPUs, NUMA nodes, " -"memory slots or PCI bridges." ); +error_report ("Warning: please upgrade to a newer machine type." ); } -acpi_align_size (tables->table_data,ACPI_BUILD_TABLE_SIZE ); +acpi_align_size (tables->table_data, guest_info->acpi_table_align); }acpi_align_size (tables->linker,ACPI_BUILD_ALIGN_SIZE );
hw/i386/pc_piix.c +5 -0
@@ -61,6 +61,8 @@ static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };static bool has_acpi_build = true;static int legacy_acpi_table_size; +static int fixed_table_align =0 ; +static int acpi_table_align =131072 ;static bool smbios_defaults = true;static bool smbios_legacy_mode;static bool smbios_uuid_encoded = true;
@@ -165,6 +167,8 @@ static void pc_init1(MachineState *machine, guest_info->has_acpi_build = has_acpi_build; guest_info->legacy_acpi_table_size = legacy_acpi_table_size; + guest_info->fixed_table_align = fixed_table_align; + guest_info->acpi_table_align = acpi_table_align; guest_info->isapc_ram_fw = !pci_enabled; guest_info->has_reserved_memory = has_reserved_memory;
@@ -362,6 +366,7 @@ static void pc_compat_2_0(MachineState *machine)* QEMU 1.7 it is 6414. For RHEL/CentOS 7.0 it is 6418. */ legacy_acpi_table_size =6652 ; + acpi_table_align =4096 ; smbios_legacy_mode = true; has_reserved_memory = false;pc_set_legacy_acpi_data_size ();
include/hw/i386/pc.h +2 -0
@@ -102,6 +102,8 @@ struct PcGuestInfo {uint64_t *node_cpu;FWCfgState *fw_cfg;int legacy_acpi_table_size; +int fixed_table_align; +int acpi_table_align;bool has_acpi_build;bool has_reserved_memory; };
Signature · 1 line
1.8.3.1
PATCH 4/4 pc: merge DSDT common parts into acpi-dsdt-common.dsl
In reply to Paolo Bonzini--- hw/i386/acpi-dsdt-common.dsl | 345 +++++++++++++++++++++++++++++++++++++- hw/i386/acpi-dsdt-dbug.dsl | 41 ----- hw/i386/acpi-dsdt-hpet.dsl | 48 ------ hw/i386/acpi-dsdt-isa.dsl | 132 --------------- hw/i386/acpi-dsdt-mem-hotplug.dsl | 176 ------------------- 5 files changed, 341 insertions(+), 401 deletions(-) delete mode 100644 hw/i386/acpi-dsdt-dbug.dsl delete mode 100644 hw/i386/acpi-dsdt-hpet.dsl delete mode 100644 hw/i386/acpi-dsdt-isa.dsl delete mode 100644 hw/i386/acpi-dsdt-mem-hotplug.dsl
hw/i386/acpi-dsdt-common.dsl +341 -4
@@ -24,10 +24,347 @@ DefinitionBlock ("acpi-dsdt-common.aml", "SSDT", 0x01, "BXPC", "BXSSDTCOMM", 0x1 External(\_SB.PCI0.PCI, DeviceObj) #include "hw/acpi/pc-hotplug.h" -#include "acpi-dsdt-dbug.dsl" -#include "acpi-dsdt-hpet.dsl" -#include "acpi-dsdt-isa.dsl" -#include "acpi-dsdt-mem-hotplug.dsl" + +/**************************************************************** + * Debugging + ****************************************************************/ + + Scope(\) { + /* Debug Output */ + OperationRegion(DBG, SystemIO, 0x0402, 0x01) + Field(DBG, ByteAcc, NoLock, Preserve) { + DBGB, 8, + } + + /* Debug method - use this method to send output to the QEMU + * BIOS debug port. This method handles strings, integers, + * and buffers. For example: DBUG("abc") DBUG(0x123) */ + Method(DBUG, 1) { + ToHexString(Arg0, Local0) + ToBuffer(Local0, Local0) + Subtract(SizeOf(Local0), 1, Local1) + Store(Zero, Local2) + While (LLess(Local2, Local1)) { + Store(DerefOf(Index(Local0, Local2)), DBGB) + Increment(Local2) + } + Store(0x0A, DBGB) + } + } + + /**************************************************************** + * HPET + ****************************************************************/ + + Scope(\_SB) { + Device(HPET) { + Name(_HID, EISAID("PNP0103")) + Name(_UID, 0) + OperationRegion(HPTM, SystemMemory, 0xFED00000, 0x400) + Field(HPTM, DWordAcc, Lock, Preserve) { + VEND, 32, + PRD, 32, + } + Method(_STA, 0, NotSerialized) { + Store(VEND, Local0) + Store(PRD, Local1) + ShiftRight(Local0, 16, Local0) + If (LOr(LEqual(Local0, 0), LEqual(Local0, 0xffff))) { + Return (0x0) + } + If (LOr(LEqual(Local1, 0), LGreater(Local1, 100000000))) { + Return (0x0) + } + Return (0x0F) + } + Name(_CRS, ResourceTemplate() { + Memory32Fixed(ReadOnly, + 0xFED00000, // Address Base + 0x00000400, // Address Length + ) + }) + } + } + + /* Common legacy ISA style devices. */ + Scope(\_SB.PCI0.ISA) { + + Device (SMC) { + Name(_HID, EisaId("APP0001")) + /* _STA will be patched to 0x0B if AppleSMC is present */ + ACPI_EXTRACT_NAME_BYTE_CONST dsdt_applesmc_sta + Name(_STA, 0xF0) + Name(_CRS, ResourceTemplate () { + IO (Decode16, 0x0300, 0x0300, 0x01, 0x20) + IRQNoFlags() { 6 } + }) + } + + Device(RTC) { + Name(_HID, EisaId("PNP0B00")) + Name(_CRS, ResourceTemplate() { + IO(Decode16, 0x0070, 0x0070, 0x10, 0x02) + IRQNoFlags() { 8 } + IO(Decode16, 0x0072, 0x0072, 0x02, 0x06) + }) + } + + Device(KBD) { + Name(_HID, EisaId("PNP0303")) + Method(_STA, 0, NotSerialized) { + Return (0x0f) + } + Name(_CRS, ResourceTemplate() { + IO(Decode16, 0x0060, 0x0060, 0x01, 0x01) + IO(Decode16, 0x0064, 0x0064, 0x01, 0x01) + IRQNoFlags() { 1 } + }) + } + + Device(MOU) { + Name(_HID, EisaId("PNP0F13")) + Method(_STA, 0, NotSerialized) { + Return (0x0f) + } + Name(_CRS, ResourceTemplate() { + IRQNoFlags() { 12 } + }) + } + + External(FDEN) + Device(FDC0) { + Name(_HID, EisaId("PNP0700")) + Method(_STA, 0, NotSerialized) { + Store(FDEN, Local0) + If (LEqual(Local0, 0)) { + Return (0x00) + } Else { + Return (0x0F) + } + } + Name(_CRS, ResourceTemplate() { + IO(Decode16, 0x03F2, 0x03F2, 0x00, 0x04) + IO(Decode16, 0x03F7, 0x03F7, 0x00, 0x01) + IRQNoFlags() { 6 } + DMA(Compatibility, NotBusMaster, Transfer8) { 2 } + }) + } + + External(LPEN) + Device(LPT) { + Name(_HID, EisaId("PNP0400")) + Method(_STA, 0, NotSerialized) { + Store(LPEN, Local0) + If (LEqual(Local0, 0)) { + Return (0x00) + } Else { + Return (0x0F) + } + } + Name(_CRS, ResourceTemplate() { + IO(Decode16, 0x0378, 0x0378, 0x08, 0x08) + IRQNoFlags() { 7 } + }) + } + + External(CAEN) + Device(COM1) { + Name(_HID, EisaId("PNP0501")) + Name(_UID, 0x01) + Method(_STA, 0, NotSerialized) { + Store(CAEN, Local0) + If (LEqual(Local0, 0)) { + Return (0x00) + } Else { + Return (0x0F) + } + } + Name(_CRS, ResourceTemplate() { + IO(Decode16, 0x03F8, 0x03F8, 0x00, 0x08) + IRQNoFlags() { 4 } + }) + } + + External(CBEN) + Device(COM2) { + Name(_HID, EisaId("PNP0501")) + Name(_UID, 0x02) + Method(_STA, 0, NotSerialized) { + Store(CBEN, Local0) + If (LEqual(Local0, 0)) { + Return (0x00) + } Else { + Return (0x0F) + } + } + Name(_CRS, ResourceTemplate() { + IO(Decode16, 0x02F8, 0x02F8, 0x00, 0x08) + IRQNoFlags() { 3 } + }) + } + } + + External(MEMORY_SLOT_NOTIFY_METHOD, MethodObj) + + Scope(\_SB.PCI0) { + Device(MEMORY_HOTPLUG_DEVICE) { + Name(_HID, "PNP0A06") + Name(_UID, "Memory hotplug resources") + External(MEMORY_SLOTS_NUMBER, IntObj) + + /* Memory hotplug IO registers */ + OperationRegion(MEMORY_HOTPLUG_IO_REGION, SystemIO, + ACPI_MEMORY_HOTPLUG_BASE, + ACPI_MEMORY_HOTPLUG_IO_LEN) + + Name(_CRS, ResourceTemplate() { + IO(Decode16, ACPI_MEMORY_HOTPLUG_BASE, ACPI_MEMORY_HOTPLUG_BASE, + 0, ACPI_MEMORY_HOTPLUG_IO_LEN, IO) + }) + + Method(_STA, 0) { + If (LEqual(MEMORY_SLOTS_NUMBER, Zero)) { + Return(0x0) + } + /* present, functioning, decoding, not shown in UI */ + Return(0xB) + } + + Field(MEMORY_HOTPLUG_IO_REGION, DWordAcc, NoLock, Preserve) { + MEMORY_SLOT_ADDR_LOW, 32, // read only + MEMORY_SLOT_ADDR_HIGH, 32, // read only + MEMORY_SLOT_SIZE_LOW, 32, // read only + MEMORY_SLOT_SIZE_HIGH, 32, // read only + MEMORY_SLOT_PROXIMITY, 32, // read only + } + Field(MEMORY_HOTPLUG_IO_REGION, ByteAcc, NoLock, Preserve) { + Offset(20), + MEMORY_SLOT_ENABLED, 1, // 1 if enabled, read only + MEMORY_SLOT_INSERT_EVENT, 1, // (read) 1 if has a insert event. (write) 1 to clear event + } + + Mutex (MEMORY_SLOT_LOCK, 0) + Field (MEMORY_HOTPLUG_IO_REGION, DWordAcc, NoLock, Preserve) { + MEMORY_SLOT_SLECTOR, 32, // DIMM selector, write only + MEMORY_SLOT_OST_EVENT, 32, // _OST event code, write only + MEMORY_SLOT_OST_STATUS, 32, // _OST status code, write only + } + + Method(MEMORY_SLOT_SCAN_METHOD, 0) { + If (LEqual(MEMORY_SLOTS_NUMBER, Zero)) { + Return(Zero) + } + + Store(Zero, Local0) // Mem devs iterrator + Acquire(MEMORY_SLOT_LOCK, 0xFFFF) + while (LLess(Local0, MEMORY_SLOTS_NUMBER)) { + Store(Local0, MEMORY_SLOT_SLECTOR) // select Local0 DIMM + If (LEqual(MEMORY_SLOT_INSERT_EVENT, One)) { // Memory device needs check + MEMORY_SLOT_NOTIFY_METHOD(Local0, 1) + Store(1, MEMORY_SLOT_INSERT_EVENT) + } + // TODO: handle memory eject request + Add(Local0, One, Local0) // goto next DIMM + } + Release(MEMORY_SLOT_LOCK) + Return(One) + } + + Method(MEMORY_SLOT_STATUS_METHOD, 1) { + Store(Zero, Local0) + + Acquire(MEMORY_SLOT_LOCK, 0xFFFF) + Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM + + If (LEqual(MEMORY_SLOT_ENABLED, One)) { + Store(0xF, Local0) + } + + Release(MEMORY_SLOT_LOCK) + Return(Local0) + } + + Method(MEMORY_SLOT_CRS_METHOD, 1, Serialized) { + Acquire(MEMORY_SLOT_LOCK, 0xFFFF) + Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM + + Name(MR64, ResourceTemplate() { + QWordMemory(ResourceProducer, PosDecode, MinFixed, MaxFixed, + Cacheable, ReadWrite, + 0x0000000000000000, // Address Space Granularity + 0x0000000000000000, // Address Range Minimum + 0xFFFFFFFFFFFFFFFE, // Address Range Maximum + 0x0000000000000000, // Address Translation Offset + 0xFFFFFFFFFFFFFFFF, // Address Length + ,, MW64, AddressRangeMemory, TypeStatic) + }) + + CreateDWordField(MR64, 14, MINL) + CreateDWordField(MR64, 18, MINH) + CreateDWordField(MR64, 38, LENL) + CreateDWordField(MR64, 42, LENH) + CreateDWordField(MR64, 22, MAXL) + CreateDWordField(MR64, 26, MAXH) + + Store(MEMORY_SLOT_ADDR_HIGH, MINH) + Store(MEMORY_SLOT_ADDR_LOW, MINL) + Store(MEMORY_SLOT_SIZE_HIGH, LENH) + Store(MEMORY_SLOT_SIZE_LOW, LENL) + + // 64-bit math: MAX = MIN + LEN - 1 + Add(MINL, LENL, MAXL) + Add(MINH, LENH, MAXH) + If (LLess(MAXL, MINL)) { + Add(MAXH, One, MAXH) + } + If (LLess(MAXL, One)) { + Subtract(MAXH, One, MAXH) + } + Subtract(MAXL, One, MAXL) + + If (LEqual(MAXH, Zero)){ + Name(MR32, ResourceTemplate() { + DWordMemory(ResourceProducer, PosDecode, MinFixed, MaxFixed, + Cacheable, ReadWrite, + 0x00000000, // Address Space Granularity + 0x00000000, // Address Range Minimum + 0xFFFFFFFE, // Address Range Maximum + 0x00000000, // Address Translation Offset + 0xFFFFFFFF, // Address Length + ,, MW32, AddressRangeMemory, TypeStatic) + }) + CreateDWordField(MR32, MW32._MIN, MIN) + CreateDWordField(MR32, MW32._MAX, MAX) + CreateDWordField(MR32, MW32._LEN, LEN) + Store(MINL, MIN) + Store(MAXL, MAX) + Store(LENL, LEN) + + Release(MEMORY_SLOT_LOCK) + Return(MR32) + } + + Release(MEMORY_SLOT_LOCK) + Return(MR64) + } + + Method(MEMORY_SLOT_PROXIMITY_METHOD, 1) { + Acquire(MEMORY_SLOT_LOCK, 0xFFFF) + Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM + Store(MEMORY_SLOT_PROXIMITY, Local0) + Release(MEMORY_SLOT_LOCK) + Return(Local0) + } + + Method(MEMORY_SLOT_OST_METHOD, 4) { + Acquire(MEMORY_SLOT_LOCK, 0xFFFF) + Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM + Store(Arg1, MEMORY_SLOT_OST_EVENT) + Store(Arg2, MEMORY_SLOT_OST_STATUS) + Release(MEMORY_SLOT_LOCK) + } + } // Device() + } // Scope() /****************************************************************
hw/i386/acpi-dsdt-dbug.dsl deleted +0 -41
41 lines not on this page · raw message
hw/i386/acpi-dsdt-hpet.dsl deleted +0 -48
48 lines not on this page · raw message
hw/i386/acpi-dsdt-isa.dsl deleted +0 -132
132 lines not on this page · raw message
hw/i386/acpi-dsdt-mem-hotplug.dsl deleted +0 -176
176 lines not on this page · raw message
Signature · 1 line
1.8.3.1
[Qemu-devel] [PATCH 6/4] pc: clean up pre-2.1 compatibility code
In reply to Paolo BonziniNow that the alignment is parameterized, we can share the call to acpi_align_size between all three (1.7-2.0/2.1/2.2+) sizing algorithms.
Also, with the new rule that SSDT cannot change except with machine-type compat code, the magic 97 constant for a CPU's AML size is not anymore "legacy", so rename it.
--- hw/i386/acpi-build.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
hw/i386/acpi-build.c +5 -6
@@ -64,8 +64,8 @@* a little bit, there should be plenty of free space since the DSDT * shrunk by ~1.5k between QEMU 2.0 and QEMU 2.1. */ -#define ACPI_BUILD_LEGACY_CPU_AML_SIZE 97 -#define ACPI_BUILD_ALIGN_SIZE 0x1000 +#define ACPI_BUILD_CPU_AML_SIZE 97 +#define ACPI_BUILD_ALIGN_SIZE 0x1000/* #define DEBUG_ACPI_BUILD */ #ifdef DEBUG_ACPI_BUILD
@@ -1690,10 +1690,9 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)*/ int legacy_aml_len = guest_info->legacy_acpi_table_size + -ACPI_BUILD_LEGACY_CPU_AML_SIZE * max_cpus; +ACPI_BUILD_CPU_AML_SIZE * max_cpus;int legacy_table_size = -ROUND_UP (tables->table_data->len - aml_len + legacy_aml_len, -ACPI_BUILD_ALIGN_SIZE ); + tables->table_data->len - aml_len + legacy_aml_len;if (tables->table_data->len > legacy_table_size) {/* Should happen only with PCI bridges and -M pc-i440fx-2.0. */ error_report ("Warning: migration may not work." );
@@ -1709,8 +1708,8 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)error_report ("Warning: migration may not work." );error_report ("Warning: please upgrade to a newer machine type." ); } -acpi_align_size (tables->table_data, guest_info->acpi_table_align); } +acpi_align_size (tables->table_data, guest_info->acpi_table_align);acpi_align_size (tables->linker,ACPI_BUILD_ALIGN_SIZE );
Signature · 1 line
1.8.3.1
[Qemu-devel] [PATCH 7/4] pc: go back to smaller ACPI tables
In reply to Paolo BonziniThe new algorithm introduced by the previous patch lets us make tables smaller and avoid migration bugs due to large tables.
Use it for 2.3+ machine types by tweaking the default fixed_table_align and acpi_table_align values. At the same time, preserve backwards-compatible logic for pc-i440fx-2.2.
Without this patch:
[ 0.000000] BIOS-e820: [mem 0x0000000000100000-0x0000000007fdffff] usable [ 0.000000] BIOS-e820: [mem 0x0000000007fe0000-0x0000000007ffffff] reserved ... [ 0.000000] init_memory_mapping: [mem 0x07000000-0x07fdffff] usable [ 0.000000] RAMDISK: [mem 0x07112000-0x07fdffff]
With this patch:
[ 0.000000] BIOS-e820: [mem 0x0000000000100000-0x0000000007ffafff] usable [ 0.000000] BIOS-e820: [mem 0x0000000007ffb000-0x0000000007ffffff] reserved ... [ 0.000000] init_memory_mapping: [mem 0x07000000-0x07ffafff] [ 0.000000] RAMDISK: [mem 0x07122000-0x07feffff]
Thanks to the new linuxboot option ROM, the initrd is loaded 64k above.
--- hw/i386/pc_piix.c | 8 +++++--- hw/i386/pc_q35.c | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-)
hw/i386/pc_piix.c +5 -3
@@ -61,8 +61,8 @@ static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };static bool has_acpi_build = true;static int legacy_acpi_table_size; -static int fixed_table_align =0 ; -static int acpi_table_align =131072 ; +static int fixed_table_align =16384 ; +static int acpi_table_align =4096 ;static bool smbios_defaults = true;static bool smbios_legacy_mode;static bool smbios_uuid_encoded = true;
@@ -332,6 +332,8 @@ static void pc_compat_2_2(MachineState *machine)x86_cpu_compat_set_features ("Haswell" ,FEAT_1_ECX ,0 ,CPUID_EXT_RDRAND );x86_cpu_compat_set_features ("Broadwell" ,FEAT_1_ECX ,0 ,CPUID_EXT_F16C );x86_cpu_compat_set_features ("Broadwell" ,FEAT_1_ECX ,0 ,CPUID_EXT_RDRAND ); + fixed_table_align =0 ; + acpi_table_align =131072 ; }static void pc_compat_2_1 (MachineState *machine)
@@ -348,7 +350,6 @@ static void pc_compat_2_1(MachineState *machine)static void pc_compat_2_0 (MachineState *machine) { -pc_compat_2_1 (machine);/* This value depends on the actual DSDT and SSDT compiled into * the source QEMU; unfortunately it depends on the binary and * not on the machine type, so we cannot make pc-i440fx-1.7 work on
@@ -365,6 +366,7 @@ static void pc_compat_2_0(MachineState *machine)* 6652 is valid for QEMU 2.0, the right value for pc-i440fx-1.7 on * QEMU 1.7 it is 6414. For RHEL/CentOS 7.0 it is 6418. */ +pc_compat_2_1 (machine); legacy_acpi_table_size =6652 ; acpi_table_align =4096 ; smbios_legacy_mode = true;
hw/i386/pc_q35.c +4 -2
@@ -155,10 +155,12 @@ static void pc_q35_init(MachineState *machine) guest_info->has_acpi_build = has_acpi_build; guest_info->has_reserved_memory = has_reserved_memory; -/* Migration was not supported in 2.0 for Q35, so do not bother -* with this hack (see hw/i386/acpi-build.c). +/* Migration was not supported in 2.0 for Q35, so do not bother with +* hacks around the ACPI table size (see hw/i386/acpi-build.c). */ guest_info->legacy_acpi_table_size =0 ; + guest_info->fixed_table_align =16384 ; + guest_info->acpi_table_align =4096 ;if (smbios_defaults) {MachineClass *mc =MACHINE_GET_CLASS (machine);
Signature · 1 line
1.8.3.1
Quoted 47 lines · Paolo Bonzini
Right now, the SSDT/DSDT is split in three parts:
- code that doesn't need patching goes in the DSDT. Furthermore, code in this category that is shared between PIIX4 and Q35 is handled via #include. There was one exception, the SMC._STA method is patched and is in the DSDT.
- shared code that needs patching goes in the SSDT
- template-based code that comes from command line arguments goes in the SSDT as well
This series changes things to:
- code that is chipset-specific goes in the DSDT first. Right now none of this needs patching
- code that is not chipset-specific, some of which needs patching, goes in the DSDT second
- template-based code that comes from command line arguments goes in the SSDT
Patch 1 moves ssdt-misc ("common code that needs patching") to the DSDT. Patches 2-4 stop using the C preprocessor in the DSDTs.
Patches 5-7 show why this could be useful. They add padding in
fw_cfgafter the DSDT, and in exchange stop padding the ACPI tables to 128K. This fixes migration problems (ROM sizes, RSDP) because the ACPI tables are split in two:1) fixed tables and the DSDT can be changed freely;
2) tables that vary depending on the command-line arguments (SSDT, MADT, ...) are versioned and, given a machine type, they have to be byte-equivalent across QEMU versions >= 2.3.
Patches 5 and 6 introduce a new sizing algorithm. Patch 7 use it to fix the migration problems.
Only the first 4 or 6 patches are meant for inclusion. Patch 7 should only be committed after Igor's series that rewrites the templating mechanism in C. That makes it much simpler to track changes to the ACPI tables, and removes dependencies on the IASL version that could cause some head-scratching.
Quoted 5 lines
The conflicts with Igor's series are nontrivial but overall not complicated to solve. Igor rewrote ssdt-misc in C, but those parts can be easily removed from his series. He has plans to build the DSDT from C, and if that materializes it can apply to acpi-dsdt-common.dsl too.
Oops, this does not update the bios-tables-test. v2 next week or after New Year.
Paolo
Quoted 47 lines · Paolo Bonzini
Right now, the SSDT/DSDT is split in three parts:
- code that doesn't need patching goes in the DSDT. Furthermore, code in this category that is shared between PIIX4 and Q35 is handled via #include. There was one exception, the SMC._STA method is patched and is in the DSDT.
- shared code that needs patching goes in the SSDT
- template-based code that comes from command line arguments goes in the SSDT as well
This series changes things to:
- code that is chipset-specific goes in the DSDT first. Right now none of this needs patching
- code that is not chipset-specific, some of which needs patching, goes in the DSDT second
- template-based code that comes from command line arguments goes in the SSDT
Patch 1 moves ssdt-misc ("common code that needs patching") to the DSDT. Patches 2-4 stop using the C preprocessor in the DSDTs.
Patches 5-7 show why this could be useful. They add padding in
fw_cfgafter the DSDT, and in exchange stop padding the ACPI tables to 128K. This fixes migration problems (ROM sizes, RSDP) because the ACPI tables are split in two:1) fixed tables and the DSDT can be changed freely;
2) tables that vary depending on the command-line arguments (SSDT, MADT, ...) are versioned and, given a machine type, they have to be byte-equivalent across QEMU versions >= 2.3.
Patches 5 and 6 introduce a new sizing algorithm. Patch 7 use it to fix the migration problems.
Only the first 4 or 6 patches are meant for inclusion. Patch 7 should only be committed after Igor's series that rewrites the templating mechanism in C. That makes it much simpler to track changes to the ACPI tables, and removes dependencies on the IASL version that could cause some head-scratching.
Quoted 7 lines
The conflicts with Igor's series are nontrivial but overall not complicated to solve. Igor rewrote ssdt-misc in C, but those parts can be easily removed from his series. He has plans to build the DSDT from C, and if that materializes it can apply to acpi-dsdt-common.dsl too.
Paolo
So I'll have to review in detail, overall the patches do look pretty clean.
Given the amount of pain caused by cross version migration issues, I am inclined to do both: arrange code in a way that makes keeping things constant easier, and have some solutions for the inevitable time when we'll find we have to change things we didn't expect.
Defense in depth, if you like.
Makes sense?
Quoted 34 lines
Paolo Bonzini (7):
pc: append ssdt-misc.dsl to the DSDT
pc: rename ssdt-misc to dsdt-common
pc: move common parts of the DSDT to dsdt-common
pc: merge DSDT common parts into acpi-dsdt-common.dsl
pc: introduce new ACPI table sizing algorithm
pc: clean up pre-2.1 compatibility code
pc: go back to smaller ACPI tableshw/i386/Makefile.objs | 2 +- hw/i386/acpi-build.c | 107 +++-- hw/i386/acpi-dsdt-common.dsl | 467 +++++++++++++++++++++ ...ex.generated => acpi-dsdt-common.hex.generated} | 4 +- hw/i386/acpi-dsdt-dbug.dsl | 41 -- hw/i386/acpi-dsdt-hpet.dsl | 48 --- hw/i386/acpi-dsdt-isa.dsl | 128 ------ hw/i386/acpi-dsdt-mem-hotplug.dsl | 176 -------- hw/i386/acpi-dsdt.dsl | 12 +- hw/i386/pc_piix.c | 9 +- hw/i386/pc_q35.c | 6 +- hw/i386/q35-acpi-dsdt.dsl | 9 +- hw/i386/ssdt-misc.dsl | 122 ------ include/hw/i386/pc.h | 2 + 14 files changed, 550 insertions(+), 583 deletions(-) create mode 100644 hw/i386/acpi-dsdt-common.dsl rename hw/i386/{ssdt-misc.hex.generated => acpi-dsdt-common.hex.generated} (96%) delete mode 100644 hw/i386/acpi-dsdt-dbug.dsl delete mode 100644 hw/i386/acpi-dsdt-hpet.dsl delete mode 100644 hw/i386/acpi-dsdt-isa.dsl delete mode 100644 hw/i386/acpi-dsdt-mem-hotplug.dsl delete mode 100644 hw/i386/ssdt-misc.dslSignature · 1 line
1.8.3.1
Quoted 2 lines · Michael S. Tsirkin
So I'll have to review in detail, overall the patches do look pretty clean.
Q35 is broken though (GArray resizing messes up the tables, fixed locally and caught by bios-tables-test even before trying it out!). I hope to send out the fixed version on Saturday (time ticking before vacation).
Quoted 7 lines
Given the amount of pain caused by cross version migration issues, I am inclined to do both: arrange code in a way that makes keeping things constant easier, and have some solutions for the inevitable time when we'll find we have to change things we didn't expect.
Defense in depth, if you like.
Makes sense?
It certainly does. I am only a bit wary because your patches are basically a workaround (as hinted by the fact that the resulting RSDP is corrupted---which doesn't matter much in practice, but it's still a red flashing light!).
So I still would like to see how stuff looks like after Igor's code is merged. Until we actually trim the size of the ACPI tables (patch 7), we do no better / no worse than released versions of QEMU.
And once Igor's code is merged, we actually have an idea of what is left in the SSDT, and how tricky that code is. "Not tricky at all" is perhaps a bit optimistic, a more realistic hope is "not any more tricky than what we do for devices".
In other words, it's only tricky now because it's new. We had all sorts of false starts, but the my patches and Igor's provide enough separation (mine: fixed vs. variable; Igor's: ASL vs. C) that the future should reserve less surprises.
I will still review your patches, of course.
Paolo
Quoted 19 lines · Paolo Bonzini
Quoted 2 lines · Michael S. Tsirkin
So I'll have to review in detail, overall the patches do look pretty clean.
Q35 is broken though (GArray resizing messes up the tables, fixed locally and caught by bios-tables-test even before trying it out!). I hope to send out the fixed version on Saturday (time ticking before vacation).
Quoted 7 lines
Given the amount of pain caused by cross version migration issues, I am inclined to do both: arrange code in a way that makes keeping things constant easier, and have some solutions for the inevitable time when we'll find we have to change things we didn't expect.
Defense in depth, if you like.
Makes sense?
Quoted 4 lines
It certainly does. I am only a bit wary because your patches are basically a workaround (as hinted by the fact that the resulting RSDP is corrupted---which doesn't matter much in practice, but it's still a red flashing light!).
Well seen in that light, your patches are also basically a work-around :)
Quoted 2 lines
So I still would like to see how stuff looks like after Igor's code is merged.
Hmm apply them to you tree and see? Do you need my help to put them on a temporary branch?
Quoted 2 lines
Until we actually trim the size of the ACPI tables (patch 7),
we do no better / no worse than released versions of QEMU.
Right, and actually trimming them seems much safer to me if we can actually guarantee that possible need to increase them back in the future will not break things.
Quoted 5 lines
And once Igor's code is merged, we actually have an idea of what is left in the SSDT, and how tricky that code is. "Not tricky at all" is perhaps a bit optimistic, a more realistic hope is "not any more tricky than what we do for devices".
Quoted 8 lines
In other words, it's only tricky now because it's new. We had all sorts of false starts, but the my patches and Igor's provide enough separation (mine: fixed vs. variable; Igor's: ASL vs. C) that the future should reserve less surprises.
I will still review your patches, of course.
Paolo
As the one who has to maintain this mess, I think my peace of mind has some value :) So from the PC side of things I'm inclined to merge this even if it proves to be not useful - it's there if we need it, and at least it does not break things.
But I do want your review of the core bits, since these things are tricky to stress-test properly.
Signature · 1 line
MST
Quoted 78 lines · Paolo Bonzini
Right now, the SSDT/DSDT is split in three parts:
- code that doesn't need patching goes in the DSDT. Furthermore, code in this category that is shared between PIIX4 and Q35 is handled via #include. There was one exception, the SMC._STA method is patched and is in the DSDT.
- shared code that needs patching goes in the SSDT
- template-based code that comes from command line arguments goes in the SSDT as well
This series changes things to:
- code that is chipset-specific goes in the DSDT first. Right now none of this needs patching
- code that is not chipset-specific, some of which needs patching, goes in the DSDT second
- template-based code that comes from command line arguments goes in the SSDT
Patch 1 moves ssdt-misc ("common code that needs patching") to the DSDT. Patches 2-4 stop using the C preprocessor in the DSDTs.
Patches 5-7 show why this could be useful. They add padding in
fw_cfgafter the DSDT, and in exchange stop padding the ACPI tables to 128K. This fixes migration problems (ROM sizes, RSDP) because the ACPI tables are split in two:1) fixed tables and the DSDT can be changed freely;
2) tables that vary depending on the command-line arguments (SSDT, MADT, ...) are versioned and, given a machine type, they have to be byte-equivalent across QEMU versions >= 2.3.
Patches 5 and 6 introduce a new sizing algorithm. Patch 7 use it to fix the migration problems.
Only the first 4 or 6 patches are meant for inclusion. Patch 7 should only be committed after Igor's series that rewrites the templating mechanism in C. That makes it much simpler to track changes to the ACPI tables, and removes dependencies on the IASL version that could cause some head-scratching.
The conflicts with Igor's series are nontrivial but overall not complicated to solve. Igor rewrote ssdt-misc in C, but those parts can be easily removed from his series. He has plans to build the DSDT from C, and if that materializes it can apply to acpi-dsdt-common.dsl too.
Paolo
Paolo Bonzini (7):
pc: append ssdt-misc.dsl to the DSDT
pc: rename ssdt-misc to dsdt-common
pc: move common parts of the DSDT to dsdt-common
pc: merge DSDT common parts into acpi-dsdt-common.dsl
pc: introduce new ACPI table sizing algorithm
pc: clean up pre-2.1 compatibility code
pc: go back to smaller ACPI tableshw/i386/Makefile.objs | 2 +- hw/i386/acpi-build.c | 107 +++-- hw/i386/acpi-dsdt-common.dsl | 467 +++++++++++++++++++++ ...ex.generated => acpi-dsdt-common.hex.generated} | 4 +- hw/i386/acpi-dsdt-dbug.dsl | 41 -- hw/i386/acpi-dsdt-hpet.dsl | 48 --- hw/i386/acpi-dsdt-isa.dsl | 128 ------ hw/i386/acpi-dsdt-mem-hotplug.dsl | 176 -------- hw/i386/acpi-dsdt.dsl | 12 +- hw/i386/pc_piix.c | 9 +- hw/i386/pc_q35.c | 6 +- hw/i386/q35-acpi-dsdt.dsl | 9 +- hw/i386/ssdt-misc.dsl | 122 ------ include/hw/i386/pc.h | 2 +
Quoted 9 lines
14 files changed, 550 insertions(+), 583 deletions(-)
create mode 100644 hw/i386/acpi-dsdt-common.dsl
rename hw/i386/{ssdt-misc.hex.generated => acpi-dsdt-common.hex.generated} (96%)
delete mode 100644 hw/i386/acpi-dsdt-dbug.dsl
delete mode 100644 hw/i386/acpi-dsdt-hpet.dsl
delete mode 100644 hw/i386/acpi-dsdt-isa.dsl
delete mode 100644 hw/i386/acpi-dsdt-mem-hotplug.dsl
delete mode 100644 hw/i386/ssdt-misc.dslPing (patches 1-4)?
Paolo