ia64/xen-unstable

changeset 9402:e45666b8b05f

[IA64] assign_new_domain_page now calls assign_domain_page

assign_new_domain_page inlines assign_new_domain0_page and calls
assign_domain_page.
cleanup in asm-ia64/xenprocessor.h

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>
author awilliam@xenbuild.aw
date Fri Mar 24 10:41:48 2006 -0700 (2006-03-24)
parents 138c76d5e493
children 51c79c67908b
files xen/arch/ia64/xen/domain.c xen/include/asm-ia64/xenprocessor.h
line diff
     1.1 --- a/xen/arch/ia64/xen/domain.c	Fri Mar 24 10:38:41 2006 -0700
     1.2 +++ b/xen/arch/ia64/xen/domain.c	Fri Mar 24 10:41:48 2006 -0700
     1.3 @@ -488,80 +488,46 @@ void new_thread(struct vcpu *v,
     1.4  	}
     1.5  }
     1.6  
     1.7 -static struct page_info * assign_new_domain0_page(unsigned long mpaddr)
     1.8 -{
     1.9 -	if (mpaddr < dom0_start || mpaddr >= dom0_start + dom0_size) {
    1.10 -		printk("assign_new_domain0_page: bad domain0 mpaddr 0x%lx!\n",mpaddr);
    1.11 -		printk("assign_new_domain0_page: start=0x%lx,end=0x%lx!\n",
    1.12 -			dom0_start, dom0_start+dom0_size);
    1.13 -		while(1);
    1.14 -	}
    1.15 -	return mfn_to_page((mpaddr >> PAGE_SHIFT));
    1.16 -}
    1.17  
    1.18 -/* allocate new page for domain and map it to the specified metaphysical addr */
    1.19 +/* Allocate a new page for domain and map it to the specified metaphysical 
    1.20 +   address.  */
    1.21  static struct page_info * assign_new_domain_page(struct domain *d, unsigned long mpaddr)
    1.22  {
    1.23 -	struct mm_struct *mm = d->arch.mm;
    1.24 -	struct page_info *pt, *p = (struct page_info *)0;
    1.25 -	pgd_t *pgd;
    1.26 -	pud_t *pud;
    1.27 -	pmd_t *pmd;
    1.28 -	pte_t *pte;
    1.29 +	unsigned long maddr;
    1.30 +	struct page_info *p;
    1.31  
    1.32 -	if (!mm->pgd) {
    1.33 -		printk("assign_new_domain_page: domain pgd must exist!\n");
    1.34 +#ifdef CONFIG_DOMAIN0_CONTIGUOUS
    1.35 +	if (d == dom0) {
    1.36 +		if (mpaddr < dom0_start || mpaddr >= dom0_start + dom0_size) {
    1.37 +			/* FIXME: is it true ?
    1.38 +			   dom0 memory is not contiguous!  */
    1.39 +			printk("assign_new_domain_page: bad domain0 "
    1.40 +			       "mpaddr=%lx, start=%lx, end=%lx!\n",
    1.41 +			       mpaddr, dom0_start, dom0_start+dom0_size);
    1.42 +			while(1);
    1.43 +		}
    1.44 +		p = mfn_to_page((mpaddr >> PAGE_SHIFT));
    1.45 +	}
    1.46 +	else
    1.47 +#endif
    1.48 +	{
    1.49 +		p = alloc_domheap_page(d);
    1.50 +		// zero out pages for security reasons
    1.51 +		if (p) memset(__va(page_to_maddr(p)),0,PAGE_SIZE);
    1.52 +	}
    1.53 +	if (unlikely(!p)) {
    1.54 +		printf("assign_new_domain_page: Can't alloc!!!! Aaaargh!\n");
    1.55  		return(p);
    1.56  	}
    1.57 -	pgd = pgd_offset(mm,mpaddr);
    1.58 -	if (pgd_none(*pgd))
    1.59 -	{
    1.60 -		pgd_populate(mm, pgd, pud_alloc_one(mm,mpaddr));
    1.61 -		pt = maddr_to_page(pgd_val(*pgd));
    1.62 -		list_add_tail(&pt->list, &d->arch.mm->pt_list);
    1.63 -	}
    1.64 -
    1.65 -	pud = pud_offset(pgd, mpaddr);
    1.66 -	if (pud_none(*pud))
    1.67 -	{
    1.68 -		pud_populate(mm, pud, pmd_alloc_one(mm,mpaddr));
    1.69 -		pt = maddr_to_page(pud_val(*pud));
    1.70 -		list_add_tail(&pt->list, &d->arch.mm->pt_list);
    1.71 -	}
    1.72 -
    1.73 -	pmd = pmd_offset(pud, mpaddr);
    1.74 -	if (pmd_none(*pmd))
    1.75 -	{
    1.76 -		pmd_populate_kernel(mm, pmd, pte_alloc_one_kernel(mm,mpaddr));
    1.77 -//		pmd_populate(mm, pmd, pte_alloc_one(mm,mpaddr));
    1.78 -		pt = maddr_to_page(pmd_val(*pmd));
    1.79 -		list_add_tail(&pt->list, &d->arch.mm->pt_list);
    1.80 +	maddr = page_to_maddr (p);
    1.81 +	if (unlikely(maddr > __get_cpu_var(vhpt_paddr)
    1.82 +		     && maddr < __get_cpu_var(vhpt_pend))) {
    1.83 +		/* FIXME: how can this happen ?
    1.84 +		   vhpt is allocated by alloc_domheap_page.  */
    1.85 +		printf("assign_new_domain_page: reassigned vhpt page %lx!!\n",
    1.86 +		       maddr);
    1.87  	}
    1.88 -
    1.89 -	pte = pte_offset_map(pmd, mpaddr);
    1.90 -	if (pte_none(*pte)) {
    1.91 -#ifdef CONFIG_DOMAIN0_CONTIGUOUS
    1.92 -		if (d == dom0) p = assign_new_domain0_page(mpaddr);
    1.93 -		else
    1.94 -#endif
    1.95 -		{
    1.96 -			p = alloc_domheap_page(d);
    1.97 -			// zero out pages for security reasons
    1.98 -			if (p) memset(__va(page_to_maddr(p)),0,PAGE_SIZE);
    1.99 -		}
   1.100 -		if (unlikely(!p)) {
   1.101 -			printf("assign_new_domain_page: Can't alloc!!!! Aaaargh!\n");
   1.102 -			return(p);
   1.103 -		}
   1.104 -		if (unlikely(page_to_maddr(p) > __get_cpu_var(vhpt_paddr)
   1.105 -			     && page_to_maddr(p) < __get_cpu_var(vhpt_pend))) {
   1.106 -			printf("assign_new_domain_page: reassigned vhpt page %lx!!\n",
   1.107 -				page_to_maddr(p));
   1.108 -		}
   1.109 -		set_pte(pte, pfn_pte(page_to_maddr(p) >> PAGE_SHIFT,
   1.110 -			__pgprot(__DIRTY_BITS | _PAGE_PL_2 | _PAGE_AR_RWX)));
   1.111 -	}
   1.112 -	else printk("assign_new_domain_page: mpaddr %lx already mapped!\n",mpaddr);
   1.113 +	assign_domain_page (d, mpaddr, maddr);
   1.114  	return p;
   1.115  }
   1.116  
     2.1 --- a/xen/include/asm-ia64/xenprocessor.h	Fri Mar 24 10:38:41 2006 -0700
     2.2 +++ b/xen/include/asm-ia64/xenprocessor.h	Fri Mar 24 10:41:48 2006 -0700
     2.3 @@ -172,14 +172,6 @@ typedef union {
     2.4      };
     2.5  } tpr_t;
     2.6  
     2.7 -#define IA64_ISR_CODE_MASK0     0xf
     2.8 -#define IA64_UNIMPL_DADDR_FAULT     0x30
     2.9 -#define IA64_UNIMPL_IADDR_TRAP      0x10
    2.10 -#define IA64_RESERVED_REG_FAULT     0x30
    2.11 -#define IA64_REG_NAT_CONSUMPTION_FAULT  0x10
    2.12 -#define IA64_NAT_CONSUMPTION_FAULT  0x20
    2.13 -#define IA64_PRIV_OP_FAULT      0x10
    2.14 -
    2.15  /* indirect register type */
    2.16  enum {
    2.17      IA64_CPUID,     /*  cpuid */