Skip to contentSkip to conversation

firmware changes as part of QEMU/Xen merge.

PATCH Superseded [email protected] 5 participants 8 messages Oct 15, 2010 – Oct 18, 2010

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover firmware changes as part of QEMU/Xen merge.

From: Anthony PERARD <[email protected]>

This two patches are for Xen-unstable and Qemu-DM.

With the integration of Xen into QEMU, we would like to minimise the change and use the ACPI implementation of QEMU. So there are some change to make on the firmware to match the QEMU's BIOS. Some IO Ports are different and the sleep state values are different.

Firmware changes:

Anthony PERARD (1):
firmware, Change ACPI IO addresses and values to match QEMU BIOS.

 tools/firmware/hvmloader/acpi/dsdt.asl |   12 ++++++------
 tools/firmware/hvmloader/hvmloader.c   |    4 ++++
 xen/include/public/hvm/ioreq.h         |    6 +++---
 3 files changed, 13 insertions(+), 9 deletions(-)

Qemu-Xen changes:

Anthony PERARD (1):
piix4acpi: change in ACPI to match the change in the BIOS.

 hw/piix4acpi.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)
Signature · 1 line
Anthony PERARD
#1 lore raw

PATCH 1/2 firmware, Change ACPI IO addresses and values to match QEMU BIOS.

From: Anthony PERARD <[email protected]>

As part of the QEMU/Xen merge, this patch comes to change the IO Port addresses, the value of sleep states and add some information in the PCI registers to match the implementation of the BIOS of QEMU.

This patch must be applied at the same time with another patch for the piix4acpi of qemu-xen.

---
 tools/firmware/hvmloader/acpi/dsdt.asl |   12 ++++++------
 tools/firmware/hvmloader/hvmloader.c   |    4 ++++
 xen/include/public/hvm/ioreq.h         |    6 +++---
 3 files changed, 13 insertions(+), 9 deletions(-)
tools/firmware/hvmloader/acpi/dsdt.asl +6 -6
index 03799d3..ea8e324 100644
@@ -33,22 +33,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, "Xen", "HVM", 0)
      */
     Name (\_S3, Package (0x04)
     {
-        0x05,  /* PM1a_CNT.SLP_TYP */
-        0x05,  /* PM1b_CNT.SLP_TYP */
+        0x01,  /* PM1a_CNT.SLP_TYP */
+        0x01,  /* PM1b_CNT.SLP_TYP */
         0x0,   /* reserved */
         0x0    /* reserved */
     })
     Name (\_S4, Package (0x04)
     {
-        0x06,  /* PM1a_CNT.SLP_TYP */
-        0x06,  /* PM1b_CNT.SLP_TYP */
+        0x00,  /* PM1a_CNT.SLP_TYP */
+        0x00,  /* PM1b_CNT.SLP_TYP */
         0x00,  /* reserved */
         0x00   /* reserved */
     })
     Name (\_S5, Package (0x04)
     {
-        0x07,  /* PM1a_CNT.SLP_TYP */
-        0x07,  /* PM1b_CNT.SLP_TYP */
+        0x00,  /* PM1a_CNT.SLP_TYP */
+        0x00,  /* PM1b_CNT.SLP_TYP */
         0x00,  /* reserved */
         0x00   /* reserved */
     })
tools/firmware/hvmloader/hvmloader.c +4 -0
index c4c5ddc..cfe026f 100644
@@ -31,6 +31,7 @@
 #include "option_rom.h"
 #include <xen/version.h>
 #include <xen/hvm/params.h>
