From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: Re: linux 3.13 guest crash with -cpu host Date: Mon, 3 Feb 2014 16:45:38 +0200 Message-ID: <20140203144538.GB24528@redhat.com> References: <20140202205930.GA2157@redhat.com> <20140203125828.GH2221@otherpad.lan.raisama.net> <20140203140601.GA24944@redhat.com> <20140203141235.GJ8874@twins.programming.kicks-ass.net> <52EFA566.4010402@redhat.com> <20140203142642.GK8874@twins.programming.kicks-ass.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Paolo Bonzini , Eduardo Habkost , kvm@vger.kernel.org To: Peter Zijlstra Return-path: Received: from mx1.redhat.com ([209.132.183.28]:51311 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751451AbaBCOlF (ORCPT ); Mon, 3 Feb 2014 09:41:05 -0500 Content-Disposition: inline In-Reply-To: <20140203142642.GK8874@twins.programming.kicks-ass.net> Sender: kvm-owner@vger.kernel.org List-ID: On Mon, Feb 03, 2014 at 03:26:42PM +0100, Peter Zijlstra wrote: > On Mon, Feb 03, 2014 at 03:19:18PM +0100, Paolo Bonzini wrote: > > Il 03/02/2014 15:12, Peter Zijlstra ha scritto: > > >>> But why doesn't it crash on baremetal? > > >>> Probably baremetal simply returns 0 or something. > > >>> Let me try .. > > >The claim "v2 and above have FEATURE_PDCM" is in fact true for real > > >hardware. > > > > > >If it didn't the rdmsr() would have generated an exception and we'd have > > >crashed just like your virtual thingy did. > > > > Right, and the virt thingy has no PEBS, so there is no correct value that we > > could return from the MSR. That's why the CPUID bit is zero. > > There's more than PEBS in there, there's also the LBR format (which you > obviously also don't have) and the full_width_write bit, which you also > don't have. > > Returning 0 is a safe value. Seeing you don't have LBR, we don't look at > the LBR format fields, seeing you don't have PEBS, we don't look at > those fields either. > > We don't appear to use the SMM_FREEZE bit at all, and 0 is in fact the > right value for full_width_write, since you lack the MSRs to support > that. > > Anyway, its easy for me to make future kernels do the right PDCM test, > probably easy to backport too (should apply with minimal trouble back a > fair number of releases). > > You can also implement the MSR to simply return 0, which is a safe > value. OK, I'm testing the following now: ---> Subject: [PATCH] kvm: emulate MSR_IA32_PERF_CAPABILITIES guests expect that this does not crash if version > 1. Signed-off-by: Michael S. Tsirkin --- 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 5d004da..eaf5016 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -2407,6 +2407,9 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata) /* CPU multiplier */ data |= (((uint64_t)4ULL) << 40); break; + case MSR_IA32_PERF_CAPABILITIES: + data = 0; + break; case MSR_EFER: data = vcpu->arch.efer; break; -- MST