From: Gleb Natapov <gleb@redhat.com>
To: Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp>
Cc: mtosatti@redhat.com, kvm@vger.kernel.org
Subject: Re: [PATCH] Revert "KVM: MMU: Move kvm_mmu_free_some_pages() into kvm_mmu_alloc_page()"
Date: Thu, 4 Apr 2013 10:27:51 +0300 [thread overview]
Message-ID: <20130404072751.GO3889@redhat.com> (raw)
In-Reply-To: <20130329140526.60b129ae.yoshikawa_takuya_b1@lab.ntt.co.jp>
On Fri, Mar 29, 2013 at 02:05:26PM +0900, Takuya Yoshikawa wrote:
> With the following commit, shadow pages can be zapped at random during
> a shadow page talbe walk:
> KVM: MMU: Move kvm_mmu_free_some_pages() into kvm_mmu_alloc_page()
> 7ddca7e43c8f28f9419da81a0e7730b66aa60fe9
>
> This patch reverts it and fixes __direct_map() and FNAME(fetch)().
>
> Signed-off-by: Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp>
Applied, thanks.
> ---
> arch/x86/kvm/mmu.c | 11 +++++++----
> arch/x86/kvm/paging_tmpl.h | 1 +
> 2 files changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index 633e30c..004cc87 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> @@ -1501,15 +1501,11 @@ static void drop_parent_pte(struct kvm_mmu_page *sp,
> mmu_spte_clear_no_track(parent_pte);
> }
>
> -static void make_mmu_pages_available(struct kvm_vcpu *vcpu);
> -
> static struct kvm_mmu_page *kvm_mmu_alloc_page(struct kvm_vcpu *vcpu,
> u64 *parent_pte, int direct)
> {
> struct kvm_mmu_page *sp;
>
> - make_mmu_pages_available(vcpu);
> -
> sp = mmu_memory_cache_alloc(&vcpu->arch.mmu_page_header_cache);
> sp->spt = mmu_memory_cache_alloc(&vcpu->arch.mmu_page_cache);
> if (!direct)
> @@ -2806,6 +2802,7 @@ exit:
>
> static bool try_async_pf(struct kvm_vcpu *vcpu, bool prefault, gfn_t gfn,
> gva_t gva, pfn_t *pfn, bool write, bool *writable);
> +static void make_mmu_pages_available(struct kvm_vcpu *vcpu);
>
> static int nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, u32 error_code,
> gfn_t gfn, bool prefault)
> @@ -2847,6 +2844,7 @@ static int nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, u32 error_code,
> spin_lock(&vcpu->kvm->mmu_lock);
> if (mmu_notifier_retry(vcpu->kvm, mmu_seq))
> goto out_unlock;
> + make_mmu_pages_available(vcpu);
> if (likely(!force_pt_level))
> transparent_hugepage_adjust(vcpu, &gfn, &pfn, &level);
> r = __direct_map(vcpu, v, write, map_writable, level, gfn, pfn,
> @@ -2924,6 +2922,7 @@ static int mmu_alloc_direct_roots(struct kvm_vcpu *vcpu)
>
> if (vcpu->arch.mmu.shadow_root_level == PT64_ROOT_LEVEL) {
> spin_lock(&vcpu->kvm->mmu_lock);
> + make_mmu_pages_available(vcpu);
> sp = kvm_mmu_get_page(vcpu, 0, 0, PT64_ROOT_LEVEL,
> 1, ACC_ALL, NULL);
> ++sp->root_count;
> @@ -2935,6 +2934,7 @@ static int mmu_alloc_direct_roots(struct kvm_vcpu *vcpu)
>
> ASSERT(!VALID_PAGE(root));
> spin_lock(&vcpu->kvm->mmu_lock);
> + make_mmu_pages_available(vcpu);
> sp = kvm_mmu_get_page(vcpu, i << (30 - PAGE_SHIFT),
> i << 30,
> PT32_ROOT_LEVEL, 1, ACC_ALL,
> @@ -2973,6 +2973,7 @@ static int mmu_alloc_shadow_roots(struct kvm_vcpu *vcpu)
> ASSERT(!VALID_PAGE(root));
>
> spin_lock(&vcpu->kvm->mmu_lock);
> + make_mmu_pages_available(vcpu);
> sp = kvm_mmu_get_page(vcpu, root_gfn, 0, PT64_ROOT_LEVEL,
> 0, ACC_ALL, NULL);
> root = __pa(sp->spt);
> @@ -3006,6 +3007,7 @@ static int mmu_alloc_shadow_roots(struct kvm_vcpu *vcpu)
> return 1;
> }
> spin_lock(&vcpu->kvm->mmu_lock);
> + make_mmu_pages_available(vcpu);
> sp = kvm_mmu_get_page(vcpu, root_gfn, i << 30,
> PT32_ROOT_LEVEL, 0,
> ACC_ALL, NULL);
> @@ -3311,6 +3313,7 @@ static int tdp_page_fault(struct kvm_vcpu *vcpu, gva_t gpa, u32 error_code,
> spin_lock(&vcpu->kvm->mmu_lock);
> if (mmu_notifier_retry(vcpu->kvm, mmu_seq))
> goto out_unlock;
> + make_mmu_pages_available(vcpu);
> if (likely(!force_pt_level))
> transparent_hugepage_adjust(vcpu, &gfn, &pfn, &level);
> r = __direct_map(vcpu, gpa, write, map_writable,
> diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
> index af143f0..da20860 100644
> --- a/arch/x86/kvm/paging_tmpl.h
> +++ b/arch/x86/kvm/paging_tmpl.h
> @@ -627,6 +627,7 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr, u32 error_code,
> goto out_unlock;
>
> kvm_mmu_audit(vcpu, AUDIT_PRE_PAGE_FAULT);
> + make_mmu_pages_available(vcpu);
> if (!force_pt_level)
> transparent_hugepage_adjust(vcpu, &walker.gfn, &pfn, &level);
> r = FNAME(fetch)(vcpu, addr, &walker, write_fault,
> --
> 1.7.5.4
--
Gleb.
prev parent reply other threads:[~2013-04-04 7:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-29 5:05 [PATCH] Revert "KVM: MMU: Move kvm_mmu_free_some_pages() into kvm_mmu_alloc_page()" Takuya Yoshikawa
2013-04-04 7:27 ` Gleb Natapov [this message]
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=20130404072751.GO3889@redhat.com \
--to=gleb@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=yoshikawa_takuya_b1@lab.ntt.co.jp \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.