All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arun Sharma <arun.sharma@intel.com>
To: Ian Pratt <Ian.Pratt@cl.cam.ac.uk>,
	Keir Fraser <Keir.Fraser@cl.cam.ac.uk>
Cc: xen-devel@lists.xensource.com
Subject: [PATCH] vmx-mmio-accel.patch
Date: Tue, 14 Jun 2005 16:15:37 -0700	[thread overview]
Message-ID: <20050614231537.GA17613@intel.com> (raw)

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@intel.com>
Signed-off-by: Arun Sharma <arun.sharma@intel.com>

--- 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 */

             reply	other threads:[~2005-06-14 23:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-14 23:15 Arun Sharma [this message]
     [not found] ` <mailman.1118790777.17454@unix-os.sc.intel.com>
2005-06-20  4:27   ` [PATCH] vmx-mmio-accel.patch Arun Sharma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050614231537.GA17613@intel.com \
    --to=arun.sharma@intel.com \
    --cc=Ian.Pratt@cl.cam.ac.uk \
    --cc=Keir.Fraser@cl.cam.ac.uk \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.