Skip to contentSkip to conversation

acpi: switch to a dummy SSDT

PATCH In review Michael S. Tsirkin 3 participants 8 messages Jan 9, 2018 – Jan 10, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 acpi: switch to a dummy SSDT

We prefer not changing table sizes depending on parameters, that's why we create a dummy table rather than just drop the MCFG table.

However, a table named "QEMU" could be put to a better use than just a stub, e.g. we could use it to pass some QEMU specific info to guests.

Replace with an SSDT and pad with the Nop opcode to preserve the length.

---
 hw/i386/acpi-build.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
hw/i386/acpi-build.c +12 -5
index 73519ab..d0afb31e 100644
@@ -2419,6 +2419,8 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
 {
     AcpiTableMcfg *mcfg;
     const char *sig;
+    const char *oem;
+    const char *oem_id;
     int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
 
     mcfg = acpi_data_push(table_data, len);
@@ -2431,16 +2433,21 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
     /* MCFG is used for ECAM which can be enabled or disabled by guest.
      * To avoid table size changes (which create migration issues),
      * always create the table even if there are no allocations,
-     * but set the signature to a reserved value in this case.
-     * ACPI spec requires OSPMs to ignore such tables.
+     * but fill it with Noop values.
+     * OSPMs ignore such tables.
      */
     if (info->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
-        /* Reserved signature: ignored by OSPM */
-        sig = "QEMU";
+        sig = "SSDT";
+        oem = "QEMU ";
+        oem_id = "NOOP";
+        /* 0xa3 - NoopOp */
+        memset(&mcfg->reserved, 0xa3, len - offsetof(AcpiTableMcfg, reserved));
     } else {
         sig = "MCFG";
+        oem = NULL;
+        oem_id = NULL;
     }
-    build_header(linker, table_data, (void *)mcfg, sig, len, 1, NULL, NULL);
+    build_header(linker, table_data, (void *)mcfg, sig, len, 1, oem, oem_id);
 }
 
 /*
Signature · 1 line
MST
#1 lore raw
Quoted 10 lines · On Tue, 9 Jan 2018 15:58:11 +0200 "Michael S. Tsirkin" <[email protected]> wrote:

We prefer not changing table sizes depending on parameters, that's why we create a dummy table rather than just drop the MCFG table.

However, a table named "QEMU" could be put to a better use than just a stub, e.g. we could use it to pass some QEMU specific info to guests.

Replace with an SSDT and pad with the Nop opcode to preserve the length.

Not sure it's useful, do you have patches on top of that, which will use this?

Quoted 45 lines
---
 hw/i386/acpi-build.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
hw/i386/acpi-build.c +12 -5
index 73519ab..d0afb31e 100644
@@ -2419,6 +2419,8 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
 {
     AcpiTableMcfg *mcfg;
     const char *sig;
+    const char *oem;
+    const char *oem_id;
     int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
 
     mcfg = acpi_data_push(table_data, len);
@@ -2431,16 +2433,21 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
     /* MCFG is used for ECAM which can be enabled or disabled by guest.
      * To avoid table size changes (which create migration issues),
      * always create the table even if there are no allocations,
-     * but set the signature to a reserved value in this case.
-     * ACPI spec requires OSPMs to ignore such tables.
+     * but fill it with Noop values.
+     * OSPMs ignore such tables.
      */
     if (info->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
-        /* Reserved signature: ignored by OSPM */
-        sig = "QEMU";
+        sig = "SSDT";
+        oem = "QEMU ";
+        oem_id = "NOOP";
+        /* 0xa3 - NoopOp */
+        memset(&mcfg->reserved, 0xa3, len - offsetof(AcpiTableMcfg, reserved));
     } else {
         sig = "MCFG";
+        oem = NULL;
+        oem_id = NULL;
     }
