Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp262892imp; Tue, 19 Feb 2019 23:11:42 -0800 (PST) X-Google-Smtp-Source: AHgI3IbclgaGdjKHW8LZoQSyAjBh1riYffW1v3MQvlxWLNQOMBS18s7+/QyvofbzQl8fW5Aed1rs X-Received: by 2002:a62:a9b:: with SMTP id 27mr33252260pfk.223.1550646702079; Tue, 19 Feb 2019 23:11:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550646702; cv=none; d=google.com; s=arc-20160816; b=d8BD+2pDaE7Zk1uI4m/5wOGwy3bheYA5ZrwSpUqK3GltFKorw6CttKzXsuplOCaG/4 ytYKq3ZX1tJm1ZahEug7iQTyZ1IVTD3Ggik+M8THR26DgD4WQ/jrcpSqV9rF3TJOj+A+ FhX78y22ngR4octeIds0/927ltdiMHKkV0TKORmK5SxrdDE8BCa7Cu1+sBdyGRSQsuzT I/lGkHRm4oY31zkEHMvMRnz1O41Hc83XF7uJ5klTtMWZwF6Gk41XPKooROkNHwhoH1X4 t3sL2Xpx+WIOUpBZ6vZa9AQQttc+vcQoSvPuhRpYunUDy8j3fAyk/axCQIi9rGuYuEGx 2dfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=bHFTh2lkHpjpAnfYbtJksfor3yKeJh5cmaQg4pSsEN4=; b=u53n5Xi5hIDyRORPk/T8WuK+SVZ7zcFUqzpFoNkNKIp+Jx+BURPn9IVaZcfUGe8D7m KQlTQedEUJr9awxoGdwF6k8uCyWdIvDmWiqNAx01Z0zoEqsHU4Ga5ddvZatlf0aC0NyY J9XZIOsDzRwUBXV/1cDacBmjE7aVm3Ba7H8L+STc+xq1e0KzrIks9HnmFbkEBKCvDm95 hWqTsGDE81dDokGzX715MjU2taL8JCL/fa92x1Ts4lHq40RXoirJ7zVIcYXomMQSiwDz 0NaUbQfG+gx0fQjdFt3ZRSraaGYiiRNhdU77k7y7sp9WOYEKOF8X+OLr3FQcpObmfJTz jCOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e67si19798526plb.107.2019.02.19.23.11.27; Tue, 19 Feb 2019 23:11:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726842AbfBTHKz (ORCPT + 99 others); Wed, 20 Feb 2019 02:10:55 -0500 Received: from mga09.intel.com ([134.134.136.24]:51384 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725869AbfBTHKy (ORCPT ); Wed, 20 Feb 2019 02:10:54 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Feb 2019 23:10:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,388,1544515200"; d="scan'208";a="116304257" Received: from zhangyu-optiplex-9020.bj.intel.com (HELO localhost) ([10.238.135.159]) by orsmga007.jf.intel.com with ESMTP; 19 Feb 2019 23:10:52 -0800 Date: Wed, 20 Feb 2019 15:06:21 +0800 From: Yu Zhang To: Paolo Bonzini Cc: kvm@vger.kernel.org, Radim =?utf-8?B?S3LEjW3DocWZ?= , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: Re: [PATCH] KVM: MMU: record maximum physical address width in kvm_mmu_extended_role Message-ID: <20190220070621.meka6jyjpdreh2ed@linux.intel.com> References: <1548950963-18414-1-git-send-email-yu.c.zhang@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1548950963-18414-1-git-send-email-yu.c.zhang@linux.intel.com> User-Agent: NeoMutt/20180622-66-b94505 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Paolo, any comments on this patch? And the other one(kvm: x86: Return LA57 feature based on hardware capability )? :-) On Fri, Feb 01, 2019 at 12:09:23AM +0800, Yu Zhang wrote: > Previously, commit 7dcd57552008 ("x86/kvm/mmu: check if tdp/shadow > MMU reconfiguration is needed") offered some optimization to avoid > the unnecessary reconfiguration. Yet one scenario is broken - when > cpuid changes VM's maximum physical address width, reconfiguration > is needed to reset the reserved bits. Also, the TDP may need to > reset its shadow_root_level when this value is changed. > > To fix this, a new field, maxphyaddr, is introduced in the extended > role structure to keep track of the configured guest physical address > width. > > Signed-off-by: Yu Zhang > --- > Cc: Paolo Bonzini > Cc: "Radim Krčmář" > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: Borislav Petkov > Cc: "H. Peter Anvin" > Cc: linux-kernel@vger.kernel.org > --- > arch/x86/include/asm/kvm_host.h | 1 + > arch/x86/kvm/mmu.c | 1 + > 2 files changed, 2 insertions(+) > > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h > index 4660ce9..be87f71 100644 > --- a/arch/x86/include/asm/kvm_host.h > +++ b/arch/x86/include/asm/kvm_host.h > @@ -299,6 +299,7 @@ struct kvm_mmu_memory_cache { > unsigned int cr4_smap:1; > unsigned int cr4_smep:1; > unsigned int cr4_la57:1; > + unsigned int maxphyaddr:6; > }; > }; > > diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c > index ce770b4..2b74505 100644 > --- a/arch/x86/kvm/mmu.c > +++ b/arch/x86/kvm/mmu.c > @@ -4769,6 +4769,7 @@ static union kvm_mmu_extended_role kvm_calc_mmu_role_ext(struct kvm_vcpu *vcpu) > ext.cr4_pse = !!is_pse(vcpu); > ext.cr4_pke = !!kvm_read_cr4_bits(vcpu, X86_CR4_PKE); > ext.cr4_la57 = !!kvm_read_cr4_bits(vcpu, X86_CR4_LA57); > + ext.maxphyaddr = cpuid_maxphyaddr(vcpu); > > ext.valid = 1; > > -- > 1.9.1 > Thanks Yu