Skip to contentSkip to conversation

acpi: move common parts of the SSDT to the DSDT (and preview of things to come)

PATCH Superseded Paolo Bonzini 3 participants 27 messages Dec 24, 2014 – Jan 20, 2015

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 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, except for parameterized code (CPU hotplug, PCI CRS).

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.

v1->v2 fixes problems due to GArray resizing and updates test data. Now passes make check.

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                   |  113 +-
 hw/i386/acpi-dsdt-common.dsl           |  467 +++++
 hw/i386/acpi-dsdt-common.hex.generated | 1897 +++++++++++++++++++
 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/acpi-dsdt.hex.generated        | 3119 +++++++++-----------------------
 hw/i386/pc_piix.c                      |    9 +-
 hw/i386/pc_q35.c                       |    6 +-
 hw/i386/q35-acpi-dsdt.dsl              |    9 +-
 hw/i386/q35-acpi-dsdt.hex.generated    | 2787 +++++++---------------------
 hw/i386/ssdt-misc.dsl                  |  122 --
 hw/i386/ssdt-misc.hex.generated        |  399 ----
 include/hw/i386/pc.h                   |    2 +
 tests/acpi-test-data/pc/DSDT           |  Bin 3592 -> 3923 bytes
 tests/acpi-test-data/pc/SSDT           |  Bin 2279 -> 1951 bytes
 tests/acpi-test-data/q35/DSDT          |  Bin 8182 -> 8513 bytes
 tests/acpi-test-data/q35/SSDT          |  Bin 560 -> 232 bytes
 21 files changed, 3905 insertions(+), 5432 deletions(-)
 create mode 100644 hw/i386/acpi-dsdt-common.dsl
 create mode 100644 hw/i386/acpi-dsdt-common.hex.generated
 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.dsl
 delete mode 100644 hw/i386/ssdt-misc.hex.generated
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v2 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          |  55 +++++++++++++++++++++++++++---------------
 tests/acpi-test-data/pc/DSDT  | Bin 3592 -> 3920 bytes
 tests/acpi-test-data/pc/SSDT  | Bin 2279 -> 1951 bytes
 tests/acpi-test-data/q35/DSDT | Bin 8182 -> 8510 bytes
 tests/acpi-test-data/q35/SSDT | Bin 560 -> 232 bytes
 5 files changed, 35 insertions(+), 20 deletions(-)
hw/i386/acpi-build.c +35 -20
index a4d0c0c..e723fe1 100644
@@ -1061,26 +1061,18 @@ static void patch_pci_windows(PcPciInfo *pci, uint8_t *start, unsigned size)
     }
 }
 
+#define SSDT_MISC_SIZE (sizeof(ssdt_misc_aml) - sizeof(AcpiTableHeader))
+
 static void
-build_ssdt(GArray *table_data, GArray *linker,
-           AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc,
-           PcPciInfo *pci, PcGuestInfo *guest_info)
+fill_ssdt_misc(uint8_t *dest, 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;
     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 +1091,27 @@ 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(dest, ssdt_ptr + sizeof(AcpiTableHeader), SSDT_MISC_SIZE);
+    g_free(ssdt_ptr);
+}
+
+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 +1436,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 size;
 
     assert(misc->dsdt_code && misc->dsdt_size);
 
-    dsdt = acpi_data_push(table_data, misc->dsdt_size);
+    size = misc->dsdt_size + SSDT_MISC_SIZE;
+    dsdt = acpi_data_push(table_data, size);
     memcpy(dsdt, misc->dsdt_code, misc->dsdt_size);
+    fill_ssdt_misc(((uint8_t *)dsdt) + misc->dsdt_size, pm, misc, pci);
 
     memset(dsdt, 0, sizeof *dsdt);
-    build_header(linker, table_data, dsdt, "DSDT",
-                 misc->dsdt_size, 1);
+    build_header(linker, table_data, dsdt, "DSDT", size, 1);
 }
 
 /* Build final rsdt table */
@@ -1591,7 +1607,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 +1620,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);
tests/acpi-test-data/pc/DSDT binary +0 -0
index ee9cc6781cea3a9515b9a176eea3459f8e4d8655..9bcc9ba9540f768afeba95231229e093b538d020 100644
GIT binary patch
tests/acpi-test-data/pc/SSDT binary +0 -0
index 558e4c85b031ec081045aec6cc382a680e9c6009..0dd46c68d186f6cb1fb7ee5ad935945fed4f31e8 100644
GIT binary patch
tests/acpi-test-data/q35/DSDT binary +0 -0
index ef0c75f4236de3e6f727e21991533f2bf8279dee..c30ec0462acee10c55e1035ba0e6798a0739dc35 100644
GIT binary patch
tests/acpi-test-data/q35/SSDT binary +0 -0
index 4e45510181c4038505ae1815b76799a2cd0e8808..3700bcc31e1469d4b9aafbf34963d937200a6f15 100644
GIT binary patch
Signature · 1 line
1.8.3.1
#2 lore raw

Re: [Qemu-devel] [PATCH v2 1/4] pc: append ssdt-misc.dsl to the DSDT

Quoted 1 line · On Wed, 24 Dec 2014 17:07:35 +0100 Paolo Bonzini <[email protected]> wrote:

This part of the ACPI tables can vary in size across machine types, but

s/machine types/QEMU versions/ since it doesn't change its size on machine type.

Quoted 1 line

does not depend on the command-line. It is an SSDT just because it is

s/does not/its size does not/

Quoted 1 line

the same for i440fx and Q35, and making it an SSDT made the code a bit

it's in SSDT because we are patching its values and DSDT were supposed to stay static (not only size but contents also).
I'd prefer to keep dynamic part in SSDT to maintain the same separation for now.

Quoted 2 lines

simpler. However, it also complicates backwards compatibility, so merge it with the DSDT.

What are these complications?

Quoted 175 lines
---
 hw/i386/acpi-build.c          |  55 +++++++++++++++++++++++++++---------------
 tests/acpi-test-data/pc/DSDT  | Bin 3592 -> 3920 bytes
 tests/acpi-test-data/pc/SSDT  | Bin 2279 -> 1951 bytes
 tests/acpi-test-data/q35/DSDT | Bin 8182 -> 8510 bytes
 tests/acpi-test-data/q35/SSDT | Bin 560 -> 232 bytes
 5 files changed, 35 insertions(+), 20 deletions(-)
hw/i386/acpi-build.c +35 -20
index a4d0c0c..e723fe1 100644
@@ -1061,26 +1061,18 @@ static void patch_pci_windows(PcPciInfo *pci, uint8_t *start, unsigned size)
     }
 }
 
