From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joel Schopp Subject: Re: [PATCH] x86: svm: don't intercept CR0 TS or MP bit write Date: Wed, 25 Feb 2015 16:39:49 -0600 Message-ID: <54EE4F35.7070808@amd.com> References: <20150220224445.2875.66846.stgit@joelvmguard2.amd.com> <20150223191729.GA2186@potion.brq.redhat.com> <54ECEC2F.1090700@amd.com> <20150225202600.GA11660@potion.brq.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Gleb Natapov , Paolo Bonzini , , Joerg Roedel , Borislav Petkov , , David Kaplan To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= Return-path: In-Reply-To: <20150225202600.GA11660@potion.brq.redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 02/25/2015 02:26 PM, Radim Kr=C4=8Dm=C3=A1=C5=99 wrote: > 2015-02-24 15:25-0600, Joel Schopp: >>>> - clr_cr_intercept(svm, INTERCEPT_CR0_WRITE); >>>> } else { >>>> set_cr_intercept(svm, INTERCEPT_CR0_READ); >>> (There is no point in checking fpu_active if cr0s are equal.) >>> >>>> - set_cr_intercept(svm, INTERCEPT_CR0_WRITE); >>> KVM uses lazy FPU and the state is undefined before the first acces= s. >>> We set cr0.ts when !svm->vcpu.fpu_active to detect the first access= , but >>> if we allow the guest to clear cr0.ts without exiting, it can acces= s FPU >>> with undefined state. >> Thanks for the valuable feedback. It's apparent I hadn't thought >> through the interaction with lazy FPU and will need to go back and >> rethink my approach here. > I don't think we can gain much without sacrificing some laziness, lik= e: > when a guest with lazy FPU clears CR0.TS, it is going to use that FPU= , > so we could pre-load FPU in this case and drop the write intercept to= o; > guests that unconditionally clear CR0.TS would perform worse though. > > It's going to take a lot of time, but two hunks in your patch, that m= ade > selective intercept benefit from decode assists, look useful even now= =2E > > Would you post them separately? I can re-post those separately. They are less useful, though probably still worth doing, on their own because SVM_EXIT_WRITE_CR0 takes precidence over SVM_EXIT_CR0_SEL_WRITE