From patchwork Mon Jun 26 18:20:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingwei Zhang X-Patchwork-Id: 13293312 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC501EB64D7 for ; Mon, 26 Jun 2023 18:20:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231696AbjFZSUf (ORCPT ); Mon, 26 Jun 2023 14:20:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231654AbjFZSU2 (ORCPT ); Mon, 26 Jun 2023 14:20:28 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 203E5CC for ; Mon, 26 Jun 2023 11:20:23 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-56cf9a86277so46167987b3.3 for ; Mon, 26 Jun 2023 11:20:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687803622; x=1690395622; 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=Y2F7UYJOU65mERHIxW2LZZxZD/ZR1RVDUwRiTiwItys=; b=6QKwtXOYY51Y7PQ7wfsNGjwbER6Yz6DPkobVYnmu5EEdKXoy/LHSOUX9cZtrLAgc6l litzVO5osAdbdQOcIO9Ga09HDzeq991xxbTlUdrk8DGRDuLeBMBX+1QgBMHmD00U7ZCs X9QGUnLkynNHJD2SfzoWZF3tX+dVdOMrEIHLmIWcHx1Rh7x8bqAaZDEP79yvnQE5l379 DXf9OnZQ/SLCBLcWzSD/1BT/NnxYx71SyISYFLLWR0lBQoIauVezVB7226VQnLXs2zJx MWP/ZgD4p03HYOWXNnBk2ZC/IgiMVf9tmFf4kqkp2snXcUqAA7joP+HYybq1y12XLq3c YW9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687803622; x=1690395622; 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=Y2F7UYJOU65mERHIxW2LZZxZD/ZR1RVDUwRiTiwItys=; b=Y8FiYZA22qPgIaj/t9dTWOZle1VeOGeTea+KSF6eqF+/NF//AyFGdCuLsH9afWtkU3 8LzfVloUkLqXwMq76xfSaXwpqsENuCPZJq0RZzKGWN1OkHP4ufwmEpV0Kj8078WNpp85 /hgCX8YjKN2WBikPF25NPzRcucJQHQ7mkaTUH1hZ6ku/7ykYOtA33yGM8qvtt0QA4hOH h5IqUVEd6w/i4/EaIiHuxCyyGLkHuywMlTFK2OEJEz3szD1ZqMs44trHs+kTW2MQoE88 zw6/QDcwI4hpOEMOQEexsKt4kvcGYnJFxn302JECUJkbLW9jnbAH4Mf11vpgwj0Sd29V 9HuA== X-Gm-Message-State: AC+VfDy6EQtX292OJakW/gHo1gR11DryrVW8VbfPib6fHPlDCrvDJw8s b7OaZjgdyJmxZAILKwxvX0tu6liC/PLD X-Google-Smtp-Source: ACHHUZ5ZiluUVnGMjRQ7bq/BIu65O/ivKvxYxEHH1I9TDadsaaA1nqbhv0CpQWdLWlFSIezrHLZb/DHWgC7m X-Received: from mizhang-super.c.googlers.com ([35.247.89.60]) (user=mizhang job=sendgmr) by 2002:a25:e0d1:0:b0:c2a:e79a:fc11 with SMTP id x200-20020a25e0d1000000b00c2ae79afc11mr130358ybg.9.1687803622386; Mon, 26 Jun 2023 11:20:22 -0700 (PDT) Reply-To: Mingwei Zhang Date: Mon, 26 Jun 2023 18:20:11 +0000 In-Reply-To: <20230626182016.4127366-1-mizhang@google.com> Mime-Version: 1.0 References: <20230626182016.4127366-1-mizhang@google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230626182016.4127366-2-mizhang@google.com> Subject: [PATCH v2 1/6] KVM: Documentation: Add the missing description for guest_mode in kvm_mmu_page_role 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 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Add the missing description for guest_mode in kvm_mmu_page_role description. guest_mode tells KVM whether a shadow page is used for the L1 or an L2. Update the missing field in documentation. Signed-off-by: Mingwei Zhang Reviewed-by: Kai Huang --- Documentation/virt/kvm/x86/mmu.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/virt/kvm/x86/mmu.rst b/Documentation/virt/kvm/x86/mmu.rst index 8364afa228ec..561efa8ec7d7 100644 --- a/Documentation/virt/kvm/x86/mmu.rst +++ b/Documentation/virt/kvm/x86/mmu.rst @@ -202,6 +202,8 @@ Shadow pages contain the following information: Is 1 if the MMU instance cannot use A/D bits. EPT did not have A/D bits before Haswell; shadow EPT page tables also cannot use A/D bits if the L1 hypervisor does not enable them. + role.guest_mode: + Indicates the shadow page is created for a nested guest. role.passthrough: The page is not backed by a guest page table, but its first entry points to one. This is set if NPT uses 5-level page tables (host From patchwork Mon Jun 26 18:20:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingwei Zhang X-Patchwork-Id: 13293313 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95389EB64DD for ; Mon, 26 Jun 2023 18:20:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231772AbjFZSUn (ORCPT ); Mon, 26 Jun 2023 14:20:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231682AbjFZSUe (ORCPT ); Mon, 26 Jun 2023 14:20:34 -0400 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4F53E75 for ; Mon, 26 Jun 2023 11:20:24 -0700 (PDT) Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-1b7f04caf5eso6952975ad.1 for ; Mon, 26 Jun 2023 11:20:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687803624; x=1690395624; 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=qTMxx/LJnmIWvUmH+gdz70kQEF0zmvOjZ2b4ibjV0JA=; b=S4eXFyS5rCCSmx6iv7PwkGg0BQvm/qIBJWemgkd6QqmzpVRLetRiUZjak1W1mQyzZr mMKoaj7RIcwyjjYeEciNW4ODHuDXAB0C13yWbXWuat885LfNkeAe1aW17ajmWdoYdpXC lk8VuAdGvlhi04z5vwImriXcHwbtXGq5yiwmyAeXX64MSqe0tt/49ZE3I4ee91HgxP3c zZI/w6Nc73N8LQ4zawaNdpS2epI7IexAi7Wb/yi0aenclZFLqPugb8wyTg5JeBEyxrHx Xt5PuAKkhVJcUdmnZRtHtS5GOOJqKuDtYqs0xkgs9jrVWM7sdTirDlmdiNS+WWD/3Ss3 DLzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687803624; x=1690395624; 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=qTMxx/LJnmIWvUmH+gdz70kQEF0zmvOjZ2b4ibjV0JA=; b=giNAWY36R0fE/ctkqHw7a94B0cHUplJaS2KASZZPwvhu6DAeGDDd/A4o3csypGTGPX dgAAM7RUGwzJPZvehyEOS16OlhCBQIWSBfEZ+s3XQI3KLsTTaCxOt4gLpqi9MlVPa+A4 9n6cpzc2pQEc6B0GkIxO4zeqHMjbNdQOsJYZp2MMx+gjKejpaGvuxYLJzphnGoFTVmfS V8stJDMIn18fRkiZzABHRMNd3Z6epChcY3Emw4an+HxXpSNxemUXzjwmMUu8KYqeEuWa PdYkY8Zwtw4T7kB0TLjukvxGUVWlXL8lRG71lh/UNruoYMYIH3qcRVz1rL2W8xT4zZMQ 7dzw== X-Gm-Message-State: AC+VfDx5da1ItqeAzvrLFEK85+pasRGWtb66GKMITOi6PmfM59sN8f48 Divjmpz+i3bkkJUZVRbGrvNzkVipwFxI X-Google-Smtp-Source: ACHHUZ552kVkUSFqA9TwyT8wN0iazFX/dbob8KYbdGOsmC7IlUncgj9SPNf6gA/YueLd90akYh2M8MrAKzKf X-Received: from mizhang-super.c.googlers.com ([35.247.89.60]) (user=mizhang job=sendgmr) by 2002:a17:902:b608:b0:1b5:bd8:5aaa with SMTP id b8-20020a170902b60800b001b50bd85aaamr1078296pls.1.1687803624119; Mon, 26 Jun 2023 11:20:24 -0700 (PDT) Reply-To: Mingwei Zhang Date: Mon, 26 Jun 2023 18:20:12 +0000 In-Reply-To: <20230626182016.4127366-1-mizhang@google.com> Mime-Version: 1.0 References: <20230626182016.4127366-1-mizhang@google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230626182016.4127366-3-mizhang@google.com> Subject: [PATCH v2 2/6] KVM: Documentation: Update the field name gfns and its description in 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 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Update the field 'gfns' in kvm_mmu_page to 'shadowed_translation' to be consistent with the code. Also update the corresponding 'gfns' in the comments. The more detailed description of 'shadowed_translation' is already inlined in the data structure definition, so no need to duplicate the text but simply just update the names. Signed-off-by: Mingwei Zhang Reviewed-by: Kai Huang --- Documentation/virt/kvm/x86/mmu.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Documentation/virt/kvm/x86/mmu.rst b/Documentation/virt/kvm/x86/mmu.rst index 561efa8ec7d7..4c9044b4dc6c 100644 --- a/Documentation/virt/kvm/x86/mmu.rst +++ b/Documentation/virt/kvm/x86/mmu.rst @@ -221,11 +221,12 @@ Shadow pages contain the following information: at __pa(sp2->spt). sp2 will point back at sp1 through parent_pte. The spt array forms a DAG structure with the shadow page as a node, and guest pages as leaves. - gfns: - An array of 512 guest frame numbers, one for each present pte. Used to - perform a reverse map from a pte to a gfn. When role.direct is set, any + shadowed_translation: + An array of 512 shadow translation entries, one for each present pte. Used + to perform a reverse map from a pte to a gfn. When role.direct is set, any element of this array can be calculated from the gfn field when used, in - this case, the array of gfns is not allocated. See role.direct and gfn. + this case, the array of shadowed_translation is not allocated. 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 From patchwork Mon Jun 26 18:20:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingwei Zhang X-Patchwork-Id: 13293314 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 379D4EB64D9 for ; Mon, 26 Jun 2023 18:20:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231748AbjFZSUk (ORCPT ); Mon, 26 Jun 2023 14:20:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231670AbjFZSUd (ORCPT ); Mon, 26 Jun 2023 14:20:33 -0400 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85F6510C9 for ; Mon, 26 Jun 2023 11:20:26 -0700 (PDT) Received: by mail-pj1-x1049.google.com with SMTP id 98e67ed59e1d1-262e9467fbaso799803a91.3 for ; Mon, 26 Jun 2023 11:20:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687803626; x=1690395626; 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=0/miHGwTxT7US89Pp4p1SvRY38MOXEBbZOtBg20Cazc=; b=EHDAWz7QvBILtIie52w2HPumTE/XxMe4cOKd0HoxlAziAbEANSPDGzUZbDDuBQD+Wh Yp1DPuuapOk0eBvd1dE5O1zoBwyM5xvIQTserlY0buVkCErHOi5Qed8HmpRRPFe9ktOy FB7LOJmQ+2BAmiv4C2ktrEZ2eUqteQcG9Ugu8OBZ6IH6bFIdOjXLCoZM8oDaCxKYf0bZ 0hXLMenwq8XpV0Z6lgKtI3wkgj8nKTdD8qgqkg1Gnfwj8HeH5XA3/WvGrAIBXo9Sil0i +Y9WNlnB4SBC9g1OJvgHnc/qT7yufkr8d67BdfJ/o15lCD0IXlkz1aAha4ybBsoY00YC SJ8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687803626; x=1690395626; 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=0/miHGwTxT7US89Pp4p1SvRY38MOXEBbZOtBg20Cazc=; b=DoDgkm89Jhp9L8zspah1+eEbseKqbdw+nz0YJy8y6FnLQKXkL8CNVwngAnIvbvoFfw bxCrpnmWYggAuWLrdMVDJUW0q6sSr9aUdICPJbbue7Q2MQY0ptdD/ZeA6pQJP9XXRwox TmBPA+zJWHyLeF8sbb2yh0lnAt77QUvrDQFrSpyBv6oyu8KlyewYHyk3bTOoA9uifl+J c0YmAMEqLlM3VQgzL5SnYlzwiEqSKMCZhzN+C2Vxp6cb5mgPjEPS6r2bqZAFjPrKGYwL mANz7ygsngZGJ5CxGzNTFynQMsa+hWknSLQG+P4G0xEmjzrM/zui7U2wWUjQmRm2Q/tS NtQA== X-Gm-Message-State: AC+VfDxv92IY6U5yA/lUG8IbitvmWrQPcZ2TNANgdiOzyEBt5Xh3m1ux TghnTKxvdSgMTgLhjF1Zwr+SuTWP422y X-Google-Smtp-Source: ACHHUZ7ILUzkwgOPJbhik1kqQlUy2tUJqjg/LBtHn1mqOnidDPGUgGGw7+y5RFsxbllPbkG7nBFVtfNmrkd+ X-Received: from mizhang-super.c.googlers.com ([35.247.89.60]) (user=mizhang job=sendgmr) by 2002:a17:90b:797:b0:262:fb5d:1483 with SMTP id l23-20020a17090b079700b00262fb5d1483mr434837pjz.6.1687803625969; Mon, 26 Jun 2023 11:20:25 -0700 (PDT) Reply-To: Mingwei Zhang Date: Mon, 26 Jun 2023 18:20:13 +0000 In-Reply-To: <20230626182016.4127366-1-mizhang@google.com> Mime-Version: 1.0 References: <20230626182016.4127366-1-mizhang@google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230626182016.4127366-4-mizhang@google.com> Subject: [PATCH v2 3/6] KVM: Documentation: Add the missing description for ptep in 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 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Add the missing description for ptep in kvm_mmu_page description. ptep is used when TDP MMU is enabled and it shares the storage with parent_ptes. Update the doc to help readers to get up-to-date info. Signed-off-by: Mingwei Zhang Reviewed-by: Kai Huang --- Documentation/virt/kvm/x86/mmu.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/virt/kvm/x86/mmu.rst b/Documentation/virt/kvm/x86/mmu.rst index 4c9044b4dc6c..5cd6cd5e8926 100644 --- a/Documentation/virt/kvm/x86/mmu.rst +++ b/Documentation/virt/kvm/x86/mmu.rst @@ -237,6 +237,11 @@ Shadow pages contain the following information: parent_ptes points at this single spte, otherwise, there exists multiple sptes pointing at this page and (parent_ptes & ~0x1) points at a data structure with a list of parent sptes. + ptep: + The reverse mapping for the pte pointing at this page's spt. This field is + used in replace of parent_ptes when TDP MMU is used. In TDP MMU, each + non-root shadow page will have one parent, while each root shadow page has + no parent. Note that this field is a union with parent_ptes. unsync: If true, then the translations in this page may not match the guest's translation. This is equivalent to the state of the tlb when a pte is From patchwork Mon Jun 26 18:20:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingwei Zhang X-Patchwork-Id: 13293317 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5DC3EB64D7 for ; Mon, 26 Jun 2023 18:20:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231727AbjFZSUu (ORCPT ); Mon, 26 Jun 2023 14:20:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231680AbjFZSUe (ORCPT ); Mon, 26 Jun 2023 14:20:34 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 890BF10D2 for ; Mon, 26 Jun 2023 11:20:28 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-bfe92598ffaso5090752276.0 for ; Mon, 26 Jun 2023 11:20:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687803627; x=1690395627; 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=DC1JUUoeIHOkdglYQmr1DfzfpGQE2uWlWtSL5MUhKa8=; b=xYtXcmWxk0P1fCDcWTRmRHQ213fqB4rQuiXjexvxKc69fWrbx+jG1hAwG0llCkpycZ vIxsx2SNm225hbYaBdJVqoTck9XSOJKHlXh8DXvyqKg1GDw5gd8l+hSpY9QBLAiV12RY rv75429GaSsLG1+mV89FXylyGQezn4c2bMvPj3UN87MBkxdRUBLLYdkdL6DAdn3RGg72 VAUFRTosn8/60fdz9qwFv3TJRj28bLsYQui4hfKh76McyD8vBN0+at6FZ+BkOw316Td+ oESmYoDPXCHZZNA1rzDVevcOJ+5+8ZFPleApgNlncNDFxrTYp6OUsyfuI65KKgKe+AdK ayrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687803627; x=1690395627; 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=DC1JUUoeIHOkdglYQmr1DfzfpGQE2uWlWtSL5MUhKa8=; b=Ei8nFlRosCI0t3hyIu1LQa1FCc92OX6z+jDaEkG/KrOujPe3S3X7CED0TVLY/ApCR3 iJFIf4BxFWyQ5wGBDAuq7SkG3nDE7ezC/bFDl0tlqOrwUaeW2durCtuFTk1h9NkUCYvS SwxJGP77And2r/K7seknJxdKs5Zgj754ouGuMiQuJt7wA/sDVrRnKWFYMlruzFazSGMr mFevNlAS2O6Oe/DsIkbXmTc6Y8I/YxKnB3JiLdCLIdkj5TtGZ0NduazAMrJjBLNH9f1q tprkSqCRIv2IkNkMS3K9v0AdohcGOIEYCq52GN9/vKQJpvc9oQeEi7DuzDPTJxxXR2WJ guAA== X-Gm-Message-State: AC+VfDwjQAYEW+tm57A/4VcGpOmKDx9jyrKmg9nrc6mCdqLT1mf2/rcQ kaA0em1l2MRbjJK2AppDuJ6W4tbH2yoR X-Google-Smtp-Source: ACHHUZ488Z5RLeNgsxoRg10Vnlrts0vwlnMOG3/l4w4TY2cIGhoT7SAOtLcxmF27YNT6IpiCb3oib0lZxORJ X-Received: from mizhang-super.c.googlers.com ([35.247.89.60]) (user=mizhang job=sendgmr) by 2002:a05:6902:18c4:b0:c1c:e037:136c with SMTP id ck4-20020a05690218c400b00c1ce037136cmr3172718ybb.0.1687803627815; Mon, 26 Jun 2023 11:20:27 -0700 (PDT) Reply-To: Mingwei Zhang Date: Mon, 26 Jun 2023 18:20:14 +0000 In-Reply-To: <20230626182016.4127366-1-mizhang@google.com> Mime-Version: 1.0 References: <20230626182016.4127366-1-mizhang@google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230626182016.4127366-5-mizhang@google.com> Subject: [PATCH v2 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 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Add the description of tdp_mmu_root_count into kvm_mmu_page description. tdp_mmu_root_count is an atomic counter used only in TDP MMU. Its usage and meaning is slightly different with root_counter in shadow MMU. Update the doc. Signed-off-by: Mingwei Zhang Reviewed-by: Kai Huang --- Documentation/virt/kvm/x86/mmu.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/virt/kvm/x86/mmu.rst b/Documentation/virt/kvm/x86/mmu.rst index 5cd6cd5e8926..97d695207e11 100644 --- a/Documentation/virt/kvm/x86/mmu.rst +++ b/Documentation/virt/kvm/x86/mmu.rst @@ -231,6 +231,11 @@ Shadow pages contain the following information: 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. + tdp_mmu_root_count: + An atomic reference counter in TDP MMU root page that allows for parallel + accesses. Accessing the page requires lifting the counter value. The + initial value is set to 2 indicating one reference from vCPU and one + from TDP MMU itself. Note this field is a union with root_count. 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 From patchwork Mon Jun 26 18:20:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingwei Zhang X-Patchwork-Id: 13293315 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7E9BC001DD for ; Mon, 26 Jun 2023 18:20:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231789AbjFZSUo (ORCPT ); Mon, 26 Jun 2023 14:20:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231700AbjFZSUf (ORCPT ); Mon, 26 Jun 2023 14:20:35 -0400 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 159AB10E7 for ; Mon, 26 Jun 2023 11:20:30 -0700 (PDT) Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-1b7ea1595b4so7967885ad.2 for ; Mon, 26 Jun 2023 11:20:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687803629; x=1690395629; 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=fPTPHDUYMvFHPd69LEESu74mldUigTMG6iEPquT4JGU=; b=hpVsGk/fUm1QcLK2YtEYFckHIZf49A1mdzhhlT6g1Lz6cLQjxC+qmUoy7IFKkrxdTa DdRNgOP3WHMEjb/9x9YWNAnaxx26m44CG5C2oiexiZybtYsDWogSxj85PydZ5tc7FW3v +NmOpbnqJCiSPeMVd7pgp+giO/Ty5+TAP/8PbLWOW2Ec1BYSHUC+OcmcCAdZGmOycB25 TxL3HUAGO524gTtd3orZ5coYXLol2k1UotilzoG9GZXIhx9ahPW0lvKpHXOCRiiyeYt/ fDkfwtXNV/lD3DYHcYbAAhYcNpnmqcXsUfzRZ8sQlZpX0eFtjRio+vRcjZCpz8EvRJNG 6MnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687803629; x=1690395629; 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=fPTPHDUYMvFHPd69LEESu74mldUigTMG6iEPquT4JGU=; b=CfRteT6IH3QzFeKFC8QwNl4ffeiW+OEQzldc0qun6CbWCKgjQL/wE4R5jIzHLn6ezy 2PUXI1rKVMdskFksthNpJO9E/Ht6bZ6+P7Dm62dbzFP82XstZpGvdMSZFuMGl2cnOxYl 4haZXnP9KLQvSGzv4LpNcH6vjrFj8sn7Q2hlpq+/AZ6rcmT1wbGNsl6ehr6zNNdTijq6 pYIM1qrArfj+U0JZFPS34QeIgJwZVY6TmDA6VZ2Ecso+sEZY1ev4yJ7jTR+7zrz9kLdB ZeP1BGh7WLcCNO1snrQ+CVq+lN7CgxCOf+midEaFbNDoNEPQYeil8OF4S7r0iiac7ApI jVLA== X-Gm-Message-State: AC+VfDzu4/PXkFhRuIHFtBpjSyIZ/BTCVODWPXuaNizCF3vL0xU9pAzy yBZgaL+//0zVKsbsIum0G5zhjS2D+9xI X-Google-Smtp-Source: ACHHUZ5i1zR1+WP8oLLG/LizLQqTDq0QVvfrsPT68I7W/9cAU32kCuDMhcHcXyiJKrkWI6nb/K9vN0SU7zL6 X-Received: from mizhang-super.c.googlers.com ([34.105.13.176]) (user=mizhang job=sendgmr) by 2002:a17:902:d58e:b0:1a6:c110:900a with SMTP id k14-20020a170902d58e00b001a6c110900amr1305666plh.3.1687803629637; Mon, 26 Jun 2023 11:20:29 -0700 (PDT) Reply-To: Mingwei Zhang Date: Mon, 26 Jun 2023 18:20:15 +0000 In-Reply-To: <20230626182016.4127366-1-mizhang@google.com> Mime-Version: 1.0 References: <20230626182016.4127366-1-mizhang@google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230626182016.4127366-6-mizhang@google.com> Subject: [PATCH v2 5/6] KVM: Documentation: Add the missing description for mmu_valid_gen 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 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Add the description for mmu_valid_gen into kvm_mmu_page description. mmu_valid_gen is used in shadow MMU for fast zapping. Update the doc to reflect that. Signed-off-by: Mingwei Zhang Reviewed-by: Kai Huang --- Documentation/virt/kvm/x86/mmu.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/virt/kvm/x86/mmu.rst b/Documentation/virt/kvm/x86/mmu.rst index 97d695207e11..cc4bd190c93d 100644 --- a/Documentation/virt/kvm/x86/mmu.rst +++ b/Documentation/virt/kvm/x86/mmu.rst @@ -208,6 +208,10 @@ Shadow pages contain the following information: The page is not backed by a guest page table, but its first entry points to one. This is set if NPT uses 5-level page tables (host CR4.LA57=1) and is shadowing L1's 4-level NPT (L1 CR4.LA57=1). + mmu_valid_gen: + Used by comparing against kvm->arch.mmu_valid_gen to check whether the + shadow page is obsolete thus a convenient variable for fast zapping. + Note that TDP MMU does not use mmu_valid_gen. gfn: Either the guest page table containing the translations shadowed by this page, or the base page frame for linear translations. See role.direct. From patchwork Mon Jun 26 18:20:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingwei Zhang X-Patchwork-Id: 13293316 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95870EB64D7 for ; Mon, 26 Jun 2023 18:20:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231802AbjFZSUr (ORCPT ); Mon, 26 Jun 2023 14:20:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231723AbjFZSUi (ORCPT ); Mon, 26 Jun 2023 14:20:38 -0400 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A1BD10F9 for ; Mon, 26 Jun 2023 11:20:31 -0700 (PDT) Received: by mail-pf1-x44a.google.com with SMTP id d2e1a72fcca58-66881827473so1571374b3a.2 for ; Mon, 26 Jun 2023 11:20:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687803631; x=1690395631; 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=ImRtxMlYFksXesGcg5ZEwinCVjK+1eznyzb1zuEq5IA=; b=Tdy68PWDHkjiU3GFNBhBXBkqsqiqqWAGIXJ/q4OjjptAOSfM5EY42+vLqgA8D8nXAS clXF5BXCK0DJ71Va0Wz2nmU5U75ABUVVNq5Soj0T8VDpURZ3pOkkmiT0d6CAOe1ulwju zjeQJ1DH2VB+yypRy/vE4EAQw+QA0GV5wZ7PWldp9hocIQmtrsxFMYgGiycX6CpHqZ+C 255CmNUW5d30tex1Crn09VGfnKT0f9g0h5xWaV48MbkB4xvLFFnOQMwOlGyQja8q+FmG 9OnaPlIw+hwtf7bPt6nXd4VP1MQrnjlW8kFoiViD+b4ievS/+PZxZqEjIARqxF5GbQdU vW4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687803631; x=1690395631; 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=ImRtxMlYFksXesGcg5ZEwinCVjK+1eznyzb1zuEq5IA=; b=Xg+aqFcPbFrtPewSTqIfFfEt4JHo3F4n9MptBmefvJq9cGTA19ODS353yR/ZEWM32G HBl1eMcQs3CBXvCAMELwonBvC9d5TCxxaK+sZTlq4PW58yYbS32uXQ7YordkkmelosRi XbcC7HpuJ7S8fQSXUqJ9BZ6KGNq44kSnp7eRKsz6e02HZCBT3A2HwboXeZn4guxEU/hG wt01BualPdUME1qilmLBoYYm0IBizCpKPHaY7l4qv3DnVFcF7CrmySWjQlT4AMXJcGaM moYBHjYHuwZm2OuPK7VJ6F6e3Yer9Hz8gj1OJB/SeqbQp2zhz1PIHBqorHZYGT/D1YnS S9Ag== X-Gm-Message-State: AC+VfDz9jM94Kmo/PjZy8v5lxFNNQufQELem14TObsnAdpNXHj/Y0ZMg 7dvNn/13ZGgFn46fr8vYCGYkJ00gAH90 X-Google-Smtp-Source: ACHHUZ6Xm5XTTB6gU7PnMdzSwbfdec0L51WkX0uwv6yQ15WhSWbv1AKPANZ7pk/pz4xlrtsDhZ9AsKLmNz+V X-Received: from mizhang-super.c.googlers.com ([34.105.13.176]) (user=mizhang job=sendgmr) by 2002:a05:6a00:2d0f:b0:675:b734:d30f with SMTP id fa15-20020a056a002d0f00b00675b734d30fmr1001451pfb.4.1687803631156; Mon, 26 Jun 2023 11:20:31 -0700 (PDT) Reply-To: Mingwei Zhang Date: Mon, 26 Jun 2023 18:20:16 +0000 In-Reply-To: <20230626182016.4127366-1-mizhang@google.com> Mime-Version: 1.0 References: <20230626182016.4127366-1-mizhang@google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230626182016.4127366-7-mizhang@google.com> Subject: [PATCH v2 6/6] KVM: Documentation: Add the missing description for tdp_mmu_page 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 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Add the description for tdp_mmu_page into kvm_mmu_page description. tdp_mmu_page is a field to differentiate shadow pages from TDP MMU and non-TDP MMU. When TDP MMU is enabled, sp->tdp_mmu_page=1 indicates a shadow page for L1, while sp->tdp_mmu_page=0 indicates a shadow page for an L2. When TDP MMU is disabled, sp->tdp_mmu_page is always 0. So update the doc to reflect the information. Signed-off-by: Mingwei Zhang Reviewed-by: Kai Huang --- Documentation/virt/kvm/x86/mmu.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/virt/kvm/x86/mmu.rst b/Documentation/virt/kvm/x86/mmu.rst index cc4bd190c93d..678dc0260a54 100644 --- a/Documentation/virt/kvm/x86/mmu.rst +++ b/Documentation/virt/kvm/x86/mmu.rst @@ -278,6 +278,8 @@ Shadow pages contain the following information: since the last time the page table was actually used; if emulation is triggered too frequently on this page, KVM will unmap the page to avoid emulation in the future. + tdp_mmu_page: + Is 1 if the shadow page is a TDP MMU page. Reverse map ===========