diff options
| -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 */ |
