diff mbox

[1/6] kvm/x86/svm: force new asid on vcpu migration

Message ID 1236255153-4432-2-git-send-email-joerg.roedel@amd.com (mailing list archive)
State New, archived
Headers show

Commit Message

Joerg Roedel March 5, 2009, 12:12 p.m. UTC
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 arch/x86/kvm/svm.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Comments

Marcelo Tosatti March 5, 2009, 5:53 p.m. UTC | #1
On Thu, Mar 05, 2009 at 01:12:28PM +0100, Joerg Roedel wrote:
> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
> ---
>  arch/x86/kvm/svm.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 1821c20..0e66bca 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -180,7 +180,7 @@ static inline void kvm_write_cr2(unsigned long val)
>  
>  static inline void force_new_asid(struct kvm_vcpu *vcpu)
>  {
> -	to_svm(vcpu)->asid_generation--;
> +	to_svm(vcpu)->asid_generation = 0;
>  }

Won't the per-cpu asig_generation overflow at some point? 

And can this comparison in pre_svm_run ever be true:

        if (svm->vcpu.cpu != cpu

?

>  static inline void flush_guest_tlb(struct kvm_vcpu *vcpu)
> @@ -716,6 +716,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);
> +		force_new_asid(vcpu);
>  	}
>  
>  	for (i = 0; i < NR_HOST_SAVE_USER_MSRS; i++)


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Avi Kivity July 26, 2009, 3:23 p.m. UTC | #2
On 03/05/2009 02:12 PM, Joerg Roedel wrote:
> Signed-off-by: Joerg Roedel<joerg.roedel@amd.com>
> ---
>   arch/x86/kvm/svm.c |    3 ++-
>   1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 1821c20..0e66bca 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -180,7 +180,7 @@ static inline void kvm_write_cr2(unsigned long val)
>
>   static inline void force_new_asid(struct kvm_vcpu *vcpu)
>   {
> -	to_svm(vcpu)->asid_generation--;
> +	to_svm(vcpu)->asid_generation = 0;
>   }
>
>   static inline void flush_guest_tlb(struct kvm_vcpu *vcpu)
> @@ -716,6 +716,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);
> +		force_new_asid(vcpu);
>   	}
>
>   	for (i = 0; i<  NR_HOST_SAVE_USER_MSRS; i++)
>    

Does this remove the need for 6eaa802c ("KVM: SVM: fix random segfaults 
with NPT enabled")?
diff mbox

Patch

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 1821c20..0e66bca 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -180,7 +180,7 @@  static inline void kvm_write_cr2(unsigned long val)
 
 static inline void force_new_asid(struct kvm_vcpu *vcpu)
 {
-	to_svm(vcpu)->asid_generation--;
+	to_svm(vcpu)->asid_generation = 0;
 }
 
 static inline void flush_guest_tlb(struct kvm_vcpu *vcpu)
@@ -716,6 +716,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);
+		force_new_asid(vcpu);
 	}
 
 	for (i = 0; i < NR_HOST_SAVE_USER_MSRS; i++)