-    build_header(linker, table_data, (void *)mcfg, sig, len, 1, NULL, NULL);
+    build_header(linker, table_data, (void *)mcfg, sig, len, 1, oem, oem_id);
 }
 
 /*
#2 lore raw
Quoted 7 lines · Igor Mammedov
Quoted 4 lines · On Tue, 9 Jan 2018 15:58:11 +0200 "Michael S. Tsirkin" <[email protected]> wrote:

We prefer not changing table sizes depending on parameters, that's why we create a dummy table rather than just drop the MCFG table.

Quoted 7 lines
Quoted 6 lines

However, a table named "QEMU" could be put to a better use than just a stub, e.g. we could use it to pass some QEMU specific info to guests.

Replace with an SSDT and pad with the Nop opcode to preserve the length.

Not sure it's useful, do you have patches on top of that, which will use this?

Yes but not me - Stefan (Cc'd) wants to add a custom table.

Quoted 46 lines
Quoted 46 lines
---
 hw/i386/acpi-build.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
hw/i386/acpi-build.c +12 -5
index 73519ab..d0afb31e 100644
@@ -2419,6 +2419,8 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
 {
     AcpiTableMcfg *mcfg;
     const char *sig;
+    const char *oem;
+    const char *oem_id;
     int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
 
     mcfg = acpi_data_push(table_data, len);
@@ -2431,16 +2433,21 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
     /* MCFG is used for ECAM which can be enabled or disabled by guest.
      * To avoid table size changes (which create migration issues),
      * always create the table even if there are no allocations,
-     * but set the signature to a reserved value in this case.
-     * ACPI spec requires OSPMs to ignore such tables.
+     * but fill it with Noop values.
+     * OSPMs ignore such tables.
      */
     if (info->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
-        /* Reserved signature: ignored by OSPM */
-        sig = "QEMU";
+        sig = "SSDT";
+        oem = "QEMU ";
+        oem_id = "NOOP";
+        /* 0xa3 - NoopOp */
+        memset(&mcfg->reserved, 0xa3, len - offsetof(AcpiTableMcfg, reserved));
     } else {
         sig = "MCFG";
+        oem = NULL;
+        oem_id = NULL;
     }
-    build_header(linker, table_data, (void *)mcfg, sig, len, 1, NULL, NULL);
+    build_header(linker, table_data, (void *)mcfg, sig, len, 1, oem, oem_id);
 }
 
 /*
#3 lore raw
Quoted 12 lines · On Wed, 10 Jan 2018 13:29:09 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 11 lines · Igor Mammedov
Quoted 8 lines · On Tue, 9 Jan 2018 15:58:11 +0200 "Michael S. Tsirkin" <[email protected]> wrote:

We prefer not changing table sizes depending on parameters, that's why we create a dummy table rather than just drop the MCFG table.

However, a table named "QEMU" could be put to a better use than just a stub, e.g. we could use it to pass some QEMU specific info to guests.

Quoted 5 lines
Quoted 3 lines
Quoted 2 lines

Replace with an SSDT and pad with the Nop opcode to preserve the length.

Not sure it's useful, do you have patches on top of that, which will use this?

Yes but not me - Stefan (Cc'd) wants to add a custom table.

Re-purposing dummy table that might become not dummy doesn't look like good approach. What if later the guest enables MCFG and reboots, DUMMY SSDT would be replaced by MCFG?

It'd be cleaner if Stefan would just use his own dedicated SSDT.

Quoted 46 lines
Quoted 46 lines
Quoted 46 lines
---
 hw/i386/acpi-build.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
hw/i386/acpi-build.c +12 -5
index 73519ab..d0afb31e 100644
@@ -2419,6 +2419,8 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
 {
     AcpiTableMcfg *mcfg;
     const char *sig;
+    const char *oem;
+    const char *oem_id;
     int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
 
     mcfg = acpi_data_push(table_data, len);
@@ -2431,16 +2433,21 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
     /* MCFG is used for ECAM which can be enabled or disabled by guest.
      * To avoid table size changes (which create migration issues),
      * always create the table even if there are no allocations,
-     * but set the signature to a reserved value in this case.
-     * ACPI spec requires OSPMs to ignore such tables.
+     * but fill it with Noop values.
+     * OSPMs ignore such tables.
      */
     if (info->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
-        /* Reserved signature: ignored by OSPM */
-        sig = "QEMU";
+        sig = "SSDT";
+        oem = "QEMU ";
+        oem_id = "NOOP";
+        /* 0xa3 - NoopOp */
+        memset(&mcfg->reserved, 0xa3, len - offsetof(AcpiTableMcfg, reserved));
     } else {
         sig = "MCFG";
+        oem = NULL;
+        oem_id = NULL;
     }
