Re: [PATCH v2 09/17] KVM: x86/mmu: Use '0' as the one and only value for an invalid PAE root

From
Sean Christopherson <seanjc@google.com>
Date
2021-03-05 18:23:11
Also in
lkml
Reply to
Paolo Bonzini, 2021-03-05
On Fri, Mar 05, 2021, Paolo Bonzini wrote:
On 05/03/21 02:10, Sean Christopherson wrote:
quoted
Use '0' to denote an invalid pae_root instead of '0' or INVALID_PAGE.
Unlike root_hpa, the pae_roots hold permission bits and thus are
guaranteed to be non-zero.  Having to deal with both values leads to
bugs, e.g. failing to set back to INVALID_PAGE, warning on the wrong
value, etc...
I don't dispute this is a good idea, but it deserves one or more comments.
Agreed.   What about adding macros?

/* Comment goes here. */
#define INVALID_PAE_ROOT	0
#define IS_VALID_PAE_ROOT(x)	(!!(x))


Also, I missed this pattern in mmu_audit.c's mmu_spte_walk():

	for (i = 0; i < 4; ++i) {
		hpa_t root = vcpu->arch.mmu->pae_root[i];

		if (root && VALID_PAGE(root)) {
			root &= PT64_BASE_ADDR_MASK;
			sp = to_shadow_page(root);
			__mmu_spte_walk(vcpu, sp, fn, 2);
		}
	}
Thread (31 messages) 31 messages, 3 authors, last reply 2021-04-08
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help