From patchwork Tue Aug 1 00:21:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingwei Zhang X-Patchwork-Id: 128934 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2359921vqg; Mon, 31 Jul 2023 17:54:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlEImKwGFQucQ3pXLLOWIhQjXEQzr9mejpEX9jtTv9Z+JkTLJ0018VueVwI0uLBryAUtkj1B X-Received: by 2002:a05:6512:3123:b0:4fe:8c4:44fb with SMTP id p3-20020a056512312300b004fe08c444fbmr1057833lfd.38.1690851276250; Mon, 31 Jul 2023 17:54:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690851276; cv=none; d=google.com; s=arc-20160816; b=JXu+QL7Wf8/p25GbmwEiI9jmkwT0WMfJD5lrrworyukksVHSFRzyV+ZToSnzecnIUE ZHTkPC36yNkxlghADTmEXKFRc1TEHJyKGFj7H/gZ/4YAOi4DqaHpmim/bH/Z+ox3kl2J LokUFjkqZdoiQZZVqcUKMmukaOt3dN+Ifla77lTyLJybMfb6ExqX3RUY9o6zG40trSZu zjIbV/nhVgMhxV6hFoQufJF2/q7iXx2UQKBoZFLzQmbyqMkPBSzzRK5W7ALLxPfaWq8r JPmo0a8/GLw41l1kXrA6Y5TVsMindCTD4fPkN9WPBRlTYpRLbhSs+yVTJvWT0igPo1nY qaeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:reply-to:dkim-signature; bh=kVIN1SxWU+09oSbIiYC5Gj1hDPsle00BScGOxCHhrag=; fh=gya5F2cZq9WTAdFit1IlKDHE8FQoHEyxSPkqDAO7wTs=; b=f+kNA5pg/FjCBIjpixULxv49baScnNfM1vZS+gXj5DJc7GqjdjmCd0ZndkyVc/mXN2 Mxb/DqEtUZoY0vQY98J1PUP03ehYDjjPQJvxWfWMlgb1r5OGAjWrvdYlxDoL3G/UPUD+ taCfHx9B4XyaPyriLoAn3tHBvbJLpKF666dvdUbiA/9u9tS4KlPniERVPUsyx6Z0lD0F PiIZZPTkl/zA8CZ5uyduj+gvcpOBcPIUJfjOw++MKJ8neCGml6w+QWX2frHAH8lVr+F6 PzOQq/jBC5eiF5/Cs5yDeeVhZFyw1F2vNf35J++zAWiGVKFfQzBoDmhb7ot0dds5diFy W/qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=i2qQfafF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a26-20020a1709065f9a00b0099318060d55si8179704eju.516.2023.07.31.17.54.12; Mon, 31 Jul 2023 17:54:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=i2qQfafF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231638AbjHAAVr (ORCPT + 99 others); Mon, 31 Jul 2023 20:21:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231304AbjHAAVj (ORCPT ); Mon, 31 Jul 2023 20:21:39 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0C501BC3 for ; Mon, 31 Jul 2023 17:21:37 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id 41be03b00d2f7-5634dbfb8b1so3056042a12.1 for ; Mon, 31 Jul 2023 17:21:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690849297; x=1691454097; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=kVIN1SxWU+09oSbIiYC5Gj1hDPsle00BScGOxCHhrag=; b=i2qQfafFamWuvPA18RkGa8E8zFcHZxADjKobAJAfD4VJl0KHKOIts34GO90Xxevqgc hl/SB+uKmk2pLiB+Pd8wvX8baxQPSWzwwsS4gu7CoO8hHrUQdLZarh468D1KcnEtSiKN MlsrnBB6f5tOLH4Y59PfUbZe02Ei0PNLblWdm3naMBwj9F57jp8VyaSAMai9p4va25V1 AvwFWeYRcz8hCZPkGrLgoyNT4+NJM13b4w/QiVC7CGIwDLa2INndl+Jn/X7POqiuLf7H VH+RNYpsHrblm82aBL7y4qM/wa6Wfs+Of6krp49zjmSohfW0sj/XEmjFyxOaXt0Q0BKB GnqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690849297; x=1691454097; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=kVIN1SxWU+09oSbIiYC5Gj1hDPsle00BScGOxCHhrag=; b=jJgXoGWduN/5VE+miTfwiRaWzrj6VmBJ5uVF7PSgboa5fzuvUkRi3TFFzcPV+SoLEF xaxBBO2anbWrAJ8M7MWivjtWxjqy4aqmzmbVIm5xP3RBfYCjMHjQrtt3qv9FMVZ2c+ct fttatzfsXeavRNteeCF7TjfDTDan/kUNTyy0vRWWHYGbkqy240cgKaaKRf4IaqAHOKT/ XAk8IswiOahCcLWutjyIy7bN3hj3RuodS5SxPBcCwxXrym971EavJ/PlEXmyNwPN6fNm ANaLXwCsUzfwyye6sQktSKJ6EdNtKnnK2jJ6BB9d4ksPS+NWorIUj/VpyE2AKRnIRa1D o14A== X-Gm-Message-State: ABy/qLZ+yHEh/aPGLBBWx0ObIgxZzhQ2z5OL+vsQ1nhsZyF2RDfS1jiz B8uU9YD3yn1QTsLVAyQcu96voBCTN+N0 X-Received: from mizhang-super.c.googlers.com ([34.105.13.176]) (user=mizhang job=sendgmr) by 2002:a63:374a:0:b0:55a:b9bb:7ca with SMTP id g10-20020a63374a000000b0055ab9bb07camr54208pgn.10.1690849296762; Mon, 31 Jul 2023 17:21:36 -0700 (PDT) Reply-To: Mingwei Zhang Date: Tue, 1 Aug 2023 00:21:24 +0000 In-Reply-To: <20230801002127.534020-1-mizhang@google.com> Mime-Version: 1.0 References: <20230801002127.534020-1-mizhang@google.com> X-Mailer: git-send-email 2.41.0.585.gd2178a4bd4-goog Message-ID: <20230801002127.534020-5-mizhang@google.com> Subject: [PATCH v3 4/6] KVM: Documentation: Add the missing description for tdp_mmu_root_count into kvm_mmu_page From: Mingwei Zhang To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Mingwei Zhang , Kai Huang , Jim Mattson , David Matlack , Ben Gardon , Xu Yilun , Zhi Wang , Randy Dunlap X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED,USER_IN_DEF_DKIM_WL 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772986067559471747 X-GMAIL-MSGID: 1772986067559471747 Add the description of tdp_mmu_root_count into kvm_mmu_page description and combine it with the description of root_count. tdp_mmu_root_count is an atomic counter used only in TDP MMU. Update the doc. Signed-off-by: Mingwei Zhang Reviewed-by: Kai Huang --- Documentation/virt/kvm/x86/mmu.rst | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Documentation/virt/kvm/x86/mmu.rst b/Documentation/virt/kvm/x86/mmu.rst index 17d90974204e..40daf8beb9b1 100644 --- a/Documentation/virt/kvm/x86/mmu.rst +++ b/Documentation/virt/kvm/x86/mmu.rst @@ -229,10 +229,14 @@ Shadow pages contain the following information: can be calculated from the gfn field when used. In addition, when role.direct is set, KVM does not track access permission for each of the gfn. See role.direct and gfn. - root_count: - A counter keeping track of how many hardware registers (guest cr3 or - pdptrs) are now pointing at the page. While this counter is nonzero, the - page cannot be destroyed. See role.invalid. + root_count / tdp_mmu_root_count: + root_count is a reference counter for root shadow pages in Shadow MMU. + vCPUs elevate the refcount when getting a shadow page that will be used as + a root page, i.e. page that will be loaded into hardware directly (CR3, + PDPTRs, nCR3 EPTP). Root pages cannot be destroyed while their refcount is + non-zero. See role.invalid. tdp_mmu_root_count is similar but exclusively + used in TDP MMU as an atomic refcount. When the value is non-zero, it + allows vCPUs acquire references while holding mmu_lock for read. parent_ptes: The reverse mapping for the pte/ptes pointing at this page's spt. If parent_ptes bit 0 is zero, only one spte points at this page and