Skip to contentSkip to conversation

kvm: don't treat NULL parent_pte as multimapped in mmu_parent_walk()

PATCH In review Roel Kluin 2 participants 2 messages Jan 7, 2010

Subsystems (3)
lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 kvm: don't treat NULL parent_pte as multimapped in mmu_parent_walk()

If a kvm_mmu_page is not multimapped but parent_pte is NULL don't treat it as multimapped and dereference it.

---
This wasn't tested and maybe I misunderstood so please review.

arch/x86/kvm/mmu.c +6 -4
index 4c3e5b2..eb17287 100644
@@ -1031,10 +1031,12 @@ static void mmu_parent_walk(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
 	struct kvm_mmu_page *parent_sp;
 	int i;
 
-	if (!sp->multimapped && sp->parent_pte) {
-		parent_sp = page_header(__pa(sp->parent_pte));
-		fn(vcpu, parent_sp);
-		mmu_parent_walk(vcpu, parent_sp, fn);
+	if (!sp->multimapped) {
+		if (sp->parent_pte) {
+			parent_sp = page_header(__pa(sp->parent_pte));
+			fn(vcpu, parent_sp);
+			mmu_parent_walk(vcpu, parent_sp, fn);
+		}
 		return;
 	}
 	hlist_for_each_entry(pte_chain, node, &sp->parent_ptes, link)
#1 lore raw
Quoted 20 lines · Roel Kluin

If a kvm_mmu_page is not multimapped but parent_pte is NULL don't treat it as multimapped and dereference it.

---
This wasn't tested and maybe I misunderstood so please review.

arch/x86/kvm/mmu.c +0 -3
index 4c3e5b2..eb17287 100644
@@ -1031,10 +1031,12 @@ static void mmu_parent_walk(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
  	struct kvm_mmu_page *parent_sp;
  	int i;
 
-	if (!sp->multimapped&&  sp->parent_pte) {
-		parent_sp = page_header(__pa(sp->parent_pte));
-		fn(vcpu, parent_sp);

arch/x86/kvm/mmu.c static void mmu_parent_walk(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp, · line 1042

Quoted 10 lines
arch/x86/kvm/mmu.c +6 -1
-		mmu_parent_walk(vcpu, parent_sp, fn);
+	if (!sp->multimapped) {
+		if (sp->parent_pte) {
+			parent_sp = page_header(__pa(sp->parent_pte));
+			fn(vcpu, parent_sp);
+			mmu_parent_walk(vcpu, parent_sp, fn);
+		}
  		return;
  	}
  	hlist_for_each_entry(pte_chain, node,&sp->parent_ptes, link)

If sp->parent_pte is NULL then the list walk terminates immediately.

Signature · 1 line
error compiling committee.c: too many arguments to function