xen-unstable.hg

changeset 10769:37c8b562a8f1

[IA64] more tlb flush when vcpu migration between pcpu.

When vcpu is migrated to another pcpu and then it returns to the first
pcpu, VHPT and mTLB must also be flushed.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author awilliam@xenbuild.aw
date Wed Jul 05 09:59:40 2006 -0600 (2006-07-05)
parents 8dc4af3f192c
children 72caf2612e52
files xen/arch/ia64/xen/domain.c xen/include/asm-ia64/domain.h
line diff
     1.1 --- a/xen/arch/ia64/xen/domain.c	Wed Jul 05 09:28:32 2006 -0600
     1.2 +++ b/xen/arch/ia64/xen/domain.c	Wed Jul 05 09:59:40 2006 -0600
     1.3 @@ -93,25 +93,32 @@ DEFINE_PER_CPU(int *, current_psr_ic_add
     1.4  
     1.5  static void flush_vtlb_for_context_switch(struct vcpu* vcpu)
     1.6  {
     1.7 -	int last_vcpu_id =
     1.8 -		vcpu->domain->arch.last_vcpu[smp_processor_id()].vcpu_id;
     1.9 +	int cpu = smp_processor_id();
    1.10 +	int last_vcpu_id = vcpu->domain->arch.last_vcpu[cpu].vcpu_id;
    1.11 +	int last_processor = vcpu->arch.last_processor;
    1.12  
    1.13 -	if (is_idle_domain(vcpu->domain) || last_vcpu_id == vcpu->vcpu_id)
    1.14 +	if (is_idle_domain(vcpu->domain))
    1.15  		return;
    1.16 -	vcpu->domain->arch.last_vcpu[smp_processor_id()].vcpu_id =
    1.17 -		vcpu->vcpu_id;
    1.18 -	if (last_vcpu_id == INVALID_VCPU_ID) 
    1.19 -		return;
    1.20 +	
    1.21 +	vcpu->domain->arch.last_vcpu[cpu].vcpu_id = vcpu->vcpu_id;
    1.22 +	vcpu->arch.last_processor = cpu;
    1.23  
    1.24 -	// if the vTLB implementation was changed,
    1.25 -	// the followings must be updated either.
    1.26 -	if (VMX_DOMAIN(vcpu)) {
    1.27 -		// currently vTLB for vt-i domian is per vcpu.
    1.28 -		// so any flushing isn't needed.
    1.29 -	} else {
    1.30 -		vhpt_flush();
    1.31 +	if ((last_vcpu_id != vcpu->vcpu_id &&
    1.32 +	     last_vcpu_id != INVALID_VCPU_ID) ||
    1.33 +	    (last_vcpu_id == vcpu->vcpu_id &&
    1.34 +	     last_processor != cpu &&
    1.35 +	     last_processor != INVALID_PROCESSOR)) {
    1.36 +
    1.37 +		// if the vTLB implementation was changed,
    1.38 +		// the followings must be updated either.
    1.39 +		if (VMX_DOMAIN(vcpu)) {
    1.40 +			// currently vTLB for vt-i domian is per vcpu.
    1.41 +			// so any flushing isn't needed.
    1.42 +		} else {
    1.43 +			vhpt_flush();
    1.44 +		}
    1.45 +		local_flush_tlb_all();
    1.46  	}
    1.47 -	local_flush_tlb_all();
    1.48  }
    1.49  
    1.50  void schedule_tail(struct vcpu *prev)
    1.51 @@ -298,6 +305,7 @@ struct vcpu *alloc_vcpu_struct(struct do
    1.52  	    v->arch.starting_rid = d->arch.starting_rid;
    1.53  	    v->arch.ending_rid = d->arch.ending_rid;
    1.54  	    v->arch.breakimm = d->arch.breakimm;
    1.55 +	    v->arch.last_processor = INVALID_PROCESSOR;
    1.56  	}
    1.57  
    1.58  	return v;
     2.1 --- a/xen/include/asm-ia64/domain.h	Wed Jul 05 09:28:32 2006 -0600
     2.2 +++ b/xen/include/asm-ia64/domain.h	Wed Jul 05 09:59:40 2006 -0600
     2.3 @@ -171,6 +171,9 @@ struct arch_vcpu {
     2.4      int mode_flags;
     2.5      fpswa_ret_t fpswa_ret;	/* save return values of FPSWA emulation */
     2.6      struct arch_vmx_struct arch_vmx; /* Virtual Machine Extensions */
     2.7 +
     2.8 +#define INVALID_PROCESSOR       INT_MAX
     2.9 +    int last_processor;
    2.10  };
    2.11  
    2.12  #include <asm/uaccess.h> /* for KERNEL_DS */