lkml.org 
[lkml]   [2023]   [Aug]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v3 4/6] KVM: Documentation: Add the missing description for tdp_mmu_root_count into kvm_mmu_page
From
On Tue, Aug 01, 2023, Mingwei Zhang wrote:
> 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 <mizhang@google.com>
> Reviewed-by: Kai Huang <kai.huang@intel.com>
> ---
> 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.

That last sentence is wrong. *vCPUs* can't acquire references while holding
mmu_lock for read. And actually, they don't ever put references while holding
for read either. vCPUs *must* hold mmu_lock for write to obtain a new root,
Not putting references while holding mmu_lock for read is mostly an implementation
quirk.

Maybe replace it with this?

tdp_mmu_root_count is similar but exclusively used in the TDP MMU as an
atomic refcount (select TDP MMU flows walk all roots while holding mmu_lock
for read, e.g. when clearing dirty bits).

\
 
 \ /
  Last update: 2023-08-17 00:47    [W:0.059 / U:0.936 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site