-    build_header(linker, table_data, (void *)mcfg, sig, len, 1, NULL, NULL);
+    build_header(linker, table_data, (void *)mcfg, sig, len, 1, oem, oem_id);
 }
 
 /*
#4 lore raw
Quoted 15 lines · Igor Mammedov
Quoted 12 lines · On Wed, 10 Jan 2018 13:29:09 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 11 lines · Igor Mammedov
Quoted 8 lines · On Tue, 9 Jan 2018 15:58:11 +0200 "Michael S. Tsirkin" <[email protected]> wrote:

We prefer not changing table sizes depending on parameters, that's why we create a dummy table rather than just drop the MCFG table.

However, a table named "QEMU" could be put to a better use than just a stub, e.g. we could use it to pass some QEMU specific info to guests.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines

Replace with an SSDT and pad with the Nop opcode to preserve the length.

Not sure it's useful, do you have patches on top of that, which will use this?

Yes but not me - Stefan (Cc'd) wants to add a custom table.

Re-purposing dummy table that might become not dummy doesn't look like good approach. What if later the guest enables MCFG and reboots, DUMMY SSDT would be replaced by MCFG?

So what's the issue? Why is this worse than a dummy QEMU table? There's actually no re-purposing here at all. Either we create an MCFG or an SSDT. We never re-purpose.

Quoted 1 line

It'd be cleaner if Stefan would just use his own dedicated SSDT.

SSDT doesn't always work. A data table is needed so e.g. seabios can process it easily.

Quoted 46 lines
Quoted 46 lines
Quoted 46 lines
Quoted 46 lines
---
 hw/i386/acpi-build.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
hw/i386/acpi-build.c +12 -5
index 73519ab..d0afb31e 100644
@@ -2419,6 +2419,8 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
 {
     AcpiTableMcfg *mcfg;
     const char *sig;
+    const char *oem;
+    const char *oem_id;
     int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
 
     mcfg = acpi_data_push(table_data, len);
@@ -2431,16 +2433,21 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
     /* MCFG is used for ECAM which can be enabled or disabled by guest.
      * To avoid table size changes (which create migration issues),
      * always create the table even if there are no allocations,
-     * but set the signature to a reserved value in this case.
-     * ACPI spec requires OSPMs to ignore such tables.
+     * but fill it with Noop values.
+     * OSPMs ignore such tables.
      */
     if (info->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
-        /* Reserved signature: ignored by OSPM */
-        sig = "QEMU";
+        sig = "SSDT";
+        oem = "QEMU ";
+        oem_id = "NOOP";
+        /* 0xa3 - NoopOp */
+        memset(&mcfg->reserved, 0xa3, len - offsetof(AcpiTableMcfg, reserved));
     } else {
         sig = "MCFG";
+        oem = NULL;
+        oem_id = NULL;
     }
