Commit 174b6e4a authored by Sean Christopherson's avatar Sean Christopherson

KVM: x86/mmu: Decrease indentation in logic to sync new indirect shadow page

Combine the back-to-back if-statements for synchronizing children when
linking a new indirect shadow page in order to decrease the indentation,
and to make it easier to "see" the logic in its entirety.

No functional change intended.

Link: https://lore.kernel.org/r/20240802203900.348808-2-seanjc@google.comSigned-off-by: default avatarSean Christopherson <seanjc@google.com>
parent acf29232
...@@ -674,27 +674,25 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault, ...@@ -674,27 +674,25 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault,
sp = kvm_mmu_get_child_sp(vcpu, it.sptep, table_gfn, sp = kvm_mmu_get_child_sp(vcpu, it.sptep, table_gfn,
false, access); false, access);
if (sp != ERR_PTR(-EEXIST)) { /*
/* * Synchronize the new page before linking it, as the CPU (KVM)
* We must synchronize the pagetable before linking it * is architecturally disallowed from inserting non-present
* because the guest doesn't need to flush tlb when * entries into the TLB, i.e. the guest isn't required to flush
* the gpte is changed from non-present to present. * the TLB when changing the gPTE from non-present to present.
* Otherwise, the guest may use the wrong mapping. *
* * For PG_LEVEL_4K, kvm_mmu_find_shadow_page() has already
* For PG_LEVEL_4K, kvm_mmu_get_page() has already * synchronized the page via kvm_sync_page().
* synchronized it transiently via kvm_sync_page(). *
* * For higher level pages, which cannot be unsync themselves
* For higher level pagetable, we synchronize it via * but can have unsync children, synchronize via the slower
* the slower mmu_sync_children(). If it needs to * mmu_sync_children(). If KVM needs to drop mmu_lock due to
* break, some progress has been made; return * contention or to reschedule, instruct the caller to retry
* RET_PF_RETRY and retry on the next #PF. * the #PF (mmu_sync_children() ensures forward progress will
* KVM_REQ_MMU_SYNC is not necessary but it * be made).
* expedites the process. */
*/ if (sp != ERR_PTR(-EEXIST) && sp->unsync_children &&
if (sp->unsync_children && mmu_sync_children(vcpu, sp, false))
mmu_sync_children(vcpu, sp, false)) return RET_PF_RETRY;
return RET_PF_RETRY;
}
/* /*
* Verify that the gpte in the page we've just write * Verify that the gpte in the page we've just write
......
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