+#define SSDT_MISC_SIZE (sizeof(ssdt_misc_aml) - sizeof(AcpiTableHeader))
+
 static void
-build_ssdt(GArray *table_data, GArray *linker,
-           AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc,
-           PcPciInfo *pci, PcGuestInfo *guest_info)
+fill_ssdt_misc(uint8_t *dest, 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;
     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 +1091,27 @@ 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(dest, ssdt_ptr + sizeof(AcpiTableHeader), SSDT_MISC_SIZE);
+    g_free(ssdt_ptr);
+}
+
+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 +1436,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 size;
 
     assert(misc->dsdt_code && misc->dsdt_size);
 
-    dsdt = acpi_data_push(table_data, misc->dsdt_size);
+    size = misc->dsdt_size + SSDT_MISC_SIZE;
+    dsdt = acpi_data_push(table_data, size);
     memcpy(dsdt, misc->dsdt_code, misc->dsdt_size);
+    fill_ssdt_misc(((uint8_t *)dsdt) + misc->dsdt_size, pm, misc, pci);
 
     memset(dsdt, 0, sizeof *dsdt);
-    build_header(linker, table_data, dsdt, "DSDT",
-                 misc->dsdt_size, 1);
+    build_header(linker, table_data, dsdt, "DSDT", size, 1);
 }
 
 /* Build final rsdt table */
@@ -1591,7 +1607,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 +1620,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);
tests/acpi-test-data/pc/DSDT binary +0 -0
index ee9cc6781cea3a9515b9a176eea3459f8e4d8655..9bcc9ba9540f768afeba95231229e093b538d020 100644
GIT binary patch
tests/acpi-test-data/pc/SSDT binary +0 -0
index 558e4c85b031ec081045aec6cc382a680e9c6009..0dd46c68d186f6cb1fb7ee5ad935945fed4f31e8 100644
GIT binary patch
tests/acpi-test-data/q35/DSDT binary +0 -0
index ef0c75f4236de3e6f727e21991533f2bf8279dee..c30ec0462acee10c55e1035ba0e6798a0739dc35 100644
GIT binary patch
tests/acpi-test-data/q35/SSDT binary +0 -0
index 4e45510181c4038505ae1815b76799a2cd0e8808..3700bcc31e1469d4b9aafbf34963d937200a6f15 100644
GIT binary patch
#3 lore raw

Re: [Qemu-devel] [PATCH v2 1/4] pc: append ssdt-misc.dsl to the DSDT

Quoted 6 lines · Igor Mammedov
Quoted 1 line · On Wed, 24 Dec 2014 17:07:35 +0100 Paolo Bonzini <[email protected]> wrote:

This part of the ACPI tables can vary in size across machine types, but

s/machine types/QEMU versions/ since it doesn't change its size on machine type.

Right.

Quoted 2 lines
Quoted 1 line

does not depend on the command-line. It is an SSDT just because it is

s/does not/its size does not/

Right.

Quoted 5 lines
Quoted 1 line

the same for i440fx and Q35, and making it an SSDT made the code a bit

it's in SSDT because we are patching its values and DSDT were supposed to stay static (not only size but contents also).
I'd prefer to keep dynamic part in SSDT to maintain the same separation for now.

The DSDT is being patched anyway for the SMC. So "the DSDT is dynamic, the SSDT is static" is not something that happens anyway. The truth is "the SSDT (apart from ssdt-misc) defines Devices each of which comes from a template". This patch removes the "apart from ssdt-misc" part, and also moves the patching of the SMC out of the per-machine-type AML, since it is shared anyway.

Quoted 3 lines
Quoted 2 lines

simpler. However, it also complicates backwards compatibility, so merge it with the DSDT.

What are these complications?

The complication arises if we want to make the SSDT exactly the same for all QEMU versions, given a (machine type, command line) pair. Then you either cannot do any change to ssdt-misc, or you have to keep different copies for each machine type.

Paolo

#4 lore raw

Re: [Qemu-devel] [PATCH v2 1/4] pc: append ssdt-misc.dsl to the DSDT

Quoted 23 lines · On Mon, 19 Jan 2015 16:41:26 +0100 Paolo Bonzini <[email protected]> wrote:
Quoted 6 lines · Igor Mammedov
Quoted 1 line · On Wed, 24 Dec 2014 17:07:35 +0100 Paolo Bonzini <[email protected]> wrote:

This part of the ACPI tables can vary in size across machine types, but

s/machine types/QEMU versions/ since it doesn't change its size on machine type.

Right.

Quoted 2 lines
Quoted 1 line

does not depend on the command-line. It is an SSDT just because it is

s/does not/its size does not/

Right.

Quoted 5 lines
Quoted 1 line

the same for i440fx and Q35, and making it an SSDT made the code a bit

it's in SSDT because we are patching its values and DSDT were supposed to stay static (not only size but contents also).
I'd prefer to keep dynamic part in SSDT to maintain the same separation for now.

Quoted 6 lines

The DSDT is being patched anyway for the SMC. So "the DSDT is dynamic, the SSDT is static" is not something that happens anyway. The truth is "the SSDT (apart from ssdt-misc) defines Devices each of which comes from a template". This patch removes the "apart from ssdt-misc" part, and also moves the patching of the SMC out of the per-machine-type AML, since it is shared anyway.

I'm fine with moving "SMC out of the per-machine-type AML", should be a separate patch anyway. But patch-able SMC being in DSDT is our mistake that we allowed it to slip there and should be better moved to SSDT rather than staying in DSDT and making thing more complex.
It's also candidate for trimming, i.e. dropping it from tables altogether if device is not present in QEMU, same applies to _S[34] Packages when respective features are disabled and to PEVT device template.

Quoted 9 lines
Quoted 4 lines
Quoted 3 lines

simpler. However, it also complicates backwards compatibility, so merge it with the DSDT.

What are these complications?

The complication arises if we want to make the SSDT exactly the same for all QEMU versions, given a (machine type, command line) pair. Then you either cannot do any change to ssdt-misc, or you have to keep different copies for each machine type.

With resizable ROM blobs in master, there shouldn't be an issue with migration in new QEMU versions if size of SSDT changes.
So question is if we still need SSDT version-ing and per machine type SSDT compatibility? /it's better not to do version-ing at all if it could be avoided, due to maintenance headache it brings along/

PS:
could you split binary/hex blobs update in separate patch(s), to simplify review/testing of series.

Quoted 2 lines

Paolo

