Re: [PATCH v3 3/3] KVM: MMU: retry #PF for softmmu

Marcelo Tosatti
2010-12-02T02:50:03Z

On Tue, Nov 30, 2010 at 05:37:36PM +0800, Xiao Guangrong wrote:
> Retry #PF for softmmu only when the current vcpu has the same root shadow page
> as the time when #PF occurs. it means they have same paging environment
>
> Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
> ---
> arch/x86/include/asm/kvm_host.h | 5 +++++
> arch/x86/kvm/mmu.c | 33 ++++++++++++++++++++++++++++++++-
> arch/x86/kvm/paging_tmpl.h | 34 +++++++++++++++++++++++-----------
> arch/x86/kvm/x86.c | 13 ++++++++++++-
> virt/kvm/async_pf.c | 1 +
> 5 files changed, 73 insertions(+), 13 deletions(-)
>
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index 209da89..5acbcab 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -191,6 +191,7 @@ union kvm_mmu_page_role {
> struct kvm_mmu_page {
> struct list_head link;
> struct hlist_node hash_link;
> + struct kref apfs_counter;
>
> /*
> * The following two entries are used to key the shadow page in the
> @@ -602,6 +603,7 @@ struct kvm_x86_ops {
> struct kvm_arch_async_pf {
> u32 token;
> gfn_t gfn;
> + struct kvm_mmu_page *root_sp;
> bool direct_map;
> };

Can't you just compare cr3 value? Its harmless to instantiate an spte
for an unused translation.