RFC: convert KVMTRACE to event traces
Convert custom marker based KVMTRACE to event trace.
Applies on top ofgit://git.kernel.org/pub/scm/linux/kernel/git/mingo/linux-2.6-x86.git
See Documentation/trace/events.txt and commit 7ce7e4249921d5073e764f7ff7ad83cfa9894bd7 if you're interested in playing with event traces.
arch/x86/kvm/vmx.c +20 -33
@@ -25,6 +25,7 @@#include <linux/highmem.h> #include <linux/sched.h> #include <linux/moduleparam.h> +#include <trace/events/kvm/x86-arch.h> #include "kvm_cache_regs.h" #include "x86.h"
@@ -2406,7 +2407,7 @@ static void vmx_inject_irq(struct kvm_vc {struct vcpu_vmx *vmx =to_vmx (vcpu); -KVMTRACE_1D (INJ_VIRQ , vcpu, (u32 )irq, handler); +trace_kvm_inj_virq (irq); ++vcpu->stat.irq_injections;if (vcpu->arch.rmode.active) {
@@ -2631,8 +2632,8 @@ static int handle_exception(struct kvm_vif (vm_need_ept ())BUG (); cr2 =vmcs_readl (EXIT_QUALIFICATION ); -KVMTRACE_3D (PAGE_FAULT , vcpu, error_code, (u32 )cr2, - (u32)((u64 )cr2 >>32 ), handler); +trace_kvm_page_fault (cr2, error_code); +if (vcpu->arch.interrupt.pending || vcpu->arch.exception.pending)kvm_mmu_unprotect_page_virt (vcpu, cr2);return kvm_mmu_page_fault (vcpu, cr2, error_code);
@@ -2679,7 +2680,6 @@ static int handle_external_interrupt(str struct kvm_run *kvm_run) { ++vcpu->stat.irq_exits; -KVMTRACE_1D (INTR , vcpu,vmcs_read32 (VM_EXIT_INTR_INFO ), handler);return 1 ; }
@@ -2727,7 +2727,7 @@ vmx_patch_hypercall(struct kvm_vcpu *vcpstatic int handle_cr (struct kvm_vcpu *vcpu,struct kvm_run *kvm_run) { -unsigned long exit_qualification; +unsigned long exit_qualification, val;int cr;int reg;
@@ -2736,25 +2736,23 @@ static int handle_cr(struct kvm_vcpu *vc reg = (exit_qualification >>8 ) &15 ;switch ((exit_qualification >>4 ) &3 ) {case 0 :/* mov to cr */ -KVMTRACE_3D (CR_WRITE , vcpu, (u32 )cr, - (u32 )kvm_register_read (vcpu, reg), - (u32)((u64 )kvm_register_read (vcpu, reg) >>32 ), - handler); + val =kvm_register_read (vcpu, reg); +trace_kvm_cr_write (cr, val);switch (cr) {case 0 : -kvm_set_cr0 (vcpu,kvm_register_read (vcpu, reg)); +kvm_set_cr0 (vcpu, val);skip_emulated_instruction (vcpu);return 1 ;case 3 : -kvm_set_cr3 (vcpu,kvm_register_read (vcpu, reg)); +kvm_set_cr3 (vcpu, val);skip_emulated_instruction (vcpu);return 1 ;case 4 : -kvm_set_cr4 (vcpu,kvm_register_read (vcpu, reg)); +kvm_set_cr4 (vcpu, val);skip_emulated_instruction (vcpu);return 1 ;case 8 : -kvm_set_cr8 (vcpu,kvm_register_read (vcpu, reg)); +kvm_set_cr8 (vcpu, val);skip_emulated_instruction (vcpu);if (irqchip_in_kernel (vcpu->kvm))return 1 ;
@@ -2767,23 +2765,19 @@ static int handle_cr(struct kvm_vcpu *vc vcpu->arch.cr0 &= ~X86_CR0_TS ;vmcs_writel (CR0_READ_SHADOW , vcpu->arch.cr0);vmx_fpu_activate (vcpu); -KVMTRACE_0D (CLTS , vcpu, handler);skip_emulated_instruction (vcpu);return 1 ;case 1 :/*mov from cr*/ switch (cr) {case 3 :kvm_register_write (vcpu, reg, vcpu->arch.cr3); -KVMTRACE_3D (CR_READ , vcpu, (u32 )cr, - (u32 )kvm_register_read (vcpu, reg), - (u32)((u64 )kvm_register_read (vcpu, reg) >>32 ), - handler); +trace_kvm_cr_read (cr, vcpu->arch.cr3);skip_emulated_instruction (vcpu);return 1 ;case 8 : -kvm_register_write (vcpu, reg,kvm_get_cr8 (vcpu)); -KVMTRACE_2D (CR_READ , vcpu, (u32 )cr, - (u32 )kvm_register_read (vcpu, reg), handler); + val =kvm_get_cr8 (vcpu); +kvm_register_write (vcpu, cr, val); +trace_kvm_cr_read (cr, val);skip_emulated_instruction (vcpu);return 1 ; }
@@ -2851,7 +2845,6 @@ static int handle_dr(struct kvm_vcpu *vc val =0 ; }kvm_register_write (vcpu, reg, val); -KVMTRACE_2D (DR_READ , vcpu, (u32 )dr, (u32 )val, handler); }else { val = vcpu->arch.regs[reg];switch (dr) {
@@ -2884,7 +2877,6 @@ static int handle_dr(struct kvm_vcpu *vc }break ; } -KVMTRACE_2D (DR_WRITE , vcpu, (u32 )dr, (u32 )val, handler); }skip_emulated_instruction (vcpu);return 1 ;
@@ -2906,8 +2898,7 @@ static int handle_rdmsr(struct kvm_vcpureturn 1 ; } -KVMTRACE_3D (MSR_READ , vcpu, ecx, (u32 )data, (u32)(data >>32 ), - handler); +trace_kvm_msr_read (ecx, data);/* FIXME: handling of bits 32:63 of rax, rdx */ vcpu->arch.regs[VCPU_REGS_RAX ] = data &-1u ;
@@ -2922,8 +2913,7 @@ static int handle_wrmsr(struct kvm_vcpuu64 data = (vcpu->arch.regs[VCPU_REGS_RAX ] &-1u ) | ((u64)(vcpu->arch.regs[VCPU_REGS_RDX ] &-1u ) <<32 ); -KVMTRACE_3D (MSR_WRITE , vcpu, ecx, (u32 )data, (u32)(data >>32 ), - handler); +trace_kvm_msr_write (ecx, data);if (vmx_set_msr (vcpu, ecx, data) !=0 ) {kvm_inject_gp (vcpu,0 );
@@ -2950,7 +2940,6 @@ static int handle_interrupt_window(struc cpu_based_vm_exec_control &= ~CPU_BASED_VIRTUAL_INTR_PENDING ;vmcs_write32 (CPU_BASED_VM_EXEC_CONTROL , cpu_based_vm_exec_control); -KVMTRACE_0D (PEND_INTR , vcpu, handler); ++vcpu->stat.irq_window_exits;/*
@@ -3076,6 +3065,7 @@ static int handle_ept_violation(struct k } gpa =vmcs_read64 (GUEST_PHYSICAL_ADDRESS ); +trace_kvm_tdp_page_fault (gpa, exit_qualification);return kvm_mmu_page_fault (vcpu, gpa &PAGE_MASK ,0 ); }
@@ -3165,8 +3155,7 @@ static int kvm_handle_exit(struct kvm_rustruct vcpu_vmx *vmx =to_vmx (vcpu);u32 vectoring_info = vmx->idt_vectoring_info; -KVMTRACE_3D (VMEXIT , vcpu, exit_reason, (u32 )kvm_rip_read (vcpu), - (u32)((u64 )kvm_rip_read (vcpu) >>32 ), entryexit); +trace_kvm_exit (exit_reason,kvm_rip_read (vcpu));/* If we need to emulate an MMIO from handle_invalid_guest_state * we just return 0 */
@@ -3514,10 +3503,8 @@ static void vmx_vcpu_run(struct kvm_vcpu/* We need to handle NMIs before interrupts are enabled */ if ((intr_info &INTR_INFO_INTR_TYPE_MASK ) ==INTR_TYPE_NMI_INTR && - (intr_info &INTR_INFO_VALID_MASK )) { -KVMTRACE_0D (NMI , vcpu, handler); + (intr_info &INTR_INFO_VALID_MASK )) asm("int $2" ); - }vmx_complete_interrupts (vmx); }
arch/x86/kvm/svm.c +7 -20
@@ -25,6 +25,7 @@#include <linux/vmalloc.h> #include <linux/highmem.h> #include <linux/sched.h> +#include <trace/events/kvm/x86-arch.h> #include <asm/desc.h>
@@ -1053,7 +1054,6 @@ static unsigned long svm_get_dr(struct k val =0 ; } -KVMTRACE_2D (DR_READ , vcpu, (u32 )dr, (u32 )val, handler);return val; }
@@ -1062,8 +1062,6 @@ static void svm_set_dr(struct kvm_vcpu * {struct vcpu_svm *svm =to_svm (vcpu); -KVMTRACE_2D (DR_WRITE , vcpu, (u32 )dr, (u32 )value, handler); - *exception =0 ;switch (dr) {
@@ -1121,13 +1119,9 @@ static int pf_interception(struct vcpu_s error_code = svm->vmcb->control.exit_info_1;if (!npt_enabled) -KVMTRACE_3D (PAGE_FAULT , &svm->vcpu, error_code, - (u32 )fault_address, (u32)(fault_address >>32 ), - handler); +trace_kvm_page_fault (fault_address, error_code);else -KVMTRACE_3D (TDP_FAULT , &svm->vcpu, error_code, - (u32 )fault_address, (u32)(fault_address >>32 ), - handler); +trace_kvm_tdp_page_fault (fault_address, error_code);/* * FIXME: Tis shouldn't be necessary here, but there is a flush * missing in the MMU code. Until we find this bug, flush the
@@ -1237,14 +1231,12 @@ static int io_interception(struct vcpu_sstatic int nmi_interception (struct vcpu_svm *svm,struct kvm_run *kvm_run) { -KVMTRACE_0D (NMI , &svm->vcpu, handler);return 1 ; }static int intr_interception (struct vcpu_svm *svm,struct kvm_run *kvm_run) { ++svm->vcpu.stat.irq_exits; -KVMTRACE_0D (INTR , &svm->vcpu, handler);return 1 ; }
@@ -1963,8 +1955,7 @@ static int rdmsr_interception(struct vcpif (svm_get_msr (&svm->vcpu, ecx, &data))kvm_inject_gp (&svm->vcpu,0 );else { -KVMTRACE_3D (MSR_READ , &svm->vcpu, ecx, (u32 )data, - (u32)(data >>32 ), handler); +trace_kvm_msr_read (ecx, data); svm->vcpu.arch.regs[VCPU_REGS_RAX ] = data &0xffffffff ; svm->vcpu.arch.regs[VCPU_REGS_RDX ] = data >>32 ;
@@ -2058,8 +2049,7 @@ static int wrmsr_interception(struct vcpu64 data = (svm->vcpu.arch.regs[VCPU_REGS_RAX ] &-1u ) | ((u64)(svm->vcpu.arch.regs[VCPU_REGS_RDX ] &-1u ) <<32 ); -KVMTRACE_3D (MSR_WRITE , &svm->vcpu, ecx, (u32 )data, (u32)(data >>32 ), - handler); +trace_kvm_msr_write (ecx, data); svm->next_rip =kvm_rip_read (&svm->vcpu) +2 ;if (svm_set_msr (&svm->vcpu, ecx, data))
@@ -2080,8 +2070,6 @@ static int msr_interception(struct vcpu_static int interrupt_window_interception (struct vcpu_svm *svm,struct kvm_run *kvm_run) { -KVMTRACE_0D (PEND_INTR , &svm->vcpu, handler); -svm_clear_vintr (svm); svm->vmcb->control.int_ctl &= ~V_IRQ_MASK ;/*
@@ -2158,8 +2146,7 @@ static int handle_exit(struct kvm_run *kstruct vcpu_svm *svm =to_svm (vcpu);u32 exit_code = svm->vmcb->control.exit_code; -KVMTRACE_3D (VMEXIT , vcpu, exit_code, (u32 )svm->vmcb->save.rip, - (u32)((u64 )svm->vmcb->save.rip >>32 ), entryexit); +trace_kvm_exit (exit_code, svm->vmcb->save.rip);if (is_nested (svm)) { nsvm_printk("nested handle_exit: 0x%x | 0x%lx | 0x%lx | 0x%lx\n",
@@ -2245,7 +2232,7 @@ static inline void svm_inject_irq(struct {struct vmcb_control_area *control; -KVMTRACE_1D (INJ_VIRQ , &svm->vcpu, (u32 )irq, handler); +trace_kvm_inj_virq (irq); ++svm->vcpu.stat.irq_injections; control = &svm->vmcb->control;
arch/x86/kvm/lapic.c +4 -3
@@ -26,6 +26,7 @@#include <linux/io.h> #include <linux/module.h> #include <linux/math64.h> +#include <trace/events/kvm/x86.h> #include <asm/processor.h> #include <asm/msr.h> #include <asm/page.h>
@@ -557,8 +558,6 @@ static u32 __apic_read(struct kvm_lapic {u32 val =0 ; -KVMTRACE_1D (APIC_ACCESS , apic->vcpu, (u32 )offset, handler); -if (offset >=LAPIC_MMIO_LENGTH )return 0 ;
@@ -599,6 +598,8 @@ static void apic_mmio_read(struct kvm_io } result =__apic_read (apic, offset & ~0xf ); +trace_kvm_apic_read (offset, result); +switch (len) {case 1 :case 2 :
@@ -694,7 +695,7 @@ static void apic_mmio_write(struct kvm_i offset &=0xff0 ; -KVMTRACE_1D (APIC_ACCESS , apic->vcpu, (u32 )offset, handler); +trace_kvm_apic_write (offset, val);switch (offset) {case APIC_ID :/* Local APIC ID */
arch/x86/kvm/Makefile +8 -3
@@ -11,12 +11,17 @@ ifeq ($(CONFIG_IOMMU_API),y) common-objs += $(addprefix ../../../virt/kvm/, iommu.o) endif +ifeq ($(CONFIG_TRACEPOINTS),y) +trace-objs = kvm-traces.o +arch-trace-objs = kvm-traces-arch.o +endif + EXTRA_CFLAGS += -Ivirt/kvm -Iarch/x86/kvm kvm-objs := $(common-objs) x86.o mmu.o x86_emulate.o i8259.o irq.o lapic.o \ - i8254.o + i8254.o $(trace-objs) obj-$(CONFIG_KVM) += kvm.o -kvm-intel-objs = vmx.o +kvm-intel-objs = vmx.o $(arch-trace-objs) obj-$(CONFIG_KVM_INTEL) += kvm-intel.o -kvm-amd-objs = svm.o +kvm-amd-objs = svm.o $(arch-trace-objs) obj-$(CONFIG_KVM_AMD) += kvm-amd.o
arch/x86/kvm/kvm-traces.c new file +5 -0
@@ -0,0 +1,5 @@ +#include <linux/sched.h> + + +#define CREATE_TRACE_POINTS +#include <trace/events/kvm/x86.h>
arch/x86/kvm/x86.c +12 -29
107 lines not on this page · raw message
arch/x86/kvm/kvm-traces-arch.c new file +5 -0
@@ -0,0 +1,5 @@ +#include <linux/sched.h> + + +#define CREATE_TRACE_POINTS +#include <trace/events/kvm/x86-arch.h>
include/trace/events/kvm/x86-arch.h new file +151 -0
151 lines not on this page · raw message
include/trace/events/kvm/x86.h new file +146 -0
146 lines not on this page · raw message
arch/x86/kvm/vmx.c static int handle_cr(struct kvm_vcpu *vc · line 2744
Quoted 6 lines · Marcelo Tosatti
arch/x86/kvm/vmx.c +2
-1+trace_kvm_cr_write (cr, val);switch (cr) {case 0 : -kvm_set_cr0 (vcpu,kvm_register_read (vcpu, reg)); +kvm_set_cr0 (vcpu, val);skip_emulated_instruction (vcpu);
Do we really need one trace point covering all cr writes, _and_ one for each specific register?
arch/x86/kvm/svm.c static int pf_interception(struct vcpu_s · line 1124
Quoted 10 lines
arch/x86/kvm/svm.c +2
-6if (!npt_enabled) -KVMTRACE_3D (PAGE_FAULT , &svm->vcpu, error_code, - (u32 )fault_address, (u32)(fault_address >>32 ), - handler); +trace_kvm_page_fault (fault_address, error_code);else -KVMTRACE_3D (TDP_FAULT , &svm->vcpu, error_code, - (u32 )fault_address, (u32)(fault_address >>32 ), - handler); +trace_kvm_tdp_page_fault (fault_address, error_code);
Again this seems a bit cumbersome. Why not just one tracepoint for page faults, with a flag if we're using npt or not?
Quoted 7 lines
arch/x86/kvm/Makefile +5
-0+ifeq ($(CONFIG_TRACEPOINTS),y) +trace-objs = kvm-traces.o +arch-trace-objs = kvm-traces-arch.o +endif + EXTRA_CFLAGS += -Ivirt/kvm -Iarch/x86/kvm
arch/x86/kvm/Makefile ifeq ($(CONFIG_IOMMU_API),y) · line 27
Quoted 10 lines
arch/x86/kvm/Makefile +3
-3kvm-objs := $(common-objs) x86.o mmu.o x86_emulate.o i8259.o irq.o lapic.o \ - i8254.o + i8254.o $(trace-objs) obj-$(CONFIG_KVM) += kvm.o -kvm-intel-objs = vmx.o +kvm-intel-objs = vmx.o $(arch-trace-objs) obj-$(CONFIG_KVM_INTEL) += kvm-intel.o -kvm-amd-objs = svm.o +kvm-amd-objs = svm.o $(arch-trace-objs) obj-$(CONFIG_KVM_AMD) += kvm-amd.o
The option to select even tracing bits is CONFIG_EVENT_TRACING and the makefile syntax used here (both the original makefile and the additions) is rather awkward.
A proper arch/x86/kvm/Makefile including tracing bits should look like the following:
-- snip --EXTRA_CFLAGS += -Ivirt/kvm -Iarch/x86/kvm
kvm-y += $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \
coalesced_mmio.o irq_comm.o)
kvm-$(CONFIG_KVM_TRACE) += $(addprefix ../../../virt/kvm/, kvm_trace.o)
kvm-$(CONFIG_IOMMU_API) += $(addprefix ../../../virt/kvm/, iommu.o)
kmv-y += x86.o mmu.o x86_emulate.o i8259.o irq.o lapic.o \ i8254.o
kvm-$(CONFIG_EVENT_TRACING) += kvm-traces.o kvm-arch-trace-$(CONFIG_EVENT_TRACING) += kvm-traces-arch.o
kvm-intel-y += vmx.o $(kvm-arch-trace-y)
kvm-amd-y += svm.o $(kvm-arch-trace-y)
obj-$(CONFIG_KVM) += kvm.o
obj-$(CONFIG_KVM_INTEL) += kvm-intel.o
obj-$(CONFIG_KVM_AMD) += kvm-amd.o
-- snip --
and do we actually still need kvm_trace.o after this?
Anyway, I'll send the upstream part of the makefile cleanup out ASAP, then you can rebase later.
arch/x86/kvm/kvm-traces.c line 5
Quoted 10 lines
Index:
linux-2.6-x86-2/arch/x86/kvm/kvm-traces.c
===================================================================arch/x86/kvm/kvm-traces.c new file +5
-0@@ -0,0 +1,5 @@ +#include <linux/sched.h> + + +#define CREATE_TRACE_POINTS +#include <trace/events/kvm/x86.h>
Can't we just put this into some other common .c file? That would also reduce the amount of makefile magic required.
arch/x86/kvm/kvm-traces-arch.c line 5
Quoted 10 lines
Index:
linux-2.6-x86-2/arch/x86/kvm/kvm-traces-arch.c
===================================================================arch/x86/kvm/kvm-traces-arch.c new file +5
-0@@ -0,0 +1,5 @@ +#include <linux/sched.h> + + +#define CREATE_TRACE_POINTS +#include <trace/events/kvm/x86-arch.h>
Same for this one, especially as the makefile hackery required for this one is even worse..
Quoted 10 lines · Christoph Hellwig
arch/x86/kvm/vmx.c static int handle_cr(struct kvm_vcpu *vc · line 2744
Quoted 6 lines · Marcelo Tosatti
arch/x86/kvm/vmx.c +2
-1+trace_kvm_cr_write (cr, val);switch (cr) {case 0 : -kvm_set_cr0 (vcpu,kvm_register_read (vcpu, reg)); +kvm_set_cr0 (vcpu, val);skip_emulated_instruction (vcpu);Do we really need one trace point covering all cr writes, _and_ one for each specific register?
There is one tracepoint named kvm_cr that covers cr reads and writes.
kvm_trace_cr_read/kvm_trace_cr_write are macros that expand to kvm_trace_cr(rw=1 or rw=0). Perhaps that is not a very good idea.
Quoted 14 lines
arch/x86/kvm/svm.c static int pf_interception(struct vcpu_s · line 1124
Quoted 11 lines
arch/x86/kvm/svm.c +2
-6if (!npt_enabled) -KVMTRACE_3D (PAGE_FAULT , &svm->vcpu, error_code, - (u32 )fault_address, (u32)(fault_address >>32 ), - handler); +trace_kvm_page_fault (fault_address, error_code);else -KVMTRACE_3D (TDP_FAULT , &svm->vcpu, error_code, - (u32 )fault_address, (u32)(fault_address >>32 ), - handler); +trace_kvm_tdp_page_fault (fault_address, error_code);Again this seems a bit cumbersome. Why not just one tracepoint for page faults, with a flag if we're using npt or not?
Issue is the meaning of these faults is different. With npt disabled the fault is a guest fault (like a normal pagefault), but with npt enabled the fault indicates the host pagetables the hardware uses to do the translation are not set up correctly.
I did unify them as you suggest but reverted back to separate tracepoints because the unification might be confusing.
Can be unified later if desirable.
Quoted 41 lines
Quoted 7 lines
arch/x86/kvm/Makefile +5
-0+ifeq ($(CONFIG_TRACEPOINTS),y) +trace-objs = kvm-traces.o +arch-trace-objs = kvm-traces-arch.o +endif + EXTRA_CFLAGS += -Ivirt/kvm -Iarch/x86/kvmarch/x86/kvm/Makefile ifeq ($(CONFIG_IOMMU_API),y) · line 27
Quoted 10 lines
arch/x86/kvm/Makefile +3
-3kvm-objs := $(common-objs) x86.o mmu.o x86_emulate.o i8259.o irq.o lapic.o \ - i8254.o + i8254.o $(trace-objs) obj-$(CONFIG_KVM) += kvm.o -kvm-intel-objs = vmx.o +kvm-intel-objs = vmx.o $(arch-trace-objs) obj-$(CONFIG_KVM_INTEL) += kvm-intel.o -kvm-amd-objs = svm.o +kvm-amd-objs = svm.o $(arch-trace-objs) obj-$(CONFIG_KVM_AMD) += kvm-amd.oThe option to select even tracing bits is
CONFIG_EVENT_TRACINGand the makefile syntax used here (both the original makefile and the additions) is rather awkward.A proper
arch/x86/kvm/Makefileincluding tracing bits should look like the following:-- snip --
EXTRA_CFLAGS+= -Ivirt/kvm -Iarch/x86/kvmkvm-y += $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \
coalesced_mmio.o irq_comm.o)
kvm-$(CONFIG_KVM_TRACE) += $(addprefix ../../../virt/kvm/, kvm_trace.o)
kvm-$(CONFIG_IOMMU_API) += $(addprefix ../../../virt/kvm/, iommu.o)kmv-y += x86.o mmu.o x86_emulate.o i8259.o irq.o lapic.o \ i8254.okvm-$(CONFIG_EVENT_TRACING) += kvm-traces.o kvm-arch-trace-$(CONFIG_EVENT_TRACING) += kvm-traces-arch.o
kvm-intel-y += vmx.o $(kvm-arch-trace-y)
kvm-amd-y += svm.o $(kvm-arch-trace-y)
Quoted 6 lines
obj-$(CONFIG_KVM) += kvm.o
obj-$(CONFIG_KVM_INTEL) += kvm-intel.o
obj-$(CONFIG_KVM_AMD) += kvm-amd.o
-- snip --and do we actually still need kvm_trace.o after this?
Your version looks much nicer. kvm_trace.o can disappear as soon as this is in Avi's tree and a decent replacement for user/kvm_trace.c is in qemu-kvm.git.
Quoted 2 lines
Anyway, I'll send the upstream part of the makefile cleanup out ASAP, then you can rebase later.
OK.
Quoted 15 lines
arch/x86/kvm/kvm-traces.c line 5
Quoted 11 lines
Index:
linux-2.6-x86-2/arch/x86/kvm/kvm-traces.c
===================================================================arch/x86/kvm/kvm-traces.c new file +5
-0@@ -0,0 +1,5 @@ +#include <linux/sched.h> + + +#define CREATE_TRACE_POINTS +#include <trace/events/kvm/x86.h> Can't we just put this into some other common .c file? That would also reduce the amount of makefile magic required.
Quoted 13 lines
arch/x86/kvm/kvm-traces-arch.c line 5
Quoted 10 lines
Index:
linux-2.6-x86-2/arch/x86/kvm/kvm-traces-arch.c
===================================================================arch/x86/kvm/kvm-traces-arch.c new file +5
-0@@ -0,0 +1,5 @@ +#include <linux/sched.h> + + +#define CREATE_TRACE_POINTS +#include <trace/events/kvm/x86-arch.h> Same for this one, especially as the makefile hackery required for this one is even worse..
Probably for both. Now that you say I can't explain the reason for the separate C files. Will put this up in a git tree in a couple of hours.
Quoted 15 lines · Marcelo Tosatti
Quoted 12 lines · Christoph Hellwig
arch/x86/kvm/vmx.c static int handle_cr(struct kvm_vcpu *vc · line 2744
Quoted 7 lines · Marcelo Tosatti
arch/x86/kvm/vmx.c +2
-1+trace_kvm_cr_write (cr, val);switch (cr) {case 0 : -kvm_set_cr0 (vcpu,kvm_register_read (vcpu, reg)); +kvm_set_cr0 (vcpu, val);skip_emulated_instruction (vcpu);Do we really need one trace point covering all cr writes, _and_ one for each specific register?
Quoted 5 lines
There is one tracepoint named
kvm_crthat covers cr reads and writes.kvm_trace_cr_read/kvm_trace_cr_write are macros that expand to
kvm_trace_cr(rw=1 or rw=0). Perhaps that is not a very good idea.
If the framework allows us to filter on arguments, that's fine (I think it does). We need a way to look at, say, cr4 reads in a sea of cr3 read/writes.
Quoted 9 lines
Quoted 3 lines
Again this seems a bit cumbersome. Why not just one tracepoint for page faults, with a flag if we're using npt or not?
Issue is the meaning of these faults is different. With npt disabled the fault is a guest fault (like a normal pagefault), but with npt enabled the fault indicates the host pagetables the hardware uses to do the translation are not set up correctly.
No, with npt disabled a fault is either a guest fault or a shadow fault or a host (minor/major) fault. With npt enabled it cannot be a guest fault, but may be a shadow fault or a host fault.
Quoted 5 lines
I did unify them as you suggest but reverted back to separate tracepoints because the unification might be confusing.
Can be unified later if desirable.
I think you can unify them, especially as they will never occur together in the same run. We'll need tracepoints later in the mmu code for dealing with the different fault types. Guest faults are marked by injecting a #GP, shadow faults by populating an spte, and host faults somewhere in the bowels of get_user_pages(). Isn't it wonderful how everything is integrated?
Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.