#5 lore raw

Re: [Qemu-devel] [PATCH v2 1/4] pc: append ssdt-misc.dsl to the DSDT

Quoted 7 lines · Igor Mammedov

I'm fine with moving "SMC out of the per-machine-type AML", should be a separate patch anyway. But patch-able SMC being in DSDT is our mistake that we allowed it to slip there and should be better moved to SSDT rather than staying in DSDT and making thing more complex.
It's also candidate for trimming, i.e. dropping it from tables altogether if device is not present in QEMU, same applies to _S[34] Packages when respective features are disabled and to PEVT device template.

Yes, trimming is better than putting it in the DSDT, at least for simple devices such as SMC and pvpanic.

Quoted 11 lines
Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines

simpler. However, it also complicates backwards compatibility, so merge it with the DSDT.

What are these complications?

The complication arises if we want to make the SSDT exactly the same for all QEMU versions, given a (machine type, command line) pair. Then you either cannot do any change to ssdt-misc, or you have to keep different copies for each machine type.

With resizable ROM blobs in master, there shouldn't be an issue with migration in new QEMU versions if size of SSDT changes.

There is only a very small issue that remains (the RSDP pointer is wrong if the size changes), so we probably should apply anyway the patch of mine that allows the DSDT size to change; and we probably should pay attention to SSDT, and version it.

