Message ID | 20230626182016.4127366-3-mizhang@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Update document description for kvm_mmu_page and kvm_mmu_page_role | expand |
Hi-- On 6/26/23 11:20, Mingwei Zhang wrote: > 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 <mizhang@google.com> > Reviewed-by: Kai Huang <kai.huang@intel.com> > --- > Documentation/virt/kvm/x86/mmu.rst | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/Documentation/virt/kvm/x86/mmu.rst b/Documentation/virt/kvm/x86/mmu.rst > index 561efa8ec7d7..4c9044b4dc6c 100644 > --- a/Documentation/virt/kvm/x86/mmu.rst > +++ b/Documentation/virt/kvm/x86/mmu.rst > @@ -221,11 +221,12 @@ 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 > + 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. 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. > + this case, the array of shadowed_translation is not allocated. See I cannot parse the before version nor the after version of this sentence (new version): 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 shadowed_translation is not allocated. > + 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
On Mon, Jun 26, 2023, Randy Dunlap wrote: > Hi-- > > On 6/26/23 11:20, Mingwei Zhang wrote: > > 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 <mizhang@google.com> > > Reviewed-by: Kai Huang <kai.huang@intel.com> > > --- > > Documentation/virt/kvm/x86/mmu.rst | 9 +++++---- > > 1 file changed, 5 insertions(+), 4 deletions(-) > > > > diff --git a/Documentation/virt/kvm/x86/mmu.rst b/Documentation/virt/kvm/x86/mmu.rst > > index 561efa8ec7d7..4c9044b4dc6c 100644 > > --- a/Documentation/virt/kvm/x86/mmu.rst > > +++ b/Documentation/virt/kvm/x86/mmu.rst > > @@ -221,11 +221,12 @@ 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 > > + 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. 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. > > + this case, the array of shadowed_translation is not allocated. See > > I cannot parse the before version nor the after version of this sentence (new version): > > 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 shadowed_translation is not allocated. > > Sorry for the late reply. Why is it not parsed? It just means that when role.direct is set, do not use gfns. The gfn can be calculated from the base address + offset. The base address here is the 'gfn' field in kvm_mmu_page. > > + 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 > > -- > ~Randy
On Mon, Jul 31, 2023, Mingwei Zhang wrote: > On Mon, Jun 26, 2023, Randy Dunlap wrote: > > Hi-- > > > > On 6/26/23 11:20, Mingwei Zhang wrote: > > > 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 <mizhang@google.com> > > > Reviewed-by: Kai Huang <kai.huang@intel.com> > > > --- > > > Documentation/virt/kvm/x86/mmu.rst | 9 +++++---- > > > 1 file changed, 5 insertions(+), 4 deletions(-) > > > > > > diff --git a/Documentation/virt/kvm/x86/mmu.rst b/Documentation/virt/kvm/x86/mmu.rst > > > index 561efa8ec7d7..4c9044b4dc6c 100644 > > > --- a/Documentation/virt/kvm/x86/mmu.rst > > > +++ b/Documentation/virt/kvm/x86/mmu.rst > > > @@ -221,11 +221,12 @@ 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 > > > + 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. 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. > > > + this case, the array of shadowed_translation is not allocated. See > > > > I cannot parse the before version nor the after version of this sentence (new version): > > > > 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 shadowed_translation is not allocated. > > > > > > Sorry for the late reply. Why is it not parsed? It just means that when > role.direct is set, do not use gfns. The gfn can be calculated from the > base address + offset. The base address here is the 'gfn' field in > kvm_mmu_page. It's a bit of a run-on sentence with confusing pronoun usage. How about this? When role.direct is set, the shadow_translation array is not allocated as the per-SPTE gfn is simply an offset from the base gfn, and KVM doesn't track access permissions for direct shadow pages.
On Mon, Jul 31, 2023, Sean Christopherson wrote: > On Mon, Jul 31, 2023, Mingwei Zhang wrote: > > On Mon, Jun 26, 2023, Randy Dunlap wrote: > > > Hi-- > > > > > > On 6/26/23 11:20, Mingwei Zhang wrote: > > > > 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 <mizhang@google.com> > > > > Reviewed-by: Kai Huang <kai.huang@intel.com> > > > > --- > > > > Documentation/virt/kvm/x86/mmu.rst | 9 +++++---- > > > > 1 file changed, 5 insertions(+), 4 deletions(-) > > > > > > > > diff --git a/Documentation/virt/kvm/x86/mmu.rst b/Documentation/virt/kvm/x86/mmu.rst > > > > index 561efa8ec7d7..4c9044b4dc6c 100644 > > > > --- a/Documentation/virt/kvm/x86/mmu.rst > > > > +++ b/Documentation/virt/kvm/x86/mmu.rst > > > > @@ -221,11 +221,12 @@ 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 > > > > + 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. 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. > > > > + this case, the array of shadowed_translation is not allocated. See > > > > > > I cannot parse the before version nor the after version of this sentence (new version): > > > > > > 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 shadowed_translation is not allocated. > > > > > > > > > > Sorry for the late reply. Why is it not parsed? It just means that when > > role.direct is set, do not use gfns. The gfn can be calculated from the > > base address + offset. The base address here is the 'gfn' field in > > kvm_mmu_page. > > It's a bit of a run-on sentence with confusing pronoun usage. How about this? > > When role.direct is set, the shadow_translation array is not allocated as the > per-SPTE gfn is simply an offset from the base gfn, and KVM doesn't track > access permissions for direct shadow pages. I think the problem might be that the sentence is slightly long. To be accurate, we have to mention access permission which the original text did not. Also, I split the sentences and try only using short ones. The overall description will be longer. How about this? 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.
diff --git a/Documentation/virt/kvm/x86/mmu.rst b/Documentation/virt/kvm/x86/mmu.rst index 561efa8ec7d7..4c9044b4dc6c 100644 --- a/Documentation/virt/kvm/x86/mmu.rst +++ b/Documentation/virt/kvm/x86/mmu.rst @@ -221,11 +221,12 @@ 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 + 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. 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. + this case, the array of shadowed_translation is not allocated. 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