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

[Xen-devel] [PATCH] vmx-mmio-accel.patch



Generalize the vmx_io_intercept() mechanism to include MMIO as well.
This is needed for the local APIC implementation and possibly for
VGA acceleration as well.

Signed-off-by: Xiaofeng Ling <xiaofeng.ling@xxxxxxxxx>
Signed-off-by: Arun Sharma <arun.sharma@xxxxxxxxx>

--- a/xen/arch/x86/vmx.c        Tue Jun 14 22:54:56 2005
+++ b/xen/arch/x86/vmx.c        Tue Jun 14 16:08:09 2005
@@ -451,10 +451,9 @@
     p->port_mm = 0;
 
     /* Check if the packet needs to be intercepted */
-    if (vmx_io_intercept(p)) {
+    if (vmx_portio_intercept(p))
        /* no blocking & no evtchn notification */
         return;
-    } 
 
     set_bit(ARCH_VMX_IO_WAIT, &d->arch.arch_vmx.flags);
     p->state = STATE_IOREQ_READY;
--- a/xen/arch/x86/vmx_intercept.c      Tue Jun 14 22:54:56 2005
+++ b/xen/arch/x86/vmx_intercept.c      Tue Jun 14 16:08:09 2005
@@ -31,14 +31,17 @@
 
 #ifdef CONFIG_VMX
 
-/* for intercepting io request after vm_exit, return value: 0--not handle; 
1--handled */
-int vmx_io_intercept(ioreq_t *p)
+/* Check if the request is handled inside xen
+   return value: 0 --not handled; 1 --handled */
+int vmx_io_intercept(ioreq_t *p, int type)
 {
     struct vcpu *d = current;
     struct vmx_handler_t *handler = 
&(d->arch.arch_vmx.vmx_platform.vmx_handler);
     int i;
     unsigned long addr, offset;
     for (i = 0; i < handler->num_slot; i++) {
+        if( type != handler->type)
+            continue;
         addr   = handler->hdl_list[i].addr;
         offset = handler->hdl_list[i].offset;
         if (p->addr >= addr &&
@@ -48,7 +51,8 @@
     return 0;
 }
 
-int register_io_handler(unsigned long addr, unsigned long offset, 
intercept_action_t action)
+int register_io_handler(unsigned long addr, unsigned long offset, 
+                        intercept_action_t action, int type)
 {
     struct vcpu *d = current;
     struct vmx_handler_t *handler = 
&(d->arch.arch_vmx.vmx_platform.vmx_handler);
@@ -63,6 +67,7 @@
     handler->hdl_list[num].offset = offset;
     handler->hdl_list[num].action = action;
     handler->num_slot++;
+    handler->type = type;
     return 1;
 
 }
@@ -256,7 +261,7 @@
         p->state = STATE_IORESP_READY;
 
        /* register handler to intercept the PIT io when vm_exit */
-       register_io_handler(0x40, 4, intercept_pit_io); 
+       register_portio_handler(0x40, 4, intercept_pit_io); 
     }
 
 }
--- a/xen/arch/x86/vmx_platform.c       Tue Jun 14 22:54:56 2005
+++ b/xen/arch/x86/vmx_platform.c       Tue Jun 14 16:08:09 2005
@@ -504,7 +504,6 @@
         domain_crash_synchronous();
     }
 
-    set_bit(ARCH_VMX_IO_WAIT, &d->arch.arch_vmx.flags);
     p->dir = dir;
     p->pdata_valid = pvalid;
 
@@ -513,7 +512,6 @@
     p->addr = gpa;
     p->u.data = value;
 
-    p->state = STATE_IOREQ_READY;
 
     if (inst_p->flags & REPZ) {
         if (vm86)
@@ -527,12 +525,11 @@
     if ((pvalid) && vmx_paging_enabled(current))
         p->u.pdata = (void *) gva_to_gpa(p->u.data);
 
-#if 0
-    printf("send_mmio_req: eip 0x%lx:0x%lx, dir %d, pdata_valid %d, ",
-       inst_decoder_regs->cs, inst_decoder_regs->eip, p->dir, p->pdata_valid);
-    printf("port_mm %d, size %lld, addr 0x%llx, value 0x%lx, count %lld\n",
-       p->port_mm, p->size, p->addr, value, p->count);
-#endif
+    if (vmx_mmio_intercept(p))
+        return;
+
+    set_bit(ARCH_VMX_IO_WAIT, &d->arch.arch_vmx.flags);
+    p->state = STATE_IOREQ_READY;
 
     evtchn_send(IOPACKET_PORT);
     vmx_wait_io();
--- a/xen/include/asm-x86/vmx_intercept.h       Tue Jun 14 22:54:56 2005
+++ b/xen/include/asm-x86/vmx_intercept.h       Tue Jun 14 16:08:09 2005
@@ -1,4 +1,3 @@
-
 #ifndef _VMX_INTERCEPT_H
 #define _VMX_INTERCEPT_H
 
@@ -14,8 +13,11 @@
 
 typedef int (*intercept_action_t)(ioreq_t*);
 
+enum {PORTIO, MMIO};
+
 struct vmx_handler_t {
     int num_slot;
+    int type;
     struct {
         unsigned long       addr;
         unsigned long       offset;
@@ -24,8 +26,32 @@
 };
 
 /* global io interception point in HV */
-extern int vmx_io_intercept(ioreq_t*);
-extern int register_io_handler(unsigned long, unsigned long, 
intercept_action_t);
+extern int vmx_io_intercept(ioreq_t *p, int type);
+extern int register_io_handler(unsigned long addr, unsigned long offset, 
+                               intercept_action_t action, int type);
 
+static inline int vmx_portio_intercept(ioreq_t *p)
+{
+    return vmx_io_intercept(p, PORTIO);
+}
+
+static inline int vmx_mmio_intercept(ioreq_t *p)
+{
+    return vmx_io_intercept(p, MMIO);
+}
+
+static inline int register_portio_handler(unsigned long addr, 
+                                          unsigned long offset, 
+                                          intercept_action_t action)
+{
+    return register_io_handler(addr, offset, action, PORTIO);
+}
+
+static inline int register_mmio_handler(unsigned long addr, 
+                                        unsigned long offset, 
+                                        intercept_action_t action)
+{
+    return register_io_handler(addr, offset, action, MMIO);
+}
 
 #endif /* _VMX_INTERCEPT_H */

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


 


Rackspace

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