ia64/xen-unstable

changeset 8834:dcbe36ee2171

[IA64] fixed switch to idle domain bug

Previously when switching to idle domain, cr.pta is set to dom0's VHPT,
then when switching from VTIdomain to idle domain, cr.pta is set to
dom0's VHPT, and in idle domain, VHPT will be not remapped by TR, so
there may be unexpected vhpt fault in idle domain, which may cause
domain crash. Above only happens in host smp platform not host up
platform. This patch is intended to fix this bug.

Signed-off-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Anthony Xu <anthony.xu@intel.com>
author awilliam@xenbuild.aw
date Fri Feb 17 15:02:40 2006 -0700 (2006-02-17)
parents 3c091740f6ff
children ded14681ae84
files xen/arch/ia64/xen/xenmisc.c xen/include/asm-ia64/linux-xen/asm/processor.h
line diff
     1.1 --- a/xen/arch/ia64/xen/xenmisc.c	Fri Feb 17 14:57:19 2006 -0700
     1.2 +++ b/xen/arch/ia64/xen/xenmisc.c	Fri Feb 17 15:02:40 2006 -0700
     1.3 @@ -295,6 +295,7 @@ unsigned long context_switch_count = 0;
     1.4  void context_switch(struct vcpu *prev, struct vcpu *next)
     1.5  {
     1.6      uint64_t spsr;
     1.7 +    uint64_t pta;
     1.8  
     1.9      local_irq_save(spsr);
    1.10      if(VMX_DOMAIN(prev)){
    1.11 @@ -302,9 +303,9 @@ void context_switch(struct vcpu *prev, s
    1.12      }
    1.13  	context_switch_count++;
    1.14  	switch_to(prev,next,prev);
    1.15 -    if(VMX_DOMAIN(current)){
    1.16 -        vtm_domain_in(current);
    1.17 -    }
    1.18 +//    if(VMX_DOMAIN(current)){
    1.19 +//        vtm_domain_in(current);
    1.20 +//    }
    1.21  
    1.22  // leave this debug for now: it acts as a heartbeat when more than
    1.23  // one domain is active
    1.24 @@ -317,18 +318,26 @@ if (!i--) { printk("+",id); i = 1000000;
    1.25  }
    1.26  
    1.27      if (VMX_DOMAIN(current)){
    1.28 +        vtm_domain_in(current);
    1.29  		vmx_load_all_rr(current);
    1.30      }else{
    1.31 -	extern char ia64_ivt;
    1.32 -	ia64_set_iva(&ia64_ivt);
    1.33 -	ia64_set_pta(VHPT_ADDR | (1 << 8) | (VHPT_SIZE_LOG2 << 2) |
    1.34 -		VHPT_ENABLED);
    1.35 +    	extern char ia64_ivt;
    1.36 +    	ia64_set_iva(&ia64_ivt);
    1.37      	if (!is_idle_domain(current->domain)) {
    1.38 +        	ia64_set_pta(VHPT_ADDR | (1 << 8) | (VHPT_SIZE_LOG2 << 2) |
    1.39 +		        VHPT_ENABLED);
    1.40  	    	load_region_regs(current);
    1.41  	    	vcpu_load_kernel_regs(current);
    1.42 -		    if (vcpu_timer_expired(current)) vcpu_pend_timer(current);
    1.43 -    	}
    1.44 -	    if (vcpu_timer_expired(current)) vcpu_pend_timer(current);
    1.45 +		    if (vcpu_timer_expired(current))
    1.46 +                vcpu_pend_timer(current);
    1.47 +    	}else {
    1.48 +        /* When switching to idle domain, only need to disable vhpt
    1.49 +        * walker. Then all accesses happen within idle context will
    1.50 +        * be handled by TR mapping and identity mapping.
    1.51 +        */
    1.52 +           pta = ia64_get_pta();
    1.53 +           ia64_set_pta(pta & ~VHPT_ENABLED);
    1.54 +        }
    1.55      }
    1.56  
    1.57      local_irq_restore(spsr);
     2.1 --- a/xen/include/asm-ia64/linux-xen/asm/processor.h	Fri Feb 17 14:57:19 2006 -0700
     2.2 +++ b/xen/include/asm-ia64/linux-xen/asm/processor.h	Fri Feb 17 15:02:40 2006 -0700
     2.3 @@ -639,6 +639,19 @@ ia64_get_ivr (void)
     2.4  	return r;
     2.5  }
     2.6  
     2.7 +#ifdef XEN
     2.8 +/* Get the page table address and control bits.  */
     2.9 +static inline __u64
    2.10 +ia64_get_pta (void)
    2.11 +{
    2.12 +   __u64 r;
    2.13 +   ia64_srlz_d();
    2.14 +   r = ia64_getreg(_IA64_REG_CR_PTA);
    2.15 +   ia64_srlz_d();
    2.16 +   return r;
    2.17 +}
    2.18 +#endif
    2.19 +
    2.20  static inline void
    2.21  ia64_set_dbr (__u64 regnum, __u64 value)
    2.22  {