# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID a64ac7fafbf09edc49a2df4c9c61968758dfacd8
# Parent d95ea17567c695cb7883d5a5842a164951fccd10
PAE page directories must be below 4GB. Based on a patch
from Gerd Knorr.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
diff -r d95ea17567c6 -r a64ac7fafbf0
linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c Thu Aug 11 08:59:47 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c Thu Aug 11 10:34:32 2005
@@ -25,6 +25,7 @@
#include <asm/mmu_context.h>
#include <asm-xen/foreign_page.h>
+#include <asm-xen/hypervisor.h>
void show_mem(void)
{
@@ -273,6 +274,11 @@
void pgd_ctor(void *pgd, kmem_cache_t *cache, unsigned long unused)
{
unsigned long flags;
+
+#ifdef CONFIG_X86_PAE
+ /* this gives us a page below 4GB */
+ xen_contig_memory((unsigned long)pgd, 0);
+#endif
if (!HAVE_SHARED_KERNEL_PMD)
spin_lock_irqsave(&pgd_lock, flags);
diff -r d95ea17567c6 -r a64ac7fafbf0 xen/arch/x86/domain_build.c
--- a/xen/arch/x86/domain_build.c Thu Aug 11 08:59:47 2005
+++ b/xen/arch/x86/domain_build.c Thu Aug 11 10:34:32 2005
@@ -74,7 +74,7 @@
unsigned long _initrd_start, unsigned long initrd_len,
char *cmdline)
{
- int i, rc, dom0_pae, xen_pae;
+ int i, rc, dom0_pae, xen_pae, order;
unsigned long pfn, mfn;
unsigned long nr_pages;
unsigned long nr_pt_pages;
@@ -143,10 +143,6 @@
nr_pages = avail_domheap_pages() +
((initrd_len + PAGE_SIZE - 1) >> PAGE_SHIFT) +
((image_len + PAGE_SIZE - 1) >> PAGE_SHIFT);
- if ( (page = alloc_largest(d, nr_pages)) == NULL )
- panic("Not enough RAM for DOM0 reservation.\n");
- alloc_spfn = page_to_pfn(page);
- alloc_epfn = alloc_spfn + d->tot_pages;
if ( (rc = parseelfimage(&dsi)) != 0 )
return rc;
@@ -215,8 +211,15 @@
#endif
}
- if ( ((v_end - dsi.v_start) >> PAGE_SHIFT) > (alloc_epfn - alloc_spfn) )
- panic("Insufficient contiguous RAM to build kernel image.\n");
+ order = get_order(v_end - dsi.v_start);
+ if ( (1UL << order) > nr_pages )
+ panic("Domain 0 allocation is too small for kernel image.\n");
+
+ /* Allocate from DMA pool: PAE L3 table must be below 4GB boundary. */
+ if ( (page = alloc_domheap_pages(d, order, ALLOC_DOM_DMA)) == NULL )
+ panic("Not enough RAM for domain 0 allocation.\n");
+ alloc_spfn = page_to_pfn(page);
+ alloc_epfn = alloc_spfn + d->tot_pages;
printk("PHYSICAL MEMORY ARRANGEMENT:\n"
" Dom0 alloc.: %"PRIphysaddr"->%"PRIphysaddr,
diff -r d95ea17567c6 -r a64ac7fafbf0 xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c Thu Aug 11 08:59:47 2005
+++ b/xen/arch/x86/mm.c Thu Aug 11 10:34:32 2005
@@ -856,6 +856,14 @@
ASSERT(!shadow_mode_refcounts(d));
+#ifdef CONFIG_X86_PAE
+ if ( pfn >= 0x100000 )
+ {
+ MEM_LOG("PAE pgd must be below 4GB (0x%lx >= 0x100000)", pfn);
+ return 0;
+ }
+#endif
+
pl3e = map_domain_page(pfn);
for ( i = 0; i < L3_PAGETABLE_ENTRIES; i++ )
{
diff -r d95ea17567c6 -r a64ac7fafbf0 xen/include/asm-x86/page.h
--- a/xen/include/asm-x86/page.h Thu Aug 11 08:59:47 2005
+++ b/xen/include/asm-x86/page.h Thu Aug 11 10:34:32 2005
@@ -283,13 +283,9 @@
static __inline__ int get_order(unsigned long size)
{
int order;
-
- size = (size-1) >> (PAGE_SHIFT-1);
- order = -1;
- do {
+ size = (size-1) >> PAGE_SHIFT;
+ for ( order = 0; size; order++ )
size >>= 1;
- order++;
- } while (size);
return order;
}
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|