[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] x86 hvm: Fixes for 22339:6fae4331d5aa



# HG changeset patch
# User Keir Fraser <keir@xxxxxxx>
# Date 1288620688 0
# Node ID 310d2cb034143024885aa146485f188901a58d1d
# Parent  b6c553f62eded729b6c01f25a020193305fb9fd2
x86 hvm: Fixes for 22339:6fae4331d5aa

Primarily fix up register names in public header file for
compatibility with old unmodified versions of virtual firmware and
qemu-dm. Also fixes a bug in the read case of handle_evt_io().

Signed-off-by: Keir Fraser <keir@xxxxxxx>
---
 xen/arch/x86/hvm/pmtimer.c     |   47 ++++++++++++++++++++---------------------
 xen/include/public/hvm/ioreq.h |   35 ++++++++++++++++++++----------
 2 files changed, 46 insertions(+), 36 deletions(-)

diff -r b6c553f62ede -r 310d2cb03414 xen/arch/x86/hvm/pmtimer.c
--- a/xen/arch/x86/hvm/pmtimer.c        Sun Oct 31 19:01:33 2010 +0000
+++ b/xen/arch/x86/hvm/pmtimer.c        Mon Nov 01 14:11:28 2010 +0000
@@ -25,12 +25,12 @@
 #include <public/hvm/params.h>
 
 /* Slightly more readable port I/O addresses for the registers we intercept */
-#define PM1a_STS_ADDR_OLD (ACPI_PM1A_EVT_BLK_ADDRESS_OLD)
-#define PM1a_EN_ADDR_OLD  (ACPI_PM1A_EVT_BLK_ADDRESS_OLD + 2)
-#define TMR_VAL_ADDR_OLD  (ACPI_PM_TMR_BLK_ADDRESS_OLD)
-#define PM1a_STS_ADDR (ACPI_PM1A_EVT_BLK_ADDRESS)
-#define PM1a_EN_ADDR  (ACPI_PM1A_EVT_BLK_ADDRESS + 2)
-#define TMR_VAL_ADDR  (ACPI_PM_TMR_BLK_ADDRESS)
+#define PM1a_STS_ADDR_V0 (ACPI_PM1A_EVT_BLK_ADDRESS_V0)
+#define PM1a_EN_ADDR_V0  (ACPI_PM1A_EVT_BLK_ADDRESS_V0 + 2)
+#define TMR_VAL_ADDR_V0  (ACPI_PM_TMR_BLK_ADDRESS_V0)
+#define PM1a_STS_ADDR_V1 (ACPI_PM1A_EVT_BLK_ADDRESS_V1)
+#define PM1a_EN_ADDR_V1  (ACPI_PM1A_EVT_BLK_ADDRESS_V1 + 2)
+#define TMR_VAL_ADDR_V1  (ACPI_PM_TMR_BLK_ADDRESS_V1)
 
 /* The interesting bits of the PM1a_STS register */
 #define TMR_STS    (1 << 0)
