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
|