Skip to contentSkip to conversation

acpi: add reset register to fadt

RFC Superseded Reza Jelveh 4 participants 7 messages Mar 28, 2015 – Mar 30, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

RFC 1/1 acpi: add reset register to fadt

Some operating systems such as FreeBSD and Mac OSX need the reset_register section of the FADT filled to know which port to write to for a system reset.

What is the right way to set the reset_val and the reset addr in this case?

---
 hw/i386/acpi-build.c | 5 +++++
 hw/i386/acpi-defs.h  | 2 ++
 2 files changed, 7 insertions(+)
hw/i386/acpi-build.c +5 -0
index d0a5c85..21c1453 100644
@@ -361,6 +361,11 @@ static void fadt_setup(AcpiFadtDescriptorRev1 *fadt, AcpiPmInfo *pm)
                               (1 << ACPI_FADT_F_SLP_BUTTON) |
                               (1 << ACPI_FADT_F_RTC_S4));
     fadt->flags |= cpu_to_le32(1 << ACPI_FADT_F_USE_PLATFORM_CLOCK);
+    fadt->flags |= cpu_to_le32(1 << ACPI_FADT_F_RESET_REG_SUP);
+    fadt->reset_val = 0xf;
+    fadt->reset_reg.address_space_id   = aml_system_io;
+    fadt->reset_reg.register_bit_width = 8;
+    fadt->reset_reg.address            = ICH9_RST_CNT_IOPORT;
     /* APIC destination mode ("Flat Logical") has an upper limit of 8 CPUs
      * For more than 8 CPUs, "Clustered Logical" mode has to be used
      */
hw/i386/acpi-defs.h +2 -0
index c4468f8..960c833 100644
@@ -132,6 +132,8 @@ struct AcpiFadtDescriptorRev1
     uint8_t  reserved4a;             /* Reserved */
     uint8_t  reserved4b;             /* Reserved */
     uint32_t flags;
+    Acpi20GenericAddress reset_reg;
+    uint8_t reset_val;
 } QEMU_PACKED;
 typedef struct AcpiFadtDescriptorRev1 AcpiFadtDescriptorRev1;
 
Signature · 1 line
2.3.4
#1 lore raw
Quoted 14 lines · Reza Jelveh

Some operating systems such as FreeBSD and Mac OSX need the reset_register section of the FADT filled to know which port to write to for a system reset.

What is the right way to set the reset_val and the reset addr in this case?

---
  hw/i386/acpi-build.c | 5 +++++
  hw/i386/acpi-defs.h  | 2 ++
  2 files changed, 7 insertions(+)
hw/i386/acpi-build.c +0 -0
index d0a5c85..21c1453 100644

hw/i386/acpi-build.c static void fadt_setup(AcpiFadtDescriptorRev1 *fadt, AcpiPmInfo *pm) · line 368

Quoted 8 lines
hw/i386/acpi-build.c +5 -0
@@ -361,6 +361,11 @@ static void fadt_setup(AcpiFadtDescriptorRev1 *fadt, AcpiPmInfo *pm)
                                (1 << ACPI_FADT_F_SLP_BUTTON) |
                                (1 << ACPI_FADT_F_RTC_S4));
      fadt->flags |= cpu_to_le32(1 << ACPI_FADT_F_USE_PLATFORM_CLOCK);
+    fadt->flags |= cpu_to_le32(1 << ACPI_FADT_F_RESET_REG_SUP);
+    fadt->reset_val = 0xf;
+    fadt->reset_reg.address_space_id   = aml_system_io;
+    fadt->reset_reg.register_bit_width = 8;
+    fadt->reset_reg.address            = ICH9_RST_CNT_IOPORT;

Hi,

Is this for both PC and Q35? Because I don't think PC has ICH9_RST_CNT_IOPORT.

Thanks,
Marcel

Quoted 17 lines
hw/i386/acpi-build.c +0 -0
      /* APIC destination mode ("Flat Logical") has an upper limit of 8 CPUs
       * For more than 8 CPUs, "Clustered Logical" mode has to be used
       */
