ia64/xen-unstable

changeset 11609:7b250cf49e50

[IA64] create page table for virtual frame table

Do not use p?d_populate() functions to create the page table for
virtual frametable.

Signed-off-by: Kouya SHIMURA <kouya@jp.fujitsu.com>
author awilliam@xenbuild.aw
date Sun Sep 24 14:55:57 2006 -0600 (2006-09-24)
parents 06bec182a66e
children 9da2d9b48ff8
files xen/arch/ia64/xen/xenmem.c
line diff
     1.1 --- a/xen/arch/ia64/xen/xenmem.c	Sun Sep 24 14:29:50 2006 -0600
     1.2 +++ b/xen/arch/ia64/xen/xenmem.c	Sun Sep 24 14:55:57 2006 -0600
     1.3 @@ -17,10 +17,19 @@
     1.4  #include <linux/efi.h>
     1.5  #include <asm/pgalloc.h>
     1.6  
     1.7 -extern pgd_t frametable_pg_dir[];
     1.8 +extern unsigned long frametable_pg_dir[];
     1.9  
    1.10 -#define frametable_pgd_offset(addr) \
    1.11 -	(frametable_pg_dir + (((addr) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1)))
    1.12 +#define FRAMETABLE_PGD_OFFSET(ADDR) \
    1.13 +	(frametable_pg_dir + (((ADDR) >> PGDIR_SHIFT) & \
    1.14 +	((1UL << (PAGE_SHIFT - 3)) - 1)))
    1.15 +
    1.16 +#define FRAMETABLE_PMD_OFFSET(PGD, ADDR) \
    1.17 +	__va((unsigned long *)(PGD) + (((ADDR) >> PMD_SHIFT) & \
    1.18 +	((1UL << (PAGE_SHIFT - 3)) - 1)))
    1.19 +
    1.20 +#define FRAMETABLE_PTE_OFFSET(PMD, ADDR) \
    1.21 +	(pte_t *)__va((unsigned long *)(PMD) + (((ADDR) >> PAGE_SHIFT) & \
    1.22 +	((1UL << (PAGE_SHIFT - 3)) - 1)))
    1.23  
    1.24  static unsigned long table_size;
    1.25  static int opt_contig_mem = 0;
    1.26 @@ -72,7 +81,7 @@ paging_init (void)
    1.27  
    1.28  #ifdef CONFIG_VIRTUAL_FRAME_TABLE
    1.29  
    1.30 -static inline void *
    1.31 +static unsigned long
    1.32  alloc_dir_page(void)
    1.33  {
    1.34  	unsigned long mfn = alloc_boot_pages(1, 1);
    1.35 @@ -82,7 +91,7 @@ alloc_dir_page(void)
    1.36  	++table_size;
    1.37  	dir = mfn << PAGE_SHIFT;
    1.38  	memset(__va(dir), 0, PAGE_SIZE);
    1.39 -	return (void *)dir;
    1.40 +	return dir;
    1.41  }
    1.42  
    1.43  static inline unsigned long
    1.44 @@ -100,15 +109,33 @@ alloc_table_page(unsigned long fill)
    1.45  	return mfn;
    1.46  }
    1.47  
    1.48 +static void
    1.49 +create_page_table(unsigned long start_page, unsigned long end_page,
    1.50 +                  unsigned long fill)
    1.51 +{
    1.52 +	unsigned long address;
    1.53 +	unsigned long *dir;
    1.54 +	pte_t *pteptr;
    1.55 +
    1.56 +	for (address = start_page; address < end_page; address += PAGE_SIZE) {
    1.57 +		dir = FRAMETABLE_PGD_OFFSET(address);
    1.58 +		if (!*dir)
    1.59 +			*dir = alloc_dir_page();
    1.60 +		dir = FRAMETABLE_PMD_OFFSET(*dir, address);
    1.61 +		if (!*dir)
    1.62 +			*dir = alloc_dir_page();
    1.63 +		pteptr = FRAMETABLE_PTE_OFFSET(*dir, address);
    1.64 +		if (pte_none(*pteptr))
    1.65 +			set_pte(pteptr, pfn_pte(alloc_table_page(fill),
    1.66 +			                        PAGE_KERNEL));
    1.67 +	}
    1.68 +}
    1.69 +
    1.70  static int
    1.71  create_frametable_page_table (u64 start, u64 end, void *arg)
    1.72  {
    1.73 -	unsigned long address, start_page, end_page;
    1.74  	struct page_info *map_start, *map_end;
    1.75 -	pgd_t *pgd;
    1.76 -	pud_t *pud;
    1.77 -	pmd_t *pmd;
    1.78 -	pte_t *pte;
    1.79 +	unsigned long start_page, end_page;
    1.80  
    1.81  	map_start = frame_table + (__pa(start) >> PAGE_SHIFT);
    1.82  	map_end   = frame_table + (__pa(end) >> PAGE_SHIFT);
    1.83 @@ -116,23 +143,7 @@ create_frametable_page_table (u64 start,
    1.84  	start_page = (unsigned long) map_start & PAGE_MASK;
    1.85  	end_page = PAGE_ALIGN((unsigned long) map_end);
    1.86  
    1.87 -	for (address = start_page; address < end_page; address += PAGE_SIZE) {
    1.88 -		pgd = frametable_pgd_offset(address);
    1.89 -		if (pgd_none(*pgd))
    1.90 -			pgd_populate(NULL, pgd, alloc_dir_page());
    1.91 -		pud = pud_offset(pgd, address);
    1.92 -
    1.93 -		if (pud_none(*pud))
    1.94 -			pud_populate(NULL, pud, alloc_dir_page());
    1.95 -		pmd = pmd_offset(pud, address);
    1.96 -
    1.97 -		if (pmd_none(*pmd))
    1.98 -			pmd_populate_kernel(NULL, pmd, alloc_dir_page());
    1.99 -		pte = pte_offset_kernel(pmd, address);
   1.100 -
   1.101 -		if (pte_none(*pte))
   1.102 -			set_pte(pte, pfn_pte(alloc_table_page(0), PAGE_KERNEL));
   1.103 -	}
   1.104 +	create_page_table(start_page, end_page, 0L);
   1.105  	return 0;
   1.106  }
   1.107  
   1.108 @@ -140,11 +151,7 @@ static int
   1.109  create_mpttable_page_table (u64 start, u64 end, void *arg)
   1.110  {
   1.111  	unsigned long map_start, map_end;
   1.112 -	unsigned long address, start_page, end_page;
   1.113 -	pgd_t *pgd;
   1.114 -	pud_t *pud;
   1.115 -	pmd_t *pmd;
   1.116 -	pte_t *pte;
   1.117 +	unsigned long start_page, end_page;
   1.118  
   1.119  	map_start = (unsigned long)(mpt_table + (__pa(start) >> PAGE_SHIFT));
   1.120  	map_end   = (unsigned long)(mpt_table + (__pa(end) >> PAGE_SHIFT));
   1.121 @@ -152,23 +159,7 @@ create_mpttable_page_table (u64 start, u
   1.122  	start_page = map_start & PAGE_MASK;
   1.123  	end_page = PAGE_ALIGN(map_end);
   1.124  
   1.125 -	for (address = start_page; address < end_page; address += PAGE_SIZE) {
   1.126 -		pgd = frametable_pgd_offset(address);
   1.127 -		if (pgd_none(*pgd))
   1.128 -			pgd_populate(NULL, pgd, alloc_dir_page());
   1.129 -		pud = pud_offset(pgd, address);
   1.130 -
   1.131 -		if (pud_none(*pud))
   1.132 -			pud_populate(NULL, pud, alloc_dir_page());
   1.133 -		pmd = pmd_offset(pud, address);
   1.134 -
   1.135 -		if (pmd_none(*pmd))
   1.136 -			pmd_populate_kernel(NULL, pmd, alloc_dir_page());
   1.137 -		pte = pte_offset_kernel(pmd, address);
   1.138 -
   1.139 -		if (pte_none(*pte))
   1.140 -			set_pte(pte, pfn_pte(alloc_table_page(INVALID_M2P_ENTRY), PAGE_KERNEL));
   1.141 -	}
   1.142 +	create_page_table(start_page, end_page, INVALID_M2P_ENTRY);
   1.143  	return 0;
   1.144  }
   1.145