("Let's just ignore the SSDT" was exactly what I feared when I disagreed with putting in resizable ROM blobs first. But now that it's in, I cannot really argue otherwise).

Quoted 3 lines

So question is if we still need SSDT version-ing and per machine type SSDT compatibility? /it's better not to do version-ing at all if it could be avoided, due to maintenance headache it brings along/

I'm okay with re-evaluating that after your patches go in.

Paolo

#6 lore raw

Re: [Qemu-devel] [PATCH v2 1/4] pc: append ssdt-misc.dsl to the DSDT

Quoted 23 lines · Paolo Bonzini
Quoted 7 lines · Igor Mammedov

I'm fine with moving "SMC out of the per-machine-type AML", should be a separate patch anyway. But patch-able SMC being in DSDT is our mistake that we allowed it to slip there and should be better moved to SSDT rather than staying in DSDT and making thing more complex.
It's also candidate for trimming, i.e. dropping it from tables altogether if device is not present in QEMU, same applies to _S[34] Packages when respective features are disabled and to PEVT device template.

Yes, trimming is better than putting it in the DSDT, at least for simple devices such as SMC and pvpanic.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines

simpler. However, it also complicates backwards compatibility, so merge it with the DSDT.

What are these complications?

The complication arises if we want to make the SSDT exactly the same for all QEMU versions, given a (machine type, command line) pair. Then you either cannot do any change to ssdt-misc, or you have to keep different copies for each machine type.

Quoted 5 lines
Quoted 2 lines

With resizable ROM blobs in master, there shouldn't be an issue with migration in new QEMU versions if size of SSDT changes.

There is only a very small issue that remains (the RSDP pointer is wrong if the size changes),

Yes - for new machine types I'll send a patch to put it
in memory.
For old ones - there's a race, and it's painful to fix. If we do want to try fixing it, one solution is to fail migration if attempted before rsdp is shadowed. Useful?

Quoted 7 lines

so we probably should apply anyway the patch of
mine that allows the DSDT size to change; and we probably should pay attention to SSDT, and version it.

("Let's just ignore the SSDT" was exactly what I feared when I disagreed with putting in resizable ROM blobs first. But now that it's in, I cannot really argue otherwise).

I don't have a strong opinion here. you guys arrive at a rough consensus.:w

Quoted 7 lines
Quoted 3 lines

So question is if we still need SSDT version-ing and per machine type SSDT compatibility? /it's better not to do version-ing at all if it could be avoided, due to maintenance headache it brings along/

I'm okay with re-evaluating that after your patches go in.

Paolo

#7 lore raw

Re: [Qemu-devel] [PATCH v2 1/4] pc: append ssdt-misc.dsl to the DSDT

Quoted 27 lines · Michael S. Tsirkin
Quoted 26 lines · Paolo Bonzini
Quoted 7 lines · Igor Mammedov

I'm fine with moving "SMC out of the per-machine-type AML", should be a separate patch anyway. But patch-able SMC being in DSDT is our mistake that we allowed it to slip there and should be better moved to SSDT rather than staying in DSDT and making thing more complex.
It's also candidate for trimming, i.e. dropping it from tables altogether if device is not present in QEMU, same applies to _S[34] Packages when respective features are disabled and to PEVT device template.

Yes, trimming is better than putting it in the DSDT, at least for simple devices such as SMC and pvpanic.

Quoted 11 lines
Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines

simpler. However, it also complicates backwards compatibility, so merge it with the DSDT.

What are these complications?

The complication arises if we want to make the SSDT exactly the same for all QEMU versions, given a (machine type, command line) pair. Then you either cannot do any change to ssdt-misc, or you have to keep different copies for each machine type.

With resizable ROM blobs in master, there shouldn't be an issue with migration in new QEMU versions if size of SSDT changes.

Quoted 12 lines
Quoted 2 lines

There is only a very small issue that remains (the RSDP pointer is wrong if the size changes),

Yes - for new machine types I'll send a patch to put it
in memory.
For old ones - there's a race, and it's painful to fix. If we do want to try fixing it, one solution is to fail migration if attempted before rsdp is shadowed. Useful?

Quoted 3 lines

so we probably should apply anyway the patch of
mine that allows the DSDT size to change; and we probably should pay attention to SSDT, and version it.

Oh, missed that.
You mean this: "Add padding after the DSDT"? Right but e.g. Igor's patches likely move RSDT anyway, no?

Quoted 15 lines
Quoted 3 lines

("Let's just ignore the SSDT" was exactly what I feared when I disagreed with putting in resizable ROM blobs first. But now that it's in, I cannot really argue otherwise).

I don't have a strong opinion here. you guys arrive at a rough consensus.:w

Quoted 7 lines
Quoted 3 lines

So question is if we still need SSDT version-ing and per machine type SSDT compatibility? /it's better not to do version-ing at all if it could be avoided, due to maintenance headache it brings along/

I'm okay with re-evaluating that after your patches go in.

Paolo

#8 lore raw

Re: [Qemu-devel] [PATCH v2 1/4] pc: append ssdt-misc.dsl to the DSDT

Quoted 5 lines · Michael S. Tsirkin
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

so we probably should apply anyway the patch of
mine that allows the DSDT size to change; and we probably should pay attention to SSDT, and version it.

Oh, missed that.
You mean this: "Add padding after the DSDT"?

Yes.

Quoted 1 line

Right but e.g. Igor's patches likely move RSDT anyway, no?

Yes, but for future machine types we can be more careful.

Paolo

#9 lore raw

Re: [Qemu-devel] [PATCH v2 1/4] pc: append ssdt-misc.dsl to the DSDT

Quoted 9 lines · Paolo Bonzini
Quoted 5 lines · Michael S. Tsirkin
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

so we probably should apply anyway the patch of
mine that allows the DSDT size to change; and we probably should pay attention to SSDT, and version it.

Oh, missed that.
You mean this: "Add padding after the DSDT"?

Quoted 7 lines

Yes.

Quoted 1 line

Right but e.g. Igor's patches likely move RSDT anyway, no?

Yes, but for future machine types we can be more careful.

Paolo

Yes absolutely, I'm not arguing against these patches. I was merely observing that they probably won't help with the specific problem.

Signature · 1 line
MST
#10 lore raw

Re: [Qemu-devel] [PATCH v2 1/4] pc: append ssdt-misc.dsl to the DSDT

In reply to Michael S. Tsirkin
Quoted 12 lines · On Mon, 19 Jan 2015 21:29:57 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 11 lines · Paolo Bonzini
Quoted 7 lines · Igor Mammedov

I'm fine with moving "SMC out of the per-machine-type AML", should be a separate patch anyway. But patch-able SMC being in DSDT is our mistake that we allowed it to slip there and should be better moved to SSDT rather than staying in DSDT and making thing more complex.
It's also candidate for trimming, i.e. dropping it from tables altogether if device is not present in QEMU, same applies to _S[34] Packages when respective features are disabled and to PEVT device template.

Quoted 2 lines
Quoted 2 lines

Yes, trimming is better than putting it in the DSDT, at least for simple devices such as SMC and pvpanic.

So are we dropping 1-2/4 from this series?
I need to know on top of what to rebase. I'll take care of moving SMC to SSDT.

Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines

simpler. However, it also complicates backwards compatibility, so merge it with the DSDT.

What are these complications?

The complication arises if we want to make the SSDT exactly the same for all QEMU versions, given a (machine type, command line) pair. Then you either cannot do any change to ssdt-misc, or you have to keep different copies for each machine type.

With resizable ROM blobs in master, there shouldn't be an issue with migration in new QEMU versions if size of SSDT changes.

Quoted 8 lines
Quoted 2 lines

There is only a very small issue that remains (the RSDP pointer is wrong if the size changes),

Yes - for new machine types I'll send a patch to put it
in memory.
For old ones - there's a race, and it's painful to fix. If we do want to try fixing it, one solution is to fail migration if attempted before rsdp is shadowed. Useful?

There were my patches on list that move RSDT at the start of blob, which fixes issue for new machine types. That patches however weren't doing good job for old machine types. I can respin that series fixing new machines and we can fix old machines in separate patch later.

Quoted 20 lines
Quoted 8 lines

so we probably should apply anyway the patch of
mine that allows the DSDT size to change; and we probably should pay attention to SSDT, and version it.

("Let's just ignore the SSDT" was exactly what I feared when I disagreed with putting in resizable ROM blobs first. But now that it's in, I cannot really argue otherwise).

I don't have a strong opinion here. you guys arrive at a rough consensus.:w

Quoted 7 lines
Quoted 3 lines

So question is if we still need SSDT version-ing and per machine type SSDT compatibility? /it's better not to do version-ing at all if it could be avoided, due to maintenance headache it brings along/

I'm okay with re-evaluating that after your patches go in.

Paolo

#11 lore raw

Re: [Qemu-devel] [PATCH v2 1/4] pc: append ssdt-misc.dsl to the DSDT

Quoted 4 lines · Igor Mammedov
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Yes, trimming is better than putting it in the DSDT, at least for simple devices such as SMC and pvpanic.

So are we dropping 1-2/4 from this series?
I need to know on top of what to rebase. I'll take care of moving SMC to SSDT.

Do not rebase on anything. You go first.

Paolo

#12 lore raw

Re: [Qemu-devel] [PATCH v2 1/4] pc: append ssdt-misc.dsl to the DSDT

In reply to Igor Mammedov
Quoted 36 lines · Igor Mammedov
Quoted 12 lines · On Mon, 19 Jan 2015 21:29:57 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 11 lines · Paolo Bonzini
Quoted 7 lines · Igor Mammedov

I'm fine with moving "SMC out of the per-machine-type AML", should be a separate patch anyway. But patch-able SMC being in DSDT is our mistake that we allowed it to slip there and should be better moved to SSDT rather than staying in DSDT and making thing more complex.
It's also candidate for trimming, i.e. dropping it from tables altogether if device is not present in QEMU, same applies to _S[34] Packages when respective features are disabled and to PEVT device template.

Quoted 2 lines
Quoted 2 lines

Yes, trimming is better than putting it in the DSDT, at least for simple devices such as SMC and pvpanic.

So are we dropping 1-2/4 from this series?
I need to know on top of what to rebase. I'll take care of moving SMC to SSDT.

Quoted 16 lines
Quoted 15 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

simpler. However, it also complicates backwards compatibility, so merge it with the DSDT.

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line

What are these complications?

The complication arises if we want to make the SSDT exactly the same for all QEMU versions, given a (machine type, command line) pair. Then you either cannot do any change to ssdt-misc, or you have to keep different copies for each machine type.

With resizable ROM blobs in master, there shouldn't be an issue with migration in new QEMU versions if size of SSDT changes.

There is only a very small issue that remains (the RSDP pointer is wrong if the size changes),

Quoted 7 lines
Quoted 5 lines

Yes - for new machine types I'll send a patch to put it
in memory.
For old ones - there's a race, and it's painful to fix. If we do want to try fixing it, one solution is to fail migration if attempted before rsdp is shadowed. Useful?

There were my patches on list that move RSDT at the start of blob, which fixes issue for new machine types.

I don't see the point - IMO for new machine types, we can just put RSDP in a memory region, have it migrated.

Quoted 3 lines

That patches however
weren't doing good job for old machine types. I can respin that series fixing new machines and we can fix old machines in separate patch later.

I don't think it's worth it since I don't see an easy way for old machine types. A harder way would be to allow rom files to share an MR. We could then stick RSDP at the tail of the MR, and look for it on incoming migration: if there, fix it up.

Needs reworking of rom_add_blob API.

Quoted 20 lines
Quoted 20 lines
Quoted 8 lines

so we probably should apply anyway the patch of
mine that allows the DSDT size to change; and we probably should pay attention to SSDT, and version it.

("Let's just ignore the SSDT" was exactly what I feared when I disagreed with putting in resizable ROM blobs first. But now that it's in, I cannot really argue otherwise).

I don't have a strong opinion here. you guys arrive at a rough consensus.:w

Quoted 7 lines
Quoted 3 lines

So question is if we still need SSDT version-ing and per machine type SSDT compatibility? /it's better not to do version-ing at all if it could be avoided, due to maintenance headache it brings along/

I'm okay with re-evaluating that after your patches go in.

Paolo

#13 lore raw

Re: [Qemu-devel] [PATCH v2 1/4] pc: append ssdt-misc.dsl to the DSDT

Quoted 42 lines · On Tue, 20 Jan 2015 12:35:47 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 41 lines · Igor Mammedov
Quoted 12 lines · On Mon, 19 Jan 2015 21:29:57 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 11 lines · Paolo Bonzini
Quoted 7 lines · Igor Mammedov

I'm fine with moving "SMC out of the per-machine-type AML", should be a separate patch anyway. But patch-able SMC being in DSDT is our mistake that we allowed it to slip there and should be better moved to SSDT rather than staying in DSDT and making thing more complex.
It's also candidate for trimming, i.e. dropping it from tables altogether if device is not present in QEMU, same applies to _S[34] Packages when respective features are disabled and to PEVT device template.

Quoted 2 lines
Quoted 2 lines

Yes, trimming is better than putting it in the DSDT, at least for simple devices such as SMC and pvpanic.

So are we dropping 1-2/4 from this series?
I need to know on top of what to rebase. I'll take care of moving SMC to SSDT.

Quoted 21 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines

simpler. However, it also complicates backwards compatibility, so merge it with the DSDT.

What are these complications?

The complication arises if we want to make the SSDT exactly the same for all QEMU versions, given a (machine type, command line) pair. Then you either cannot do any change to ssdt-misc, or you have to keep different copies for each machine type.

Quoted 5 lines
Quoted 2 lines

With resizable ROM blobs in master, there shouldn't be an issue with migration in new QEMU versions if size of SSDT changes.

There is only a very small issue that remains (the RSDP pointer is wrong if the size changes),

Yes - for new machine types I'll send a patch to put it
in memory.
For old ones - there's a race, and it's painful to fix. If we do want to try fixing it, one solution is to fail migration if attempted before rsdp is shadowed. Useful?

Quoted 5 lines
Quoted 2 lines

There were my patches on list that move RSDT at the start of blob, which fixes issue for new machine types.

I don't see the point - IMO for new machine types, we can just put RSDP in a memory region, have it migrated.

you mean to put it into ROM blob, that should will cover not only migration issue but also reboot after bridge hotplug, since updated RSDP will be used.

Quoted 32 lines
Quoted 4 lines

That patches however
weren't doing good job for old machine types. I can respin that series fixing new machines and we can fix old machines in separate patch later.

I don't think it's worth it since I don't see an easy way for old machine types. A harder way would be to allow rom files to share an MR. We could then stick RSDP at the tail of the MR, and look for it on incoming migration: if there, fix it up.

Needs reworking of rom_add_blob API.

Quoted 20 lines
Quoted 20 lines
Quoted 8 lines

so we probably should apply anyway the patch of
mine that allows the DSDT size to change; and we probably should pay attention to SSDT, and version it.

("Let's just ignore the SSDT" was exactly what I feared when I disagreed with putting in resizable ROM blobs first. But now that it's in, I cannot really argue otherwise).

I don't have a strong opinion here. you guys arrive at a rough consensus.:w

Quoted 7 lines
Quoted 3 lines

So question is if we still need SSDT version-ing and per machine type SSDT compatibility? /it's better not to do version-ing at all if it could be avoided, due to maintenance headache it brings along/

I'm okay with re-evaluating that after your patches go in.

Paolo

#14 lore raw

Re: [Qemu-devel] [PATCH v2 1/4] pc: append ssdt-misc.dsl to the DSDT

Quoted 45 lines · Igor Mammedov
Quoted 42 lines · On Tue, 20 Jan 2015 12:35:47 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 41 lines · Igor Mammedov
Quoted 12 lines · On Mon, 19 Jan 2015 21:29:57 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 11 lines · Paolo Bonzini
Quoted 7 lines · Igor Mammedov

I'm fine with moving "SMC out of the per-machine-type AML", should be a separate patch anyway. But patch-able SMC being in DSDT is our mistake that we allowed it to slip there and should be better moved to SSDT rather than staying in DSDT and making thing more complex.
It's also candidate for trimming, i.e. dropping it from tables altogether if device is not present in QEMU, same applies to _S[34] Packages when respective features are disabled and to PEVT device template.

Quoted 2 lines
Quoted 2 lines

Yes, trimming is better than putting it in the DSDT, at least for simple devices such as SMC and pvpanic.

So are we dropping 1-2/4 from this series?
I need to know on top of what to rebase. I'll take care of moving SMC to SSDT.

Quoted 21 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines

simpler. However, it also complicates backwards compatibility, so merge it with the DSDT.

What are these complications?

The complication arises if we want to make the SSDT exactly the same for all QEMU versions, given a (machine type, command line) pair. Then you either cannot do any change to ssdt-misc, or you have to keep different copies for each machine type.

Quoted 5 lines
Quoted 2 lines

With resizable ROM blobs in master, there shouldn't be an issue with migration in new QEMU versions if size of SSDT changes.

There is only a very small issue that remains (the RSDP pointer is wrong if the size changes),

Yes - for new machine types I'll send a patch to put it
in memory.
For old ones - there's a race, and it's painful to fix. If we do want to try fixing it, one solution is to fail migration if attempted before rsdp is shadowed. Useful?

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

There were my patches on list that move RSDT at the start of blob, which fixes issue for new machine types.

I don't see the point - IMO for new machine types, we can just put RSDP in a memory region, have it migrated.

you mean to put it into ROM blob, that should will cover not only migration issue but also reboot after bridge hotplug, since updated RSDP will be used.

Exactly.
We can reuse the original rom blob but it's tricky given existing APIs.

Quoted 32 lines
Quoted 32 lines
Quoted 4 lines

That patches however
weren't doing good job for old machine types. I can respin that series fixing new machines and we can fix old machines in separate patch later.

I don't think it's worth it since I don't see an easy way for old machine types. A harder way would be to allow rom files to share an MR. We could then stick RSDP at the tail of the MR, and look for it on incoming migration: if there, fix it up.

Needs reworking of rom_add_blob API.

Quoted 20 lines
Quoted 20 lines
Quoted 8 lines

so we probably should apply anyway the patch of
mine that allows the DSDT size to change; and we probably should pay attention to SSDT, and version it.

("Let's just ignore the SSDT" was exactly what I feared when I disagreed with putting in resizable ROM blobs first. But now that it's in, I cannot really argue otherwise).

I don't have a strong opinion here. you guys arrive at a rough consensus.:w

Quoted 7 lines
Quoted 3 lines

So question is if we still need SSDT version-ing and per machine type SSDT compatibility? /it's better not to do version-ing at all if it could be avoided, due to maintenance headache it brings along/

I'm okay with re-evaluating that after your patches go in.

Paolo

#15 lore raw

Re: [Qemu-devel] [PATCH v2 1/4] pc: append ssdt-misc.dsl to the DSDT

In reply to Paolo Bonzini
Quoted 52 lines · Paolo Bonzini

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          |  55 +++++++++++++++++++++++++++---------------
 tests/acpi-test-data/pc/DSDT  | Bin 3592 -> 3920 bytes
 tests/acpi-test-data/pc/SSDT  | Bin 2279 -> 1951 bytes
 tests/acpi-test-data/q35/DSDT | Bin 8182 -> 8510 bytes
 tests/acpi-test-data/q35/SSDT | Bin 560 -> 232 bytes
 5 files changed, 35 insertions(+), 20 deletions(-)
hw/i386/acpi-build.c +5 -13
index a4d0c0c..e723fe1 100644
@@ -1061,26 +1061,18 @@ static void patch_pci_windows(PcPciInfo *pci, uint8_t *start, unsigned size)
     }
 }
 
+#define SSDT_MISC_SIZE (sizeof(ssdt_misc_aml) - sizeof(AcpiTableHeader))
+
 static void
-build_ssdt(GArray *table_data, GArray *linker,
-           AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc,
-           PcPciInfo *pci, PcGuestInfo *guest_info)
+fill_ssdt_misc(uint8_t *dest, 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;
     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';
     }

hw/i386/acpi-build.c build_ssdt(GArray *table_data, GArray *linker, · line 1096

Quoted 6 lines
hw/i386/acpi-build.c +3 -0
@@ -1099,6 +1091,27 @@ 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(dest, ssdt_ptr + sizeof(AcpiTableHeader), SSDT_MISC_SIZE);
+    g_free(ssdt_ptr);
+}

We are trying to avoid low-level memory manipulation around acpi generation.
Maybe you can rewrite it to push the data into GArray? After all, that's what rest of the code uses.

Quoted 29 lines
hw/i386/acpi-build.c +20 -1
+
+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 +1436,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)
 {

hw/i386/acpi-build.c build_dmar_q35(GArray *table_data, GArray *linker) · line 1450

Quoted 10 lines
hw/i386/acpi-build.c +4 -1
     AcpiTableHeader *dsdt;
+    size_t size;
 
     assert(misc->dsdt_code && misc->dsdt_size);
 
-    dsdt = acpi_data_push(table_data, misc->dsdt_size);
+    size = misc->dsdt_size + SSDT_MISC_SIZE;
+    dsdt = acpi_data_push(table_data, size);
     memcpy(dsdt, misc->dsdt_code, misc->dsdt_size);
+    fill_ssdt_misc(((uint8_t *)dsdt) + misc->dsdt_size, pm, misc, pci);

I prefer avoiding pointer math above.
If doing pushes here, I would do:

AcpiTableHeader *dsdt = acpi_data_push(table_data, misc->dsdt_size); AcpiTableHeader *ssdt = acpi_data_push(table_data, SSDT_MISC_SIZE);

hw/i386/acpi-build.c build_dmar_q35(GArray *table_data, GArray *linker) · line 1453

Quoted 5 lines
hw/i386/acpi-build.c +1 -2
     memset(dsdt, 0, sizeof *dsdt);
-    build_header(linker, table_data, dsdt, "DSDT",
-                 misc->dsdt_size, 1);
+    build_header(linker, table_data, dsdt, "DSDT", size, 1);

You can just save the size at start of function, then replace size with

    table_data->len - dsdt_start

like we do e.g. for dmar.

tests/acpi-test-data/q35/SSDT

Quoted 77 lines
hw/i386/acpi-build.c +2 -3
 }
 
 /* Build final rsdt table */
@@ -1591,7 +1607,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 +1620,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);
tests/acpi-test-data/pc/DSDT binary +0 -0
index ee9cc6781cea3a9515b9a176eea3459f8e4d8655..9bcc9ba9540f768afeba95231229e093b538d020 100644
GIT binary patch
tests/acpi-test-data/pc/SSDT binary +0 -0
index 558e4c85b031ec081045aec6cc382a680e9c6009..0dd46c68d186f6cb1fb7ee5ad935945fed4f31e8 100644
GIT binary patch
tests/acpi-test-data/q35/DSDT binary +0 -0
index ef0c75f4236de3e6f727e21991533f2bf8279dee..c30ec0462acee10c55e1035ba0e6798a0739dc35 100644
GIT binary patch
tests/acpi-test-data/q35/SSDT binary +0 -0
index 4e45510181c4038505ae1815b76799a2cd0e8808..3700bcc31e1469d4b9aafbf34963d937200a6f15 100644
GIT binary patch

Binary diffs break whenever I rebase, no need to include them - just remind in commit log that they need to be updated.

Quoted 4 lines
Signature · 1 line
1.8.3.1
#16 lore raw

PATCH v2 2/4 pc: rename ssdt-misc to dsdt-common

In reply to Paolo Bonzini

All the changes to generated files are in the header, so there is no need to rebuild test data.

---
 hw/i386/Makefile.objs                              |  2 +-
 hw/i386/acpi-build.c                               | 36 +++++++++++-----------
 hw/i386/{ssdt-misc.dsl => acpi-dsdt-common.dsl}    |  8 ++---
 ...ex.generated => acpi-dsdt-common.hex.generated} | 30 +++++++++---------
 hw/i386/acpi-dsdt.dsl                              |  2 +-
 5 files changed, 39 insertions(+), 39 deletions(-)
 rename hw/i386/{ssdt-misc.dsl => acpi-dsdt-common.dsl} (94%)
 rename hw/i386/{ssdt-misc.hex.generated => acpi-dsdt-common.hex.generated} (93%)
hw/i386/Makefile.objs +1 -1
index 9d419ad..fe6b846 100644
@@ -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 +18 -18
index e723fe1..c0b3c04 100644
@@ -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"
 
@@ -1061,38 +1061,38 @@ static void patch_pci_windows(PcPciInfo *pci, uint8_t *start, unsigned size)
     }
 }
 