+#include <xen/hvm/ioreq.h>
 #include <xen/memory.h>
 
 asm (
@@ -222,9 +223,12 @@ static void pci_setup(void)
             /* PIIX4 ACPI PM. Special device with special PCI config space. */
             ASSERT((vendor_id == 0x8086) && (device_id == 0x7113));
             pci_writew(devfn, 0x20, 0x0000); /* No smb bus IO enable */
+            pci_writew(devfn, 0xd2, 0x0000); /* No smb bus IO enable */
             pci_writew(devfn, 0x22, 0x0000);
             pci_writew(devfn, 0x3c, 0x0009); /* Hardcoded IRQ9 */
             pci_writew(devfn, 0x3d, 0x0001);
+            pci_writel(devfn, 0x40, ACPI_PM1A_EVT_BLK_ADDRESS | 1);
+            pci_writeb(devfn, 0x80, 0x01); /* enable PM io space */
             break;
         case 0x0101:
             if ( vendor_id == 0x8086 )
xen/include/public/hvm/ioreq.h +3 -3
index 0c10c08..00f5c15 100644
@@ -100,11 +100,11 @@ struct buffered_piopage {
 };
 #endif /* defined(__ia64__) */
 
-#define ACPI_PM1A_EVT_BLK_ADDRESS           0x0000000000001f40
+#define ACPI_PM1A_EVT_BLK_ADDRESS           0x000000000000b000
 #define ACPI_PM1A_CNT_BLK_ADDRESS           (ACPI_PM1A_EVT_BLK_ADDRESS + 0x04)
 #define ACPI_PM_TMR_BLK_ADDRESS             (ACPI_PM1A_EVT_BLK_ADDRESS + 0x08)
-#define ACPI_GPE0_BLK_ADDRESS               (ACPI_PM_TMR_BLK_ADDRESS + 0x20)
-#define ACPI_GPE0_BLK_LEN                   0x08
+#define ACPI_GPE0_BLK_ADDRESS               (0x000000000000afe0)
+#define ACPI_GPE0_BLK_LEN                   0x04
 
 #endif /* _IOREQ_H_ */
 
Signature · 1 line
1.7.1
#2 lore raw

PATCH 2/2 piix4acpi: change in ACPI to match the change in the BIOS.

In reply to [email protected]

From: Anthony PERARD <[email protected]>

Some change have been introduced in the firmware to match QEMU's BIOS. So this patch changes the sleep state values to use the new one and changes the ioport address of the ACPI IOPort mapping.

---
 hw/piix4acpi.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)
hw/piix4acpi.c +4 -5
index 1efa77d..ae31729 100644
@@ -52,9 +52,9 @@
 
 /* Sleep state type codes as defined by the \_Sx objects in the DSDT. */
 /* These must be kept in sync with the DSDT (hvmloader/acpi/dsdt.asl) */
-#define SLP_TYP_S4        (6 << 10)
-#define SLP_TYP_S3        (5 << 10)
-#define SLP_TYP_S5        (7 << 10)
+#define SLP_TYP_S4        (0 << 10)
+#define SLP_TYP_S3        (1 << 10)
+#define SLP_TYP_S5        (0 << 10)
 
 #define ACPI_DBG_IO_ADDR  0xb044
 #define ACPI_PHP_IO_ADDR  0x10c0
@@ -179,7 +179,6 @@ static void acpi_shutdown(uint32_t val)
         cmos_set_s3_resume();
         xc_set_hvm_param(xc_handle, domid, HVM_PARAM_ACPI_S_STATE, 3);
         break;
-    case SLP_TYP_S4:
     case SLP_TYP_S5:
         qemu_system_shutdown_request();
         break;
@@ -703,7 +702,7 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
     pci_conf[0x43] = 0x00;
     d->pm1_control = SCI_EN;
 
-    acpi_map((PCIDevice *)d, 0, 0x1f40, 0x10, PCI_ADDRESS_SPACE_IO);
+    acpi_map((PCIDevice *)d, 0, ACPI_PM1A_EVT_BLK_ADDRESS, 0x10, PCI_ADDRESS_SPACE_IO);
 
     gpe_acpi_init();
 #ifdef CONFIG_PASSTHROUGH
Signature · 1 line
1.7.1
#3 lore raw
In reply to [email protected]

We cannot make changes to qemu-dm that are not backwards compatible with saved guests. Not only does this affect qemu in this case, but the register blocks you move around also affect Xen's emulation of ACPI pmtimer. Both will/would need to be configurable based on whether this is an old or new guest.

Hence this has to be strongly NACKed in its current form.

-- Keir

Quoted 27 lines · On 15/10/2010 18:35, "[email protected]" <[email protected]>…

From: Anthony PERARD <[email protected]>

This two patches are for Xen-unstable and Qemu-DM.

With the integration of Xen into QEMU, we would like to minimise the change and use the ACPI implementation of QEMU. So there are some change to make on the firmware to match the QEMU's BIOS. Some IO Ports are different and the sleep state values are different.

Firmware changes:

