ia64/xen-unstable

changeset 9000:a220579c2aa8

[IA64] fix SMP bug for vhpt

vhpt_paddr & vhpt_pend are now per-cpu variables, since VHPT is allocated
per cpu. This should really improve stability.

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>
author awilliam@xenbuild.aw
date Mon Feb 27 14:00:33 2006 -0700 (2006-02-27)
parents a4a4a28a1686
children b5a6da522577
files xen/arch/ia64/xen/domain.c xen/arch/ia64/xen/regionreg.c xen/arch/ia64/xen/vhpt.c xen/include/asm-ia64/vhpt.h
line diff
     1.1 --- a/xen/arch/ia64/xen/domain.c	Mon Feb 27 13:31:10 2006 -0700
     1.2 +++ b/xen/arch/ia64/xen/domain.c	Mon Feb 27 14:00:33 2006 -0700
     1.3 @@ -46,6 +46,7 @@
     1.4  #include <asm/vmx_vcpu.h>
     1.5  #include <asm/vmx_vpd.h>
     1.6  #include <asm/pal.h>
     1.7 +#include <asm/vhpt.h>
     1.8  #include <public/hvm/ioreq.h>
     1.9  
    1.10  #define CONFIG_DOMAIN0_CONTIGUOUS
    1.11 @@ -399,7 +400,6 @@ struct page * assign_new_domain_page(str
    1.12  	pud_t *pud;
    1.13  	pmd_t *pmd;
    1.14  	pte_t *pte;
    1.15 -extern unsigned long vhpt_paddr, vhpt_pend;
    1.16  
    1.17  	if (!mm->pgd) {
    1.18  		printk("assign_new_domain_page: domain pgd must exist!\n");
    1.19 @@ -433,9 +433,11 @@ extern unsigned long vhpt_paddr, vhpt_pe
    1.20  printf("assign_new_domain_page: Can't alloc!!!! Aaaargh!\n");
    1.21  			return(p);
    1.22  		}
    1.23 -if (unlikely(page_to_maddr(p) > vhpt_paddr && page_to_maddr(p) < vhpt_pend)) {
    1.24 -  printf("assign_new_domain_page: reassigned vhpt page %p!!\n",page_to_maddr(p));
    1.25 -}
    1.26 +		if (unlikely(page_to_maddr(p) > __get_cpu_var(vhpt_paddr)
    1.27 +			     && page_to_maddr(p) < __get_cpu_var(vhpt_pend))) {
    1.28 +		  printf("assign_new_domain_page: reassigned vhpt page %p!!\n",
    1.29 +			 page_to_maddr(p));
    1.30 +		}
    1.31  		set_pte(pte, pfn_pte(page_to_maddr(p) >> PAGE_SHIFT,
    1.32  			__pgprot(__DIRTY_BITS | _PAGE_PL_2 | _PAGE_AR_RWX)));
    1.33  	}
     2.1 --- a/xen/arch/ia64/xen/regionreg.c	Mon Feb 27 13:31:10 2006 -0700
     2.2 +++ b/xen/arch/ia64/xen/regionreg.c	Mon Feb 27 14:00:33 2006 -0700
     2.3 @@ -211,7 +211,6 @@ int set_one_rr(unsigned long rr, unsigne
     2.4  	unsigned long rreg = REGION_NUMBER(rr);
     2.5  	ia64_rr rrv, newrrv, memrrv;
     2.6  	unsigned long newrid;
     2.7 -	extern unsigned long vhpt_paddr;
     2.8  
     2.9  	if (val == -1) return 1;
    2.10  
    2.11 @@ -249,10 +248,12 @@ int set_one_rr(unsigned long rr, unsigne
    2.12  	newrrv.rid = newrid;
    2.13  	newrrv.ve = 1;  // VHPT now enabled for region 7!!
    2.14  	newrrv.ps = PAGE_SHIFT;
    2.15 -	if (rreg == 0) v->arch.metaphysical_saved_rr0 =
    2.16 -		vmMangleRID(newrrv.rrval);
    2.17 -	if (rreg == 7) ia64_new_rr7(vmMangleRID(newrrv.rrval),v->vcpu_info,
    2.18 -				v->arch.privregs, vhpt_paddr, pal_vaddr);
    2.19 +	if (rreg == 0)
    2.20 +		v->arch.metaphysical_saved_rr0 = vmMangleRID(newrrv.rrval);
    2.21 +	else if (rreg == 7)
    2.22 +		ia64_new_rr7(vmMangleRID(newrrv.rrval),v->vcpu_info,
    2.23 +			     v->arch.privregs, __get_cpu_var(vhpt_paddr),
    2.24 +			     pal_vaddr);
    2.25  	else set_rr(rr,newrrv.rrval);
    2.26  #endif
    2.27  	return 1;
     3.1 --- a/xen/arch/ia64/xen/vhpt.c	Mon Feb 27 13:31:10 2006 -0700
     3.2 +++ b/xen/arch/ia64/xen/vhpt.c	Mon Feb 27 14:00:33 2006 -0700
     3.3 @@ -15,7 +15,8 @@
     3.4  #include <asm/dma.h>
     3.5  #include <asm/vhpt.h>
     3.6  
     3.7 -unsigned long vhpt_paddr, vhpt_pend, vhpt_pte;
     3.8 +DEFINE_PER_CPU (unsigned long, vhpt_paddr);
     3.9 +DEFINE_PER_CPU (unsigned long, vhpt_pend);
    3.10  
    3.11  void vhpt_flush(void)
    3.12  {
    3.13 @@ -77,12 +78,12 @@ void vhpt_flush_address(unsigned long va
    3.14  }
    3.15  #endif
    3.16  
    3.17 -void vhpt_map(void)
    3.18 +static void vhpt_map(unsigned long pte)
    3.19  {
    3.20  	unsigned long psr;
    3.21  
    3.22  	psr = ia64_clear_ic();
    3.23 -	ia64_itr(0x2, IA64_TR_VHPT, VHPT_ADDR, vhpt_pte, VHPT_SIZE_LOG2);
    3.24 +	ia64_itr(0x2, IA64_TR_VHPT, VHPT_ADDR, pte, VHPT_SIZE_LOG2);
    3.25  	ia64_set_psr(psr);
    3.26  	ia64_srlz_i();
    3.27  }
    3.28 @@ -122,6 +123,7 @@ void vhpt_multiple_insert(unsigned long 
    3.29  void vhpt_init(void)
    3.30  {
    3.31  	unsigned long vhpt_total_size, vhpt_alignment;
    3.32 +	unsigned long paddr, pte;
    3.33  	struct page_info *page;
    3.34  #if !VHPT_ENABLED
    3.35  	return;
    3.36 @@ -141,11 +143,13 @@ void vhpt_init(void)
    3.37  		printf("vhpt_init: can't allocate VHPT!\n");
    3.38  		while(1);
    3.39  	}
    3.40 -	vhpt_paddr = page_to_maddr(page);
    3.41 -	vhpt_pend = vhpt_paddr + vhpt_total_size - 1;
    3.42 -	printf("vhpt_init: vhpt paddr=%p, end=%p\n",vhpt_paddr,vhpt_pend);
    3.43 -	vhpt_pte = pte_val(pfn_pte(vhpt_paddr >> PAGE_SHIFT, PAGE_KERNEL));
    3.44 -	vhpt_map();
    3.45 +	paddr = page_to_maddr(page);
    3.46 +	__get_cpu_var(vhpt_paddr) = paddr;
    3.47 +	__get_cpu_var(vhpt_pend) = paddr + vhpt_total_size - 1;
    3.48 +	printf("vhpt_init: vhpt paddr=%p, end=%p\n",
    3.49 +	       paddr, __get_cpu_var(vhpt_pend));
    3.50 +	pte = pte_val(pfn_pte(paddr >> PAGE_SHIFT, PAGE_KERNEL));
    3.51 +	vhpt_map(pte);
    3.52  	ia64_set_pta(VHPT_ADDR | (1 << 8) | (VHPT_SIZE_LOG2 << 2) |
    3.53  		VHPT_ENABLED);
    3.54  	vhpt_flush();
     4.1 --- a/xen/include/asm-ia64/vhpt.h	Mon Feb 27 13:31:10 2006 -0700
     4.2 +++ b/xen/include/asm-ia64/vhpt.h	Mon Feb 27 14:00:33 2006 -0700
     4.3 @@ -121,6 +121,11 @@ extern void vhpt_multiple_insert(unsigne
     4.4  extern void vhpt_insert (unsigned long vadr, unsigned long ptr,
     4.5  			 unsigned logps);
     4.6  extern void vhpt_flush(void);
     4.7 +
     4.8 +/* Currently the VHPT is allocated per CPU.  */
     4.9 +DECLARE_PER_CPU (unsigned long, vhpt_paddr);
    4.10 +DECLARE_PER_CPU (unsigned long, vhpt_pend);
    4.11 +
    4.12  #endif /* !__ASSEMBLY */
    4.13  
    4.14  #if !VHPT_ENABLED