-#define SSDT_MISC_SIZE (sizeof(ssdt_misc_aml) - sizeof(AcpiTableHeader))
+#define DSDT_COMMON_SIZE (sizeof(dsdt_common_aml) - sizeof(AcpiTableHeader))
 
 static void
-fill_ssdt_misc(uint8_t *dest, AcpiPmInfo *pm, AcpiMiscInfo *misc,
-               PcPciInfo *pci)
+fill_dsdt_common(uint8_t *dest, AcpiPmInfo *pm, AcpiMiscInfo *misc,
+                 PcPciInfo *pci)
 {
     MachineState *machine = MACHINE(qdev_get_machine());
     uint32_t nr_mem = machine->ram_slots;
-    uint8_t *ssdt_ptr;
+    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(dest, ssdt_ptr + sizeof(AcpiTableHeader), SSDT_MISC_SIZE);
-    g_free(ssdt_ptr);
+    memcpy(dest, dsdt_ptr + sizeof(AcpiTableHeader), DSDT_COMMON_SIZE);
+    g_free(dsdt_ptr);
 }
 
 static void
@@ -1444,10 +1444,10 @@ build_dsdt(GArray *table_data, GArray *linker, AcpiPmInfo *pm,
 
     assert(misc->dsdt_code && misc->dsdt_size);
 
-    size = misc->dsdt_size + SSDT_MISC_SIZE;
+    size = misc->dsdt_size + DSDT_COMMON_SIZE;
     dsdt = acpi_data_push(table_data, size);
     memcpy(dsdt, misc->dsdt_code, misc->dsdt_size);
-    fill_ssdt_misc(((uint8_t *)dsdt) + misc->dsdt_size, pm, misc, pci);
+    fill_dsdt_common(((uint8_t *)dsdt) + misc->dsdt_size, pm, misc, pci);
 
     memset(dsdt, 0, sizeof *dsdt);
     build_header(linker, table_data, dsdt, "DSDT", size, 1);
hw/i386/acpi-dsdt-common.dsl renamed from hw/i386/ssdt-misc.dsl +4 -4
similarity index 94%
rename from hw/i386/ssdt-misc.dsl
rename to hw/i386/acpi-dsdt-common.dsl
index 1e3baae..f7849c0 100644
@@ -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 +15 -15
similarity index 93%
rename from hw/i386/ssdt-misc.hex.generated
rename to hw/i386/acpi-dsdt-common.hex.generated
index cbcf61d..5127845 100644
@@ -4,8 +4,8 @@ static unsigned char acpi_pci64_length[] = {
 static unsigned char acpi_s4_pkg[] = {
 0x99
 };
-static unsigned char ssdt_mctrl_nr_slots[] = {
-0x7d
+static unsigned char acpi_s4_name[] = {
+0x92
 };
 static unsigned char acpi_s3_name[] = {
 0x86
@@ -16,7 +16,10 @@ static unsigned char acpi_pci32_start[] = {
 static unsigned char acpi_pci64_valid[] = {
 0x43
 };
-static unsigned char ssdp_misc_aml[] = {
+static unsigned char dsdt_isa_pest[] = {
+0xda
+};
+static unsigned char dsdt_common_aml[] = {
 0x53,
 0x53,
 0x44,
@@ -26,7 +29,7 @@ static unsigned char ssdp_misc_aml[] = {
 0x0,
 0x0,
 0x1,
-0x3,
+0x2f,
 0x42,
 0x58,
 0x50,
@@ -39,8 +42,8 @@ static unsigned char ssdp_misc_aml[] = {
 0x53,
 0x44,
 0x54,
-0x53,
-0x55,
+0x43,
+0x4f,
 0x1,
 0x0,
 0x0,
@@ -49,9 +52,9 @@ static unsigned char ssdp_misc_aml[] = {
 0x4e,
 0x54,
 0x4c,
-0x28,
-0x8,
-0x14,
+0x13,
+0x9,
+0x12,
 0x20,
 0x10,
 0x4c,
@@ -382,12 +385,6 @@ static unsigned char ssdp_misc_aml[] = {
 0x4d,
 0x58
 };
-static unsigned char ssdt_isa_pest[] = {
-0xda
-};
-static unsigned char acpi_s4_name[] = {
-0x92
-};
 static unsigned char acpi_pci64_start[] = {
 0x4d
 };
@@ -397,3 +394,6 @@ static unsigned char acpi_pci64_end[] = {
 static unsigned char acpi_pci32_end[] = {
 0x39
 };
+static unsigned char dsdt_mctrl_nr_slots[] = {
+0x7d
+};
hw/i386/acpi-dsdt.dsl +1 -1
index a611e07..e50efeb 100644
@@ -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
#17 lore raw

[Qemu-devel] [PATCH v2 5/4] pc: introduce new ACPI table sizing algorithm

In reply to Paolo Bonzini

Add 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
index 63f3d80..1bb3222 100644
@@ -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, ...)        \
@@ -1614,6 +1612,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);
@@ -1696,15 +1698,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
index 220f741..16de5c9 100644
@@ -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
index e475b92..70fb47c 100644
@@ -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
#18 lore raw

Re: [Qemu-devel] [PATCH v2 5/4] pc: introduce new ACPI table sizing algorithm

Quoted 64 lines · Paolo Bonzini

Add 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
index 63f3d80..1bb3222 100644
@@ -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, ...)        \
@@ -1614,6 +1612,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);
@@ -1696,15 +1698,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 +0 -0
index 220f741..16de5c9 100644

hw/i386/pc_piix.c static const int ide_irq[MAX_IDE_BUS] = { 14, 15 }; · line 65

Quoted 5 lines
hw/i386/pc_piix.c +2 -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;

I prefer hex please: 0x20000

Quoted 37 lines
hw/i386/pc_piix.c +3 -0
 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
index e475b92..70fb47c 100644
@@ -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
#19 lore raw

PATCH v2 3/4 pc: move common parts of the DSDT to dsdt-common

In reply to Paolo Bonzini
---
 hw/i386/acpi-build.c                   |   12 +-
 hw/i386/acpi-dsdt-common.dsl           |   14 +-
 hw/i386/acpi-dsdt-common.hex.generated | 1578 +++++++++++++++-
 hw/i386/acpi-dsdt-isa.dsl              |    6 +-
 hw/i386/acpi-dsdt.dsl                  |   10 +-
 hw/i386/acpi-dsdt.hex.generated        | 3119 +++++++++-----------------------
 hw/i386/q35-acpi-dsdt.dsl              |    9 +-
 hw/i386/q35-acpi-dsdt.hex.generated    | 2787 +++++++---------------------
 tests/acpi-test-data/pc/DSDT           |  Bin 3920 -> 3923 bytes
 tests/acpi-test-data/q35/DSDT          |  Bin 8510 -> 8513 bytes
 10 files changed, 3020 insertions(+), 4515 deletions(-)
hw/i386/acpi-build.c +4 -8
index c0b3c04..63f3d80 100644
@@ -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,17 +124,11 @@ 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) =
-        applesmc_find() ? 0x0b : 0x00;
 }
 
 static
@@ -715,7 +709,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"
 
@@ -1091,6 +1084,9 @@ fill_dsdt_common(uint8_t *dest, AcpiPmInfo *pm, AcpiMiscInfo *misc,
     ACPI_BUILD_SET_LE(dsdt_ptr, sizeof(dsdt_common_aml),
                       dsdt_mctrl_nr_slots[0], 32, nr_mem);
 
+    /* Patch in appropriate value for AppleSMC _STA */
+    dsdt_ptr[dsdt_applesmc_sta[0]]= applesmc_find() ? 0x0b : 0x00;
+
     memcpy(dest, dsdt_ptr + sizeof(AcpiTableHeader), DSDT_COMMON_SIZE);
     g_free(dsdt_ptr);
 }
hw/i386/acpi-dsdt-common.dsl +11 -3
index f7849c0..1929f8f 100644
@@ -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-common.hex.generated +1538 -40

1,614 lines not on this page · raw message

hw/i386/acpi-dsdt-isa.dsl +5 -1
index deb37de..a8851b0 100644
@@ -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
index e50efeb..71d1e3f 100644
@@ -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/acpi-dsdt.hex.generated +812 -2307

1,237 lines not on this page · raw message

hw/i386/q35-acpi-dsdt.dsl +2 -7
index e1cee5d..398aec1 100644

Lines of this file are not shown. View the raw message.

hw/i386/q35-acpi-dsdt.hex.generated +646 -2141

2,787 lines not on this page · raw message

tests/acpi-test-data/pc/DSDT binary +0 -0
index 9bcc9ba9540f768afeba95231229e093b538d020..76edb15b23cf1f9a0fcdb17807492553c1115b61 100644
GIT binary patch
tests/acpi-test-data/q35/DSDT binary +0 -0
index c30ec0462acee10c55e1035ba0e6798a0739dc35..fb79eb4ed84fc0e95aa7a1eb6c64b941cec321d1 100644
GIT binary patch

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.8.3.1

Part of the diff is not shown here. View the raw message.

#20 lore raw

[Qemu-devel] [PATCH v2 6/4] pc: clean up pre-2.1 compatibility code

In reply to Paolo Bonzini

Now 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
index 1bb3222..df930b7 100644
@@ -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
@@ -1688,10 +1688,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.");
@@ -1707,8 +1706,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
#21 lore raw

[Qemu-devel] [PATCH v2 7/4] pc: go back to smaller ACPI tables

In reply to Paolo Bonzini

The 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]
---
 hw/i386/pc_piix.c | 6 ++++--
 hw/i386/pc_q35.c  | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)
hw/i386/pc_piix.c +4 -2
index 16de5c9..a5e36b9 100644
@@ -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)
hw/i386/pc_q35.c +4 -2
index 7ba0535..4fd9527 100644
@@ -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
#22 lore raw

Re: [Qemu-devel] [PATCH v2 7/4] pc: go back to smaller ACPI tables

Quoted 32 lines · Paolo Bonzini

The 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]
---
 hw/i386/pc_piix.c | 6 ++++--
 hw/i386/pc_q35.c  | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)
