xen-unstable.hg

changeset 10765:6d8136d0b302

[IA64] allow vcpu to move between pcpus

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author awilliam@xenbuild.aw
date Mon Jul 03 08:53:02 2006 -0600 (2006-07-03)
parents 93e8817694ab
children 75b4a0ff27b8
files xen/arch/ia64/xen/domain.c xen/arch/ia64/xen/vhpt.c xen/include/asm-ia64/domain.h xen/include/asm-ia64/vhpt.h
line diff
     1.1 --- a/xen/arch/ia64/xen/domain.c	Mon Jul 03 08:35:05 2006 -0600
     1.2 +++ b/xen/arch/ia64/xen/domain.c	Mon Jul 03 08:53:02 2006 -0600
     1.3 @@ -92,6 +92,29 @@ DEFINE_PER_CPU(int *, current_psr_ic_add
     1.4  
     1.5  #include <xen/sched-if.h>
     1.6  
     1.7 +static void flush_vtlb_for_context_switch(struct vcpu* vcpu)
     1.8 +{
     1.9 +	int last_vcpu_id =
    1.10 +		vcpu->domain->arch.last_vcpu[smp_processor_id()].vcpu_id;
    1.11 +
    1.12 +	if (is_idle_domain(vcpu->domain) || last_vcpu_id == vcpu->vcpu_id)
    1.13 +		return;
    1.14 +	vcpu->domain->arch.last_vcpu[smp_processor_id()].vcpu_id =
    1.15 +		vcpu->vcpu_id;
    1.16 +	if (last_vcpu_id == INVALID_VCPU_ID) 
    1.17 +		return;
    1.18 +
    1.19 +	// if the vTLB implementation was changed,
    1.20 +	// the followings must be updated either.
    1.21 +	if (VMX_DOMAIN(vcpu)) {
    1.22 +		// currently vTLB for vt-i domian is per vcpu.
    1.23 +		// so any flushing isn't needed.
    1.24 +	} else {
    1.25 +		vhpt_flush();
    1.26 +	}
    1.27 +	local_flush_tlb_all();
    1.28 +}
    1.29 +
    1.30  void schedule_tail(struct vcpu *prev)
    1.31  {
    1.32  	extern char ia64_ivt;
    1.33 @@ -110,6 +133,7 @@ void schedule_tail(struct vcpu *prev)
    1.34  		__ia64_per_cpu_var(current_psr_ic_addr) = (int *)
    1.35  		  (current->domain->arch.shared_info_va + XSI_PSR_IC_OFS);
    1.36  	}
    1.37 +	flush_vtlb_for_context_switch(current);
    1.38  }
    1.39  
    1.40  void context_switch(struct vcpu *prev, struct vcpu *next)
    1.41 @@ -175,6 +199,7 @@ if (!i--) { i = 1000000; printk("+"); }
    1.42  		__ia64_per_cpu_var(current_psr_ic_addr) = NULL;
    1.43          }
    1.44      }
    1.45 +    flush_vtlb_for_context_switch(current);
    1.46      local_irq_restore(spsr);
    1.47      context_saved(prev);
    1.48  }
    1.49 @@ -309,9 +334,14 @@ static void init_switch_stack(struct vcp
    1.50  
    1.51  int arch_domain_create(struct domain *d)
    1.52  {
    1.53 +	int i;
    1.54 +	
    1.55  	// the following will eventually need to be negotiated dynamically
    1.56  	d->arch.shared_info_va = DEFAULT_SHAREDINFO_ADDR;
    1.57  	d->arch.breakimm = 0x1000;
    1.58 +	for (i = 0; i < NR_CPUS; i++) {
    1.59 +		d->arch.last_vcpu[i].vcpu_id = INVALID_VCPU_ID;
    1.60 +	}
    1.61  
    1.62  	if (is_idle_domain(d))
    1.63  	    return 0;
     2.1 --- a/xen/arch/ia64/xen/vhpt.c	Mon Jul 03 08:35:05 2006 -0600
     2.2 +++ b/xen/arch/ia64/xen/vhpt.c	Mon Jul 03 08:53:02 2006 -0600
     2.3 @@ -23,7 +23,7 @@ extern long running_on_sim;
     2.4  DEFINE_PER_CPU (unsigned long, vhpt_paddr);
     2.5  DEFINE_PER_CPU (unsigned long, vhpt_pend);
     2.6  
     2.7 -static void vhpt_flush(void)
     2.8 +void vhpt_flush(void)
     2.9  {
    2.10  	struct vhpt_lf_entry *v = __va(__ia64_per_cpu_var(vhpt_paddr));
    2.11  	int i;
     3.1 --- a/xen/include/asm-ia64/domain.h	Mon Jul 03 08:35:05 2006 -0600
     3.2 +++ b/xen/include/asm-ia64/domain.h	Mon Jul 03 08:53:02 2006 -0600
     3.3 @@ -58,6 +58,11 @@ struct mm_struct {
     3.4      //	atomic_t mm_users;			/* How many users with user space? */
     3.5  };
     3.6  
     3.7 +struct last_vcpu {
     3.8 +#define INVALID_VCPU_ID INT_MAX
     3.9 +    int vcpu_id;
    3.10 +} ____cacheline_aligned_in_smp;
    3.11 +
    3.12  struct arch_domain {
    3.13      struct mm_struct mm;
    3.14      unsigned long metaphysical_rr0;
    3.15 @@ -101,6 +106,8 @@ struct arch_domain {
    3.16      void *efi_runtime;
    3.17      /* Metaphysical address to fpswa_interface_t in domain firmware memory is set. */
    3.18      void *fpswa_inf;
    3.19 +
    3.20 +    struct last_vcpu last_vcpu[NR_CPUS];
    3.21  };
    3.22  #define INT_ENABLE_OFFSET(v) 		  \
    3.23      (sizeof(vcpu_info_t) * (v)->vcpu_id + \
     4.1 --- a/xen/include/asm-ia64/vhpt.h	Mon Jul 03 08:35:05 2006 -0600
     4.2 +++ b/xen/include/asm-ia64/vhpt.h	Mon Jul 03 08:53:02 2006 -0600
     4.3 @@ -42,6 +42,7 @@ extern void vhpt_multiple_insert(unsigne
     4.4  				 unsigned long logps);
     4.5  extern void vhpt_insert (unsigned long vadr, unsigned long pte,
     4.6  			 unsigned long logps);
     4.7 +void vhpt_flush(void);
     4.8  
     4.9  /* Currently the VHPT is allocated per CPU.  */
    4.10  DECLARE_PER_CPU (unsigned long, vhpt_paddr);