lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Sat, 17 Apr 2010 16:50:13 +0800
From:	Lai Jiangshan <laijs@...fujitsu.com>
To:	Avi Kivity <avi@...hat.com>, Marcelo Tosatti <mtosatti@...hat.com>,
	LKML <linux-kernel@...r.kernel.org>, kvm@...r.kernel.org
Subject: [PATCH] kvm x86 mmu: simplify kvm_mmu_unlink_parents()


mmu_page_remove_parent_pte() does much maintenance works,
but kvm_mmu_unlink_parents() unlink all parents, so
such maintenance works are not need.

This patch simplifies the works of kvm_mmu_unlink_parents()
by unlinking parents without so many maintenance works.

Signed-off-by: Lai Jiangshan <laijs@...fujitsu.com>
---
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 90f666e..71faa04 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1453,22 +1453,33 @@ static void kvm_mmu_reset_last_pte_updated(struct kvm *kvm)
 
 static void kvm_mmu_unlink_parents(struct kvm *kvm, struct kvm_mmu_page *sp)
 {
-	u64 *parent_pte;
+	if (!sp->multimapped) {
+		if (!sp->parent_pte)
+			return;
 
-	while (sp->multimapped || sp->parent_pte) {
-		if (!sp->multimapped)
-			parent_pte = sp->parent_pte;
-		else {
-			struct kvm_pte_chain *chain;
+		__set_spte(sp->parent_pte, shadow_trap_nonpresent_pte);
+		sp->parent_pte = NULL;
+		return;
+	}
 
-			chain = container_of(sp->parent_ptes.first,
-					     struct kvm_pte_chain, link);
-			parent_pte = chain->parent_ptes[0];
+	while (!hlist_empty(&sp->parent_ptes)) {
+		struct kvm_pte_chain *chain;
+		u64 *parent_pte;
+		int i;
+
+		chain = hlist_entry(sp->parent_ptes.first,
+				    struct kvm_pte_chain, link);
+		for (i = 0; i < NR_PTE_CHAIN_ENTRIES; ++i) {
+			parent_pte = chain->parent_ptes[i];
+			if (!parent_pte)
+				break;
+			__set_spte(parent_pte, shadow_trap_nonpresent_pte);
 		}
-		BUG_ON(!parent_pte);
-		kvm_mmu_put_page(sp, parent_pte);
-		__set_spte(parent_pte, shadow_trap_nonpresent_pte);
+		hlist_del(&chain->link);
+		mmu_free_pte_chain(chain);
 	}
+	sp->multimapped = 0;
+	sp->parent_pte = NULL;
 }
 
 static int mmu_zap_unsync_children(struct kvm *kvm,

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