Skip to content

Commit c0dba6e

Browse files
Ben Gardonbonzini
authored andcommitted
KVM: x86/mmu: Clarify TDP MMU page list invariants
The tdp_mmu_roots and tdp_mmu_pages in struct kvm_arch should only contain pages with tdp_mmu_page set to true. tdp_mmu_pages should not contain any pages with a non-zero root_count and tdp_mmu_roots should only contain pages with a positive root_count, unless a thread holds the MMU lock and is in the process of modifying the list. Various functions expect these invariants to be maintained, but they are not explictily documented. Add to the comments on both fields to document the above invariants. Signed-off-by: Ben Gardon <bgardon@google.com> Message-Id: <20210107001935.3732070-2-bgardon@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent a889ea5 commit c0dba6e

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

arch/x86/include/asm/kvm_host.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,9 +1010,21 @@ struct kvm_arch {
10101010
*/
10111011
bool tdp_mmu_enabled;
10121012

1013-
/* List of struct tdp_mmu_pages being used as roots */
1013+
/*
1014+
* List of struct kvmp_mmu_pages being used as roots.
1015+
* All struct kvm_mmu_pages in the list should have
1016+
* tdp_mmu_page set.
1017+
* All struct kvm_mmu_pages in the list should have a positive
1018+
* root_count except when a thread holds the MMU lock and is removing
1019+
* an entry from the list.
1020+
*/
10141021
struct list_head tdp_mmu_roots;
1015-
/* List of struct tdp_mmu_pages not being used as roots */
1022+
1023+
/*
1024+
* List of struct kvmp_mmu_pages not being used as roots.
1025+
* All struct kvm_mmu_pages in the list should have
1026+
* tdp_mmu_page set and a root_count of 0.
1027+
*/
10161028
struct list_head tdp_mmu_pages;
10171029
};
10181030

0 commit comments

Comments
 (0)