-    build_header(linker, table_data, (void *)mcfg, sig, len, 1, NULL, NULL);
+    build_header(linker, table_data, (void *)mcfg, sig, len, 1, oem, oem_id);
 }
 
 /*
#5 lore raw
Quoted 20 lines · On Wed, 10 Jan 2018 13:55:37 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 19 lines · Igor Mammedov
Quoted 16 lines · On Wed, 10 Jan 2018 13:29:09 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 14 lines · Igor Mammedov
Quoted 10 lines · On Tue, 9 Jan 2018 15:58:11 +0200 "Michael S. Tsirkin" <[email protected]> wrote:

We prefer not changing table sizes depending on parameters, that's why we create a dummy table rather than just drop the MCFG table.

However, a table named "QEMU" could be put to a better use than just a stub, e.g. we could use it to pass some QEMU specific info to guests.

Replace with an SSDT and pad with the Nop opcode to preserve the length.

Not sure it's useful, do you have patches on top of that, which will use this?

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Yes but not me - Stefan (Cc'd) wants to add a custom table.

Re-purposing dummy table that might become not dummy doesn't look like good approach. What if later the guest enables MCFG and reboots, DUMMY SSDT would be replaced by MCFG?

So what's the issue? Why is this worse than a dummy QEMU table? There's actually no re-purposing here at all. Either we create an MCFG or an SSDT. We never re-purpose.

I think, I've misread commit message, so it's table name 'QEMU' that's going to be reused.

Having several tables with name QEMU shouldn't be an issue, adding oem/oem_id should be sufficient to distinguish them for parsing side (if there is any).

As for change from ignored table to always parsed SSDT table, having ignored one seems better.
So I'd drop SSDT+memset and keep oem[id] parts in this patch.

Quoted 51 lines
Quoted 1 line

It'd be cleaner if Stefan would just use his own dedicated SSDT.

SSDT doesn't always work. A data table is needed so e.g. seabios can process it easily.

Quoted 46 lines
Quoted 46 lines
Quoted 46 lines
Quoted 46 lines
---
 hw/i386/acpi-build.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
hw/i386/acpi-build.c +12 -5
index 73519ab..d0afb31e 100644
@@ -2419,6 +2419,8 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
 {
     AcpiTableMcfg *mcfg;
     const char *sig;
+    const char *oem;
+    const char *oem_id;
     int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
 
     mcfg = acpi_data_push(table_data, len);
@@ -2431,16 +2433,21 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
     /* MCFG is used for ECAM which can be enabled or disabled by guest.
      * To avoid table size changes (which create migration issues),
      * always create the table even if there are no allocations,
-     * but set the signature to a reserved value in this case.
-     * ACPI spec requires OSPMs to ignore such tables.
+     * but fill it with Noop values.
+     * OSPMs ignore such tables.
      */
     if (info->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
-        /* Reserved signature: ignored by OSPM */
-        sig = "QEMU";
+        sig = "SSDT";
+        oem = "QEMU ";
+        oem_id = "NOOP";
+        /* 0xa3 - NoopOp */
+        memset(&mcfg->reserved, 0xa3, len - offsetof(AcpiTableMcfg, reserved));
     } else {
         sig = "MCFG";
+        oem = NULL;
+        oem_id = NULL;
     }
-    build_header(linker, table_data, (void *)mcfg, sig, len, 1, NULL, NULL);
+    build_header(linker, table_data, (void *)mcfg, sig, len, 1, oem, oem_id);
 }
 
 /*  
#6 lore raw
Quoted 30 lines · Igor Mammedov
Quoted 20 lines · On Wed, 10 Jan 2018 13:55:37 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 19 lines · Igor Mammedov
Quoted 16 lines · On Wed, 10 Jan 2018 13:29:09 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 14 lines · Igor Mammedov
Quoted 10 lines · On Tue, 9 Jan 2018 15:58:11 +0200 "Michael S. Tsirkin" <[email protected]> wrote:

We prefer not changing table sizes depending on parameters, that's why we create a dummy table rather than just drop the MCFG table.

However, a table named "QEMU" could be put to a better use than just a stub, e.g. we could use it to pass some QEMU specific info to guests.

Replace with an SSDT and pad with the Nop opcode to preserve the length.

Not sure it's useful, do you have patches on top of that, which will use this?

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Yes but not me - Stefan (Cc'd) wants to add a custom table.

Re-purposing dummy table that might become not dummy doesn't look like good approach. What if later the guest enables MCFG and reboots, DUMMY SSDT would be replaced by MCFG?

So what's the issue? Why is this worse than a dummy QEMU table? There's actually no re-purposing here at all. Either we create an MCFG or an SSDT. We never re-purpose.

Quoted 6 lines

I think, I've misread commit message, so it's table name 'QEMU' that's going to be reused.

Having several tables with name QEMU shouldn't be an issue, adding oem/oem_id should be sufficient to distinguish them for parsing side (if there is any).

It seems more work for bios to scan all such tables and not just the first one. I might be wrong here.

Quoted 3 lines

As for change from ignored table to always parsed SSDT table, having ignored one seems better.
So I'd drop SSDT+memset and keep oem[id] parts in this patch.

I'll wait until Stefan posts his patches using this, then we can see what does look better.

Quoted 51 lines
Quoted 51 lines
Quoted 1 line

It'd be cleaner if Stefan would just use his own dedicated SSDT.

SSDT doesn't always work. A data table is needed so e.g. seabios can process it easily.

Quoted 46 lines
Quoted 46 lines
Quoted 46 lines
Quoted 46 lines
---
 hw/i386/acpi-build.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
hw/i386/acpi-build.c +12 -5
index 73519ab..d0afb31e 100644
@@ -2419,6 +2419,8 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
 {
     AcpiTableMcfg *mcfg;
     const char *sig;
+    const char *oem;
+    const char *oem_id;
     int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
 
     mcfg = acpi_data_push(table_data, len);
@@ -2431,16 +2433,21 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
     /* MCFG is used for ECAM which can be enabled or disabled by guest.
      * To avoid table size changes (which create migration issues),
      * always create the table even if there are no allocations,
-     * but set the signature to a reserved value in this case.
-     * ACPI spec requires OSPMs to ignore such tables.
+     * but fill it with Noop values.
+     * OSPMs ignore such tables.
      */
     if (info->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
-        /* Reserved signature: ignored by OSPM */
-        sig = "QEMU";
+        sig = "SSDT";
+        oem = "QEMU ";
+        oem_id = "NOOP";
+        /* 0xa3 - NoopOp */
+        memset(&mcfg->reserved, 0xa3, len - offsetof(AcpiTableMcfg, reserved));
     } else {
         sig = "MCFG";
+        oem = NULL;
+        oem_id = NULL;
     }
