All of lore.kernel.org
 help / color / mirror / Atom feed
* KVM: SVM: force new asid on vcpu migration
@ 2009-07-21 15:47 Marcelo Tosatti
  2009-07-21 15:56 ` Joerg Roedel
  0 siblings, 1 reply; 2+ messages in thread
From: Marcelo Tosatti @ 2009-07-21 15:47 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: kvm


If a migrated vcpu matches the asid_generation value of the target pcpu,
there will be no TLB flush via TLB_CONTROL_FLUSH_ALL_ASID.

The check for vcpu.cpu in pre_svm_run is meaningless since svm_vcpu_load 
already updated it on schedule in.

Such vcpu will VMRUN with stale TLB entries.

Based on original patch from Joerg Roedel (http://patchwork.kernel.org/patch/10021/)

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 18085d3..90fe88f 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -739,6 +739,7 @@ static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
 		svm->vmcb->control.tsc_offset += delta;
 		vcpu->cpu = cpu;
 		kvm_migrate_timers(vcpu);
+		svm->asid_generation = 0;
 	}
 
 	for (i = 0; i < NR_HOST_SAVE_USER_MSRS; i++)
@@ -1071,7 +1072,6 @@ static void new_asid(struct vcpu_svm *svm, struct svm_cpu_data *svm_data)
 		svm->vmcb->control.tlb_ctl = TLB_CONTROL_FLUSH_ALL_ASID;
 	}
 
-	svm->vcpu.cpu = svm_data->cpu;
 	svm->asid_generation = svm_data->asid_generation;
 	svm->vmcb->control.asid = svm_data->next_asid++;
 }
@@ -2320,8 +2320,8 @@ static void pre_svm_run(struct vcpu_svm *svm)
 	struct svm_cpu_data *svm_data = per_cpu(svm_data, cpu);
 
 	svm->vmcb->control.tlb_ctl = TLB_CONTROL_DO_NOTHING;
-	if (svm->vcpu.cpu != cpu ||
-	    svm->asid_generation != svm_data->asid_generation)
+ 	/* FIXME: handle wraparound of asid_generation */
+	if (svm->asid_generation != svm_data->asid_generation)
 		new_asid(svm, svm_data);
 }
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: KVM: SVM: force new asid on vcpu migration
  2009-07-21 15:47 KVM: SVM: force new asid on vcpu migration Marcelo Tosatti
@ 2009-07-21 15:56 ` Joerg Roedel
  0 siblings, 0 replies; 2+ messages in thread
From: Joerg Roedel @ 2009-07-21 15:56 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: kvm

On Tue, Jul 21, 2009 at 12:47:45PM -0300, Marcelo Tosatti wrote:
> 
> If a migrated vcpu matches the asid_generation value of the target pcpu,
> there will be no TLB flush via TLB_CONTROL_FLUSH_ALL_ASID.
> 
> The check for vcpu.cpu in pre_svm_run is meaningless since svm_vcpu_load 
> already updated it on schedule in.
> 
> Such vcpu will VMRUN with stale TLB entries.
> 
> Based on original patch from Joerg Roedel (http://patchwork.kernel.org/patch/10021/)
> 
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Acked-by: Joerg Roedel <joerg.roedel@amd.com>

> 
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 18085d3..90fe88f 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -739,6 +739,7 @@ static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
>  		svm->vmcb->control.tsc_offset += delta;
>  		vcpu->cpu = cpu;
>  		kvm_migrate_timers(vcpu);
> +		svm->asid_generation = 0;
>  	}
>  
>  	for (i = 0; i < NR_HOST_SAVE_USER_MSRS; i++)
> @@ -1071,7 +1072,6 @@ static void new_asid(struct vcpu_svm *svm, struct svm_cpu_data *svm_data)
>  		svm->vmcb->control.tlb_ctl = TLB_CONTROL_FLUSH_ALL_ASID;
>  	}
>  
> -	svm->vcpu.cpu = svm_data->cpu;
>  	svm->asid_generation = svm_data->asid_generation;
>  	svm->vmcb->control.asid = svm_data->next_asid++;
>  }
> @@ -2320,8 +2320,8 @@ static void pre_svm_run(struct vcpu_svm *svm)
>  	struct svm_cpu_data *svm_data = per_cpu(svm_data, cpu);
>  
>  	svm->vmcb->control.tlb_ctl = TLB_CONTROL_DO_NOTHING;
> -	if (svm->vcpu.cpu != cpu ||
> -	    svm->asid_generation != svm_data->asid_generation)
> + 	/* FIXME: handle wraparound of asid_generation */
> +	if (svm->asid_generation != svm_data->asid_generation)
>  		new_asid(svm, svm_data);
>  }
>  
> 

-- 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-07-21 15:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-21 15:47 KVM: SVM: force new asid on vcpu migration Marcelo Tosatti
2009-07-21 15:56 ` Joerg Roedel

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.