2023-09-13 02:49:31

by Mingwei Zhang

[permalink] [raw]
Subject: [PATCH v4 0/6] Update document description for kvm_mmu_page and kvm_mmu_page_role

This is 4th version of the series, minor fixes as follows:
- correct the descripotion of tdp_mmu_root_count [seanjc]
- update the descripotion of mmu_valid_gen [seanjc]

v3: https://lore.kernel.org/all/[email protected]/

Mingwei Zhang (6):
KVM: Documentation: Add the missing description for guest_mode in
kvm_mmu_page_role
KVM: Documentation: Update the field name gfns and its description in
kvm_mmu_page
KVM: Documentation: Add the missing description for ptep in
kvm_mmu_page
KVM: Documentation: Add the missing description for tdp_mmu_root_count
into kvm_mmu_page
KVM: Documentation: Add the missing description for mmu_valid_gen into
kvm_mmu_page
KVM: Documentation: Add the missing description for tdp_mmu_page into
kvm_mmu_page

Documentation/virt/kvm/x86/mmu.rst | 43 +++++++++++++++++++++++-------
1 file changed, 34 insertions(+), 9 deletions(-)


base-commit: bfd926291c585600ace63ea3b6eb1458aa067f4f
--
2.42.0.283.g2d96d420d3-goog


2023-09-13 13:55:18

by Mingwei Zhang

[permalink] [raw]
Subject: [PATCH v4 6/6] KVM: Documentation: Add the missing description for tdp_mmu_page into kvm_mmu_page

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 <[email protected]>
Reviewed-by: Kai Huang <[email protected]>
---
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
===========
--
2.42.0.283.g2d96d420d3-goog

2023-09-13 23:30:20

by Mingwei Zhang

[permalink] [raw]
Subject: [PATCH v4 2/6] KVM: Documentation: Update the field name gfns and its description in kvm_mmu_page

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 <[email protected]>
Reviewed-by: Kai Huang <[email protected]>
---
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
--
2.42.0.283.g2d96d420d3-goog

2023-09-14 02:53:54

by Mingwei Zhang

[permalink] [raw]
Subject: [PATCH v4 3/6] KVM: Documentation: Add the missing description for ptep in kvm_mmu_page

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 <[email protected]>
Reviewed-by: Kai Huang <[email protected]>
---
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
--
2.42.0.283.g2d96d420d3-goog

2023-09-28 19:30:22

by Sean Christopherson

[permalink] [raw]
Subject: Re: [PATCH v4 0/6] Update document description for kvm_mmu_page and kvm_mmu_page_role

On Tue, 12 Sep 2023 18:45:47 +0000, Mingwei Zhang wrote:
> This is 4th version of the series, minor fixes as follows:
> - correct the descripotion of tdp_mmu_root_count [seanjc]
> - update the descripotion of mmu_valid_gen [seanjc]
>
> v3: https://lore.kernel.org/all/[email protected]/
>
> Mingwei Zhang (6):
> KVM: Documentation: Add the missing description for guest_mode in
> kvm_mmu_page_role
> KVM: Documentation: Update the field name gfns and its description in
> kvm_mmu_page
> KVM: Documentation: Add the missing description for ptep in
> kvm_mmu_page
> KVM: Documentation: Add the missing description for tdp_mmu_root_count
> into kvm_mmu_page
> KVM: Documentation: Add the missing description for mmu_valid_gen into
> kvm_mmu_page
> KVM: Documentation: Add the missing description for tdp_mmu_page into
> kvm_mmu_page
>
> [...]

Applied to kvm-x86 docs, thanks!

[1/6] KVM: Documentation: Add the missing description for guest_mode in kvm_mmu_page_role
https://github.com/kvm-x86/linux/commit/b207cfbc8c1d
[2/6] KVM: Documentation: Update the field name gfns and its description in kvm_mmu_page
https://github.com/kvm-x86/linux/commit/fdaca560b6c4
[3/6] KVM: Documentation: Add the missing description for ptep in kvm_mmu_page
https://github.com/kvm-x86/linux/commit/b40a2455e9eb
[4/6] KVM: Documentation: Add the missing description for tdp_mmu_root_count into kvm_mmu_page
https://github.com/kvm-x86/linux/commit/6a713928ae1c
[5/6] KVM: Documentation: Add the missing description for mmu_valid_gen into kvm_mmu_page
https://github.com/kvm-x86/linux/commit/c3204c406b6d
[6/6] KVM: Documentation: Add the missing description for tdp_mmu_page into kvm_mmu_page
https://github.com/kvm-x86/linux/commit/78b5605d44e6

--
https://github.com/kvm-x86/linux/tree/next