Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6339724pxv; Thu, 29 Jul 2021 12:03:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFxO/A7OoW+QRB3fpD1gA5eLazC/KEedZvbElNXchs8Zs8Pa8NP16G2/ZFODrtPytcRve2 X-Received: by 2002:a5d:8888:: with SMTP id d8mr5277995ioo.170.1627585433801; Thu, 29 Jul 2021 12:03:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627585433; cv=none; d=google.com; s=arc-20160816; b=vzAwMkVLkkIeMZxzXJRzKQ8/9pHmTGeAu9jE4XZzSQl9/J8IiHuieLTUItKhALBJA5 r9+9DlYqHwC/pTWFZYJbMJwFAZgQyzW0mYAyb77uix4KRBrTb9dIeJVH+nDIxAtbRL4W PwgilMdFuYsZ/bVl1GkkjqBSwHS8xCGatyippPC4et/cqqtV7DLUNj45mouhzLoTTteE y5VHl4rBYOCwDb9CwDR4ExET68+0Wn4R+qobwh/cwePSJap0GkiGwXv3Q3wTvbm+gT5E MAs4poc3URxLh9FY+/pzDVhQdm6i4ajjkzaWCj1qUme37adBxzQI3cRVRJ9D7HE0DU7J 6tfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=tMRycNlt7ES7kF6ezVUYuskwJ/T4IKJjcQobjR4RSD4=; b=MP3r12gnx/JE611NMNMYKWVyWrmy9sClNl1kl5U7cJAPc3skJpytmii2LuvCDu0mP5 5e0DoimOcLEwqTjJkt4DbnFiWI/2+0v7eokxKSw0LIMijHKCkXvOksr7X69nanOFaKqW 1xCxmJhwLK3M3xejLuDC5AnKbOOSCnS3ZMN5Rmer/5X6XNxUrXLaGzoDs8MzZy/7Ju3i 6FzNd3QJyKY4O3tUhz+Ks6KZ65cE/NFY6fIcCc0oBYNInc04WuJZKd95VeGCiQOp5mrG 9uv8E+4KkAdrFl+s1zKjEYp7rxiOSd51N5FtI9uQMJjksqMzwAzI011zexJ7oaMFAO1h pe1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=cFpi1M7q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h4si3797027ilj.137.2021.07.29.12.03.37; Thu, 29 Jul 2021 12:03:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=cFpi1M7q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230376AbhG2TBQ (ORCPT + 99 others); Thu, 29 Jul 2021 15:01:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229672AbhG2TBP (ORCPT ); Thu, 29 Jul 2021 15:01:15 -0400 Received: from mail-yb1-xb2e.google.com (mail-yb1-xb2e.google.com [IPv6:2607:f8b0:4864:20::b2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 744B9C061765 for ; Thu, 29 Jul 2021 12:01:12 -0700 (PDT) Received: by mail-yb1-xb2e.google.com with SMTP id d73so11822368ybc.10 for ; Thu, 29 Jul 2021 12:01:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tMRycNlt7ES7kF6ezVUYuskwJ/T4IKJjcQobjR4RSD4=; b=cFpi1M7qYM3XfdgHPKkC+vm6dZjwvdn3EfcqmOIMjLRz4TQ3UIZKJjUYKMD3Fokfje CpDCFZnH22rDjKqdDFAnPE7Gv+TC8SgFU7u5Kbtpkl6AO1H7ZzasMqae45NlY+mD7DlR unyPSHCscYq40R6qTALdXsIeSQ8vhRHr6aAJJuEsVkqKjT6WSkBTey38Tc3dRUFZgdJK i5GMfbKdEeEz7U8FjuylRaqKXdxsrSeIakRGyYZs81CWJrmr2K7cvUspdDvg7TDn/D8x jKlvuhH5+OCt4K47XyjlkrQx7o5ut8imc67k+/jnhp8N5qDYMfFgtxByJ56kpcQQb7d/ 8PhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tMRycNlt7ES7kF6ezVUYuskwJ/T4IKJjcQobjR4RSD4=; b=htJw+V2B6fgXaev+SKxTtIs+yDkv09cvHU0xEhzhIzG2uOmK8Jp2sd2q8sesaGn375 1UNXzDK/vgIW9u8NouARCYeRvNjww3Pfb2zSH09W69UOFsWpiXTBYigvZJfoQtzpzRfJ pZ/bf2n5aGQ0RlgMdcj+EwyDukZhayxAbF8mwf4omZyXSuLR2IpyYnphSos0gZRCBxrk OehBFnLxnHNAUJ2hvoyIXPCX55REn0exXLAqdro419PvlsJVT/vjISFb6fmRthktB8tD HOacSwMIcFRChIJTdTHIPM3+Cg+uRU+UX8VjIJonEFcnZtZwKcJJxRFH7cDWvCHS68oh VZVA== X-Gm-Message-State: AOAM530WUR48EvdE3LtMIytMxxDr2e+YRfz6SBlX2bdaFbmB4ngAkiTF Z3vdKCJJ9dR2RVtVzDjHdn+m2naQ25M5sMY/r2gsRw== X-Received: by 2002:a25:b708:: with SMTP id t8mr8963591ybj.139.1627585271495; Thu, 29 Jul 2021 12:01:11 -0700 (PDT) MIME-Version: 1.0 References: <20210726175357.1572951-1-mizhang@google.com> <20210726175357.1572951-3-mizhang@google.com> In-Reply-To: From: Mingwei Zhang Date: Thu, 29 Jul 2021 12:01:00 -0700 Message-ID: Subject: Re: [PATCH v2 2/3] KVM: x86/mmu: Avoid collision with !PRESENT SPTEs in TDP MMU lpage stats To: Sean Christopherson Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Ben Gardon , Jing Zhang Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org oh, definitely. Sorry for the confusion. On Thu, Jul 29, 2021 at 11:34 AM Sean Christopherson wrote: > > On Mon, Jul 26, 2021, Mingwei Zhang wrote: > > Factor in whether or not the old/new SPTEs are shadow-present when > > adjusting the large page stats in the TDP MMU. A modified MMIO SPTE can > > toggle the page size bit, as bit 7 is used to store the MMIO generation, > > i.e. is_large_pte() can get a false positive when called on a MMIO SPTE. > > Ditto for nuking SPTEs with REMOVED_SPTE, which sets bit 7 in its magic > > value. > > > > Opportunistically move the logic below the check to verify at least one > > of the old/new SPTEs is shadow present. > > > > Use is/was_leaf even though is/was_present would suffice. The code > > generation is roughly equivalent since all flags need to be computed > > prior to the code in question, and using the *_leaf flags will minimize > > the diff in a future enhancement to account all pages, i.e. will change > > the check to "is_leaf != was_leaf". > > > > Suggested-by: Sean Christopherson > > There's no hard rule for when to use Suggested-by vs. giving Author credit, but > in this case, since you took the patch and changelog verbatim[*] (sans the missing > tags below), it's more polite to take the full patch (with me as Author in > this case) and add your SOB since you're posting the patch. > > Fixes: 1699f65c8b65 ("kvm/x86: Fix 'lpages' kvm stat for TDM MMU") > Cc: stable@vger.kernel.org > > [*] https://lkml.kernel.org/r/YPho0ME5pSjqRSoc@google.com > > > Signed-off-by: Mingwei Zhang