Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751624AbdHPN0e (ORCPT ); Wed, 16 Aug 2017 09:26:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38478 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751089AbdHPN0c (ORCPT ); Wed, 16 Aug 2017 09:26:32 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B5B5DB0AAF Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=rkrcmar@redhat.com Date: Wed, 16 Aug 2017 15:26:29 +0200 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Lan Tianyu Cc: pbonzini@redhat.com, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] KVM/VMX: Avoid CR3 VMEXIT during guest real mode when "unrestricted guest" is supported. Message-ID: <20170816132625.GD5975@flask> References: <1502848704-7474-1-git-send-email-tianyu.lan@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1502848704-7474-1-git-send-email-tianyu.lan@intel.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 16 Aug 2017 13:26:32 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 955 Lines: 24 2017-08-15 21:58-0400, Lan Tianyu: > These CR3 VMEXITs was introduced for platform without "unrestricted guest" > support. This is to set ept identity table to guest CR3 in guest real > mode because these platforms don't support ept real mode(CR0.PE and CR0.PG > must be set to 1). But these VMEXITs is redundant for platforms with > "unrestricted guest" support. > > Signed-off-by: Lan Tianyu > --- > arch/x86/kvm/vmx.c | 22 +++++++++++++--------- > 1 file changed, 13 insertions(+), 9 deletions(-) > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > @@ -4311,7 +4313,9 @@ static void vmx_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3) > } > > vmx_flush_tlb(vcpu); > - vmcs_writel(GUEST_CR3, guest_cr3); > + > + if (!enable_unrestricted_guest || !enable_ept) > + vmcs_writel(GUEST_CR3, guest_cr3); This looks wrong -- it would prevent update GUEST_CR3 outside of non-root mode with enable_unrestricted_guest.