[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4AEED8A8.9030606@redhat.com>
Date: Mon, 02 Nov 2009 15:03:36 +0200
From: Avi Kivity <avi@...hat.com>
To: Gleb Natapov <gleb@...hat.com>
CC: kvm@...r.kernel.org, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 07/11] Retry fault before vmentry
On 11/01/2009 01:56 PM, Gleb Natapov wrote:
> When page is swapped in it is mapped into guest memory only after guest
> tries to access it again and generate another fault. To save this fault
> we can map it immediately since we know that guest is going to access
> the page.
>
>
>
> diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
> index 9fe2ecd..b1fe61f 100644
> --- a/arch/x86/kvm/paging_tmpl.h
> +++ b/arch/x86/kvm/paging_tmpl.h
> @@ -375,7 +375,7 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
> * Returns: 1 if we need to emulate the instruction, 0 otherwise, or
> * a negative value on error.
> */
> -static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr,
> +static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gpa_t cr3, gva_t addr,
> u32 error_code)
> {
> int write_fault = error_code& PFERR_WRITE_MASK;
> @@ -388,6 +388,7 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr,
> pfn_t pfn;
> int level = PT_PAGE_TABLE_LEVEL;
> unsigned long mmu_seq;
> + gpa_t curr_cr3 = vcpu->arch.cr3;
>
> pgprintk("%s: addr %lx err %x\n", __func__, addr, error_code);
> kvm_mmu_audit(vcpu, "pre page fault");
> @@ -396,6 +397,13 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr,
> if (r)
> return r;
>
> + if (curr_cr3 != cr3) {
> + vcpu->arch.cr3 = cr3;
> + paging_new_cr3(vcpu);
> + if (kvm_mmu_reload(vcpu))
> + goto switch_cr3;
> + }
> +
>
This is a little frightening. I can't put my finger on anything
though. But playing with cr3 under the guest's feet worries me.
--
error compiling committee.c: too many arguments to function
--
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