hw/i386/acpi-defs.h +2 -0
index c4468f8..960c833 100644
@@ -132,6 +132,8 @@ struct AcpiFadtDescriptorRev1
      uint8_t  reserved4a;             /* Reserved */
      uint8_t  reserved4b;             /* Reserved */
      uint32_t flags;
+    Acpi20GenericAddress reset_reg;
+    uint8_t reset_val;
  } QEMU_PACKED;
  typedef struct AcpiFadtDescriptorRev1 AcpiFadtDescriptorRev1;
 
#3 lore raw
In reply to Reza Jelveh
Quoted 30 lines · On Sat, 28 Mar 2015 15:46:53 +0100 Reza Jelveh <[email protected]> wrote:

Some operating systems such as FreeBSD and Mac OSX need the reset_register section of the FADT filled to know which port to write to for a system reset.

What is the right way to set the reset_val and the reset addr in this case?

---
 hw/i386/acpi-build.c | 5 +++++
 hw/i386/acpi-defs.h  | 2 ++
 2 files changed, 7 insertions(+)
hw/i386/acpi-build.c +5 -0
index d0a5c85..21c1453 100644
@@ -361,6 +361,11 @@ static void fadt_setup(AcpiFadtDescriptorRev1 *fadt, AcpiPmInfo *pm)
                               (1 << ACPI_FADT_F_SLP_BUTTON) |
                               (1 << ACPI_FADT_F_RTC_S4));
     fadt->flags |= cpu_to_le32(1 << ACPI_FADT_F_USE_PLATFORM_CLOCK);
+    fadt->flags |= cpu_to_le32(1 << ACPI_FADT_F_RESET_REG_SUP);
+    fadt->reset_val = 0xf;
+    fadt->reset_reg.address_space_id   = aml_system_io;
+    fadt->reset_reg.register_bit_width = 8;
+    fadt->reset_reg.address            = ICH9_RST_CNT_IOPORT;
     /* APIC destination mode ("Flat Logical") has an upper limit of 8 CPUs
      * For more than 8 CPUs, "Clustered Logical" mode has to be used
      */
hw/i386/acpi-defs.h +0 -0
index c4468f8..960c833 100644

hw/i386/acpi-defs.h struct AcpiFadtDescriptorRev1 · line 136

Quoted 5 lines
hw/i386/acpi-defs.h +2 -0
@@ -132,6 +132,8 @@ struct AcpiFadtDescriptorRev1
     uint8_t  reserved4a;             /* Reserved */
     uint8_t  reserved4b;             /* Reserved */
     uint32_t flags;
+    Acpi20GenericAddress reset_reg;
+    uint8_t reset_val;

you are extending structure beyond of what specified by ACPI 1.0b spec, that might break guests.
We probably can't change revision since Windows ACPI implementation is mostly 1.0b based so we are stuck with it.
Patch needs to be tested with Windows guests starting with XP.

related issue,
adding fields without changing major version to a corresponding one doesn't look correct.

Quoted 3 lines
hw/i386/acpi-defs.h +0 -0
 } QEMU_PACKED;
 typedef struct AcpiFadtDescriptorRev1 AcpiFadtDescriptorRev1;
 
#4 lore raw
Quoted 6 lines · Igor Mammedov

you are extending structure beyond of what specified by ACPI 1.0b spec, that might break guests.
We probably can't change revision since Windows ACPI implementation is mostly 1.0b based so we are stuck with it.
Patch needs to be tested with Windows guests starting with XP.

Works fine with XP as long as you don't use q35, but i guess that's unsupported by xp by default.

Quoted 4 lines

related issue,
adding fields without changing major version to a corresponding one doesn't look correct.

What do you suggest? saying we support 2.0a just because of introducing reset_reg is not really valid is it?

#5 lore raw
Quoted 11 lines · On Mon, 30 Mar 2015 15:27:26 +0200 Reza Jelveh <[email protected]> wrote:
Quoted 6 lines · Igor Mammedov

