kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: Handle MSR_IA32_PERF_CTL
@ 2016-05-26  7:32 kmeaw
  2016-05-26 20:39 ` Radim Krčmář
  2016-05-27 15:28 ` Radim Krčmář
  0 siblings, 2 replies; 11+ messages in thread
From: kmeaw @ 2016-05-26  7:32 UTC (permalink / raw)
  To: linux-kernel, kvm; +Cc: gleb, pbonzini

From: Dmitry Bilunov <kmeaw@yandex-team.ru>

Intel CPUs having Turbo Boost feature implement an MSR to provide a
control interface via rdmsr/wrmsr instructions. One could detect the
presence of this feature by issuing one of these instructions and
handling the #GP exception which is generated in case the referenced MSR
is not implemented by the CPU.

KVM's vCPU model behaves exactly as a real CPU in this case by injecting
a fault when MSR_IA32_PERF_CTL is called (which KVM does not support).
However, some operating systems use this register during an early boot
stage in which their kernel is not capable of handling #GP correctly,
causing #DP and finally a triple fault effectively resetting the vCPU.

This patch implements a dummy handler for MSR_IA32_PERF_CTL to avoid the
crashes. Most notably it fixes an issue with MacOS X 10.10 kernel.

Signed-off-by: Dmitry Bilunov <kmeaw@yandex-team.ru>
---
 arch/x86/kvm/x86.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index c805cf4..9f38c7f 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -983,6 +983,7 @@ static u32 emulated_msrs[] = {
        MSR_IA32_MCG_STATUS,
        MSR_IA32_MCG_CTL,
        MSR_IA32_SMBASE,
+       MSR_IA32_PERF_CTL,
 };
 
 static unsigned num_emulated_msrs;
@@ -2050,6 +2051,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
        case MSR_VM_HSAVE_PA:
        case MSR_AMD64_PATCH_LOADER:
        case MSR_AMD64_BU_CFG2:
+       case MSR_IA32_PERF_CTL:
                break;
 
        case MSR_EFER:
@@ -2314,6 +2316,7 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
        case MSR_AMD64_NB_CFG:
        case MSR_FAM10H_MMIO_CONF_BASE:
        case MSR_AMD64_BU_CFG2:
+       case MSR_IA32_PERF_CTL:
                msr_info->data = 0;
                break;
        case MSR_K7_EVNTSEL0 ... MSR_K7_EVNTSEL3:
-- 
2.8.2

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-05-31 14:57 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-26  7:32 [PATCH] KVM: Handle MSR_IA32_PERF_CTL kmeaw
2016-05-26 20:39 ` Radim Krčmář
2016-05-26 20:44   ` Gabriel L. Somlo
     [not found]     ` <920591464331762@webcorp02f.yandex-team.ru>
2016-05-27 15:22       ` Radim Krčmář
2016-05-27 15:38         ` Radim Krčmář
2016-05-31  7:53           ` Paolo Bonzini
2016-05-31 13:05             ` Radim Krčmář
     [not found]             ` <1317601464689200@webcorp01d.yandex-team.ru>
2016-05-31 13:16               ` [PATCH v3] " Radim Krčmář
2016-05-31 14:38                 ` [PATCH] " Dmitry Bilunov
2016-05-31 14:57                   ` Radim Krčmář
2016-05-27 15:28 ` Radim Krčmář

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).