# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 4fa90e2a32578379e196bc7d856cf09b87a53277
# Parent 839d3ac75da39ecbffe9321155725735c6c21bce
Fix domain0 builder for PAE.
Signed-off-by: Chris Wright <chrisw@xxxxxxxx>
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
diff -r 839d3ac75da3 -r 4fa90e2a3257 xen/arch/x86/domain_build.c
--- a/xen/arch/x86/domain_build.c Wed Aug 10 13:06:00 2005
+++ b/xen/arch/x86/domain_build.c Wed Aug 10 14:11:40 2005
@@ -78,8 +78,8 @@
unsigned long pfn, mfn;
unsigned long nr_pages;
unsigned long nr_pt_pages;
- unsigned long alloc_start;
- unsigned long alloc_end;
+ unsigned long alloc_spfn;
+ unsigned long alloc_epfn;
unsigned long count;
struct pfn_info *page = NULL;
start_info_t *si;
@@ -145,8 +145,8 @@
((image_len + PAGE_SIZE - 1) >> PAGE_SHIFT);
if ( (page = alloc_largest(d, nr_pages)) == NULL )
panic("Not enough RAM for DOM0 reservation.\n");
- alloc_start = page_to_phys(page);
- alloc_end = alloc_start + (d->tot_pages << PAGE_SHIFT);
+ alloc_spfn = page_to_pfn(page);
+ alloc_epfn = alloc_spfn + d->tot_pages;
if ( (rc = parseelfimage(&dsi)) != 0 )
return rc;
@@ -166,7 +166,7 @@
return -EINVAL;
}
if (strstr(dsi.xen_section_string, "SHADOW=translate"))
- opt_dom0_translate = 1;
+ opt_dom0_translate = 1;
/* Align load address to 4MB boundary. */
dsi.v_start &= ~((1UL<<22)-1);
@@ -215,12 +215,12 @@
#endif
}
- if ( (v_end - dsi.v_start) > (alloc_end - alloc_start) )
+ if ( ((v_end - dsi.v_start) >> PAGE_SHIFT) > (alloc_epfn - alloc_spfn) )
panic("Insufficient contiguous RAM to build kernel image.\n");
printk("PHYSICAL MEMORY ARRANGEMENT:\n"
- " Dom0 alloc.: %p->%p",
- _p(alloc_start), _p(alloc_end));
+ " Dom0 alloc.: %"PRIphysaddr"->%"PRIphysaddr,
+ pfn_to_phys(alloc_spfn), pfn_to_phys(alloc_epfn));
if ( d->tot_pages < nr_pages )
printk(" (%lu pages to be allocated)",
nr_pages - d->tot_pages);
@@ -249,7 +249,8 @@
return -ENOMEM;
}
- mpt_alloc = (vpt_start - dsi.v_start) + alloc_start;
+ mpt_alloc = (vpt_start - dsi.v_start) +
+ (unsigned long)pfn_to_phys(alloc_spfn);
/*
* We're basically forcing default RPLs to 1, so that our "what privilege
@@ -306,7 +307,7 @@
#endif
l2tab += l2_linear_offset(dsi.v_start);
- mfn = alloc_start >> PAGE_SHIFT;
+ mfn = alloc_spfn;
for ( count = 0; count < ((v_end-dsi.v_start)>>PAGE_SHIFT); count++ )
{
if ( !((unsigned long)l1tab & (PAGE_SIZE-1)) )
@@ -428,7 +429,7 @@
v->arch.guest_table = mk_pagetable(__pa(l4start));
l4tab += l4_table_offset(dsi.v_start);
- mfn = alloc_start >> PAGE_SHIFT;
+ mfn = alloc_spfn;
for ( count = 0; count < ((v_end-dsi.v_start)>>PAGE_SHIFT); count++ )
{
if ( !((unsigned long)l1tab & (PAGE_SIZE-1)) )
@@ -563,11 +564,11 @@
/* Write the phys->machine and machine->phys table entries. */
for ( pfn = 0; pfn < d->tot_pages; pfn++ )
{
- mfn = pfn + (alloc_start>>PAGE_SHIFT);
+ mfn = pfn + alloc_spfn;
#ifndef NDEBUG
#define REVERSE_START ((v_end - dsi.v_start) >> PAGE_SHIFT)
if ( !opt_dom0_translate && (pfn > REVERSE_START) )
- mfn = (alloc_end>>PAGE_SHIFT) - (pfn - REVERSE_START);
+ mfn = alloc_epfn - (pfn - REVERSE_START);
#endif
((u32 *)vphysmap_start)[pfn] = mfn;
machine_to_phys_mapping[mfn] = pfn;
@@ -580,7 +581,7 @@
{
mfn = page_to_pfn(page);
#ifndef NDEBUG
-#define pfn (nr_pages - 1 - (pfn - ((alloc_end - alloc_start) >> PAGE_SHIFT)))
+#define pfn (nr_pages - 1 - (pfn - (alloc_epfn - alloc_spfn)))
#endif
((u32 *)vphysmap_start)[pfn] = mfn;
machine_to_phys_mapping[mfn] = pfn;
@@ -620,13 +621,13 @@
if ( opt_dom0_shadow || opt_dom0_translate )
{
- printk("dom0: shadow enable\n");
+ printk("dom0: shadow enable\n");
shadow_mode_enable(d, (opt_dom0_translate
? SHM_enable | SHM_refcounts | SHM_translate
: SHM_enable));
if ( opt_dom0_translate )
{
- printk("dom0: shadow translate\n");
+ printk("dom0: shadow translate\n");
#if defined(__i386__) && defined(CONFIG_X86_PAE)
printk("FIXME: PAE code needed here: %s:%d (%s)\n",
__FILE__, __LINE__, __FUNCTION__);
@@ -659,7 +660,7 @@
}
update_pagetables(v); /* XXX SMP */
- printk("dom0: shadow setup done\n");
+ printk("dom0: shadow setup done\n");
}
return 0;
diff -r 839d3ac75da3 -r 4fa90e2a3257 xen/include/asm-x86/page.h
--- a/xen/include/asm-x86/page.h Wed Aug 10 13:06:00 2005
+++ b/xen/include/asm-x86/page.h Wed Aug 10 14:11:40 2005
@@ -188,6 +188,9 @@
#define phys_to_page(kaddr) (frame_table + ((kaddr) >> PAGE_SHIFT))
#define virt_to_page(kaddr) (frame_table + (__pa(kaddr) >> PAGE_SHIFT))
#define pfn_valid(_pfn) ((_pfn) < max_page)
+
+#define pfn_to_phys(pfn) ((physaddr_t)(pfn) << PAGE_SHIFT)
+#define phys_to_pfn(pa) ((unsigned long)((pa) >> PAGE_SHIFT))
/* High table entries are reserved by the hypervisor. */
#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
diff -r 839d3ac75da3 -r 4fa90e2a3257 xen/include/asm-x86/types.h
--- a/xen/include/asm-x86/types.h Wed Aug 10 13:06:00 2005
+++ b/xen/include/asm-x86/types.h Wed Aug 10 14:11:40 2005
@@ -38,13 +38,16 @@
typedef unsigned long long u64;
#if defined(CONFIG_X86_PAE)
typedef u64 physaddr_t;
+#define PRIphysaddr "016llx"
#else
-typedef u32 physaddr_t;
+typedef unsigned long physaddr_t;
+#define PRIphysaddr "08lx"
#endif
#elif defined(__x86_64__)
typedef signed long s64;
typedef unsigned long u64;
-typedef u64 physaddr_t;
+typedef unsigned long physaddr_t;
+#define PRIphysaddr "016lx"
#endif
typedef unsigned long size_t;
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|