@@ -146,12 +146,17 @@ static int handle_evt_io(
     uint32_t addr, data, byte;
     int i;
 
+    addr = port -
+        ((v->domain->arch.hvm_domain.params[
+            HVM_PARAM_ACPI_IOPORTS_LOCATION] == 0) ?
+         PM1a_STS_ADDR_V0 : PM1a_STS_ADDR_V1);
+
     spin_lock(&s->lock);
 
     if ( dir == IOREQ_WRITE )
     {
         /* Handle this I/O one byte at a time */
-        for ( i = bytes, addr = port, data = *val;
+        for ( i = bytes, data = *val;
               i > 0;
               i--, addr++, data >>= 8 )
         {
@@ -159,24 +164,18 @@ static int handle_evt_io(
             switch ( addr )
             {
                 /* PM1a_STS register bits are write-to-clear */
-            case PM1a_STS_ADDR_OLD:
-            case PM1a_STS_ADDR:
+            case 0 /* PM1a_STS_ADDR */:
                 s->pm.pm1a_sts &= ~byte;
                 break;
-            case PM1a_STS_ADDR_OLD + 1:
-            case PM1a_STS_ADDR + 1:
+            case 1 /* PM1a_STS_ADDR + 1 */:
                 s->pm.pm1a_sts &= ~(byte << 8);
                 break;
-                
-            case PM1a_EN_ADDR_OLD:
-            case PM1a_EN_ADDR:
+            case 2 /* PM1a_EN_ADDR */:
                 s->pm.pm1a_en = (s->pm.pm1a_en & 0xff00) | byte;
                 break;
-            case PM1a_EN_ADDR_OLD + 1:
-            case PM1a_EN_ADDR + 1:
+            case 3 /* PM1a_EN_ADDR + 1 */:
                 s->pm.pm1a_en = (s->pm.pm1a_en & 0xff) | (byte << 8);
                 break;
-                
             default:
                 gdprintk(XENLOG_WARNING, 
                          "Bad ACPI PM register write: %x bytes (%x) at %x\n", 
@@ -189,7 +188,7 @@ static int handle_evt_io(
     else /* p->dir == IOREQ_READ */
     {
         data = s->pm.pm1a_sts | (((uint32_t) s->pm.pm1a_en) << 16);
-        data >>= 8 * (port - PM1a_STS_ADDR);
+        data >>= 8 * addr;
         if ( bytes == 1 ) data &= 0xff;
         else if ( bytes == 2 ) data &= 0xffff;
         *val = data;
@@ -296,14 +295,14 @@ int pmtimer_change_ioport(struct domain 
     if ( version == 1 )
     {
         /* Moving from version 0 to version 1. */
-        relocate_portio_handler(d, TMR_VAL_ADDR_OLD, TMR_VAL_ADDR, 4);
-        relocate_portio_handler(d, PM1a_STS_ADDR_OLD, PM1a_STS_ADDR, 4);
+        relocate_portio_handler(d, TMR_VAL_ADDR_V0, TMR_VAL_ADDR_V1, 4);
+        relocate_portio_handler(d, PM1a_STS_ADDR_V0, PM1a_STS_ADDR_V1, 4);
     }
     else
     {
         /* Moving from version 1 to version 0. */
-        relocate_portio_handler(d, TMR_VAL_ADDR, TMR_VAL_ADDR_OLD, 4);
-        relocate_portio_handler(d, PM1a_STS_ADDR, PM1a_STS_ADDR_OLD, 4);
+        relocate_portio_handler(d, TMR_VAL_ADDR_V1, TMR_VAL_ADDR_V0, 4);
+        relocate_portio_handler(d, PM1a_STS_ADDR_V1, PM1a_STS_ADDR_V0, 4);
     }
 
     return 0;
@@ -321,8 +320,8 @@ void pmtimer_init(struct vcpu *v)
 
     /* Intercept port I/O (need two handlers because PM1a_CNT is between
      * PM1a_EN and TMR_VAL and is handled by qemu) */
-    register_portio_handler(v->domain, TMR_VAL_ADDR_OLD, 4, handle_pmt_io);
-    register_portio_handler(v->domain, PM1a_STS_ADDR_OLD, 4, handle_evt_io);
+    register_portio_handler(v->domain, TMR_VAL_ADDR_V0, 4, handle_pmt_io);
+    register_portio_handler(v->domain, PM1a_STS_ADDR_V0, 4, handle_evt_io);
 
     /* Set up callback to fire SCIs when the MSB of TMR_VAL changes */
     init_timer(&s->timer, pmt_timer_callback, s, v->processor);
diff -r b6c553f62ede -r 310d2cb03414 xen/include/public/hvm/ioreq.h
--- a/xen/include/public/hvm/ioreq.h    Sun Oct 31 19:01:33 2010 +0000
+++ b/xen/include/public/hvm/ioreq.h    Mon Nov 01 14:11:28 2010 +0000
@@ -101,20 +101,31 @@ struct buffered_piopage {
 #endif /* defined(__ia64__) */
 
 /*
- * Value used by old qemu-dm, there have been replace to match
- * the QEMU BIOS.
+ * ACPI Control/Event register locations. Location is controlled by a 
+ * version number in HVM_PARAM_ACPI_IOPORTS_LOCATION.
  */
-#define ACPI_PM1A_EVT_BLK_ADDRESS_OLD 0x1f40
-#define ACPI_PM1A_CNT_BLK_ADDRESS_OLD (ACPI_PM1A_EVT_BLK_ADDRESS_OLD + 0x04)
-#define ACPI_PM_TMR_BLK_ADDRESS_OLD   (ACPI_PM1A_EVT_BLK_ADDRESS_OLD + 0x08)
-#define ACPI_GPE0_BLK_ADDRESS_OLD     (ACPI_PM_TMR_BLK_ADDRESS_OLD + 0x20)
-#define ACPI_GPE0_BLK_LEN_OLD         0x08
 
-#define ACPI_PM1A_EVT_BLK_ADDRESS     0xb000
-#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         0xafe0
-#define ACPI_GPE0_BLK_LEN             0x04
+/* Version 0 (default): Traditional Xen locations. */
+#define ACPI_PM1A_EVT_BLK_ADDRESS_V0 0x1f40
+#define ACPI_PM1A_CNT_BLK_ADDRESS_V0 (ACPI_PM1A_EVT_BLK_ADDRESS_V0 + 0x04)
+#define ACPI_PM_TMR_BLK_ADDRESS_V0   (ACPI_PM1A_EVT_BLK_ADDRESS_V0 + 0x08)
+#define ACPI_GPE0_BLK_ADDRESS_V0     (ACPI_PM_TMR_BLK_ADDRESS_V0 + 0x20)
+#define ACPI_GPE0_BLK_LEN_V0         0x08
+
+/* Version 1: Locations preferred by modern Qemu. */
+#define ACPI_PM1A_EVT_BLK_ADDRESS_V1 0xb000
+#define ACPI_PM1A_CNT_BLK_ADDRESS_V1 (ACPI_PM1A_EVT_BLK_ADDRESS_V1 + 0x04)
+#define ACPI_PM_TMR_BLK_ADDRESS_V1   (ACPI_PM1A_EVT_BLK_ADDRESS_V1 + 0x08)
+#define ACPI_GPE0_BLK_ADDRESS_V1     0xafe0
+#define ACPI_GPE0_BLK_LEN_V1         0x04
+
+/* Compatibility definitions for the default location (version 0). */
+#define ACPI_PM1A_EVT_BLK_ADDRESS    ACPI_PM1A_EVT_BLK_ADDRESS_V0
+#define ACPI_PM1A_CNT_BLK_ADDRESS    ACPI_PM1A_CNT_BLK_ADDRESS_V0
+#define ACPI_PM_TMR_BLK_ADDRESS      ACPI_PM_TMR_BLK_ADDRESS_V0
+#define ACPI_GPE0_BLK_ADDRESS        ACPI_GPE0_BLK_ADDRESS_V0
+#define ACPI_GPE0_BLK_LEN            ACPI_GPE0_BLK_LEN_V0
+
 
 #endif /* _IOREQ_H_ */
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.