Commit 529c4ebd authored by Ben Gardon's avatar Ben Gardon Committed by Yu Zhang
Browse files

KVM: x86/mmu: Clarify TDP MMU page list invariants

mainline inclusion
from mainline-v5.11-rc3
commit c0dba6e4
category: feature
bugzilla: https://gitee.com/openeuler/intel-kernel/issues/I7S3VQ
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c0dba6e46825716db15c4b3a8f05c85b4a59edda



----------------------------------------------------------------------

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: default avatarBen Gardon <bgardon@google.com>
Message-Id: <20210107001935.3732070-2-bgardon@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarYu Zhang <yu.c.zhang@linux.intel.com>
parent 7c5b95a2
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -1039,9 +1039,21 @@ struct kvm_arch {
	 */
	bool tdp_mmu_enabled;

	/* List of struct tdp_mmu_pages being used as roots */
	/*
	 * List of struct kvmp_mmu_pages being used as roots.
	 * All struct kvm_mmu_pages in the list should have
	 * tdp_mmu_page set.
	 * All struct kvm_mmu_pages in the list should have a positive
	 * root_count except when a thread holds the MMU lock and is removing
	 * an entry from the list.
	 */
	struct list_head tdp_mmu_roots;
	/* List of struct tdp_mmu_pages not being used as roots */

	/*
	 * List of struct kvmp_mmu_pages not being used as roots.
	 * All struct kvm_mmu_pages in the list should have
	 * tdp_mmu_page set and a root_count of 0.
	 */
	struct list_head tdp_mmu_pages;

	/*