ia64/xen-unstable
changeset 6094:4fa90e2a3257
Fix domain0 builder for PAE.
Signed-off-by: Chris Wright <chrisw@osdl.org>
Signed-off-by: Keir Fraser <keir@xensource.com>
Signed-off-by: Chris Wright <chrisw@osdl.org>
Signed-off-by: Keir Fraser <keir@xensource.com>
author | kaf24@firebug.cl.cam.ac.uk |
---|---|
date | Wed Aug 10 14:11:40 2005 +0000 (2005-08-10) |
parents | 839d3ac75da3 |
children | 49671266459c |
files | xen/arch/x86/domain_build.c xen/include/asm-x86/page.h xen/include/asm-x86/types.h |
line diff
1.1 --- a/xen/arch/x86/domain_build.c Wed Aug 10 13:06:00 2005 +0000 1.2 +++ b/xen/arch/x86/domain_build.c Wed Aug 10 14:11:40 2005 +0000 1.3 @@ -78,8 +78,8 @@ int construct_dom0(struct domain *d, 1.4 unsigned long pfn, mfn; 1.5 unsigned long nr_pages; 1.6 unsigned long nr_pt_pages; 1.7 - unsigned long alloc_start; 1.8 - unsigned long alloc_end; 1.9 + unsigned long alloc_spfn; 1.10 + unsigned long alloc_epfn; 1.11 unsigned long count; 1.12 struct pfn_info *page = NULL; 1.13 start_info_t *si; 1.14 @@ -145,8 +145,8 @@ int construct_dom0(struct domain *d, 1.15 ((image_len + PAGE_SIZE - 1) >> PAGE_SHIFT); 1.16 if ( (page = alloc_largest(d, nr_pages)) == NULL ) 1.17 panic("Not enough RAM for DOM0 reservation.\n"); 1.18 - alloc_start = page_to_phys(page); 1.19 - alloc_end = alloc_start + (d->tot_pages << PAGE_SHIFT); 1.20 + alloc_spfn = page_to_pfn(page); 1.21 + alloc_epfn = alloc_spfn + d->tot_pages; 1.22 1.23 if ( (rc = parseelfimage(&dsi)) != 0 ) 1.24 return rc; 1.25 @@ -166,7 +166,7 @@ int construct_dom0(struct domain *d, 1.26 return -EINVAL; 1.27 } 1.28 if (strstr(dsi.xen_section_string, "SHADOW=translate")) 1.29 - opt_dom0_translate = 1; 1.30 + opt_dom0_translate = 1; 1.31 1.32 /* Align load address to 4MB boundary. */ 1.33 dsi.v_start &= ~((1UL<<22)-1); 1.34 @@ -215,12 +215,12 @@ int construct_dom0(struct domain *d, 1.35 #endif 1.36 } 1.37 1.38 - if ( (v_end - dsi.v_start) > (alloc_end - alloc_start) ) 1.39 + if ( ((v_end - dsi.v_start) >> PAGE_SHIFT) > (alloc_epfn - alloc_spfn) ) 1.40 panic("Insufficient contiguous RAM to build kernel image.\n"); 1.41 1.42 printk("PHYSICAL MEMORY ARRANGEMENT:\n" 1.43 - " Dom0 alloc.: %p->%p", 1.44 - _p(alloc_start), _p(alloc_end)); 1.45 + " Dom0 alloc.: %"PRIphysaddr"->%"PRIphysaddr, 1.46 + pfn_to_phys(alloc_spfn), pfn_to_phys(alloc_epfn)); 1.47 if ( d->tot_pages < nr_pages ) 1.48 printk(" (%lu pages to be allocated)", 1.49 nr_pages - d->tot_pages); 1.50 @@ -249,7 +249,8 @@ int construct_dom0(struct domain *d, 1.51 return -ENOMEM; 1.52 } 1.53 1.54 - mpt_alloc = (vpt_start - dsi.v_start) + alloc_start; 1.55 + mpt_alloc = (vpt_start - dsi.v_start) + 1.56 + (unsigned long)pfn_to_phys(alloc_spfn); 1.57 1.58 /* 1.59 * We're basically forcing default RPLs to 1, so that our "what privilege 1.60 @@ -306,7 +307,7 @@ int construct_dom0(struct domain *d, 1.61 #endif 1.62 1.63 l2tab += l2_linear_offset(dsi.v_start); 1.64 - mfn = alloc_start >> PAGE_SHIFT; 1.65 + mfn = alloc_spfn; 1.66 for ( count = 0; count < ((v_end-dsi.v_start)>>PAGE_SHIFT); count++ ) 1.67 { 1.68 if ( !((unsigned long)l1tab & (PAGE_SIZE-1)) ) 1.69 @@ -428,7 +429,7 @@ int construct_dom0(struct domain *d, 1.70 v->arch.guest_table = mk_pagetable(__pa(l4start)); 1.71 1.72 l4tab += l4_table_offset(dsi.v_start); 1.73 - mfn = alloc_start >> PAGE_SHIFT; 1.74 + mfn = alloc_spfn; 1.75 for ( count = 0; count < ((v_end-dsi.v_start)>>PAGE_SHIFT); count++ ) 1.76 { 1.77 if ( !((unsigned long)l1tab & (PAGE_SIZE-1)) ) 1.78 @@ -563,11 +564,11 @@ int construct_dom0(struct domain *d, 1.79 /* Write the phys->machine and machine->phys table entries. */ 1.80 for ( pfn = 0; pfn < d->tot_pages; pfn++ ) 1.81 { 1.82 - mfn = pfn + (alloc_start>>PAGE_SHIFT); 1.83 + mfn = pfn + alloc_spfn; 1.84 #ifndef NDEBUG 1.85 #define REVERSE_START ((v_end - dsi.v_start) >> PAGE_SHIFT) 1.86 if ( !opt_dom0_translate && (pfn > REVERSE_START) ) 1.87 - mfn = (alloc_end>>PAGE_SHIFT) - (pfn - REVERSE_START); 1.88 + mfn = alloc_epfn - (pfn - REVERSE_START); 1.89 #endif 1.90 ((u32 *)vphysmap_start)[pfn] = mfn; 1.91 machine_to_phys_mapping[mfn] = pfn; 1.92 @@ -580,7 +581,7 @@ int construct_dom0(struct domain *d, 1.93 { 1.94 mfn = page_to_pfn(page); 1.95 #ifndef NDEBUG 1.96 -#define pfn (nr_pages - 1 - (pfn - ((alloc_end - alloc_start) >> PAGE_SHIFT))) 1.97 +#define pfn (nr_pages - 1 - (pfn - (alloc_epfn - alloc_spfn))) 1.98 #endif 1.99 ((u32 *)vphysmap_start)[pfn] = mfn; 1.100 machine_to_phys_mapping[mfn] = pfn; 1.101 @@ -620,13 +621,13 @@ int construct_dom0(struct domain *d, 1.102 1.103 if ( opt_dom0_shadow || opt_dom0_translate ) 1.104 { 1.105 - printk("dom0: shadow enable\n"); 1.106 + printk("dom0: shadow enable\n"); 1.107 shadow_mode_enable(d, (opt_dom0_translate 1.108 ? SHM_enable | SHM_refcounts | SHM_translate 1.109 : SHM_enable)); 1.110 if ( opt_dom0_translate ) 1.111 { 1.112 - printk("dom0: shadow translate\n"); 1.113 + printk("dom0: shadow translate\n"); 1.114 #if defined(__i386__) && defined(CONFIG_X86_PAE) 1.115 printk("FIXME: PAE code needed here: %s:%d (%s)\n", 1.116 __FILE__, __LINE__, __FUNCTION__); 1.117 @@ -659,7 +660,7 @@ int construct_dom0(struct domain *d, 1.118 } 1.119 1.120 update_pagetables(v); /* XXX SMP */ 1.121 - printk("dom0: shadow setup done\n"); 1.122 + printk("dom0: shadow setup done\n"); 1.123 } 1.124 1.125 return 0;
2.1 --- a/xen/include/asm-x86/page.h Wed Aug 10 13:06:00 2005 +0000 2.2 +++ b/xen/include/asm-x86/page.h Wed Aug 10 14:11:40 2005 +0000 2.3 @@ -189,6 +189,9 @@ typedef struct { u64 pfn; } pagetable_t; 2.4 #define virt_to_page(kaddr) (frame_table + (__pa(kaddr) >> PAGE_SHIFT)) 2.5 #define pfn_valid(_pfn) ((_pfn) < max_page) 2.6 2.7 +#define pfn_to_phys(pfn) ((physaddr_t)(pfn) << PAGE_SHIFT) 2.8 +#define phys_to_pfn(pa) ((unsigned long)((pa) >> PAGE_SHIFT)) 2.9 + 2.10 /* High table entries are reserved by the hypervisor. */ 2.11 #if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE) 2.12 #define DOMAIN_ENTRIES_PER_L2_PAGETABLE \
3.1 --- a/xen/include/asm-x86/types.h Wed Aug 10 13:06:00 2005 +0000 3.2 +++ b/xen/include/asm-x86/types.h Wed Aug 10 14:11:40 2005 +0000 3.3 @@ -38,13 +38,16 @@ typedef signed long long s64; 3.4 typedef unsigned long long u64; 3.5 #if defined(CONFIG_X86_PAE) 3.6 typedef u64 physaddr_t; 3.7 +#define PRIphysaddr "016llx" 3.8 #else 3.9 -typedef u32 physaddr_t; 3.10 +typedef unsigned long physaddr_t; 3.11 +#define PRIphysaddr "08lx" 3.12 #endif 3.13 #elif defined(__x86_64__) 3.14 typedef signed long s64; 3.15 typedef unsigned long u64; 3.16 -typedef u64 physaddr_t; 3.17 +typedef unsigned long physaddr_t; 3.18 +#define PRIphysaddr "016lx" 3.19 #endif 3.20 3.21 typedef unsigned long size_t;