Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp201654imp; Wed, 20 Feb 2019 23:06:59 -0800 (PST) X-Google-Smtp-Source: AHgI3IbPtD0t/2kzeQKNoiAREwrj6QSOIbDHSDhUb2qhJpW8bDjqNUS8GFhJ8GNnIodqucoB+ouf X-Received: by 2002:a17:902:4324:: with SMTP id i33mr40248096pld.227.1550732819421; Wed, 20 Feb 2019 23:06:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550732819; cv=none; d=google.com; s=arc-20160816; b=oRd9AGWtRL+kZ5mrYyhsWNDBQzY9RQzu3oDJvfysN0HJ4rC01ir/7o7VeYvZoM7Nhn q62ePz2ahVvhdf6KVFt5C4hllPO5i5dAkv+o+PCWJXJePWxRSGjaTJdnr+O4gxIagwgt Sa2k5Q/bn9Q0Rap1xPPE8MMe/NREKnkOLikofb4jY2rHw00JZeTi42ocQeEcdVgaQpBD 12PBL0MXyNHWBkRckpdlTeVHO8cm11H66xq+9mrpv5JRBngtf2TSWoFuuZcQ5q6icYEB yLz+CqqYMXZu38gwpmZyOrNnfHmDs/7iSRqSfPjJdz4nYVtktikRrtbxnRAjIs59vHE9 Ix2w== 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=T+H4e3YLuYfdoRZFO8C2ahy5wgpYNzgda8JG3xkbBao=; b=bGrbF3D1PpCK+tTpE899Qqhy6hUeRjdQ3X0XjyF5+5iV6PY3Wp1JdyUWuh8OksMFEm +G+lCovSurbeQba2DwnRoGBvzDbsa9Wbpt0CnXbm7EB/sZqzFLiCmULAVgjM38ovzG0N riq3kGt/t6HaZKRGuX0dxWBERYlR7wBOaBYJ8Xdb9jUrxu9a73dpk9vAQWE6DKNrIPf+ XoTQ8719y6DPeyFurTrRykTL/j8DozBOAKC2dNko6gqvhcaxYVZQaJ63TDGrwlIkGV0Q 3Tqx6zm4wSAmYUvEq/+9UsmsNw51TWDGh2AdZuHQ2vy2UANbVHEv+iDy826BuW85AAHJ y07g== 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 c4si19731614pgd.179.2019.02.20.23.06.44; Wed, 20 Feb 2019 23:06:59 -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 S1726737AbfBUHCy (ORCPT + 99 others); Thu, 21 Feb 2019 02:02:54 -0500 Received: from mga02.intel.com ([134.134.136.20]:48024 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726355AbfBUHCy (ORCPT ); Thu, 21 Feb 2019 02:02:54 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Feb 2019 23:02:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,394,1544515200"; d="scan'208";a="135181936" Received: from zhangyu-optiplex-9020.bj.intel.com (HELO localhost) ([10.238.135.159]) by FMSMGA003.fm.intel.com with ESMTP; 20 Feb 2019 23:02:51 -0800 Date: Thu, 21 Feb 2019 14:58:19 +0800 From: Yu Zhang To: Vitaly Kuznetsov , 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: <20190221065819.fu2lvakahoby5mcc@linux.intel.com> References: <1548950963-18414-1-git-send-email-yu.c.zhang@linux.intel.com> <878syatuzx.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <878syatuzx.fsf@vitty.brq.redhat.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 On Wed, Feb 20, 2019 at 03:06:10PM +0100, Vitaly Kuznetsov wrote: > Yu Zhang writes: > > > 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; > > It seems that we can now drop 'valid' from role_ext as maxphyaddr can't > be 0. Thanks, Vitaly. Yes, we can drop this field. :) > > Reviewed-by: Vitaly Kuznetsov > > -- > Vitaly > B.R. Yu