hw/i386/pc_piix.c +0 -0
index 16de5c9..a5e36b9 100644

hw/i386/pc_piix.c static const int ide_irq[MAX_IDE_BUS] = { 14, 15 }; · line 65

Quoted 7 lines
hw/i386/pc_piix.c +2 -2
@@ -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;

same here - hex please.

Quoted 31 lines
hw/i386/pc_piix.c +2 -0
 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)
hw/i386/pc_q35.c +4 -2
index 7ba0535..4fd9527 100644
@@ -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
MST
#23 lore raw

PATCH v2 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
index 1929f8f..19e9753 100644
@@ -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
#24 lore raw

Re: [Qemu-devel] [PATCH v2 4/4] pc: merge DSDT common parts into acpi-dsdt-common.dsl

Quoted 1 line · Paolo Bonzini

This isn't a dependency of patches 5 and on, is it?

Quoted 793 lines
---
 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
index 1929f8f..19e9753 100644
@@ -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
deleted file mode 100644
index 86230f7..0000000
@@ -1,41 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-/****************************************************************
- * 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)
-    }
-}
hw/i386/acpi-dsdt-hpet.dsl deleted +0 -48
deleted file mode 100644
index 44961b8..0000000
@@ -1,48 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-/****************************************************************
- * 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
-                )
-        })
-    }
-}
hw/i386/acpi-dsdt-isa.dsl deleted +0 -132
deleted file mode 100644
index a8851b0..0000000
@@ -1,132 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-/* 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 }
-        })
-    }
-}
hw/i386/acpi-dsdt-mem-hotplug.dsl deleted +0 -176
deleted file mode 100644
index 2a36c47..0000000
@@ -1,176 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-    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()
Signature · 1 line
1.8.3.1
#25 lore raw

Re: [Qemu-devel] [PATCH v2 4/4] pc: merge DSDT common parts into acpi-dsdt-common.dsl

Quoted 3 lines · Michael S. Tsirkin
Quoted 1 line · Paolo Bonzini
Quoted 1 line

This isn't a dependency of patches 5 and on, is it?

No, it isn't.

Paolo

#26 lore raw

Re: [Qemu-devel] [PATCH v2 4/4] pc: merge DSDT common parts into acpi-dsdt-common.dsl

Quoted 10 lines · Paolo Bonzini
Quoted 3 lines · Michael S. Tsirkin
Quoted 1 line · Paolo Bonzini
Quoted 1 line

This isn't a dependency of patches 5 and on, is it?

No, it isn't.

Paolo

In that case maybe you can comment (in commit log too) on why you think it's preferable to put them all in a single file.