From patchwork Sun Jun 18 00:08: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: 13283746 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 3802BEB64D9 for ; Sun, 18 Jun 2023 00:09:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231709AbjFRAJR (ORCPT ); Sat, 17 Jun 2023 20:09:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230213AbjFRAJO (ORCPT ); Sat, 17 Jun 2023 20:09: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 F0F65170B for ; Sat, 17 Jun 2023 17:09:13 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-1b549e81cc1so1553895ad.2 for ; Sat, 17 Jun 2023 17:09:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687046953; x=1689638953; 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=VS80TIN3Apx7Lv9ngje3zYu1jx02+rpCr9yV1s94q+g=; b=qsV0MFwzdd4/C7i0HHJ9CBkbmMVR7hwOd2cmA+0KzTHzNh9ELEVms5TTB/4dzHUDyy gGGdEsHTFl85eB0vuIJz6s3e58HYKqZmv2eJfSw+XXEzHrnK15RPIln+eN/w3Mzlec61 nqju5F/mk+3B7UGborz8J3MyzvFeWabttyLOn3D+a0ziu6+Xt2aVdnvkedR5h4IlvrhX Y3FuKXEauGt+lxIdBa18cGzxxXjmubFYp/Y+G3XWoTZOCVdaFMpsjXlNOe1u6FIM6l0U DxJKRaifxq5yPP+xvMAo0t85Tci89KUCc436mq+go+r+m0TnblxwU7rIG/1LtDaTjYR9 hoBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687046953; x=1689638953; 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=VS80TIN3Apx7Lv9ngje3zYu1jx02+rpCr9yV1s94q+g=; b=YbicZgmLn3uItJoMnBsZhT0QOPJFQMkPQwZlCohNGBsymCHoz/XHX/8D8cGhc8lh8a qMFuER2GuxeZmX3drWeoSnw4bhN9HvBLsdnpfWFde5EwZRIGiUMDrsnT3y0RW7nsv1+l W7ewgGDbGr8GNx0rLaRyTuX67wIM34fLPyLdeCvXVIv22qEqX2GhgnWNyDG1Oua8XxI1 Nefrpvr6VuCb0wL4bV5Bb0HGctLfKRwOkG6VtiWFtHK5Tp6NnoRfhgZgjB4jMSG/UoOY b3lNegTwsKUaBhQCt8PB+c05SBmNi6+489ADQtIB6zWjSGq/IYjk2QwE2rDpDk7q7Wiy bPpA== X-Gm-Message-State: AC+VfDwYq6zlSECD21hY55oHvevhWVmuYFeGr6jB4Y6RN66elBGGPTQU UyO9UCUHMafuofBY3cKAjSZbiwxtNWS+ X-Google-Smtp-Source: ACHHUZ7FUaWe91QusDNXC7G8USu5P3g7Xm5fFQ3geWg+aIW+9MIzFHs89tza+DkgLMXcq6FDjqk2LCkqQA35 X-Received: from mizhang-super.c.googlers.com ([34.105.13.176]) (user=mizhang job=sendgmr) by 2002:a63:ed06:0:b0:546:a389:b815 with SMTP id d6-20020a63ed06000000b00546a389b815mr385438pgi.1.1687046953388; Sat, 17 Jun 2023 17:09:13 -0700 (PDT) Reply-To: Mingwei Zhang Date: Sun, 18 Jun 2023 00:08:51 +0000 In-Reply-To: <20230618000856.1714902-1-mizhang@google.com> Mime-Version: 1.0 References: <20230618000856.1714902-1-mizhang@google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230618000856.1714902-2-mizhang@google.com> Subject: [PATCH 1/6] KVM: Documentation: Add the missing 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 , Jim Mattson , David Matlack , Ben Gardon Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Add the missing 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 Sun Jun 18 00:08: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: 13283747 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 222F1EB64D9 for ; Sun, 18 Jun 2023 00:09:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231321AbjFRAJU (ORCPT ); Sat, 17 Jun 2023 20:09:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231808AbjFRAJR (ORCPT ); Sat, 17 Jun 2023 20:09:17 -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 C1653170A for ; Sat, 17 Jun 2023 17:09:15 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id 41be03b00d2f7-53b9eb7bda0so1045691a12.0 for ; Sat, 17 Jun 2023 17:09:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687046955; x=1689638955; 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=v4DzIL/JVZchPV22EuNnJq/QdjxEQvSn2xrLtsDRw40=; b=WKB50UB0Mn3hH19NA/nQXNn4+OgIolVAiUqkFQCburr0Gk5bLVcJO0ERA6DsplScVO WGEXmbbUibqWtYGZd/7OQuoboJiIH++5nwxAZhSzT2C5EODsSvMTVefqmDd/hdpkwTSr jYBWaRY187nNjecdriEmiPHoWRRnGcXXaq7lMlwvT6OLaue5uK8YDrV79FP7A2WZC5nu kkEuqmmCQCaEbpEzi41NNFDBXqa38/4Dfg1teK1ACDBuvQJ4vdYkgC+HQVvrHff9cKF6 tOerjifpAymfFex7td0LJ/dIrHdApOXgD8DDzUW2NwwDCEeBXY6/AL3fLfAj8nbo+0BU aMrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687046955; x=1689638955; 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=v4DzIL/JVZchPV22EuNnJq/QdjxEQvSn2xrLtsDRw40=; b=S9bHwjEmntOeLh7V8P4p3iQwsM1kb9HATxYhJHvCBlLgGHMLVUmzcpkMECr8/yG8kF H2MEukSEgkAxrqga2GwTdAtwgeMz0BEPBLvkGlaN76s+PTmysdg5C/Ww4ZzA826K8JOe 0yLUqCj1whf6mY+nCCxXu3ZtWOCim+x5tA5SgsEztxvzan02mL42tyDVN0YEIqZvWCCO UzZcBKHTJM2XRtbOnUYHb+qYT72HnQSLQgGGK2/bKEtLsAFR2PsCgAzDSi3GdlFSxVik cAy5bD1obKGE7rbY9P+8/AC8Ji4JYzyV0Fj2tghiLiAO9RR67PRViAqiecuPCdOj57DJ UaKw== X-Gm-Message-State: AC+VfDxGlNaNrfG97OhD6J5Gp6+6hZwB2ZSHFRkI0VH9E3+wL/hiWhJR D8FjYc/40cWyc3sDFio08OAWgZWxn6xN X-Google-Smtp-Source: ACHHUZ6FM2shHdCtG4zHIoAoYPcYeJUqWXPelrDHcsq7bWlSJsIKfktBJmeYwjBAYAOYW9Saw4A54qRqqhhh X-Received: from mizhang-super.c.googlers.com ([34.105.13.176]) (user=mizhang job=sendgmr) by 2002:a63:83c1:0:b0:553:3ba2:f36 with SMTP id h184-20020a6383c1000000b005533ba20f36mr417311pge.9.1687046955292; Sat, 17 Jun 2023 17:09:15 -0700 (PDT) Reply-To: Mingwei Zhang Date: Sun, 18 Jun 2023 00:08:52 +0000 In-Reply-To: <20230618000856.1714902-1-mizhang@google.com> Mime-Version: 1.0 References: <20230618000856.1714902-1-mizhang@google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230618000856.1714902-3-mizhang@google.com> Subject: [PATCH 2/6] KVM: Documentation: Update the field name gfns 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 , Jim Mattson , David Matlack , Ben Gardon Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Update the 'gfns' in kvm_mmu_page to 'shadowed_translation'to be consistent with the code. 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 name. Signed-off-by: Mingwei Zhang Reviewed-by: Kai Huang --- Documentation/virt/kvm/x86/mmu.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/virt/kvm/x86/mmu.rst b/Documentation/virt/kvm/x86/mmu.rst index 561efa8ec7d7..149dd3cba48f 100644 --- a/Documentation/virt/kvm/x86/mmu.rst +++ b/Documentation/virt/kvm/x86/mmu.rst @@ -221,7 +221,7 @@ 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: + shadowed_translation: 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 From patchwork Sun Jun 18 00:08: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: 13283749 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 461CDEB64DC for ; Sun, 18 Jun 2023 00:09:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233235AbjFRAJV (ORCPT ); Sat, 17 Jun 2023 20:09:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232051AbjFRAJS (ORCPT ); Sat, 17 Jun 2023 20:09:18 -0400 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA52A170B for ; Sat, 17 Jun 2023 17:09:17 -0700 (PDT) Received: by mail-pf1-x449.google.com with SMTP id d2e1a72fcca58-66868a94bb3so652791b3a.0 for ; Sat, 17 Jun 2023 17:09:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687046957; x=1689638957; 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=SWUWH2lvAYfFJm9Hx/6bdaK1OOQ3GRc/IjgAVTyvQ3A=; b=30sbRvHSEui1YuUerrYqr2XHk9jphndeiTUEpOhR4E/MjyMQ1vFoouVxAiTi+cWC2b z68RRVMYzKkyMcAJOFe9blpf8xgZ8aCKYV/bLeBkqCGnAYyF+I2DklMOG9N1+BvZnfdu wfyveTLvxnSK7i5/yPlXLgYGxmgdAxy6dmsWfAy3EwaEkNPHPb39w1nH1Vs6X+W0iXFC BQ7C5nEuqvgBVkKP7Sfb/2gv7rR5lbOsr+lTA9UnW0phq1AzQFgGDzruoKEnJsqowt8e v80Te8LKsZJf0Fvy4Y4zuIkUzFA+UHI/AsSBvfilqKtD4FLzAZAWaSxbeOOFjebG9hn/ PdVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687046957; x=1689638957; 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=SWUWH2lvAYfFJm9Hx/6bdaK1OOQ3GRc/IjgAVTyvQ3A=; b=UvN3F2mGaAfRzdhIhCIZebb2u/ARmKGfxXYoSPF9KU4JCFdwjUoPoE3BMx2v99BpeC tbFG7ixq5fYSz1TIcHFePAwdaH0fw+gfvZnGx+JXff6IQLUYuoNJ2Yh1BgSw9AxjQMHG H5C/0PSRlzrDZbVfRTP3wCDYRJ5eUVSUKzjehcBv7IGyDmU/D0wn6BykiXA14tOSGWpw JhKou31M8dUGKlGSW6u7HohxZdJWZoKWGTNsi1iv2cpMB2CikU5aPJjEc+KoXL2yKiIA 0PaGCToemJoOpkzIzgTbWz7oYMzRjoMUia/wGxsqtf7KZ/KD8VUNhafNRDHnr+0VR/6Q 4faw== X-Gm-Message-State: AC+VfDz2TKEiKsburRKZRQR6byFxXZxEsQClu+wMALi/0WhUXXG69RSh Aaib7MnSPzoFQk/xZetWomQHXgxdWnNX X-Google-Smtp-Source: ACHHUZ79mIcs2IxhJoFUUkYrk9X7TD65uocd+N5bEK1pWUIg35JWl817ZPlg6BzzlYKbhgPk/Fly8vAOJETY X-Received: from mizhang-super.c.googlers.com ([34.105.13.176]) (user=mizhang job=sendgmr) by 2002:a05:6a00:1789:b0:643:a542:b311 with SMTP id s9-20020a056a00178900b00643a542b311mr1764182pfg.0.1687046957241; Sat, 17 Jun 2023 17:09:17 -0700 (PDT) Reply-To: Mingwei Zhang Date: Sun, 18 Jun 2023 00:08:53 +0000 In-Reply-To: <20230618000856.1714902-1-mizhang@google.com> Mime-Version: 1.0 References: <20230618000856.1714902-1-mizhang@google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230618000856.1714902-4-mizhang@google.com> Subject: [PATCH 3/6] KVM: Documentation: Add the missing 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 , Jim Mattson , David Matlack , Ben Gardon Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Add the missing 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 --- 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 149dd3cba48f..36bfe0fe02bb 100644 --- a/Documentation/virt/kvm/x86/mmu.rst +++ b/Documentation/virt/kvm/x86/mmu.rst @@ -236,6 +236,10 @@ 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: + Pointer to the parent spte when TDP MMU is enabled. In TDP MMU, each + shadow page will have at most one 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 Sun Jun 18 00:08:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingwei Zhang X-Patchwork-Id: 13283748 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 6F10EEB64DB for ; Sun, 18 Jun 2023 00:09:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233369AbjFRAJX (ORCPT ); Sat, 17 Jun 2023 20:09:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232828AbjFRAJU (ORCPT ); Sat, 17 Jun 2023 20:09:20 -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 888CC170B for ; Sat, 17 Jun 2023 17:09:19 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id 41be03b00d2f7-53f44c25595so1035623a12.2 for ; Sat, 17 Jun 2023 17:09:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687046959; x=1689638959; 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=SZRhH39sdwsf6mf7jmU2xtyZAtu6JfAYC83IgKKrw3g=; b=yKkIRX0QpeQIZE1DidVGEAYWTGzy1a7kdjPPYLn8eK2kTitM+zJT9u6VA55WaqmtV6 pWHjiKIuMZWbo2Pnap/dtOis3oRHJicAz7uD3wD5V/AnkB+f30edVXETNO//NaRsMPv0 k/E+3VFdUlcad6EjHg+NVkBMrG8YirRZjg8CNYDb5HsmaTFw8gxIHruDw+7xEj5a/N9b s5WHerxEKQKPsUwVjAKK/8YaGjoM7Q8orVuDn+mfc8+Hw4YWUMIAnvwn2u9CkSdrJgFI sI+/eW+ixsQaT0cz+EHG9Hcon8LeQaDmkuRhNbgFglelLp5mNWJKezlzTzT9vI5/yjsC 68sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687046959; x=1689638959; 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=SZRhH39sdwsf6mf7jmU2xtyZAtu6JfAYC83IgKKrw3g=; b=eTfuSYxm9PWaTh2i0zCDJnWKNPwr5pc6r+sH3txf0adCDCJi3sZzuztB7VohVfBqCT a6azpMy8Z2w4juraILNd9FpimtoYA2Pry/qO7QCc9Cbl9TFsbcj2EdXikYAXl6S+TTNl 51dOH0soX/fRgXlqUhmZj5DmSVtu+SCT7sJsHO50iTfnq1Jd10XMdHorrBI/VW+bcfJk EiUXYpGobbfr667KBwJcc6hgE4PT7oI6rcTUQZpuPmSCVuMFrM9YcTe9zgA5N/9sag6f RuyOEm8KbOTX2LpvQ99BNcpWqj8DPAkeI9Ay0EpzsS73+BqS5+ij2wHp5DTG5tmlz17n AO8g== X-Gm-Message-State: AC+VfDzkIE3tZSan6+sC01ud6DN3tYbE+KoRXyhlpo5wpP6bugbpNLev NEIzfMcyDBhWmvYlgnK0zBRRtICwGDyE X-Google-Smtp-Source: ACHHUZ6s/0SDgBjDHb7lnw7v17wR8UYblxJ4u12S9rHeLlYYijB1xGLNmU6+VDed2EOc0mlXhPDl+/6YPoZi X-Received: from mizhang-super.c.googlers.com ([35.247.89.60]) (user=mizhang job=sendgmr) by 2002:a63:782:0:b0:517:ce37:756e with SMTP id 124-20020a630782000000b00517ce37756emr406250pgh.7.1687046959115; Sat, 17 Jun 2023 17:09:19 -0700 (PDT) Reply-To: Mingwei Zhang Date: Sun, 18 Jun 2023 00:08:54 +0000 In-Reply-To: <20230618000856.1714902-1-mizhang@google.com> Mime-Version: 1.0 References: <20230618000856.1714902-1-mizhang@google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230618000856.1714902-5-mizhang@google.com> Subject: [PATCH 4/6] KVM: Documentation: Add the missing 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 , Jim Mattson , David Matlack , Ben Gardon Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Add 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 --- Documentation/virt/kvm/x86/mmu.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/virt/kvm/x86/mmu.rst b/Documentation/virt/kvm/x86/mmu.rst index 36bfe0fe02bb..3dce2426ad6d 100644 --- a/Documentation/virt/kvm/x86/mmu.rst +++ b/Documentation/virt/kvm/x86/mmu.rst @@ -230,6 +230,12 @@ 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 that allows for parallel + accesses. Accessing the page requires lifting the counter value. The + initial value is set as 2 indicating one reference from vCPU and one + from TDP MMU itself. While this counter is nonzero, the page cannot be + destroyed. 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 Sun Jun 18 00:08:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingwei Zhang X-Patchwork-Id: 13283750 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 ED563EB64DD for ; Sun, 18 Jun 2023 00:09:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234603AbjFRAJa (ORCPT ); Sat, 17 Jun 2023 20:09:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233460AbjFRAJX (ORCPT ); Sat, 17 Jun 2023 20:09:23 -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 5E0F0170F for ; Sat, 17 Jun 2023 17:09:21 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id 98e67ed59e1d1-25efb82179dso41942a91.1 for ; Sat, 17 Jun 2023 17:09:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687046961; x=1689638961; 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=kxL2IQh8QsyzT6M8Esvdn0S5tsYGjEEcYbokMBIJOOA=; b=gMXMhYIhG2lW0SrPMUMr/jEaUXXnHOTAKNZtToKxzpFzIj9Y9m+1qXmo4dWsPoPvLr plVHnLbDVoL5nKbQ24qCLpgop2Mkxkv7z5E7x36gOXD9Dv/3IpNI29XczZ5e3dxJ9BP5 Cs3tNz3R/gYemrR4La3CUU0Zn/VzUphnGNOjltb587gpzFz4xxs5CatONKNqj/b+sqYP wCO65H1ExzPgkkFj1vYdx6rCHjXIFdEOiqH5Bjg9KaAtsBFNSIVBwGspnXohbEd1i1Jp wmu+yRapRmaZ33Czkeh7p9/dDzsqGZ1fhQBD2GtD2OUTNCuohWlQWzkhxhJft5S+PZFv /L5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687046961; x=1689638961; 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=kxL2IQh8QsyzT6M8Esvdn0S5tsYGjEEcYbokMBIJOOA=; b=knIH2DnQ28445LsTyCs04dQm8p+Ljtb3xz8EW/FGoLuAxrSAf0sIepTccAFOn3bTtS EOTo4Aj/UHkOpDdnk0ILpwOTr1k9EnT3MrrMtBy2bxCdQqPwYKhgFN/CfMCjXFjkSuAN QVQlfpoUSi9TVqX2tDnOyKHwDwv6tBTXVbRQVGSR038QodTl3Xw7UGG4sW+x3Le/SlQP Vf4R1jcXEb9HJ3n83+62sAVSqXhfr6vprfrKDROyuTCrOQfRiRk11u2SagW1MW8vrxgq aQyglYQaDos7+gqFdFINNeyeenYl8v1PE1P7wFE/SigQFMfBViVTLSyfS0YB3W9wuAMv 9D4w== X-Gm-Message-State: AC+VfDyzqG0Iq2i4ejstdLD26URGxBamHa+QHdrs+IET2ilsHYWxUcT8 TbbjNp0XjBRshTz93BvNhbFVWDI1Ue3T X-Google-Smtp-Source: ACHHUZ667rmHgnnVMFyiOS98UlXH2hDjVOn68VnJ+dNKWA2D/uGC0vcKPrekHRymKGd05CoJKmuP1cPxyqdg X-Received: from mizhang-super.c.googlers.com ([35.247.89.60]) (user=mizhang job=sendgmr) by 2002:a05:6a00:1a15:b0:654:8eb9:4607 with SMTP id g21-20020a056a001a1500b006548eb94607mr1818385pfv.4.1687046960661; Sat, 17 Jun 2023 17:09:20 -0700 (PDT) Reply-To: Mingwei Zhang Date: Sun, 18 Jun 2023 00:08:55 +0000 In-Reply-To: <20230618000856.1714902-1-mizhang@google.com> Mime-Version: 1.0 References: <20230618000856.1714902-1-mizhang@google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230618000856.1714902-6-mizhang@google.com> Subject: [PATCH 5/6] KVM: Documentation: Add the missing 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 , Jim Mattson , David Matlack , Ben Gardon Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Add 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 3dce2426ad6d..0dbdb7fb8cc6 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 Sun Jun 18 00:08:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingwei Zhang X-Patchwork-Id: 13283751 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 40062C001B1 for ; Sun, 18 Jun 2023 00:09:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229668AbjFRAJc (ORCPT ); Sat, 17 Jun 2023 20:09:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233536AbjFRAJY (ORCPT ); Sat, 17 Jun 2023 20:09:24 -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 327F31724 for ; Sat, 17 Jun 2023 17:09:23 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-1afba64045aso19148975ad.0 for ; Sat, 17 Jun 2023 17:09:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687046962; x=1689638962; 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=1VCe6Te4dbtLGKgb4rOHMky/xQ+L+u4Ve7fRkEOuWfM=; b=eM6eEMdeAdA3q12h/4zPiNDSyzDv6iURF6JeeAlS92vFN138+Ea57eUPBYKXB/1hSK LO+sRsz7LswUmxtY2fR1MXtZ5ODEii85FISwNsl00srPgkpT+xOgRzsXGZenLTovEC4K 5bCdZnpVEh3xw/+QxJve/qwSzVD1fa3TqfhTUHfYi7y0bg4vv9JGAYAycx//ck2bTtEa x0mjE8f8m8SfrfLilZa2KalRke5BniQVDR2ujyq/cZrSDYm/79+HVziX7w7RrRTnHlXw fYE6FC2kIKP7Hw3VUVpp7d1JE/EkJAqrZYwsEiLJj6sx6zDZWhNU/Od3Bkmt9PNwwxke +F7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687046962; x=1689638962; 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=1VCe6Te4dbtLGKgb4rOHMky/xQ+L+u4Ve7fRkEOuWfM=; b=VgG/G+7ioHeHJqLBHzKEqtbDx/ixi4G7CGKK941KVnB4ywbHRPpiqEjhqId1tL2JW+ mz71BUE9AcgHUElho1rm63jEi5ZqY9Gn8jKSmkU24MKjou6DLkLpctUz+4FztVcbzx7i cu3in/OjR2FAmuYj7J+IzkLjHQE7o+7xC0QhQmNbmCh0UwE7j2n06A3VNtJkC0mn9yRh mz6djZ0dudPT3d35qi8OLAme/Ru8WYTG/QEvMgTJP8jK0QUd/FyqkQRjJDuuuILM4wZd vCCsZYzJP1sJeKRWgcHpztdBmq+dW3LR/8wJEGJemAT3wOIFrGsoIWz509BAoa6+y3bx diWA== X-Gm-Message-State: AC+VfDxzfaJJOmVeVQWA3eZjW4Bw1jwiRmN56X/YtoXyMAzN52uWWZMz w2Qd+mgGiYCf0pMGjtmrRrzpnzp0mehO X-Google-Smtp-Source: ACHHUZ587n83fnu4WPNdcoRuCpjN8gdiXgApo0KsiKTF4x3Syc0S5oMmIS04y4PImd7mWuJ5Od9KbFTaOwBX X-Received: from mizhang-super.c.googlers.com ([35.247.89.60]) (user=mizhang job=sendgmr) by 2002:a17:902:e88b:b0:1a8:1f4:2d50 with SMTP id w11-20020a170902e88b00b001a801f42d50mr1222628plg.4.1687046962586; Sat, 17 Jun 2023 17:09:22 -0700 (PDT) Reply-To: Mingwei Zhang Date: Sun, 18 Jun 2023 00:08:56 +0000 In-Reply-To: <20230618000856.1714902-1-mizhang@google.com> Mime-Version: 1.0 References: <20230618000856.1714902-1-mizhang@google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230618000856.1714902-7-mizhang@google.com> Subject: [PATCH 6/6] KVM: Documentation: Add the missing 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 , Jim Mattson , David Matlack , Ben Gardon Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Add 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 --- 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 0dbdb7fb8cc6..cbad49c37629 100644 --- a/Documentation/virt/kvm/x86/mmu.rst +++ b/Documentation/virt/kvm/x86/mmu.rst @@ -277,6 +277,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. When TDP MMU is disabled, + this field is always 0. + Reverse map ===========