Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp1131606rdf; Wed, 22 Nov 2023 06:29:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IGT/eNbN/jBtoumWZTUZk3bQs+tevhh/6V1Gygn2Xh3zMTd8r1HFKqG96r8XNgt9JAwjP/z X-Received: by 2002:a17:903:11ce:b0:1cc:4985:fc04 with SMTP id q14-20020a17090311ce00b001cc4985fc04mr2601905plh.66.1700663370876; Wed, 22 Nov 2023 06:29:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700663370; cv=none; d=google.com; s=arc-20160816; b=G4aSgCGZg0XEQ9Lh0Njh/bpd9Nr+8SNGy0Cfh3QEqnjn9fFVfjFk9h4pmjjIUFeoR2 X/lAGTZdVdi8P4iNuc9sseEeXT0PUk5NuwNw+GT9Mgentm034MvAGByjiKmIu0qT5p12 SriHoUIdEjnulaAAyXwkDkf6JXyg0QLWGKBHA7NZisllg95R5ZSzEZp7iwvomFsblo2l Df5Mwu4sdH2hPbcHjgQKfxAMT7TZd0kQ7kmOBcM68cvRckKIRRkJagtjAbNciXfhufQD hGwzMf/YePD9wtULoh4z/GtStyuTM4ob7aGTfMublsywxq1+w60QVpi+Fz3WQrv/T0ZN mFBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=wo6gnxn2eO1BtyMv62hl81YvMUp6BMFkJ/e7KAUQ15o=; fh=4CF4qKzotzJ176Gn8AKpB0i7vTCJWAf48X96pWdApYI=; b=p0K5dexv8kZfPuv7lrNSE8AqT46PKZCZN8bk+B0a2+0GmhiqsDDlkrYzCDjgPQ8Vus nXJ1GLWPFocInwjpxUgx/WHih46qpmf86Yiwd/FoV9IcSoHI7fLtKLcLbTv6KhsOFzM3 kPCA+zF9opYmuSudrBppgxgz4+KAGIqNso4I/ADEHExA/Y634nKO3W1j5UYPE6djzZ6Z 61/ai44exsyNiZ7RFqM/XibN9yJq7ouCnkbdnTRhp1rQwVHU6WhYil95F2xxz1hGhSHW CHtOZsgdj/w+89MCUwcLpaBJtfY2Vbf7xlSH1rJXdf3AUZA4OQ+KP6U62+eKwBfo1Ow2 7/TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kGNNK8zL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id bj12-20020a170902850c00b001cc649af5e7si12231788plb.243.2023.11.22.06.29.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 06:29:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kGNNK8zL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 0CC5781DA39D; Wed, 22 Nov 2023 06:29:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231883AbjKVO31 (ORCPT + 99 others); Wed, 22 Nov 2023 09:29:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231767AbjKVO3Z (ORCPT ); Wed, 22 Nov 2023 09:29:25 -0500 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9557419D; Wed, 22 Nov 2023 06:29:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700663359; x=1732199359; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=BFl13xeC7OE11pBxBT1ZHjb6Yh6uZMtqWKK7X350nBU=; b=kGNNK8zLM1ZRFIGAYL+/Gr7pCjlu8BhGbol0PQtpOcoggBeWpK+j9/YE WSExscuL4HAspMB4KtXnfz/KzxD+8w2xwhep9TSbEI44/skFTHXrE/dzo iw/4934kNAADSKZLArJg/LU1ODt9qD8pzOzdI7clBxksPCUvUw58qb7dd 2/W4Q07fTn6ziWk1OP0TdzLNlQopAXWsEYZoDkp5F0XMDX3Uqf+GjAQf2 muOGvURhBsYROYob/wJaW5jwv0c7fsUEK2Zk5Wtgoy/vAEacFjO9GLwaD MYvF/M/mhZRal2m96bpdHNQwVLsSp4V2b1QK7gVJdPGkFeYjaREE3SYh0 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10902"; a="10724610" X-IronPort-AV: E=Sophos;i="6.04,219,1695711600"; d="scan'208";a="10724610" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2023 06:29:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10902"; a="837430258" X-IronPort-AV: E=Sophos;i="6.04,219,1695711600"; d="scan'208";a="837430258" Received: from yilunxu-optiplex-7050.sh.intel.com (HELO localhost) ([10.239.159.165]) by fmsmga004.fm.intel.com with ESMTP; 22 Nov 2023 06:29:15 -0800 Date: Wed, 22 Nov 2023 22:27:22 +0800 From: Xu Yilun To: David Woodhouse Cc: Paul Durrant , Sean Christopherson , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v8 07/15] KVM: pfncache: include page offset in uhva and use it consistently Message-ID: References: <20231121180223.12484-1-paul@xen.org> <20231121180223.12484-8-paul@xen.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 22 Nov 2023 06:29:30 -0800 (PST) On Wed, Nov 22, 2023 at 09:12:18AM +0000, David Woodhouse wrote: > On Wed, 2023-11-22 at 16:54 +0800, Xu Yilun wrote: > > > > > @@ -259,13 +258,25 @@ static int __kvm_gpc_refresh(struct gfn_to_pfn_cache *gpc, gpa_t gpa, > > >                         ret = -EFAULT; > > >                         goto out; > > >                 } > > > + > > > +               hva_change = true; > > > +       } else { > > > +               /* > > > +                * No need to do any re-mapping if the only thing that has > > > +                * changed is the page offset. Just page align it to allow the > > > +                * new offset to be added in. > > > > I don't understand how the uhva('s offset) could be changed when both gpa and > > slot are not changed. Maybe I have no knowledge of xen, but in later > > patch you said your uhva would never change... > > It doesn't change on a normal refresh with kvm_gpc_refresh(), which is > just for revalidation after memslot changes or MMU invalidation. > > But it can change if the gpc is being reinitialized with a new address > (perhaps because the guest has made another hypercall to set the > address, etc.) > > That new address could happen to be in the *same* page as the previous In this case, the lower bits of new gpa should be different to gpc->gpa, so will hit "if (gpc->gpa != gpa ...)" branch. And I see this comment is deleted in v9, which makes sense to me. Thanks, Yilun > one. In fact the xen_shinfo_test explicitly tests that case, IIRC. > > And kvm_gpc_activate() also happens to use __kvm_gpc_refresh() > internally.