From patchwork Tue Sep 12 18:45:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingwei Zhang X-Patchwork-Id: 13382051 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 69FF9EE3F0B for ; Tue, 12 Sep 2023 18:46:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230237AbjILSqD (ORCPT ); Tue, 12 Sep 2023 14:46:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235481AbjILSqD (ORCPT ); Tue, 12 Sep 2023 14:46:03 -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 130F710D3 for ; Tue, 12 Sep 2023 11:45:59 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-594e1154756so65928757b3.2 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=SYBscCkxJzJkAvlaV3CFXTl79QWrC6JqRhN3L53Roo9eJOi+Yd+5T/kyfjCdbyRFmK yakSwn9AgO2+K7IrgZPFpQPYQX7IJDW4wy9VB/0pstTpxnI7hiUWOBrZtU2RpsTeuMlB 99qwWMWiwmy931NKuyMgChMRioLCWufu+xRxS9UyTaegsR1koTApSCB+TLA7/Sq4AVDP bHCsB29wx5V2yxkg3s2KCaRD4GSMx5Aos0lVc1gvtu9zR9EXrSp2ZzqQ4Z02A27NY3qF JjeWHq8X6PZkG6J0EZ49lj4kp6VLzqh1EUS+OxiSjFwpS0UGRIPXGjvhyclkM8sM1eJ3 U4Fw== X-Gm-Message-State: AOJu0Yy2zhEulX/qyz1ywWavKiaecQ8RkPwwwIqiOT83hqAd85YdQFzB LzpURQaadF6ozZJ2PebFfrZy32RJHhEE 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: 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 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 From patchwork Tue Sep 12 18:45:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingwei Zhang X-Patchwork-Id: 13382052 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 E345BEE3F11 for ; Tue, 12 Sep 2023 18:46:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237504AbjILSqG (ORCPT ); Tue, 12 Sep 2023 14:46:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237399AbjILSqE (ORCPT ); Tue, 12 Sep 2023 14:46:04 -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 CBCE710DF for ; Tue, 12 Sep 2023 11:46:00 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d78452de9cbso5621631276.2 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=sAZcTodw0taMf24xA0XQ8XYIkIA59Bk492Z9j6dzYv3++mI4Sd5FiHSVq/Z3NrznqE pSrNbvbI8vou9CzOHiNJ7BCgabkv9QC8MMQid17GRjmog+E8vIzdNhl/5TDHXoKghGd9 4kwXavrZNL291xqjvytUJPuX75L3Nbm7x8BdUGYNpSgjiGU+bX51+ye+KbQxXpoOaipF pao+urB/lpXGo8piyIcO+YjVmOQ0PUMMBYLBUGdwkIP2xGwjgiYvzhf5gLDx8N0zN7YJ Tnkwx7+jKViEBC6GztJ0hhHvn6GvX9FmbG68zTDdJZm5uIbMyP2KHZujH+8BxUtM9R29 VuEQ== X-Gm-Message-State: AOJu0YzISR2Jw5DWIs0s+8mrLyhLur3EFyBTi0Od51P7kgPCESjw3esz GAeHCoPANLOFi7u0Lk3B6PSWvFEqlS5g 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: 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 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Documentation/virt/kvm/x86/mmu.rst b/Documentation/virt/kvm/x86/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 not + allocated. This is because the gfn contained in any element of this array + 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 From patchwork Tue Sep 12 18:45:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingwei Zhang X-Patchwork-Id: 13382053 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 BF91FEE3F0D for ; Tue, 12 Sep 2023 18:46:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237494AbjILSqI (ORCPT ); Tue, 12 Sep 2023 14:46:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237492AbjILSqG (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 41C6310F4 for ; Tue, 12 Sep 2023 11:46:02 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id 98e67ed59e1d1-267f00f6876so7058297a91.3 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=p/efavnfSOTAOJXkb05steYpzgyQ1hG4IC7n9jgb8VkB5AbovUdCTL3yzoCdW/zc6I fo56ARGRxArvrmKuxOmbQTvcCxZR4QSM8FyYdM8L1llsOkIXyhOwbtQuz7h2DBe14684 nw+mxeIdEHmr3eTyf0PtfARiLNt8SNDoN+Y4TA2UQC0OWsjAQwcRWMEddx1qVMMqMQaF NoisUxi+lGbkJ6dLO81RM70PIjkV3loSfWmF3nqLmhpVD5sNXaFOUKpCg0NwyMd1Jlov dfdFTsg0OZAeguJHO45N+YGr//yGNwdZM8MHTWacJVgbM70IBiPWKO/fH6OZYtfwnPbO 1rYQ== X-Gm-Message-State: AOJu0YxrRlduLkq8Hf2jSkHHih8RbmhhV3CTjaSaXxyfzORPkwulSFYR hmjDYw3WDAVABMbGlz1qnbLpSBld12NC 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: 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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/virt/kvm/x86/mmu.rst b/Documentation/virt/kvm/x86/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 multiple 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_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 Tue Sep 12 18:45:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingwei Zhang X-Patchwork-Id: 13382054 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 8EE5CEE3F0E for ; Tue, 12 Sep 2023 18:46:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237517AbjILSqV (ORCPT ); Tue, 12 Sep 2023 14:46:21 -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 S237539AbjILSqK (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 DE0731710 for ; Tue, 12 Sep 2023 11:46:04 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d7e857a3fd5so5841995276.3 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=DLM/hyQWmcla9gUFrjGBZWZv+uzTS/d6UWUbhx/5/dYH+WISrtwpG+3/3nywm6kZ6s +4nNePfdJOcW8b9fauhtoLRUmKDxuosj9gLXTaZSeeA6bvAFf+mNBpBEc4O0G9/Lv8CG QS9crOkdjzdJ6ZDsPKc9Ir+lg3d87TUCRMGwlE0RANCUBxxs/QJOz3F/taKWoSrc8NvQ fn9NUl3/Av484YQDiRLV+cEoNdRZu6HZvzLQRWapwtT6vH0x7oFbvGwMlHxdta2006RV ZO0IBrVDrAvCvw1g7Z0JKq0shHjmbbtA+7EzHMsvNpCP2sK+nYH0l4IObfh1QD7c8qsy HJrQ== X-Gm-Message-State: AOJu0Yxy4PMzayKO+KoN4xvSlKkQ9V/eSmuDVWYurFwW6ktG98Ql5zUs 1FJHWrvp/dTkA9/yEBcgyPWKaBloAE50 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: kvm@vger.kernel.org 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/x86/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 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. 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 Tue Sep 12 18:45:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingwei Zhang X-Patchwork-Id: 13382055 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 A4E38EE3F10 for ; Tue, 12 Sep 2023 18:46:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237617AbjILSqW (ORCPT ); Tue, 12 Sep 2023 14:46:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237535AbjILSqO (ORCPT ); Tue, 12 Sep 2023 14:46:14 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 574641729 for ; Tue, 12 Sep 2023 11:46:06 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-1c3257c8971so83697815ad.0 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=MeWtuQnKpRO7M5bZvg5C0JEEAy9cEjWpw387eR5lJlDAbcoacSyT7XQ9FrRs5vpyQb naYJmqqjIZWeT6bSavIXFkGZp15k33KsNNQI2oIiu1ZniXnmEAxDclj9BzSFC390I9yE 474gU7ecaRxm5qXbVUfdQQ3l3eDq/o/N0TYSamXIG8+CJ32u39jtpQo5ZmgG6AymJIuO S0y0G7Ff/YvBnZIGbfR1T02MPdfGdcbHmmOKTlewpYGCX+1xfzN1MTL39LE9749AMeHs EaQRXM50sCr8xrmHISfuJJPQDQdLsGgvUHC22qCG/bd2OuxDbVJ2vmbr1Ksb3FyTMtPN iR2A== X-Gm-Message-State: AOJu0YyOJab5Afh5c0j072pzeGJ5EnirnilyOOGu2doUKVF1PMbKPs0S wARBDs+8yU6yYUEr+yxmwgSKfRIpkkEU 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: 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 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/virt/kvm/x86/mmu.rst b/Documentation/virt/kvm/x86/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=1) and is shadowing L1's 4-level NPT (L1 CR4.LA57=0). + mmu_valid_gen: + The MMU generation of this page, used to fast zap of all MMU pages within 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 each 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 doesn'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 this page, or the base page frame for linear translations. See role.direct. From patchwork Tue Sep 12 18:45:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingwei Zhang X-Patchwork-Id: 13382056 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 DF8BFEE3F0B for ; Tue, 12 Sep 2023 18:46:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237646AbjILSqX (ORCPT ); Tue, 12 Sep 2023 14:46:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237642AbjILSqQ (ORCPT ); Tue, 12 Sep 2023 14:46:16 -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 02EB11991 for ; Tue, 12 Sep 2023 11:46:08 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-58fb8933e18so64459437b3.3 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=saHq4BcbuibCAXUZqqo8VAMfw3bdns6LpIUcP8v4V3YWZ/uAd8uuFl/6F9DCO9aNlh 4UJFKBVae9uNC6nER51q409yBW1D3TR0piVYHE4628m10oaGto0PjSUF/0rSmdjXiIsV HSy5MbxBwqZ1WmlpuWA3BnZwrEI3e6ey4CYcNTWJG2V8JeSj2xcKRqMFShOhoFBEn6hf WmjUQa8foLm7t8HuBTNRt6kQ3LJn/kwyTUt04hP8SCl3e/WZL+MpsB0O/mXbiGepPL9c CeSbu0/HwtZ/l8ZL1RRQgJMVfrsyYUILe7eho/Mv33Fi1cXtxTuk59MH5Vbx2rw8nkYN Nvvw== X-Gm-Message-State: AOJu0YyN1Qi9yVknENsVdgxkD6qLEwCUZYzTfTpqpk9G5tfL5yneDYL+ mtMBZnieh51KnMlvmOCh5Kfl5KtVq9KB 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: 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. 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 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 that may + contain pages from both TDP MMU and shadow MMU. Reverse map ===========