2022-06-06 06:09:48

by Lai Jiangshan

[permalink] [raw]
Subject: [PATCH 00/12] KVM: X86/MMU: Simpliy mmu_unsync_walk()

From: Lai Jiangshan <[email protected]>

mmu_pages_clear_parents() is not really required (see patch4).

mmu_unsync_walk() can be simplified when the function is removed.

Lai Jiangshan (12):
KVM: X86/MMU: Warn if sp->unsync_children > 0 in link_shadow_page()
KVM: X86/MMU: Rename kvm_unlink_unsync_page() to
kvm_mmu_page_clear_unsync()
KVM: X86/MMU: Split a part of kvm_unsync_page() as
kvm_mmu_page_mark_unsync()
KVM: X86/MMU: Remove mmu_pages_clear_parents()
KVM: X86/MMU: Clear unsync bit directly in __mmu_unsync_walk()
KVM: X86/MMU: Rename mmu_unsync_walk() to mmu_unsync_walk_and_clear()
KVM: X86/MMU: Remove the useless struct mmu_page_path
KVM: X86/MMU: Remove the useless idx from struct kvm_mmu_pages
KVM: X86/MMU: Unfold struct mmu_page_and_offset in struct
kvm_mmu_pages
KVM: X86/MMU: Don't add parents to struct kvm_mmu_pages
KVM: X86/MMU: Remove mmu_pages_first() and mmu_pages_next()
KVM: X86/MMU: Rename struct kvm_mmu_pages to struct kvm_mmu_page_vec

arch/x86/kvm/mmu/mmu.c | 173 ++++++++++++-----------------------------
1 file changed, 51 insertions(+), 122 deletions(-)

--
2.19.1.6.gb485710b


2022-06-06 06:19:00

by Lai Jiangshan

[permalink] [raw]
Subject: [PATCH 01/12] KVM: X86/MMU: Warn if sp->unsync_children > 0 in link_shadow_page()

From: Lai Jiangshan <[email protected]>

The check for sp->unsync_children in link_shadow_page() can be removed
since FNAME(fetch) ensures it is zero. (@sp is direct when
link_shadow_page() is called from other places, which also means
sp->unsync_children is zero.)

link_shadow_page() is not a fast path, check it and warn instead.

Signed-off-by: Lai Jiangshan <[email protected]>
---
arch/x86/kvm/mmu/mmu.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 086f32dffdbe..f61416818116 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -2197,7 +2197,13 @@ static void link_shadow_page(struct kvm_vcpu *vcpu, u64 *sptep,

mmu_page_add_parent_pte(vcpu, sp, sptep);

- if (sp->unsync_children || sp->unsync)
+ /*
+ * Propagate the unsync bit when sp->unsync.
+ *
+ * The caller ensures the sp is synced when it has unsync children,
+ * so sp->unsync_children must be zero. See FNAME(fetch).
+ */
+ if (sp->unsync || WARN_ON_ONCE(sp->unsync_children))
mark_unsync(sptep);
}

--
2.19.1.6.gb485710b