From patchwork Tue Aug 1 00:21:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingwei Zhang X-Patchwork-Id: 13335620 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 935E1C04A94 for ; Tue, 1 Aug 2023 00:21:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231220AbjHAAVf (ORCPT ); Mon, 31 Jul 2023 20:21:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231197AbjHAAVd (ORCPT ); Mon, 31 Jul 2023 20:21:33 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2112D19A4 for ; Mon, 31 Jul 2023 17:21:32 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id 41be03b00d2f7-55be4f03661so5207964a12.1 for ; Mon, 31 Jul 2023 17:21:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690849291; x=1691454091; 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=2V2qqbRtJdIF4yKoul1PG5FvBTRojVE4noGz8EUUEGo=; b=b4gXIVWX4cTKAZEBzuS9bcuTAIwnIpR66S3yHkHBzJg6Pqk6/twID1GBjAw9sqMNEe sr8t7BYV6mty7CFn9oOUry++ndP3gel1ZBA8n433pUcnMmtKavpQiAYhxdjtq1zNP+qW A8K77tu+LeGtGiHgEOpdG7tDsHmKWquXFI6tAAxOsBTLMioIR2PHsAOh+VW6BFFxkxcA 9CrK1F/fby5iCi3/bzHMc/edGX33OcDpyrk8Q2FoI/Y4wqcJJHZfuATFIWdUgbI2RS9R GNpOA/tcOK68CMq2+Z/xSUQ1C7Fa6o9a9EpLwQSaxRB1rwWII+JOkwVx5V2Wyx1Ewdl/ ZR7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690849291; x=1691454091; 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=2V2qqbRtJdIF4yKoul1PG5FvBTRojVE4noGz8EUUEGo=; b=TGJZKAMhwCKminEJkv/rUOGOQtCHPTbJoDX4StxQ78CjYa/D+hM6cMiBXC1AUb5kHC RYPyHJafZBtYN35cI/rIxTZMNpot6kiWCyAg/zwV6CaBSxRWsIoZjE2sCm10G1Tm4joi tkUdbC5prNhaODcjcMmGSvQSykxykTYcXUhan02vcDnLhW22/lm5z9OGdfk/dXIuQMaq Ns1ISKF8iNn7r+26VpPk7qF23OCuH/O7XWdEePVoX3ne6JaPhLMqxxoXl/nZhqpXjeYE kvAW8Bswuob3cBfhlX4z66+pfGlfvY7EuqH7QcEWLMLjdGBvVyfm6Lajhah5zpNcjUdN IPCg== X-Gm-Message-State: ABy/qLYLbOqTk85PO/C9INwlsYSdV46kl0UpY/6qtqZYYxx8lbxUacKN 1p8WS53vPFj0l2rIgJgwBpET1KeMChQu X-Google-Smtp-Source: APBJJlE2zNXDzrG9zPFf9F8B6Qrdnzu1M70NsJqVru5PDje4e8hKGj6bKUmauq0mTOtpQsX6jWWyA46aK0Ss X-Received: from mizhang-super.c.googlers.com ([34.105.13.176]) (user=mizhang job=sendgmr) by 2002:a63:7e54:0:b0:564:f85:c822 with SMTP id o20-20020a637e54000000b005640f85c822mr66706pgn.8.1690849291659; Mon, 31 Jul 2023 17:21:31 -0700 (PDT) Reply-To: Mingwei Zhang Date: Tue, 1 Aug 2023 00:21:21 +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-2-mizhang@google.com> Subject: [PATCH v3 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 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 Tue Aug 1 00:21:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingwei Zhang X-Patchwork-Id: 13335621 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 558B2C04A94 for ; Tue, 1 Aug 2023 00:21:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231321AbjHAAVj (ORCPT ); Mon, 31 Jul 2023 20:21:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231197AbjHAAVg (ORCPT ); Mon, 31 Jul 2023 20:21:36 -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 30114199E for ; Mon, 31 Jul 2023 17:21:34 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-564fb1018bcso61593117b3.0 for ; Mon, 31 Jul 2023 17:21:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690849293; x=1691454093; 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=MiBo42sK/GMXkVAkei5JHweORvWMqcmgUZYS33J6fF0=; b=xCOyw96l+NGIsCoqla91ojMChbo7SK0mxjsBS5En4m6U8FZuat4rWttoEUC2kEUlRC Kc5Tdi3f/aC074kdK9WPVcbpEqFOD5snoJtJRh/GW8NPp7DdzGioQ2jCQ53aKAAMVNgV H5LOLNlPJaayXRR+pgE4o+eqbb3X+xSKM0jo1106+iKscpzsP1EGPa0ydb/aj4FLtxsY 0donlqAlwXUUmCYafnPKmqmI1HPi+8LHmgKCNUbUmu3rVwJ7KhsLSWeNCX/OGzUbsggN aeRLetSPiTZb1U7EoSaftIT6N09FIkj+uoCbe5WsmP3ETqmIpdraN0k9VEsoVBooWVQW kbAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690849293; x=1691454093; 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=MiBo42sK/GMXkVAkei5JHweORvWMqcmgUZYS33J6fF0=; b=G7PyCRS2TS4LxVFwR3r1hUBokKSBRml2MPzRX5E8UBY+DkHDvBm98RX1Ri27x48sFI Wn/KduH6WmeC1f1473Dp8kLcEFmlihX3HwZ645SXDHq/Z0FtAh1QkLgKyNcAjfJrvoVJ FKiqGc3Biyo0MzAY7d6VtNeoQA2cDJc4fXA2up7vaquFdbBv8RD0O3Q61o1k2k6252Hm M5XkJVMoSAlsoyxrgXtj4Y1FNXFLZvymG/LKJJD10Ld7ggQG5V3SjRFJLVbOvyDeUFkc UDpKZ7q1a9QYYMuRYv0hPM1MOw1ccaF5CwVjeNtqqrvWgOnSyMkCECTq+yJqL5Y/W22H SzNw== X-Gm-Message-State: ABy/qLZ7z4hJnV5nmtfYJ0VPOrOagnSgVl1TbetoqT/+FPj4RRNrGfE1 Lxk/VO8s0lmyA1PImqURv7OMIaBitFn4 X-Google-Smtp-Source: APBJJlGpUWg+0m6Di2ciPKp63ZPdDfCAbOAGMntPsJDwNxKLL6tSalkKPOVTHrd+Kt2b4p6aLGkz6Mdh0g5v X-Received: from mizhang-super.c.googlers.com ([34.105.13.176]) (user=mizhang job=sendgmr) by 2002:a81:b710:0:b0:576:92da:cd3d with SMTP id v16-20020a81b710000000b0057692dacd3dmr79492ywh.8.1690849293487; Mon, 31 Jul 2023 17:21:33 -0700 (PDT) Reply-To: Mingwei Zhang Date: Tue, 1 Aug 2023 00:21:22 +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-3-mizhang@google.com> Subject: [PATCH v3 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 561efa8ec7d7..35e642303962 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 Aug 1 00:21:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingwei Zhang X-Patchwork-Id: 13335622 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 9E30BC001DF for ; Tue, 1 Aug 2023 00:21:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231521AbjHAAVn (ORCPT ); Mon, 31 Jul 2023 20:21:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231272AbjHAAVh (ORCPT ); Mon, 31 Jul 2023 20:21:37 -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 BEECD19A4 for ; Mon, 31 Jul 2023 17:21:35 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-c8f360a07a2so3911684276.2 for ; Mon, 31 Jul 2023 17:21:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690849295; x=1691454095; 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=X6gKOGhlGB8pLW0DYtQuv9ffBJaXjDy6pmjMuBOFYgg=; b=kQoqrjZUSpYSVWxRkD8CyHapEmqNssIKnU0p8DbOeOtORHqvQa2sRcXhVsWCzU4YXH zZKas3OblcCNpHead2nGTkpMYThMQMfZeHh41WgRE1hPLNiwbHntVRxHiv/NqnNsu6We KNZIuYEWFnyjDmvXcOy5RwHVYQaGudAGf1nLCyRoZSHMxNSpdZrY7aU4AzRIfp1+8ha8 gqHlW5ZZCXCmF7ZW8oxl02SvyyCRoY3Egwy9Mv5L85kKyaSF/yQkV7Trl0FnFZ+9EL1R mMTvAT/jSm6uCb3HkZgyPqa4An9p+T65XcE0u04cE0v+XXg1hINDwPuIhtIjwA+Za4dr /fEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690849295; x=1691454095; 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=X6gKOGhlGB8pLW0DYtQuv9ffBJaXjDy6pmjMuBOFYgg=; b=fScxLYzKlc2/v3WDSCf6rl8n/F91A9wd9GMMH46fFPOFrDRDDtXyDEWDxMkilzLfgx FZgxXbauaGwhcH0y93eiK2dX9tPz6ZXi4EhnXCVP0xkNvI2qNsox6N9WW/Ug3KUW06Cx 4dpJIgaErOTA/KsZ0EImh7ByNvm6D6bxXPi6Jj37Y7M4xeggoQ1G2Qeuz/Mnd5vvFL02 11F/mERIGY0MRhYCNlRSUAnsKUYqolH4gM4VRezqqR/cxKcto0/TJqiutpm/BKMtVUJx z4CP2eCmbLaRwJBr/XOPWOb7TOKwe/y3D/kdqutHbxRkZAw0GzMA2fCIzGUQtV/Nk9RE NwjA== X-Gm-Message-State: ABy/qLavUe6T8aUW2YHi3dnbDBagfSIC4OIzK6xuuyWX7qlUfC7TOOTY +HhCl/1ibTKec7FfkWOap4KjFta0JPjx X-Google-Smtp-Source: APBJJlGQXpt19T8IbJ/4u2FYTII6o/ixlgwOW+5f/+XsCEFskp5UWl0qK1dtlRzD0c0+xHtP+LDk5mW3oGkO X-Received: from mizhang-super.c.googlers.com ([35.247.89.60]) (user=mizhang job=sendgmr) by 2002:a05:6902:11ca:b0:d09:b19:fe2c with SMTP id n10-20020a05690211ca00b00d090b19fe2cmr70907ybu.12.1690849294946; Mon, 31 Jul 2023 17:21:34 -0700 (PDT) Reply-To: Mingwei Zhang Date: Tue, 1 Aug 2023 00:21:23 +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-4-mizhang@google.com> Subject: [PATCH v3 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 35e642303962..17d90974204e 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 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: 13335623 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 E59F1C41513 for ; Tue, 1 Aug 2023 00:21:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231268AbjHAAVp (ORCPT ); Mon, 31 Jul 2023 20:21:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231310AbjHAAVj (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 C0ECA1BC5 for ; Mon, 31 Jul 2023 17:21:37 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id 41be03b00d2f7-55c79a5565aso3053758a12.3 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=F6cXusq3Di3OwyEvuAcJEUVfeC22K70XeoQZRMLzXOCejRQ7gE7kUtxAALuE+eG9QI VvG5TbpxqdvKfhDyg0ZCr+1OzbV/ANH0x+i0PhfV9nMD3lSqYO1/BbWf0x/mcV9HYnqG Osij6z6s1Rn1BrG/uG8JxW3lrPj7nEXL8jWQG4sQx4L6qmeSQz08uOuvCh04o13cEsxC 5oPnR/u2mmMuKVV2/ShCEVehcAwFfRI/ugLbSi0dBnDy3DgZMrwAubt5q0/CmB+qSYez viDE0TGxmtmsz0C6vB8RdUDbCUrDKEnsC6OF33WzwtOBBD9DWUvZSmXjuuEOh9pE6n0s ixWg== X-Gm-Message-State: ABy/qLbe1WWHz2lapn2rzwspH+VNDdShxWfAl7+6dgzOrXQOTcUSzO9N dsl42GI+fYuSKoWdGImkBfSGHojwCRx8 X-Google-Smtp-Source: APBJJlELwnl3GUQy3Na83yDaRQb7sAcLNrn13muWfp9pcSJTl+zrx0TaA0fbVl0AY71dCRmOn2C9ltzLT5eh 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 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 | 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 From patchwork Tue Aug 1 00:21:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingwei Zhang X-Patchwork-Id: 13335624 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 56DECC04E69 for ; Tue, 1 Aug 2023 00:21:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231280AbjHAAVv (ORCPT ); Mon, 31 Jul 2023 20:21:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231421AbjHAAVm (ORCPT ); Mon, 31 Jul 2023 20:21:42 -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 762061BC9 for ; Mon, 31 Jul 2023 17:21:39 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d0d27cd9db9so9401245276.0 for ; Mon, 31 Jul 2023 17:21:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690849298; x=1691454098; 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=lAQnhGDOkYRMbkZrdC3SL5zoWbQR4X7L8Yn3+Vr770Y=; b=mSlCLmLdSdPxkircK3iN8jwT5W5vP1eDs51MN2JElm1ENf0E0zV1+hxVIqVpBj8Lbq 3YbA2/WyG5K4xCuq9Coj3iUMdMibr4FQcUpL6vKn/cEb0mcK+XtbQBYhpoD1utE9R/hw sNnyB6mq7sHFk+jZtZuvaN58hRjds+AE8Y+onHTyMUrpDQcsvWZDQTAAoX0qYG6i2kei BlqqustZeYnIPg8lYc6HCZmKcoW3EI/AsWv3P+mg4OOKdmJfb1bjcImHHRWilDTHx0WD OiGbBfE4+wE/VlffLCEkwsxzLb7nSfkAHH9Dkh8+py9OmsUsIBcfhvxGec3zqaWc+OQH 1g3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690849298; x=1691454098; 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=lAQnhGDOkYRMbkZrdC3SL5zoWbQR4X7L8Yn3+Vr770Y=; b=DVLvdwqRBoBMLp1mUp1YppAMHz6bL14tO+0RA5k5daN4y9cfxXR7R46ka127rJTwRI BAKOUB5Lqy4EhTngbXey8ePbu2hPLhGCo2yECW1rWeP8eqmM/riVRsTjcmvIcq2K4dXf u8DDKIrHH3RNiSFYX9spe0be0mkhk2PJrEDdtoQ2lNQrlKYYpcbLQixpteskfeMSYWxj y2ct56MvIAQ++TXEbclpLrHgiksiy6P4lysP9Fa9zd1X7O7nLDhh3mvHH2I28hbiilfd 82+1wdyZbvmp7UAW0F8SU8mNekB+OxfIsThlxMJl8v0dP899YPJOGBsYBfOmZA8plWff /Jeg== X-Gm-Message-State: ABy/qLYvb45Cst5cQXWzzY4i+JVz61BGxew6m7ahwvkQo2uY5pK6qPfi 9QXTzVt+wcwHs2XODRiwefioN/lMUBNV X-Google-Smtp-Source: APBJJlEbXDgaPfEPE0+Rh+gqu5EcA7wjOaPwSG51qBZAvMseTavHv77hIuRMa7UCmBrdjjzh7UNZF7RaBIf5 X-Received: from mizhang-super.c.googlers.com ([34.105.13.176]) (user=mizhang job=sendgmr) by 2002:a25:dfc3:0:b0:d15:53b5:509f with SMTP id w186-20020a25dfc3000000b00d1553b5509fmr119752ybg.2.1690849298640; Mon, 31 Jul 2023 17:21:38 -0700 (PDT) Reply-To: Mingwei Zhang Date: Tue, 1 Aug 2023 00:21:25 +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-6-mizhang@google.com> Subject: [PATCH v3 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 40daf8beb9b1..581e53fa00a2 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=1). + mmu_valid_gen: + The MMU generation of this page, used to fast zap of all MMU pages within a + VM without blocking vCPUs. 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 Aug 1 00:21:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingwei Zhang X-Patchwork-Id: 13335626 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 32A0CC04A94 for ; Tue, 1 Aug 2023 00:22:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230060AbjHAAV7 (ORCPT ); Mon, 31 Jul 2023 20:21:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231572AbjHAAVn (ORCPT ); Mon, 31 Jul 2023 20:21:43 -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 340B21BE9 for ; Mon, 31 Jul 2023 17:21:41 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d1ebc896bd7so6005360276.2 for ; Mon, 31 Jul 2023 17:21:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690849300; x=1691454100; 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=IZ3RpcngQEoYF628RWUm7FlAucMXyfC7tt8DVxrqfpY=; b=57IFX5W4Q+tAl7op44Oy2FM4bWgLYmdYlV0ogtgE5VG/ceIH+YmCPWbyTsDo7fM9HN Lnws4wIpSYfJP0UKGkymy0Y9qXgPTHZMA1sxCxyWUSD9ih6zw8bvFEzlCftl0K6cQTss +cPMLOtCZiICXqKSWGuNnDiPpNVODe1ajPspNsrTYIclyEnCffPmoeUMnORWiwoduSCr zQS61STgZlvgz8Yu1+FnDARWgqHun0qtMl3aGJbVHKvXfCsV3YJQ7Ij8D9Nt6LV81ioT 7+p+yXyQJEPBAvWCncTEjzJ/A8lxjPAogZ7LriiCKW6wLSbz0zZujQ/ZJU30KoiZfXYq lz+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690849300; x=1691454100; 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=IZ3RpcngQEoYF628RWUm7FlAucMXyfC7tt8DVxrqfpY=; b=XHLxsuX9ezaZ0BeOWlMn39+S4mAX98Wk39iXOIvHm7zwKcEDuLcG8xS/sku9QbnVXx IPCtcmcq77cv8CN8M9kURJofIL0YKidNPXhw6DGLy8jzhe6fc0eBdn3tDDSFzlyGS6ct JOG3OdE98/3+S9obhtpQV7gngcPKWUt9JVPlGA04gcrWSgMF9d7mG0neN9t5aluuwzTe FFe+0qYIba1k83EKVyiTDwNO3u54pjiVKLVkJa1PJ35cP1kpmilUk/XYn1GGpuQ9nFhA usoRNnN7/Frzx1Kpx92g3YJ+b7wCkIgcnhqO0b0nS7ikugNNhlpUe+o9T6xk8wQbRTkc bHCw== X-Gm-Message-State: ABy/qLbo1HT50rDuDVqUJbLhS53OYpUooR3hasM5qpgRucCy6O10tVGN sBU/x56oCqBCdFnV6dhV9X6MXeGWtPFQ X-Google-Smtp-Source: APBJJlGJZOcCOYVE+Z3Mr3gxRHTtU7mDeCgTwRv8AU1gHlMS/GALs031HQ+FAdpW5/GEBF/82uyGtU1Fbz42 X-Received: from mizhang-super.c.googlers.com ([35.247.89.60]) (user=mizhang job=sendgmr) by 2002:a25:dbcc:0:b0:c4d:9831:9712 with SMTP id g195-20020a25dbcc000000b00c4d98319712mr65659ybf.0.1690849300437; Mon, 31 Jul 2023 17:21:40 -0700 (PDT) Reply-To: Mingwei Zhang Date: Tue, 1 Aug 2023 00:21:26 +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-7-mizhang@google.com> Subject: [PATCH v3 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 581e53fa00a2..3be646a6daf5 100644 --- a/Documentation/virt/kvm/x86/mmu.rst +++ b/Documentation/virt/kvm/x86/mmu.rst @@ -283,6 +283,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 ===========