WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] x86 hvm: Introduce pmtimer_change_ioport

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] x86 hvm: Introduce pmtimer_change_ioport and HVM_PARAM_ACPI_IOPORTS_LOCATION
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 02 Nov 2010 04:50:45 -0700
Delivery-date: Tue, 02 Nov 2010 04:54:14 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir@xxxxxxx>
# Date 1288374154 -3600
# Node ID 6fae4331d5aab48d6061f4448ab72621367b8bde
# Parent  7031e1e74c3d180055cdcae480bd50b9a33b11c6
x86 hvm: Introduce pmtimer_change_ioport and HVM_PARAM_ACPI_IOPORTS_LOCATION

By default, Xen will handle the old ACPI IO port. But it can switch to
the new one by setting the HVM_PARAM_ACPI_IOPORTS_LOCATION to 1.

Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
Signed-off-by: Keir Fraser <keir@xxxxxxx>
---
 xen/arch/x86/hvm/hvm.c          |    3 ++
 xen/arch/x86/hvm/intercept.c    |   16 ++++-----------
 xen/arch/x86/hvm/pmtimer.c      |   41 ++++++++++++++++++++++++++++++++++++++--
 xen/include/asm-x86/hvm/io.h    |   12 ++++++-----
 xen/include/asm-x86/hvm/vpt.h   |    1 
 xen/include/public/hvm/ioreq.h  |   20 ++++++++++++++-----
 xen/include/public/hvm/params.h |   13 +++++++++++-
 7 files changed, 82 insertions(+), 24 deletions(-)

diff -r 7031e1e74c3d -r 6fae4331d5aa xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c    Fri Oct 29 18:14:01 2010 +0100
+++ b/xen/arch/x86/hvm/hvm.c    Fri Oct 29 18:42:34 2010 +0100
@@ -2991,6 +2991,9 @@ long do_hvm_op(unsigned long op, XEN_GUE
                     rc = -EINVAL;
 
                 break;
+            case HVM_PARAM_ACPI_IOPORTS_LOCATION:
+                rc = pmtimer_change_ioport(d, a.value);
+                break;
             }
 
             if ( rc == 0 )
diff -r 7031e1e74c3d -r 6fae4331d5aa xen/arch/x86/hvm/intercept.c
--- a/xen/arch/x86/hvm/intercept.c      Fri Oct 29 18:14:01 2010 +0100
+++ b/xen/arch/x86/hvm/intercept.c      Fri Oct 29 18:42:34 2010 +0100
@@ -241,24 +241,18 @@ void register_io_handler(
     handler->num_slot++;
 }
 