you are extending structure beyond of what specified by ACPI 1.0b spec, that might break guests.
We probably can't change revision since Windows ACPI implementation is mostly 1.0b based so we are stuck with it.
Patch needs to be tested with Windows guests starting with XP.

Works fine with XP as long as you don't use q35, but i guess that's unsupported by xp by default.

what about other windows versions?

Quoted 9 lines
Quoted 6 lines

related issue,
adding fields without changing major version to a corresponding one doesn't look correct.

What do you suggest? saying we support 2.0a just because of introducing reset_reg is not really valid is it?

Try to check whether windows works fine with a newer revision,
if it is, we can create revX FADT structure and use in with new machine types. In that case we could consider implementing rev5 table so it could be reused in ARM target.

#2 lore raw
In reply to Marcel Apfelbaum
Quoted 29 lines · Marcel Apfelbaum
Quoted 17 lines · Reza Jelveh

Some operating systems such as FreeBSD and Mac OSX need the reset_register
section of the FADT filled to know which port to write to for a system reset.

What is the right way to set the reset_val and the reset addr in this case?

---
  hw/i386/acpi-build.c | 5 +++++
  hw/i386/acpi-defs.h  | 2 ++
  2 files changed, 7 insertions(+)
hw/i386/acpi-build.c +0 -0
index d0a5c85..21c1453 100644

hw/i386/acpi-build.c static void fadt_setup(AcpiFadtDescriptorRev1 · line 369

Quoted 9 lines
hw/i386/acpi-build.c +5 -0
@@ -361,6 +361,11 @@ static void fadt_setup(AcpiFadtDescriptorRev1
 *fadt, AcpiPmInfo *pm)
                                (1 << ACPI_FADT_F_SLP_BUTTON) |
                                (1 << ACPI_FADT_F_RTC_S4));
      fadt->flags |= cpu_to_le32(1 << ACPI_FADT_F_USE_PLATFORM_CLOCK);
+    fadt->flags |= cpu_to_le32(1 << ACPI_FADT_F_RESET_REG_SUP);
+    fadt->reset_val = 0xf;
+    fadt->reset_reg.address_space_id   = aml_system_io;
+    fadt->reset_reg.register_bit_width = 8;
+    fadt->reset_reg.address            = ICH9_RST_CNT_IOPORT;

Hi,

Quoted 2 lines

Is this for both PC and Q35? Because I don't think PC has ICH9_RST_CNT_IOPORT.

It does (see RCR_IOPORT).

Paolo

Quoted 24 lines

Thanks,
Marcel

Quoted 18 lines
hw/i386/acpi-build.c +0 -0
      /* APIC destination mode ("Flat Logical") has an upper limit of

8 CPUs
* For more than 8 CPUs, "Clustered Logical" mode has to be used */

hw/i386/acpi-defs.h +2 -0
index c4468f8..960c833 100644
@@ -132,6 +132,8 @@ struct AcpiFadtDescriptorRev1
      uint8_t  reserved4a;             /* Reserved */
      uint8_t  reserved4b;             /* Reserved */
      uint32_t flags;
+    Acpi20GenericAddress reset_reg;
+    uint8_t reset_val;
  } QEMU_PACKED;
  typedef struct AcpiFadtDescriptorRev1 AcpiFadtDescriptorRev1;
 
#6 lore raw
In reply to Reza Jelveh
Quoted 8 lines · Reza Jelveh

you are extending structure beyond of what specified by ACPI 1.0b spec, that might break guests.
We probably can't change revision since Windows ACPI implementation is mostly 1.0b based so we are stuck with it.
Patch needs to be tested with Windows guests starting with XP.

Works fine with XP as long as you don't use q35, but i guess that's unsupported by xp by default.

Isn't that just because XP doesn't have an AHCI driver? You should still be able to use XP with q35 and virtio, by using a driver disk. Or add a PATA controller:

   -device piix4-ide,id=pata \
   -drive if=none,id=hd,file=... \
   -device ide-hd,drive=hd,bus=pata.0

Paolo