From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris Lalancette Subject: Re: [PATCH]: Fix MSR_K7_EVNTSEL{0,3} for SVM Date: Fri, 25 Apr 2008 14:43:19 -0400 Message-ID: <48122647.4080404@redhat.com> References: <480F7E92.6030709@redhat.com> <48103855.70006@qumranet.com> <4810926E.3070900@redhat.com> <4810A538.1070104@qumranet.com> <481105FB.1080705@redhat.com> <4811887E.6040202@qumranet.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel To: Avi Kivity Return-path: In-Reply-To: <4811887E.6040202@qumranet.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces@lists.sourceforge.net Errors-To: kvm-devel-bounces@lists.sourceforge.net List-Id: kvm.vger.kernel.org Avi Kivity wrote: > > Hmm, looking back at the dump: > >> 1811: 8d 86 00 00 ff 3f lea 0x3fff0000(%rsi),%eax >> 1817: 83 f8 03 cmp $0x3,%eax >> 181a: 0f 87 e2 01 00 00 ja 1a02 > > So while gcc is using %rsi, it loads the result back into %eax, which > has the effect of dropping back into 32-bits. So looks like gcc was > right here. Sorry for spreading confusion and apologies to gcc. > Avi, Arg. I was completely, utterly wrong about the problem here (although there is definitely still a problem). I'm sorry for making a confusing mess out of this. Here is what is actually happening: During startup, the RHEL-4 x86_64 kernel (2.6.9-67.EL, if you care) setups up the NMI watchdog. It does the following: for(i = 0; i < 4; ++i) { /* Simulator may not support it */ if (checking_wrmsrl(MSR_K7_EVNTSEL0+i, 0UL)) return; wrmsrl(MSR_K7_PERFCTR0+i, 0UL); } checking_wrmsrl() just does a "test write" to the msr; because of the code that is currently in there, this succeeds. However, when it tries to do the MSR_K7_PERFCTR0 wrmsr, *that* is where it fails, since we don't currently handle that MSR, and KVM injects a GPF into the guest (which kills it). My previous patch just happened to fix this because it was making checking_wrmsrl() fail on the EVNTSEL0, so we just returned out of this loop rather than trying to write to the PERFCTR0. Unfortunately, we can't just "fake emulate" MSR_K7_PERFCTR[0-3] like we are doing for MSR_K7_EVNTSEL[0-3]; if they are there, linux expects to be able to put values into them. I think the correct solution here is to emulate MSR_K7_PERFCTR[0-3] and MSR_K7_EVNTSEL[0-3] for real. I'm working on a patch to do this now. Chris Lalancette ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone