From: Marcelo Tosatti <marcelo-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org>
To: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [PATCH 3/4] KVM: MMU: Avoid calling gfn_to_page() in mmu_set_spte()
Date: Mon, 31 Dec 2007 09:50:23 -0500 [thread overview]
Message-ID: <20071231145023.GA15378@dmt> (raw)
In-Reply-To: <1199013439-2047-4-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
On Sun, Dec 30, 2007 at 01:17:18PM +0200, Avi Kivity wrote:
> Since gfn_to_page() is a sleeping function, and we want to make the core mmu
> spinlocked, we need to pass the page from the walker context (which can sleep)
> to the shadow context (which cannot).
>
> Signed-off-by: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
> ---
> arch/x86/kvm/mmu.c | 58 ++++++++++++++++++++++++++++++++++++++++----
> arch/x86/kvm/paging_tmpl.h | 25 +++++++++++++++----
> include/asm-x86/kvm_host.h | 5 ++++
> 3 files changed, 78 insertions(+), 10 deletions(-)
>
> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index 3b91227..1b68f07 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> +static void mmu_guess_page_from_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
> + const u8 *new, int bytes)
> +{
> + gfn_t gfn;
> + int r;
> + u64 gpte = 0;
> +
> + if (bytes != 4 && bytes != 8)
> + return;
> +
> + down_read(¤t->mm->mmap_sem);
kvm_mmu_pte_write() already holds mmap_sem in read-mode, so this is not
required (and is deadlock prone actually).
Other than that the patchset looks good, thanks.
--- mmu.c.orig 2007-12-31 09:34:50.000000000 -0500
+++ mmu.c 2007-12-31 09:34:52.000000000 -0500
@@ -1360,7 +1360,6 @@ static void mmu_guess_page_from_pte_writ
if (bytes != 4 && bytes != 8)
return;
- down_read(¤t->mm->mmap_sem);
/*
* Assume that the pte write on a page table of the same type
* as the current vcpu paging mode. This is nearly always true
@@ -1372,7 +1371,7 @@ static void mmu_guess_page_from_pte_writ
if ((bytes == 4) && (gpa % 4 == 0)) {
r = kvm_read_guest(vcpu->kvm, gpa & ~(u64)7, &gpte, 8);
if (r)
- goto out;
+ return;
memcpy((void *)&gpte + (gpa % 8), new, 4);
} else if ((bytes == 8) && (gpa % 8 == 0)) {
memcpy((void *)&gpte, new, 8);
@@ -1382,12 +1381,10 @@ static void mmu_guess_page_from_pte_writ
memcpy((void *)&gpte, new, 4);
}
if (!is_present_pte(gpte))
- goto out;
+ return;
gfn = (gpte & PT64_BASE_ADDR_MASK) >> PAGE_SHIFT;
vcpu->arch.update_pte.gfn = gfn;
vcpu->arch.update_pte.page = gfn_to_page(vcpu->kvm, gfn);
-out:
- up_read(¤t->mm->mmap_sem);
}
void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
next prev parent reply other threads:[~2007-12-31 14:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-30 11:17 [PATCH 0/4] Updated kvm mmu scaling patch Avi Kivity
[not found] ` <1199013439-2047-1-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-12-30 11:17 ` [PATCH 1/4] KVM: MMU: Concurrent guest walkers Avi Kivity
[not found] ` <1199013439-2047-2-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-12-30 13:28 ` Avi Kivity
[not found] ` <47779CF8.1000408-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-12-30 14:39 ` Avi Kivity
2007-12-30 11:17 ` [PATCH 2/4] KVM: Add kvm_read_guest_atomic() Avi Kivity
2007-12-30 11:17 ` [PATCH 3/4] KVM: MMU: Avoid calling gfn_to_page() in mmu_set_spte() Avi Kivity
[not found] ` <1199013439-2047-4-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-12-31 14:50 ` Marcelo Tosatti [this message]
2007-12-31 14:55 ` Avi Kivity
2007-12-30 11:17 ` [PATCH 4/4] KVM: MMU: Switch to mmu spinlock Avi Kivity
[not found] ` <1199013439-2047-5-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-12-31 15:06 ` Marcelo Tosatti
2007-12-31 13:39 ` [PATCH 0/4] Updated kvm mmu scaling patch Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071231145023.GA15378@dmt \
--to=marcelo-bw31mazkks3ytjvyw6ydsg@public.gmane.org \
--cc=avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox