Commit dc1ce455 authored by Paolo Bonzini's avatar Paolo Bonzini

KVM: MMU: update comment on the number of page role combinations

Fix the number of bits in the role, and simplify the explanation of
why several bits or combinations of bits are redundant.
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent ad5b3532
...@@ -291,19 +291,25 @@ struct kvm_kernel_irq_routing_entry; ...@@ -291,19 +291,25 @@ struct kvm_kernel_irq_routing_entry;
* the number of unique SPs that can theoretically be created is 2^n, where n * the number of unique SPs that can theoretically be created is 2^n, where n
* is the number of bits that are used to compute the role. * is the number of bits that are used to compute the role.
* *
* But, even though there are 18 bits in the mask below, not all combinations * But, even though there are 19 bits in the mask below, not all combinations
* of modes and flags are possible. The maximum number of possible upper-level * of modes and flags are possible:
* shadow pages for a single gfn is in the neighborhood of 2^13.
* *
* - invalid shadow pages are not accounted. * - invalid shadow pages are not accounted, so the bits are effectively 18
* - level is effectively limited to four combinations, not 16 as the number *
* bits would imply, as 4k SPs are not tracked (allowed to go unsync). * - quadrant will only be used if gpte_is_8_bytes=0 (non-PAE paging);
* - level is effectively unused for non-PAE paging because there is exactly * execonly and ad_disabled are only used for nested EPT which has
* one upper level (see 4k SP exception above). * gpte_is_8_bytes=1. Therefore, 2 bits are always unused.
* - quadrant is used only for non-PAE paging and is exclusive with *
* gpte_is_8_bytes. * - the 4 bits of level are effectively limited to the values 2/3/4/5,
* - execonly and ad_disabled are used only for nested EPT, which makes it * as 4k SPs are not tracked (allowed to go unsync). In addition non-PAE
* exclusive with quadrant. * paging has exactly one upper level, making level completely redundant
* when gpte_is_8_bytes=0.
*
* - on top of this, smep_andnot_wp and smap_andnot_wp are only set if
* cr0_wp=0, therefore these three bits only give rise to 5 possibilities.
*
* Therefore, the maximum number of possible upper-level shadow pages for a
* single gfn is a bit less than 2^13.
*/ */
union kvm_mmu_page_role { union kvm_mmu_page_role {
u32 word; u32 word;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment