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] xentrace:Trace mmio/io read/write value

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] xentrace:Trace mmio/io read/write value
From: "George Dunlap" <dunlapg@xxxxxxxxx>
Date: Mon, 3 Nov 2008 13:13:43 +0000
Delivery-date: Mon, 03 Nov 2008 05:14:07 -0800
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:mime-version:content-type:content-transfer-encoding :content-disposition:x-google-sender-auth; bh=gLPJHF/FPNzOG57vxJOuYFIt5TQhIgGsowJSNQknw14=; b=TOn8TEJGxhTI7IryuqfdMqbKS23oDO5Upf9IQMDMnQ3kov1HJv7iowZhqq46jKiEBc yR+koiokBUn8Kl160OomIJdqmtc0nGWD1FhWnaJwsE6TCDdKgrRHWYS0kHaUZmfgNVOp ccFlgiNZvFmPyFfHNoCO9BgcpOJf5fDzVWOcc=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition:x-google-sender-auth; b=DfZKQhn8AGt40C77mk8qZ8ZJSHi/VTamFvlx/UwCJSXS5/6Lyisp3GHWJTctb06Fmq dqIED486ISS5n/prRAjREZoU+qUqDNNHFLDTSXQmgYQnDlX23l8d5KDCfbs43iACyuXt gXhT/n9CuY8VSeeb5sb3dvYl7qdpJBKNh1gPQ=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
xentrace: Trace mmio/io read/write value

Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxxxxx>

diff -r f12d9595d07c xen/arch/x86/hvm/emulate.c
--- a/xen/arch/x86/hvm/emulate.c        Fri Oct 31 14:02:39 2008 +0000
+++ b/xen/arch/x86/hvm/emulate.c        Mon Nov 03 13:11:16 2008 +0000
@@ -14,10 +14,73 @@
 #include <xen/lib.h>
 #include <xen/sched.h>
 #include <xen/paging.h>
+#include <xen/trace.h>
 #include <asm/event.h>
 #include <asm/hvm/emulate.h>
 #include <asm/hvm/hvm.h>
 #include <asm/hvm/support.h>
+
+#define HVMTRACE_IO_ASSIST_WRITE 0x200
+static inline void hvmtrace_io_assist(int is_mmio, ioreq_t *p)
+{
+    unsigned event, size;
+
+    if(is_mmio)
+        event = TRC_HVM_MMIO_ASSIST;
+    else
+        event = TRC_HVM_IO_ASSIST;
+#ifdef __x86_64__
+    if ( p->addr > ((u32)-1) )
+    {
+        struct {
+            u64 addr;
+            u32 data;
+        } __attribute__((packed)) d;
+
+        d.addr = p->addr;
+
+        /* 64-bit address */
+        event |= TRC_FLAG_64;
+
+        /* Change "read" bit into a "write" bit */
+        if ( !p->dir )
+            event |= HVMTRACE_IO_ASSIST_WRITE;
+
+        if ( !p->data_is_ptr )
+        {
+            d.data = p->data;
+            size = sizeof(d);
+        }
+        else
+            size=sizeof(d.addr);
+
+        trace_var(event, 0/*!cycles*/,size, (unsigned char *)&d);
+    }
+    else
+#endif
+    {
+        struct {
+            u32 addr, data;
+        } d;
+
+        d.addr = p->addr;
+
+        /* Change "read" bit into a "write" bit */
+        if ( !p->dir )
+            event |= HVMTRACE_IO_ASSIST_WRITE;
+
+        if ( !p->data_is_ptr )
+        {
+            d.data = p->data;
+            size = sizeof(d);
+        }
+        else
+            size=sizeof(d.addr);
+
+        trace_var(event, 0/*!cycles*/,size, (unsigned char *)&d);
+    }
+}
+

 static int hvmemul_do_io(
     int is_mmio, paddr_t addr, unsigned long *reps, int size,
@@ -110,6 +173,8 @@
     p->df = df;
     p->data = value;
     p->io_count++;
+
+    hvmtrace_io_assist(is_mmio, p);

     if ( is_mmio )
     {
diff -r f12d9595d07c xen/include/public/trace.h
--- a/xen/include/public/trace.h        Fri Oct 31 14:02:39 2008 +0000
+++ b/xen/include/public/trace.h        Mon Nov 03 13:11:16 2008 +0000
@@ -142,7 +142,9 @@
 #define TRC_HVM_INVLPG64        (TRC_HVM_HANDLER + TRC_64_FLAG + 0x14)
 #define TRC_HVM_MCE             (TRC_HVM_HANDLER + 0x15)
 #define TRC_HVM_IO_ASSIST       (TRC_HVM_HANDLER + 0x16)
+#define TRC_HVM_IO_ASSIST64     (TRC_HVM_HANDLER + TRC_64_FLAG + 0x16)
 #define TRC_HVM_MMIO_ASSIST     (TRC_HVM_HANDLER + 0x17)
+#define TRC_HVM_MMIO_ASSIST64   (TRC_HVM_HANDLER + TRC_64_FLAG + 0x17)
 #define TRC_HVM_CLTS            (TRC_HVM_HANDLER + 0x18)
 #define TRC_HVM_LMSW            (TRC_HVM_HANDLER + 0x19)
 #define TRC_HVM_LMSW64          (TRC_HVM_HANDLER + TRC_64_FLAG + 0x19)

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

<Prev in Thread] Current Thread [Next in Thread>