diff options
author | Gleb Natapov <gleb@redhat.com> | 2011-10-05 08:01:23 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-11-17 09:28:00 -0500 |
commit | d7cd97964ba6d70c558348bd2c87290dce885583 (patch) | |
tree | d75eaa02e97b49cf46b3b7542401fbda93f94665 /arch | |
parent | 8bf00a529967dafbbb210b377c38a15834d1e979 (diff) |
KVM: VMX: Add support for guest/host-only profiling
Support guest/host-only profiling by switch perf msrs on
a guest entry if needed.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kvm/vmx.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 55e849b52d9e..98f4b0bcc660 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <asm/mce.h> | 39 | #include <asm/mce.h> |
40 | #include <asm/i387.h> | 40 | #include <asm/i387.h> |
41 | #include <asm/xcr.h> | 41 | #include <asm/xcr.h> |
42 | #include <asm/perf_event.h> | ||
42 | 43 | ||
43 | #include "trace.h" | 44 | #include "trace.h" |
44 | 45 | ||
@@ -6050,6 +6051,24 @@ static void vmx_cancel_injection(struct kvm_vcpu *vcpu) | |||
6050 | vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, 0); | 6051 | vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, 0); |
6051 | } | 6052 | } |
6052 | 6053 | ||
6054 | static void atomic_switch_perf_msrs(struct vcpu_vmx *vmx) | ||
6055 | { | ||
6056 | int i, nr_msrs; | ||
6057 | struct perf_guest_switch_msr *msrs; | ||
6058 | |||
6059 | msrs = perf_guest_get_msrs(&nr_msrs); | ||
6060 | |||
6061 | if (!msrs) | ||
6062 | return; | ||
6063 | |||
6064 | for (i = 0; i < nr_msrs; i++) | ||
6065 | if (msrs[i].host == msrs[i].guest) | ||
6066 | clear_atomic_switch_msr(vmx, msrs[i].msr); | ||
6067 | else | ||
6068 | add_atomic_switch_msr(vmx, msrs[i].msr, msrs[i].guest, | ||
6069 | msrs[i].host); | ||
6070 | } | ||
6071 | |||
6053 | #ifdef CONFIG_X86_64 | 6072 | #ifdef CONFIG_X86_64 |
6054 | #define R "r" | 6073 | #define R "r" |
6055 | #define Q "q" | 6074 | #define Q "q" |
@@ -6099,6 +6118,8 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) | |||
6099 | if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP) | 6118 | if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP) |
6100 | vmx_set_interrupt_shadow(vcpu, 0); | 6119 | vmx_set_interrupt_shadow(vcpu, 0); |
6101 | 6120 | ||
6121 | atomic_switch_perf_msrs(vmx); | ||
6122 | |||
6102 | vmx->__launched = vmx->loaded_vmcs->launched; | 6123 | vmx->__launched = vmx->loaded_vmcs->launched; |
6103 | asm( | 6124 | asm( |
6104 | /* Store host registers */ | 6125 | /* Store host registers */ |