From nobody Sat Feb 7 23:47:55 2026 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 7BBAEEE3F0C for ; Tue, 12 Sep 2023 18:46:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237486AbjILSqF (ORCPT ); Tue, 12 Sep 2023 14:46:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236045AbjILSqD (ORCPT ); Tue, 12 Sep 2023 14:46:03 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15B7D10D9 for ; Tue, 12 Sep 2023 11:45:59 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-59b6083fa00so47053377b3.0 for ; Tue, 12 Sep 2023 11:45:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694544358; x=1695149158; darn=vger.kernel.org; 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=KxsKqPZq5p15xyDVXXLvft8EHyxkBVs3E9jtZwaSo4E=; b=beoIYyLFM6CO3BCIy1jNFebumt2d2ns9gQYUKwO8+Q9KedfEyiM4fjqVxRku4Xi7By YiS6U3jeonxaFNPbMT83ihaXc6eX/exIotwuQoDt/WDBId7nUhZbEC9jEqvlc8ikl4AQ KOTd41NHeMWUCF2Dg7r56FsABJwdmU1NZ72sBuEEqqdeKnMdNfrdj/9iQq2LzKaosplr hAC232JS3B43leablPeUM8hxRkbAsGBs+UYAf51jXBeXh1SzFTBT/tPLdXTKRjSewhBv 7DaeH5chbzOTuY/V7Vq/F8LxMAMkgelzhGo2+dEQ18hzESGTZZEp7Vx8UxFhPwuKEdMT 5PmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694544358; x=1695149158; 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=KxsKqPZq5p15xyDVXXLvft8EHyxkBVs3E9jtZwaSo4E=; b=bn+59xeS+X3OnerE/96ygX9AzWTSdsegd4oZP2XjAW97iQStRb9wk0gO3APx45DDs5 5+W/gSTUWTanbldvQjb93O2x9L3nTzficmTJK1DHze+iWk4O2Mtqthlmw3BxCF2r/JEd NVoN6lDHW9VamI0oYNK3Q2gGvKgRa08o6zRHiOZk+qpHDgQcAHuIM06tnavO+XkwqXGh Z0LjLflGbKNx673T17+XE3Tbf+B9iolUkNx9l4NSI9QOegailaGnZCmE3PO1Z9VBIMEW IIqTiv8pQkBSOjXXLxqGrjABvcfR2t1qTEuaRzvyiqHx+Zs6+o3jV3tfaSkCZTYccnAn 6Xgw== X-Gm-Message-State: AOJu0YwGYYuIMs4spMbJgq3gcDL2daYpQjrZ6XQeRz7IBozm/MKVbKKI sVm6ouQC0HOWYVFRqZ/eGNssPqC/5gza X-Google-Smtp-Source: AGHT+IFD8uQU6j1QBXjlKBLUMj8KgXKe6xDa8o8kykJFhbrLmwmFQU0DfU98SyrqwHQvlTqlsPmIHW+g351a X-Received: from mizhang-super.c.googlers.com ([34.105.13.176]) (user=mizhang job=sendgmr) by 2002:a81:ac55:0:b0:581:3899:91bc with SMTP id z21-20020a81ac55000000b00581389991bcmr10628ywj.6.1694544358303; Tue, 12 Sep 2023 11:45:58 -0700 (PDT) Reply-To: Mingwei Zhang Date: Tue, 12 Sep 2023 18:45:48 +0000 In-Reply-To: <20230912184553.1887764-1-mizhang@google.com> Mime-Version: 1.0 References: <20230912184553.1887764-1-mizhang@google.com> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog Message-ID: <20230912184553.1887764-2-mizhang@google.com> Subject: [PATCH v4 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 , Randy Dunlap Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/x8= 6/mmu.rst index 26f62034b6f3..23c20455d4e7 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 --=20 2.42.0.283.g2d96d420d3-goog From nobody Sat Feb 7 23:47:55 2026 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 1AD49EE3F0F for ; Tue, 12 Sep 2023 18:46:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237522AbjILSqJ (ORCPT ); Tue, 12 Sep 2023 14:46:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237472AbjILSqE (ORCPT ); Tue, 12 Sep 2023 14:46:04 -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 C9A0210D3 for ; Tue, 12 Sep 2023 11:46:00 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-59224c40275so65957377b3.3 for ; Tue, 12 Sep 2023 11:46:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694544360; x=1695149160; darn=vger.kernel.org; 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=qTWRNy0B9f+ysXrRobFDRO6uVjKtmJ5Zj+3oA+uRqFw=; b=SCrNki8Jh/KDjueh7CYSf8v07IBDd9cSO/+obsBUIryLQl7iWKfUYdvrOP/lP4xd12 pUB6Q9ptoCMePKL0iBY3/KqftWHmf2MpHdnvDsGEKJwgQvlMGH0+lpOa/Xyz01zV/PIR rhn8WPzS6ljB3+62B7C3ZQ+Ish0RWVTcq376F5xXgAZt8TgiQRwhzalmvzjTRDa7fMJz TqfjDKafiSVCk6Wro+5heXmfd3NbS6aXrDYiZU5c47CdyEM+QU39EofFWnrAoUs+u2yQ yB2dGwwl9pz2fSygR3HGud1CQUHAv+bh5xXalmEOZq00EyvEIOc8EWW5hgQtMBrvmbDz zajg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694544360; x=1695149160; 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=qTWRNy0B9f+ysXrRobFDRO6uVjKtmJ5Zj+3oA+uRqFw=; b=k8rcEhUtx51oo+0poVQqAh88xnDfl+FIF9SC7dq/ZpzDDZ2qw1bvlJSH5tJexzLIbb Lqlgdqhn0YPzowEqKyLSHeqi7lrPSXwQfZrN2v+YA51Spq9r9AbEgHF831NXcVxYjoIN RSeq1LyTe7F8nC/yn03rxxtWl5JhDbODRR6x5q4D1lx8GEGKoNEYQw2e2V+pjjZwXJV0 9Qe+XSKvYASbHQr+elBlZI28YiL+V1PtVIGOg1WdM7C4CLroumXJolHj5z8TRExMYxWm JYyGKNEX8f8SmBTbGJJg6EqhCj5g4HJ/IT3CM8qH08bPh9dnVk36VqUu9S7IV7aT/9b9 x9kQ== X-Gm-Message-State: AOJu0Yw6BwktWVF83AnOyzeno/yrcDHDFENqNmIiEzkHx/q1jSbQHNy4 81vdj5EKbTWxVCQZqJsQJ70in53kFnZa X-Google-Smtp-Source: AGHT+IExxh81sJmoda00gQCx452m1kAPhvdCiEgMvshXnrLFY3W2YcbVYQ9y4uEExivicBlb6fdygWXh8dff X-Received: from mizhang-super.c.googlers.com ([35.247.89.60]) (user=mizhang job=sendgmr) by 2002:a25:949:0:b0:d80:ff9:d19e with SMTP id u9-20020a250949000000b00d800ff9d19emr4790ybm.9.1694544360050; Tue, 12 Sep 2023 11:46:00 -0700 (PDT) Reply-To: Mingwei Zhang Date: Tue, 12 Sep 2023 18:45:49 +0000 In-Reply-To: <20230912184553.1887764-1-mizhang@google.com> Mime-Version: 1.0 References: <20230912184553.1887764-1-mizhang@google.com> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog Message-ID: <20230912184553.1887764-3-mizhang@google.com> Subject: [PATCH v4 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 , Randy Dunlap Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Documentation/virt/kvm/x86/mmu.rst b/Documentation/virt/kvm/x8= 6/mmu.rst index 23c20455d4e7..f659f282357d 100644 --- a/Documentation/virt/kvm/x86/mmu.rst +++ b/Documentation/virt/kvm/x86/mmu.rst @@ -221,11 +221,14 @@ 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 - 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. + 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 as well as its access + permission. When role.direct is set, the shadow_translation array is n= ot + allocated. This is because the gfn contained in any element of this ar= ray + 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 t= he + 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 --=20 2.42.0.283.g2d96d420d3-goog From nobody Sat Feb 7 23:47:55 2026 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 99AC0EE3F12 for ; Tue, 12 Sep 2023 18:46:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237532AbjILSqJ (ORCPT ); Tue, 12 Sep 2023 14:46:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237489AbjILSqG (ORCPT ); Tue, 12 Sep 2023 14:46:06 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FE2A10EF for ; Tue, 12 Sep 2023 11:46:02 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id 98e67ed59e1d1-26f49625bffso7076580a91.1 for ; Tue, 12 Sep 2023 11:46:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694544362; x=1695149162; darn=vger.kernel.org; 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=mMn9wfgwSNeBQXqC1xBrAj9DL3zD7p3ffh9VRzzCD10=; b=S3Rp41f5pj9Xq0M0JICGfaFghn6ICKnxgTM9yCGAeXmGyJlC44I732tpv1fT+chYcQ ZDtTodqENBFq1gDBu65cXYQvK9sjFeu+gm/exz1DJ3Rvpqhcz6hbBkrI0hSn9j/4eUE8 CJq9qtA0y6x3jnfuta+LmY5WQeTrbxalxrFavt4DsyRKKQ2rFTrvZEwyDp9sNlCNp6oV daau+6OQLLmTIq3dNVmRIohVO9tVZkThMw3Gyh3VrtML9u+e05ppukjKjI7ElQlo4Y8F TtQzpcBTL7Hm4Kv0g9CJJLm2SlwkKZHsFMrwu6T383d+kYoZwAK8ZhngosHyqRYq6Xsd FPXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694544362; x=1695149162; 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=mMn9wfgwSNeBQXqC1xBrAj9DL3zD7p3ffh9VRzzCD10=; b=ngTTMOhPSxrPZXUF70BzX2Hd8oJYWe0dNfMovuodeqPqsa9osNEqpM3/RkFog0Kmnp uDX8sqUH2wN71niyViFYJvYIcbukvXo+v0OoWJgJsPMGYJSSlvIXBWXXodNOkF2zvp/x ZRM5DMDLa9jTq0esiBDoZvIqzL6V3FrNdpjjDjtJ0bLD4X6Mp5zW1sfdmSNTlcaTLyCm 4Y61v027uk0ZdKSHwgNih4H37grxTtrsqTovpL/4cSuIKaQuk6BsH9J0eKmx3bRV99OV 8YjBPcleyca56UA/NTqRWUxuUpjQssZVssiQ7GnXVAZZrUQbr0KFztbq1WKh0/KcvCrv ghQQ== X-Gm-Message-State: AOJu0Yx6IjKuaCITMoPx9BmvX6KHxomH/0u8SzCXf1zNjNX+qmsxzeKm ysudZFnFu/4cV93YbSgQq3IjbHZxSihF X-Google-Smtp-Source: AGHT+IH2ju4PxTOUbeBNOmPUAvNt/h8Wx/ykN1r+31ERSCan0rZqj213XzGxPXFcP/vgRsmo6KWk3swmsvTL X-Received: from mizhang-super.c.googlers.com ([35.247.89.60]) (user=mizhang job=sendgmr) by 2002:a17:90b:110a:b0:268:2de3:e6b2 with SMTP id gi10-20020a17090b110a00b002682de3e6b2mr2664pjb.5.1694544361761; Tue, 12 Sep 2023 11:46:01 -0700 (PDT) Reply-To: Mingwei Zhang Date: Tue, 12 Sep 2023 18:45:50 +0000 In-Reply-To: <20230912184553.1887764-1-mizhang@google.com> Mime-Version: 1.0 References: <20230912184553.1887764-1-mizhang@google.com> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog Message-ID: <20230912184553.1887764-4-mizhang@google.com> Subject: [PATCH v4 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 , Randy Dunlap Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/virt/kvm/x86/mmu.rst b/Documentation/virt/kvm/x8= 6/mmu.rst index f659f282357d..22d221c180d7 100644 --- a/Documentation/virt/kvm/x86/mmu.rst +++ b/Documentation/virt/kvm/x86/mmu.rst @@ -239,6 +239,9 @@ Shadow pages contain the following information: parent_ptes points at this single spte, otherwise, there exists multip= le sptes pointing at this page and (parent_ptes & ~0x1) points at a data structure with a list of parent sptes. + ptep: + The kernel virtual address of the SPTE that points at this shadow page. + Used exclusively by the TDP MMU, this field is a union with parent_pte= s. 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 --=20 2.42.0.283.g2d96d420d3-goog From nobody Sat Feb 7 23:47:55 2026 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 384FBEE3F0F for ; Tue, 12 Sep 2023 18:46:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237618AbjILSqW (ORCPT ); Tue, 12 Sep 2023 14:46:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237544AbjILSqK (ORCPT ); Tue, 12 Sep 2023 14:46:10 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDE19170B for ; Tue, 12 Sep 2023 11:46:04 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d7e79ec07b4so5870385276.0 for ; Tue, 12 Sep 2023 11:46:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694544364; x=1695149164; darn=vger.kernel.org; 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=1yc1t1cPhcaHcfI5EVv9bF1nMQXNiuICbyEqqARRk08=; b=0D+IFsg/c/klBU+DNRVCXwQuaPdObjt4HEf0QzddULB5ht7UgbaNXDYbBQkw6l6+h2 bX6JEWXm/U32/BCN60XpkiaP24KDjH8ok6J3Vn4eFun8NNaBHThdBOVbhvZN+VrUuKiT YHDJM4NQtAfEbY0OaRb1dFlXL8b/frwQ2gJ3nFBKGUJZ1t1qj2AEZGebXZ8o0BVbFdf3 WNqFkx7x4GNC1yxEidYpQeAs9dKdAhdvYKbjQITFc9UVZ958ueUWhyGA1AT1XVF80ktf ISjhn2nWRyT+iQDFTSBEG6dz1lQDnamH1KnfihB3yvKz8F8mzXFNvTEv/sj25rpuZFLH u1Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694544364; x=1695149164; 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=1yc1t1cPhcaHcfI5EVv9bF1nMQXNiuICbyEqqARRk08=; b=Rbc6QwW8FcsYP2L71I0D9R2znHQFMQYygOKXODYZGabRBS0n6xZmN4cL2KIc4dPzYC OY9578ME0ALchru5WJT2BfqO4PsqIwznHdoUYt4HhgUC7Qm3HHYhNTQdxknbwMoCGhdd Oa/z6ggQpAGU/CK5m1R0QahM0RjXH6aJU9t2q0M0xTZ7Sjqxg/rJNDsUa+5MRYduA/VJ saBjy7VIFSsneQcKnTbW1DMngQrEtGWnKmm268bPutTOFfyUoUMUJEolNyuHEuWkCrSj A5UvT5ePZ3FfmrnXeH5O1ZK+yauJN3/cGSkPUJYDzq41ZIeGGy7BoS6xaKhl5E5asLvh G4qw== X-Gm-Message-State: AOJu0YzGPezj5qrCxmcgYDEoKG3nK19tS9a9iqdF5Fc6PIDxl1CPwm+t oE3awrkaVfzk6l0y/8+jem2ofLZLsCN5 X-Google-Smtp-Source: AGHT+IHHhcRDlPw3DSpf44fo6CQF4LFDpfJyENmkPgeVqzhES7DO2nLgb88kYl04s/IipXV1gy4yvLlc+lQb X-Received: from mizhang-super.c.googlers.com ([35.247.89.60]) (user=mizhang job=sendgmr) by 2002:a25:549:0:b0:d74:6bcc:7b22 with SMTP id 70-20020a250549000000b00d746bcc7b22mr5283ybf.6.1694544363864; Tue, 12 Sep 2023 11:46:03 -0700 (PDT) Reply-To: Mingwei Zhang Date: Tue, 12 Sep 2023 18:45:51 +0000 In-Reply-To: <20230912184553.1887764-1-mizhang@google.com> Mime-Version: 1.0 References: <20230912184553.1887764-1-mizhang@google.com> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog Message-ID: <20230912184553.1887764-5-mizhang@google.com> Subject: [PATCH v4 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Documentation/virt/kvm/x86/mmu.rst b/Documentation/virt/kvm/x8= 6/mmu.rst index 22d221c180d7..4a82fa016833 100644 --- a/Documentation/virt/kvm/x86/mmu.rst +++ b/Documentation/virt/kvm/x86/mmu.rst @@ -229,10 +229,13 @@ 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 t= he 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 us= ed as + a root page, i.e. page that will be loaded into hardware directly (CR= 3, + PDPTRs, nCR3 EPTP). Root pages cannot be destroyed while their refcou= nt is + non-zero. See role.invalid. tdp_mmu_root_count is similar but exclusi= vely + used in TDP MMU as an atomic refcount. 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 --=20 2.42.0.283.g2d96d420d3-goog From nobody Sat Feb 7 23:47:55 2026 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 A6816EE3F0C for ; Tue, 12 Sep 2023 18:46:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237674AbjILSqZ (ORCPT ); Tue, 12 Sep 2023 14:46:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237537AbjILSqO (ORCPT ); Tue, 12 Sep 2023 14:46:14 -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 57DA210F7 for ; Tue, 12 Sep 2023 11:46:06 -0700 (PDT) Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-1c0d58f127fso83564165ad.2 for ; Tue, 12 Sep 2023 11:46:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694544366; x=1695149166; darn=vger.kernel.org; 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=XcIQx89b7EXA4Jd30psh2om9W5cX9cr0aEmWIDQQPw0=; b=kZrO76abI+5Y7yb5qnQK8fohA9OAUhhARJhdzXibtKW9ISWk52Oe0jVG3iNwF+frPC VweDyg/qdaOGycLMaBqOKJyn+q7+aSkaL4nBKzsqiIA0f7jp/T6O21SrufoSfMrHNm3e 1wLzbE7L0vZcnZG1NGCb/IdecABMSNj5pXjZlTmVtiWRRAxDe7NmePFihn5/pE9Aaq/E XjSp8xbBJ0xtM4kSDI4zMMm5bauKY5QFkhZOlCMh6/UMCZuTntfQ0v+P81tt6AauJDrU CTWG3inqQ1+5VmhtsTA0Tj0OZpPdyKoJ6IL0D8XmPpjLAMg0kp/n9jEToTXr8PrqS/50 2GMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694544366; x=1695149166; 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=XcIQx89b7EXA4Jd30psh2om9W5cX9cr0aEmWIDQQPw0=; b=bSabMcxOczWJTR8KXaq6m/YsZA8Y2AeFu6xe4qXdq7J9y7+JPD3B0UY3lZr7TmNe/8 37bA/oUMjilABfQYNG3VNIN31aXk59Py6Dhfw4zj2t0ZguI/qEilqmCHWeICTLN3oQoA YTSsnOV0xabPYX+RSJx3A1seskRKOr1xAdfL8mHJWFihpH15Q2Vet7/jqG9LIWgvBkBl XgrXdtzdvF5RhieVdV0hts6diYu4CJ+5F7RKRMWC/MEiI7tpI2/i8RQNc0kAQCY6HeMd dfYEU6cgfawa6esiQgXsWA5CSsa4Rf8Xs0qHmOjb0kVgGrr5P3xDaeIHhSihrdu5Q+Bf IR6w== X-Gm-Message-State: AOJu0YzG4i7ERkS+VZMnYRm91UK9ar27jzw/IGCRqupScEDTkUCiZMtw P4BaZm63bKyYntYHxOJ0cwFyml38wO9n X-Google-Smtp-Source: AGHT+IGqq6x9d5HVPWndODMEBXDlwAy8Xp83EGfJSqGJEHDZ9LhqD2Cj4ch/JRrq3iQPJn9/ImPHNYbFcoBO X-Received: from mizhang-super.c.googlers.com ([35.247.89.60]) (user=mizhang job=sendgmr) by 2002:a17:902:e749:b0:1b8:a593:7568 with SMTP id p9-20020a170902e74900b001b8a5937568mr86132plf.8.1694544365752; Tue, 12 Sep 2023 11:46:05 -0700 (PDT) Reply-To: Mingwei Zhang Date: Tue, 12 Sep 2023 18:45:52 +0000 In-Reply-To: <20230912184553.1887764-1-mizhang@google.com> Mime-Version: 1.0 References: <20230912184553.1887764-1-mizhang@google.com> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog Message-ID: <20230912184553.1887764-6-mizhang@google.com> Subject: [PATCH v4 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 , Randy Dunlap Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/virt/kvm/x86/mmu.rst b/Documentation/virt/kvm/x8= 6/mmu.rst index 4a82fa016833..16d5d6a1c174 100644 --- a/Documentation/virt/kvm/x86/mmu.rst +++ b/Documentation/virt/kvm/x86/mmu.rst @@ -208,6 +208,16 @@ 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=3D1) and is shadowing L1's 4-level NPT (L1 CR4.LA57=3D0). + mmu_valid_gen: + The MMU generation of this page, used to fast zap of all MMU pages wit= hin a + VM without blocking vCPUs too long. Specifically, KVM updates the per-= VM + valid MMU generation which causes the mismatch of mmu_valid_gen for ea= ch mmu + page. This makes all existing MMU pages obsolete. Obsolete pages can't= be + used. Therefore, vCPUs must load a new, valid root before re-entering = the + guest. The MMU generation is only ever '0' or '1'. Note, the TDP MMU d= oesn't + use this field as non-root TDP MMU pages are reachable only from their + owning root. Thus it suffices for TDP MMU to use role.invalid in root = pages + to invalidate all MMU pages. gfn: Either the guest page table containing the translations shadowed by th= is page, or the base page frame for linear translations. See role.direct. --=20 2.42.0.283.g2d96d420d3-goog From nobody Sat Feb 7 23:47:55 2026 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 1EF83EE3F0B for ; Tue, 12 Sep 2023 18:46:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237653AbjILSq2 (ORCPT ); Tue, 12 Sep 2023 14:46:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237640AbjILSqP (ORCPT ); Tue, 12 Sep 2023 14:46:15 -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 02D5E198E for ; Tue, 12 Sep 2023 11:46:08 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5924b2aac52so64416217b3.2 for ; Tue, 12 Sep 2023 11:46:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694544368; x=1695149168; darn=vger.kernel.org; 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=8NSnv/WTj9TePiwJ3e7yhez5Y5Fg6PSmoubFG+0am4I=; b=lpm26PFNLDdB5U8I7PH2zsOgtkh+8n0wJP0UoVJtwGT+9Xu+VjkiJVDdx4zHQPubY/ S8cijbfRWnpZ4dxhQtu7bZEsr5tPu7vz4wKAaEXNU25dTmwMf4i4Bfk/5WUapQXcjymE gWlyxfXlsgTZ0rLMBweEaxkezHhe54GKjk+xJX10cnAbRo/DzGoYz9DKYc7FdecAAy4F +NZanwJDCYaHoSGcPIUZ3Tq3awy+/KTrOPQr2Dm6JuMqOuq4EqopP0epCmdTT/gwL/3S U1bICPIiYBRO3KwhC+2Nv0/+tVVWPyjhegLFMhUiFDZBtn1ilkZSfk/7jbSW7wrlWfPt 2yHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694544368; x=1695149168; 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=8NSnv/WTj9TePiwJ3e7yhez5Y5Fg6PSmoubFG+0am4I=; b=o+OUC9lFaltKTR3E2ibX9R3nUL/WE9nMtdHWLOm665WRDiKSjsJ4JWvnBoYte9FNIm 12aatbfAU1C1XNOnAJEe9dGZU75CKWau/rRgOe3wli7L+B0z6P55e//QSoYt6Uhx1944 KQTa14/BuEjA5+mx1ukxx6oYCnZ02bNuN5TEme/4fOKbjTVWwx/sOUo1iNXlXRWMI3Kb i34I5BqKnTxa44VFKvrVP9iWCmLHPcCeI2HnR/p1mk4bn9T2g7gU8FzwLteujwmbpAfA b1MBU9+W09zzskYn5q1D32erkSeQLuiOurXSdEnkdBMVWYSjC+f77+iDdwguF8OKKDjP x9dA== X-Gm-Message-State: AOJu0YzL/9rZX3+RRhA3w4L8jK60pvp13HfE/9BjFGl4Nn9ozPl0AgBo Vt+BaNcc3WnWUsk6dtVr16a9BcJWXY/8 X-Google-Smtp-Source: AGHT+IFADHJrwy/aa2LM6dPwu4H3fm1xiVyTj+CcoUMEvy5vi37pxe5Yg8FlnTokO/LcSVDIT1ldwzVEBl20 X-Received: from mizhang-super.c.googlers.com ([34.105.13.176]) (user=mizhang job=sendgmr) by 2002:a81:400c:0:b0:589:a855:7af with SMTP id l12-20020a81400c000000b00589a85507afmr8853ywn.7.1694544367876; Tue, 12 Sep 2023 11:46:07 -0700 (PDT) Reply-To: Mingwei Zhang Date: Tue, 12 Sep 2023 18:45:53 +0000 In-Reply-To: <20230912184553.1887764-1-mizhang@google.com> Mime-Version: 1.0 References: <20230912184553.1887764-1-mizhang@google.com> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog Message-ID: <20230912184553.1887764-7-mizhang@google.com> Subject: [PATCH v4 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 , Randy Dunlap Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. 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/x8= 6/mmu.rst index 16d5d6a1c174..82c5c6a6da2c 100644 --- a/Documentation/virt/kvm/x86/mmu.rst +++ b/Documentation/virt/kvm/x86/mmu.rst @@ -282,6 +282,10 @@ 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. This variable is used to + bifurcate the control flows for KVM when walking any data structure th= at may + contain pages from both TDP MMU and shadow MMU. =20 Reverse map =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --=20 2.42.0.283.g2d96d420d3-goog