-void unregister_io_handler(
-    struct domain *d, unsigned long addr, unsigned long size, int type)
+void relocate_io_handler(
+    struct domain *d, unsigned long old_addr, unsigned long new_addr,
+    unsigned long size, int type)
 {
     struct hvm_io_handler *handler = &d->arch.hvm_domain.io_handler;
     int i;
 
     for ( i = 0; i < handler->num_slot; i++ )
-        if ( (handler->hdl_list[i].addr == addr) &&
+        if ( (handler->hdl_list[i].addr == old_addr) &&
              (handler->hdl_list[i].size == size) &&
              (handler->hdl_list[i].type == type) )
-            goto found;
-    return;
-
- found:
-    memcpy(&handler->hdl_list[i],
-           &handler->hdl_list[handler->num_slot-1],
-           sizeof(struct io_handler));
-    handler->num_slot--;
+            handler->hdl_list[i].addr = new_addr;
 }
 
 /*
diff -r 7031e1e74c3d -r 6fae4331d5aa xen/arch/x86/hvm/pmtimer.c
--- a/xen/arch/x86/hvm/pmtimer.c        Fri Oct 29 18:14:01 2010 +0100
+++ b/xen/arch/x86/hvm/pmtimer.c        Fri Oct 29 18:42:34 2010 +0100
@@ -22,8 +22,12 @@
 #include <asm/hvm/io.h>
 #include <asm/hvm/support.h>
 #include <asm/acpi.h> /* for hvm_acpi_power_button prototype */
+#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)
@@ -155,16 +159,20 @@ static int handle_evt_io(
             switch ( addr )
             {
                 /* PM1a_STS register bits are write-to-clear */
+            case PM1a_STS_ADDR_OLD:
             case PM1a_STS_ADDR:
                 s->pm.pm1a_sts &= ~byte;
                 break;
+            case PM1a_STS_ADDR_OLD + 1:
             case PM1a_STS_ADDR + 1:
                 s->pm.pm1a_sts &= ~(byte << 8);
                 break;
                 
+            case PM1a_EN_ADDR_OLD:
             case 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:
                 s->pm.pm1a_en = (s->pm.pm1a_en & 0xff) | (byte << 8);
                 break;
@@ -272,6 +280,35 @@ HVM_REGISTER_SAVE_RESTORE(PMTIMER, pmtim
 HVM_REGISTER_SAVE_RESTORE(PMTIMER, pmtimer_save, pmtimer_load, 
                           1, HVMSR_PER_DOM);
 
+int pmtimer_change_ioport(struct domain *d, unsigned int version)
+{
+    unsigned int old_version;
+
+    /* Check that version is changing. */
+    old_version = d->arch.hvm_domain.params[HVM_PARAM_ACPI_IOPORTS_LOCATION];
+    if ( version == old_version )
+        return 0;
+
+    /* Only allow changes between versions 0 and 1. */
+    if ( (version ^ old_version) != 1 )
+        return -EINVAL;
+
+    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);
+    }
+    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);
+    }
+
+    return 0;
+}
+
 void pmtimer_init(struct vcpu *v)
 {
     PMTState *s = &v->domain->arch.hvm_domain.pl_time.vpmt;
@@ -284,8 +321,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, 4, handle_pmt_io);
-    register_portio_handler(v->domain, PM1a_STS_ADDR, 4, handle_evt_io);
+    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);
 
     /* 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 7031e1e74c3d -r 6fae4331d5aa xen/include/asm-x86/hvm/io.h
--- a/xen/include/asm-x86/hvm/io.h      Fri Oct 29 18:14:01 2010 +0100
+++ b/xen/include/asm-x86/hvm/io.h      Fri Oct 29 18:42:34 2010 +0100
@@ -69,8 +69,9 @@ void register_io_handler(
 void register_io_handler(
     struct domain *d, unsigned long addr, unsigned long size,
     void *action, int type);
-void unregister_io_handler(
-    struct domain *d, unsigned long addr, unsigned long size, int type);
+void relocate_io_handler(
+    struct domain *d, unsigned long old_addr, unsigned long new_addr,
+    unsigned long size, int type);
 
 static inline int hvm_portio_intercept(ioreq_t *p)
 {
@@ -92,10 +93,11 @@ static inline void register_portio_handl
     register_io_handler(d, addr, size, action, HVM_PORTIO);
 }
 
-static inline void unregister_portio_handler(
-    struct domain *d, unsigned long addr, unsigned long size)
+static inline void relocate_portio_handler(
+    struct domain *d, unsigned long old_addr, unsigned long new_addr,
+    unsigned long size)
 {
-    unregister_io_handler(d, addr, size, HVM_PORTIO);
+    relocate_io_handler(d, old_addr, new_addr, size, HVM_PORTIO);
 }
 
 static inline void register_buffered_io_handler(
diff -r 7031e1e74c3d -r 6fae4331d5aa xen/include/asm-x86/hvm/vpt.h
--- a/xen/include/asm-x86/hvm/vpt.h     Fri Oct 29 18:14:01 2010 +0100
+++ b/xen/include/asm-x86/hvm/vpt.h     Fri Oct 29 18:42:34 2010 +0100
@@ -179,6 +179,7 @@ void pmtimer_init(struct vcpu *v);
 void pmtimer_init(struct vcpu *v);
 void pmtimer_deinit(struct domain *d);
 void pmtimer_reset(struct domain *d);
+int pmtimer_change_ioport(struct domain *d, unsigned int version);
 
 void hpet_init(struct vcpu *v);
 void hpet_deinit(struct domain *d);
diff -r 7031e1e74c3d -r 6fae4331d5aa xen/include/public/hvm/ioreq.h
--- a/xen/include/public/hvm/ioreq.h    Fri Oct 29 18:14:01 2010 +0100
+++ b/xen/include/public/hvm/ioreq.h    Fri Oct 29 18:42:34 2010 +0100
@@ -100,11 +100,21 @@ struct buffered_piopage {
 };
 #endif /* defined(__ia64__) */
 
-#define ACPI_PM1A_EVT_BLK_ADDRESS           0x0000000000001f40
-#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
+/*
+ * Value used by old qemu-dm, there have been replace to match
+ * the QEMU BIOS.
+ */
+#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
 
 #endif /* _IOREQ_H_ */
 
diff -r 7031e1e74c3d -r 6fae4331d5aa xen/include/public/hvm/params.h
--- a/xen/include/public/hvm/params.h   Fri Oct 29 18:14:01 2010 +0100
+++ b/xen/include/public/hvm/params.h   Fri Oct 29 18:42:34 2010 +0100
@@ -113,6 +113,17 @@
 #define HVM_PARAM_CONSOLE_PFN    17
 #define HVM_PARAM_CONSOLE_EVTCHN 18
 
-#define HVM_NR_PARAMS          19
+/*
+ * Select location of ACPI PM1a and TMR control blocks. Currently two locations
+ * are supported, specified by version 0 or 1 in this parameter:
+ *   - 0: default, use the old addresses
+ *        PM1A_EVT == 0x1f40; PM1A_CNT == 0x1f44; PM_TMR == 0x1f48
+ *   - 1: use the new default qemu addresses
+ *        PM1A_EVT == 0xb000; PM1A_CNT == 0xb004; PM_TMR == 0xb008
+ * You can find these address definitions in <hvm/ioreq.h>
+ */
+#define HVM_PARAM_ACPI_IOPORTS_LOCATION 19
+
+#define HVM_NR_PARAMS          20
 
 #endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] x86 hvm: Introduce pmtimer_change_ioport and HVM_PARAM_ACPI_IOPORTS_LOCATION, Xen patchbot-unstable <=