2010-01-07 15:53:03

by Roel Kluin

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Roel Kluin <[email protected]>
---
This wasn't tested and maybe I misunderstood so please review.

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 4c3e5b2..eb17287 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -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)


2010-01-07 16:48:12

by Avi Kivity

[permalink] [raw]
Subject: Re: [PATCH] kvm: don't treat NULL parent_pte as multimapped in mmu_parent_walk()

On 01/07/2010 05:56 PM, Roel Kluin wrote:
> If a kvm_mmu_page is not multimapped but parent_pte is NULL
> don't treat it as multimapped and dereference it.
>
> Signed-off-by: Roel Kluin<[email protected]>
> ---
> This wasn't tested and maybe I misunderstood so please review.
>
> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index 4c3e5b2..eb17287 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> @@ -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)
>
>

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

--
error compiling committee.c: too many arguments to function