Anthony PERARD (1):
firmware, Change ACPI IO addresses and values to match QEMU BIOS.

 tools/firmware/hvmloader/acpi/dsdt.asl |   12 ++++++------
 tools/firmware/hvmloader/hvmloader.c   |    4 ++++
 xen/include/public/hvm/ioreq.h         |    6 +++---
 3 files changed, 13 insertions(+), 9 deletions(-)

Qemu-Xen changes:

Anthony PERARD (1):
piix4acpi: change in ACPI to match the change in the BIOS.

 hw/piix4acpi.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)
#4 lore raw
Quoted 8 lines

We cannot make changes to qemu-dm that are not backwards compatible with saved guests. Not only does this affect qemu in this case, but the register
blocks you move around also affect Xen's emulation of ACPI pmtimer. Both will/would need to be configurable based on whether this is an old or new guest.

Hence this has to be strongly NACKed in its current form.

It's getting to the point where we might have to consider having two qemu binaries, one for compatibility, one that new VMs are transitioned on to.

Things are now so different that I'm worried that installed guests might complain even when just fresh booted on the new qemu. This is something that we'd need to test and devise workarounds. Trying to retain saved image compatibility with a single binary looks ugly.

Ian

#5 lore raw
Quoted 7 lines · Ian Pratt
Quoted 7 lines

We cannot make changes to qemu-dm that are not backwards compatible with saved guests. Not only does this affect qemu in this case, but the register
blocks you move around also affect Xen's emulation of ACPI pmtimer. Both will/would need to be configurable based on whether this is an old or new guest.

Quoted 6 lines
Quoted 1 line

Hence this has to be strongly NACKed in its current form.

It's getting to the point where we might have to consider having two qemu binaries, one for compatibility, one that new VMs are transitioned on to.

Things are now so different that I'm worried that installed guests might complain even when just fresh booted on the new qemu. This is something that we'd need to test and devise workarounds. Trying to retain saved image compatibility with a single binary looks ugly.

I agree.

However in this particular case the firmware changes are only for ACPI support and we might be able to support both the old AND the new ioports in qemu-xen, so that we can switch the firmware to the new interface while keeping backward compatibility in qemu.

That said I doubt we'll be able to do the same in upstream qemu, so at some point the old ioport interface will probably be dropped.

#6 lore raw
Quoted 9 lines · Stefano Stabellini

I agree.

However in this particular case the firmware changes are only for ACPI support and we might be able to support both the old AND the new ioports in qemu-xen, so that we can switch the firmware to the new interface while keeping backward compatibility in qemu.

That said I doubt we'll be able to do the same in upstream qemu, so at some point the old ioport interface will probably be dropped.

I don't think we can necessarily expect to drop all our patches against upstream qemu, for things like that this that we (ought to) care about and they don't need to care about and will consider ugly. The backwards compatibility is going to be needed and be maintained somewhere -- if not in core Xen releases, then it'll end up in XenServer/XCP -- so we may as well get our story straight on it up front now.

-- Keir

#7 lore raw
In reply to Ian Pratt

Ian Pratt writes ("RE: [Xen-devel] [PATCH 00/02] firmware changes as part of QEMU/Xen merge."):

Quoted 3 lines

It's getting to the point where we might have to consider having two qemu binaries, one for compatibility, one that new VMs are transitioned on to.

Yes. But the "new" qemu binary will be, hopefully, upstream qemu's, based on the work that Anthony is doing against upstream.

Quoted 2 lines

Things are now so different that I'm worried that installed guests might complain even when just fresh booted on the new qemu.

That's a possibility. Some PCI IDs and device strings have changed.

Quoted 3 lines

This is something that we'd need to test and devise
workarounds. Trying to retain saved image compatibility with a single binary looks ugly.

It would be difficult. I guess we might be able to write an external qemu save image translator.

The difficulty with the ACPI values is that ideally we want to be able to use the same BIOS with both qemus and that means that the two qemus either need to use the same values or there needs to be some negotiation somewhere. We don't want to try to patch the "new" qemu use the old values.

So the combinations which we want to work are:

    qemu           BIOS            ACPI values   notes
    ------------   ----------      -----------   -----------

upstream/new upstream's standard native qemu

upstream/new ours standard under Xen } save/restore
upstream/new upstream's standard in future } compat

old ours old Xen current Xen

This implies that we need to change "our" BIOS to be able to cope with either arrangement.

Ian.