From: Xiao Guangrong <guangrong.xiao@linux.intel.com>
To: Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp>,
pbonzini@redhat.com
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, mtosatti@redhat.com
Subject: Re: [PATCH 09/10] KVM: x86: MMU: Move parent_pte handling from kvm_mmu_get_page() to link_shadow_page()
Date: Fri, 20 Nov 2015 16:57:47 +0800 [thread overview]
Message-ID: <564EE08B.4040100@linux.intel.com> (raw)
In-Reply-To: <20151120174805.a91793d1fce2f0a493f1b955@lab.ntt.co.jp>
You can move this patch to the front of
[PATCH 08/10] KVM: x86: MMU: Use for_each_rmap_spte macro instead of pte_list_walk()
By moving kvm_mmu_mark_parents_unsync() to the behind of mmu_spte_set() (then the parent
spte is present now), you can directly clean up for_each_rmap_spte().
On 11/20/2015 04:48 PM, Takuya Yoshikawa wrote:
> Every time kvm_mmu_get_page() is called with a non-NULL parent_pte
> argument, link_shadow_page() follows that to set the parent entry so
> that the new mapping will point to the returned page table.
>
> Moving parent_pte handling there allows to clean up the code because
> parent_pte is passed to kvm_mmu_get_page() just for mark_unsync() and
> mmu_page_add_parent_pte().
>
> Signed-off-by: Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp>
> ---
> arch/x86/kvm/mmu.c | 22 ++++++++--------------
> arch/x86/kvm/paging_tmpl.h | 6 ++----
> 2 files changed, 10 insertions(+), 18 deletions(-)
>
> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index 4e29d9a..b020323 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> @@ -2107,14 +2107,9 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu,
> if (sp->unsync_children) {
> kvm_make_request(KVM_REQ_MMU_SYNC, vcpu);
> kvm_mmu_mark_parents_unsync(sp);
> - if (parent_pte)
> - mark_unsync(parent_pte);
> } else if (sp->unsync) {
> kvm_mmu_mark_parents_unsync(sp);
> - if (parent_pte)
> - mark_unsync(parent_pte);
> }
> - mmu_page_add_parent_pte(vcpu, sp, parent_pte);
>
> __clear_sp_write_flooding_count(sp);
> trace_kvm_mmu_get_page(sp, false);
> @@ -2125,8 +2120,6 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu,
>
> sp = kvm_mmu_alloc_page(vcpu, direct);
>
> - mmu_page_add_parent_pte(vcpu, sp, parent_pte);
> -
> sp->gfn = gfn;
> sp->role = role;
> hlist_add_head(&sp->hash_link,
> @@ -2194,7 +2187,8 @@ static void shadow_walk_next(struct kvm_shadow_walk_iterator *iterator)
> return __shadow_walk_next(iterator, *iterator->sptep);
> }
>
> -static void link_shadow_page(u64 *sptep, struct kvm_mmu_page *sp)
> +static void link_shadow_page(struct kvm_vcpu *vcpu, u64 *sptep,
> + struct kvm_mmu_page *sp)
> {
> u64 spte;
>
> @@ -2205,6 +2199,11 @@ static void link_shadow_page(u64 *sptep, struct kvm_mmu_page *sp)
> shadow_user_mask | shadow_x_mask | shadow_accessed_mask;
>
> mmu_spte_set(sptep, spte);
> +
> + if (sp->unsync_children || sp->unsync)
> + mark_unsync(sptep);
> +
> + mmu_page_add_parent_pte(vcpu, sp, sptep);
> }
>
> static void validate_direct_spte(struct kvm_vcpu *vcpu, u64 *sptep,
> @@ -2263,11 +2262,6 @@ static void kvm_mmu_page_unlink_children(struct kvm *kvm,
> mmu_page_zap_pte(kvm, sp, sp->spt + i);
> }
>
> -static void kvm_mmu_put_page(struct kvm_mmu_page *sp, u64 *parent_pte)
> -{
> - mmu_page_remove_parent_pte(sp, parent_pte);
> -}
> -
> static void kvm_mmu_unlink_parents(struct kvm *kvm, struct kvm_mmu_page *sp)
> {
> u64 *sptep;
> @@ -2733,7 +2727,7 @@ static int __direct_map(struct kvm_vcpu *vcpu, int write, int map_writable,
> iterator.level - 1,
> 1, ACC_ALL, iterator.sptep);
>
> - link_shadow_page(iterator.sptep, sp);
> + link_shadow_page(vcpu, iterator.sptep, sp);
> }
> }
> return emulate;
> diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
> index 11650ea..0dcf9c8 100644
> --- a/arch/x86/kvm/paging_tmpl.h
> +++ b/arch/x86/kvm/paging_tmpl.h
> @@ -598,7 +598,7 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
> goto out_gpte_changed;
>
> if (sp)
> - link_shadow_page(it.sptep, sp);
> + link_shadow_page(vcpu, it.sptep, sp);
> }
>
> for (;
> @@ -618,7 +618,7 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
>
> sp = kvm_mmu_get_page(vcpu, direct_gfn, addr, it.level-1,
> true, direct_access, it.sptep);
> - link_shadow_page(it.sptep, sp);
> + link_shadow_page(vcpu, it.sptep, sp);
> }
>
> clear_sp_write_flooding_count(it.sptep);
> @@ -629,8 +629,6 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
> return emulate;
>
> out_gpte_changed:
> - if (sp)
> - kvm_mmu_put_page(sp, it.sptep);
> kvm_release_pfn_clean(pfn);
> return 0;
> }
>
next prev parent reply other threads:[~2015-11-20 9:04 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-20 8:40 [PATCH V3 00/10] KVM: x86: MMU: Clean up x86's mmu code for future work Takuya Yoshikawa
2015-11-20 8:41 ` [PATCH 01/10] KVM: x86: MMU: Encapsulate the type of rmap-chain head in a new struct Takuya Yoshikawa
2015-11-20 8:42 ` [PATCH 02/10] KVM: x86: MMU: Remove unused parameter of __direct_map() Takuya Yoshikawa
2015-11-20 8:43 ` [PATCH 03/10] KVM: x86: MMU: Add helper function to clear a bit in unsync child bitmap Takuya Yoshikawa
2015-11-20 8:44 ` [PATCH 04/10] KVM: x86: MMU: Make mmu_set_spte() return emulate value Takuya Yoshikawa
2015-11-20 8:44 ` [PATCH 05/10] KVM: x86: MMU: Remove is_rmap_spte() and use is_shadow_present_pte() Takuya Yoshikawa
2015-11-20 8:45 ` [PATCH 06/10] KVM: x86: MMU: Consolidate BUG_ON checks for reverse-mapped sptes Takuya Yoshikawa
2015-11-20 8:46 ` [PATCH 07/10] KVM: x86: MMU: Move initialization of parent_ptes out from kvm_mmu_alloc_page() Takuya Yoshikawa
2015-11-20 8:47 ` [PATCH 08/10] KVM: x86: MMU: Use for_each_rmap_spte macro instead of pte_list_walk() Takuya Yoshikawa
2015-11-20 8:46 ` Xiao Guangrong
2015-11-20 9:08 ` Takuya Yoshikawa
2015-11-25 16:29 ` Paolo Bonzini
2015-11-20 8:48 ` [PATCH 09/10] KVM: x86: MMU: Move parent_pte handling from kvm_mmu_get_page() to link_shadow_page() Takuya Yoshikawa
2015-11-20 8:57 ` Xiao Guangrong [this message]
2015-11-25 16:32 ` Paolo Bonzini
2015-11-26 2:36 ` Takuya Yoshikawa
2015-11-20 8:48 ` [PATCH 10/10] KVM: x86: MMU: Remove unused parameter parent_pte from kvm_mmu_get_page() Takuya Yoshikawa
2015-11-20 9:35 ` [PATCH V3 00/10] KVM: x86: MMU: Clean up x86's mmu code for future work Xiao Guangrong
2015-11-20 16:01 ` Paolo Bonzini
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=564EE08B.4040100@linux.intel.com \
--to=guangrong.xiao@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=pbonzini@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox