Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753555AbbBYU02 (ORCPT ); Wed, 25 Feb 2015 15:26:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52743 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753265AbbBYU00 (ORCPT ); Wed, 25 Feb 2015 15:26:26 -0500 Date: Wed, 25 Feb 2015 21:26:01 +0100 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Joel Schopp Cc: Gleb Natapov , Paolo Bonzini , kvm@vger.kernel.org, Joerg Roedel , Borislav Petkov , linux-kernel@vger.kernel.org, David Kaplan Subject: Re: [PATCH] x86: svm: don't intercept CR0 TS or MP bit write Message-ID: <20150225202600.GA11660@potion.brq.redhat.com> References: <20150220224445.2875.66846.stgit@joelvmguard2.amd.com> <20150223191729.GA2186@potion.brq.redhat.com> <54ECEC2F.1090700@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54ECEC2F.1090700@amd.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1416 Lines: 32 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 access. > > 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 access 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, like: 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 too; 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 made selective intercept benefit from decode assists, look useful even now. Would you post them separately? Thanks. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/