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-devel

[Xen-devel] [PATCH V5 3/6] xen, Introduce pmtimer_change_ioport and HVM_

To: Xen Devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH V5 3/6] xen, Introduce pmtimer_change_ioport and HVM_PARAM_ACPI_IOPORTS_LOCATION.
From: anthony.perard@xxxxxxxxxx
Date: Fri, 29 Oct 2010 18:22:22 +0100
Cc: anthony.perard@xxxxxxxxxx
Delivery-date: Fri, 29 Oct 2010 10:27:45 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1288372945-5869-1-git-send-email-anthony.perard@xxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <1288372945-5869-1-git-send-email-anthony.perard@xxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
From: Anthony PERARD <anthony.perard@xxxxxxxxxx>

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>
---
 xen/arch/x86/hvm/hvm.c          |    9 +++++++++
 xen/arch/x86/hvm/pmtimer.c      |   26 ++++++++++++++++++++++++--
 xen/include/asm-x86/hvm/vpt.h   |    1 +
 xen/include/public/hvm/params.h |   12 +++++++++++-
 4 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 94190d3..4b85000 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -2991,6 +2991,15 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE(void) 
arg)
                     rc = -EINVAL;
 
                 break;
+            case HVM_PARAM_ACPI_IOPORTS_LOCATION:
+                if (a.value == 1)
+                    pmtimer_change_ioport(d, 1);
+                else if (a.value == 0)
+                    pmtimer_change_ioport(d, 0);
+                else
+                    rc = -EINVAL;
+
+                break;
             }
 
             if ( rc == 0 )
diff --git a/xen/arch/x86/hvm/pmtimer.c b/xen/arch/x86/hvm/pmtimer.c
index 1b9ab7b..f046201 100644
--- a/xen/arch/x86/hvm/pmtimer.c
+++ b/xen/arch/x86/hvm/pmtimer.c
@@ -24,6 +24,9 @@
 #include <asm/acpi.h> /* for hvm_acpi_power_button prototype */
 
 /* 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 +158,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 +279,21 @@ static int pmtimer_load(struct domain *d, 
hvm_domain_context_t *h)
 HVM_REGISTER_SAVE_RESTORE(PMTIMER, pmtimer_save, pmtimer_load, 
                           1, HVMSR_PER_DOM);
 
+void pmtimer_change_ioport(struct domain *d, int use_new)
+{
+    if (use_new) {
+        register_portio_handler(d, TMR_VAL_ADDR, 4, handle_pmt_io);
+        register_portio_handler(d, PM1a_STS_ADDR, 4, handle_evt_io);
+        unregister_portio_handler(d, TMR_VAL_ADDR_OLD, 4);
+        unregister_portio_handler(d, PM1a_STS_ADDR_OLD, 4);
+    } else {
+        register_portio_handler(d, TMR_VAL_ADDR_OLD, 4, handle_pmt_io);
+        register_portio_handler(d, PM1a_STS_ADDR_OLD, 4, handle_evt_io);
+        unregister_portio_handler(d, TMR_VAL_ADDR, 4);
+        unregister_portio_handler(d, PM1a_STS_ADDR, 4);
+    }
+}
+
 void pmtimer_init(struct vcpu *v)
 {
     PMTState *s = &v->domain->arch.hvm_domain.pl_time.vpmt;
@@ -284,8 +306,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 --git a/xen/include/asm-x86/hvm/vpt.h b/xen/include/asm-x86/hvm/vpt.h
index 65b0dff..6b68888 100644
--- a/xen/include/asm-x86/hvm/vpt.h
+++ b/xen/include/asm-x86/hvm/vpt.h
@@ -179,6 +179,7 @@ void rtc_update_clock(struct domain *d);
 void pmtimer_init(struct vcpu *v);
 void pmtimer_deinit(struct domain *d);
 void pmtimer_reset(struct domain *d);
+void pmtimer_change_ioport(struct domain *d, int use_new);
 
 void hpet_init(struct vcpu *v);
 void hpet_deinit(struct domain *d);
diff --git a/xen/include/public/hvm/params.h b/xen/include/public/hvm/params.h
index 673148b..2558070 100644
--- a/xen/include/public/hvm/params.h
+++ b/xen/include/public/hvm/params.h
@@ -113,6 +113,16 @@
 #define HVM_PARAM_CONSOLE_PFN    17
 #define HVM_PARAM_CONSOLE_EVTCHN 18
 
-#define HVM_NR_PARAMS          19
+/*
+ * The firmware have changed to match the QEMU one, specifically, the addresses
+ * of the ACPI port I/O have changed. So, this parameter give the ability for
+ * Xen to handle both addresses. Possible values:
+ *   - 0: default, use the old addresses (0x1f40, 0x1f48)
+ *   - 1: use the qemu/new addresses (0xb000, 0xb0008)
+ * You can found the addresses in xen/include/public/hvm/ioreq.h.
+ */
+#define HVM_PARAM_ACPI_IOPORTS_LOCATION 19
+
+#define HVM_NR_PARAMS          20
 
 #endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */
-- 
1.7.1


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