Re: [kvm-devel] [PATCH RFC 1/4]Porting Xentrace to kvm

2008-03-16 Thread Chris Wright
* Liu, Eric E ([EMAIL PROTECTED]) wrote:
> +#ifdef CONFIG_KVM_TRACE
> +#define KVMTRACE_ND(evt, vcpu, cycles, count, d1, d2, d3, d4)
> \
> + do {
> \
> + if (unlikely(kvm_trace_enable_flag)) {
> \
> + if (KVM_TRC_##evt == KVM_TRC_VMEXIT ||
> \
> + KVM_TRC_##evt == KVM_TRC_PAGE_FAULT) {
> \
> + struct {
> \
> + u32 pid:16, vid:16;
> \
> + u32 data1;
> \
> + unsigned long data2;
> \
> + } _d;
> \
> + _d.pid  = (u16)current->tgid;
> \
> + _d.vid  = (vcpu)->vcpu_id;
> \
> + _d.data1 = d1;
> \
> + _d.data2 = d2;
> \
> + kvm_trace_var(KVM_TRC_ ## evt, cycles,

BTW, this appears to break bisectability of the series, since
kvm_trace_var doesn't exist until next patch.

thanks,
-chris

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH RFC 1/4]Porting Xentrace to kvm

2008-03-16 Thread Avi Kivity
Liu, Eric E wrote:
> >From 0d7f1ee470fe907e00ac6246bfa11e5322bc64fb Mon Sep 17 00:00:00 2001
> From: Feng (Eric) Liu <[EMAIL PROTECTED]>
> Date: Sat, 15 Mar 2008 06:07:33 -0400
> Subject: [PATCH] KVM: Add some trace entries in current code, when the
> KVM_TRACE
> compilation option is enabled, it outputs the data info thrace
> buffer. Define some interfaces for userspace tools to use the
> buffer and analyze the trace data.
>   

>  
> +#ifdef CONFIG_KVM_TRACE
> +#define KVMTRACE_ND(evt, vcpu, cycles, count, d1, d2, d3, d4)
> \
> + do {
> \
> + if (unlikely(kvm_trace_enable_flag)) {
> \
> + if (KVM_TRC_##evt == KVM_TRC_VMEXIT ||
> \
> + KVM_TRC_##evt == KVM_TRC_PAGE_FAULT) {
> \
> + struct {
> \
> + u32 pid:16, vid:16;
>   

pids can be 32-bit, I think...

> \
> + u32 data1;
> \
> + unsigned long data2;
> \
> + } _d;
> \
> + _d.pid  = (u16)current->tgid;
> \
> + _d.vid  = (vcpu)->vcpu_id;
> \
> + _d.data1 = d1;
> \
> + _d.data2 = d2;
> \
> + kvm_trace_var(KVM_TRC_ ## evt, cycles,
> \
> + sizeof(_d), (unsigned char *)&_d);
> \
> + } else {
> \
>   

This special-casing of exits and page faults is probably unnecessary.  
Zeroing a couple of variables in a developer-only environment isn't 
worth it.


-- 
error compiling committee.c: too many arguments to function


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH RFC 1/4]Porting Xentrace to kvm

2008-03-13 Thread Liu, Eric E

>From 0d7f1ee470fe907e00ac6246bfa11e5322bc64fb Mon Sep 17 00:00:00 2001
From: Feng (Eric) Liu <[EMAIL PROTECTED]>
Date: Sat, 15 Mar 2008 06:07:33 -0400
Subject: [PATCH] KVM: Add some trace entries in current code, when the
KVM_TRACE
compilation option is enabled, it outputs the data info thrace
buffer. Define some interfaces for userspace tools to use the
buffer and analyze the trace data.

Signed-off-by: Feng (Eric) Liu <[EMAIL PROTECTED]>
---
 arch/x86/kvm/Kconfig   |7 ++
 arch/x86/kvm/Makefile  |2 +-
 arch/x86/kvm/vmx.c |   21 +-
 arch/x86/kvm/x86.c |   21 +++
 include/asm-x86/kvm.h  |   20 ++
 include/asm-x86/kvm_host.h |   47

 include/linux/kvm.h|   46
+++
 include/linux/kvm_host.h   |6 +
 virt/kvm/kvm_main.c|   22 
 9 files changed, 189 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig
index 41962e7..9fa53be 100644
--- a/arch/x86/kvm/Kconfig
+++ b/arch/x86/kvm/Kconfig
@@ -36,6 +36,13 @@ config KVM
 
  If unsure, say N.
 
+config KVM_TRACE
+   bool "KVM trace support"
+   depends on KVM
+   default n 
+   ---help---
+ Say yes here to enable KVM trace support
+
 config KVM_INTEL
tristate "KVM for Intel processors support"
depends on KVM
diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile
index 4d0c22e..db5dfa9 100644
--- a/arch/x86/kvm/Makefile
+++ b/arch/x86/kvm/Makefile
@@ -2,7 +2,7 @@
 # Makefile for Kernel-based Virtual Machine module
 #
 
-common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o)
+common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o kvm_trace.o
ioapic.o)
 
 EXTRA_CFLAGS += -Ivirt/kvm -Iarch/x86/kvm
 
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 9951ec9..55f22ad 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1793,6 +1793,8 @@ out:
 static void vmx_inject_irq(struct kvm_vcpu *vcpu, int irq)
 {
struct vcpu_vmx *vmx = to_vmx(vcpu);
+   KVMTRACE_1D(INJ_VIRQ, vcpu, 0,
+   irq | INTR_TYPE_SOFT_INTR | INTR_INFO_VALID_MASK);
 
if (vcpu->arch.rmode.active) {
vmx->rmode.irq.pending = true;
@@ -1944,6 +1946,7 @@ static int handle_exception(struct kvm_vcpu *vcpu,
struct kvm_run *kvm_run)
error_code = vmcs_read32(VM_EXIT_INTR_ERROR_CODE);
if (is_page_fault(intr_info)) {
cr2 = vmcs_readl(EXIT_QUALIFICATION);
+   KVMTRACE_2D(PAGE_FAULT, vcpu, 0, error_code, cr2);
return kvm_mmu_page_fault(vcpu, cr2, error_code);
}
 
@@ -1972,6 +1975,7 @@ static int handle_external_interrupt(struct
kvm_vcpu *vcpu,
 struct kvm_run *kvm_run)
 {
++vcpu->stat.irq_exits;
+   KVMTRACE_1D(INTR, vcpu, 0, vmcs_read32(VM_EXIT_INTR_INFO));
return 1;
 }
 
@@ -2029,6 +2033,7 @@ static int handle_cr(struct kvm_vcpu *vcpu, struct
kvm_run *kvm_run)
reg = (exit_qualification >> 8) & 15;
switch ((exit_qualification >> 4) & 3) {
case 0: /* mov to cr */
+   KVMTRACE_2D(CR_WRITE, vcpu, 0, cr,
vcpu->arch.regs[reg]);
switch (cr) {
case 0:
vcpu_load_rsp_rip(vcpu);
@@ -2061,6 +2066,7 @@ static int handle_cr(struct kvm_vcpu *vcpu, struct
kvm_run *kvm_run)
vcpu->arch.cr0 &= ~X86_CR0_TS;
vmcs_writel(CR0_READ_SHADOW, vcpu->arch.cr0);
vmx_fpu_activate(vcpu);
+   KVMTRACE_0D(CLTS, vcpu, 0);
skip_emulated_instruction(vcpu);
return 1;
case 1: /*mov from cr*/
@@ -2069,12 +2075,14 @@ static int handle_cr(struct kvm_vcpu *vcpu,
struct kvm_run *kvm_run)
vcpu_load_rsp_rip(vcpu);
vcpu->arch.regs[reg] = vcpu->arch.cr3;
vcpu_put_rsp_rip(vcpu);
+   KVMTRACE_2D(CR_READ, vcpu, 0, cr,
vcpu->arch.regs[reg]);
skip_emulated_instruction(vcpu);
return 1;
case 8:
vcpu_load_rsp_rip(vcpu);
vcpu->arch.regs[reg] = kvm_get_cr8(vcpu);
vcpu_put_rsp_rip(vcpu);
+   KVMTRACE_2D(CR_READ, vcpu, 0, cr,
vcpu->arch.regs[reg]);
skip_emulated_instruction(vcpu);
return 1;
}
@@ -2120,6 +2128,7 @@ static int handle_dr(struct kvm_vcpu *vcpu, struct
kvm_run *kvm_run)
val = 0;
}
vcpu->arch.regs[reg] = val;
+   KVMTRACE_2D(DR_READ, vcpu, 0, dr, val);
} else {
/* mov to dr */
}
@@ -2144,6 +2153,8 @@ static int handle_rdmsr(struct kvm_vcpu *vcpu,
struct kvm_run *kvm_run)