-    build_header(linker, table_data, (void *)mcfg, sig, len, 1, NULL, NULL);
+    build_header(linker, table_data, (void *)mcfg, sig, len, 1, oem, oem_id);
 }
 
 /*  
#7 lore raw
In reply to Michael S. Tsirkin
Quoted 8 lines · Michael S. Tsirkin
Quoted 7 lines · Igor Mammedov
Quoted 4 lines · On Tue, 9 Jan 2018 15:58:11 +0200 "Michael S. Tsirkin" <[email protected]> wrote:

We prefer not changing table sizes depending on parameters, that's why we create a dummy table rather than just drop the MCFG table.

Quoted 8 lines
Quoted 7 lines
Quoted 6 lines

However, a table named "QEMU" could be put to a better use than just a stub, e.g. we could use it to pass some QEMU specific info to guests.

Replace with an SSDT and pad with the Nop opcode to preserve the length.

Not sure it's useful, do you have patches on top of that, which will use this?

Yes but not me - Stefan (Cc'd) wants to add a custom table.

With the virtual device at a well known address I don't need the custom table anymore...

Stefan

Quoted 46 lines
Quoted 46 lines
Quoted 46 lines
---
  hw/i386/acpi-build.c | 17 ++++++++++++-----
  1 file changed, 12 insertions(+), 5 deletions(-)
hw/i386/acpi-build.c +12 -5
index 73519ab..d0afb31e 100644
@@ -2419,6 +2419,8 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
  {
      AcpiTableMcfg *mcfg;
      const char *sig;
+    const char *oem;
+    const char *oem_id;
      int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]);
 
      mcfg = acpi_data_push(table_data, len);
@@ -2431,16 +2433,21 @@ build_mcfg_q35(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
      /* MCFG is used for ECAM which can be enabled or disabled by guest.
       * To avoid table size changes (which create migration issues),
       * always create the table even if there are no allocations,
-     * but set the signature to a reserved value in this case.
-     * ACPI spec requires OSPMs to ignore such tables.
+     * but fill it with Noop values.
+     * OSPMs ignore such tables.
       */
      if (info->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) {
-        /* Reserved signature: ignored by OSPM */
-        sig = "QEMU";
+        sig = "SSDT";
+        oem = "QEMU ";
+        oem_id = "NOOP";
+        /* 0xa3 - NoopOp */
+        memset(&mcfg->reserved, 0xa3, len - offsetof(AcpiTableMcfg, reserved));
      } else {
          sig = "MCFG";
+        oem = NULL;
+        oem_id = NULL;
      }
-    build_header(linker, table_data, (void *)mcfg, sig, len, 1, NULL, NULL);
+    build_header(linker, table_data, (void *)mcfg, sig, len, 1, oem, oem_id);
  }
 
  /*