[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] Re-factor e820 truncation code and reintroduce clipping for 32-on-64



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1184062238 -3600
# Node ID 1f348e70a5affdea9b44c1e39cd5ef094ad4a0bf
# Parent  73290f6fe70a56a093f0a6224a14013e53686c71
Re-factor e820 truncation code and reintroduce clipping for 32-on-64
guests (to 166GB).
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 xen/arch/x86/e820.c |   71 ++++++++++++++++++++--------------------------------
 1 files changed, 28 insertions(+), 43 deletions(-)

diff -r 73290f6fe70a -r 1f348e70a5af xen/arch/x86/e820.c
--- a/xen/arch/x86/e820.c       Tue Jul 10 10:22:41 2007 +0100
+++ b/xen/arch/x86/e820.c       Tue Jul 10 11:10:38 2007 +0100
@@ -310,23 +310,22 @@ static unsigned long __init find_max_pfn
     return max_pfn;
 }
 
-#ifdef __i386__
-static void __init clip_4gb(void)
-{
-    unsigned long long limit = (1ULL << 30) * MACHPHYS_MBYTES;
-    int i;
-
-    /* 32-bit systems restricted to a 4GB physical memory map,
-     * with PAE to 16 GB (with current memory layout) */
+static void __init clip_to_limit(uint64_t limit, char *warnmsg)
+{
+    int i;
+    char _warnmsg[160];
+
     for ( i = 0; i < e820.nr_map; i++ )
     {
         if ( (e820.map[i].addr + e820.map[i].size) <= limit )
             continue;
-        printk("WARNING: Only the first %d GB of the physical memory map "
-               "can be accessed\n"
-               "         by Xen in 32-bit mode. "
-               "Truncating the memory map...\n",
-              MACHPHYS_MBYTES);
+        if ( warnmsg )
+        {
+            snprintf(_warnmsg, sizeof(_warnmsg), warnmsg, (int)(limit>>30));
+            printk("WARNING: %s\n", _warnmsg);
+        }
+        printk("Truncating memory map to %lukB\n",
+               (unsigned long)(limit >> 10));
         if ( e820.map[i].addr >= limit )
         {
             e820.nr_map = i;
@@ -336,34 +335,6 @@ static void __init clip_4gb(void)
             e820.map[i].size = limit - e820.map[i].addr;
             e820.nr_map = i + 1;                
         }            
-    }
-}
-#else
-#define clip_4gb() ((void)0)
-#endif
-
-static void __init clip_mem(void)
-{
-    int i;
-
-    if ( !opt_mem )
-        return;
-
-    for ( i = 0; i < e820.nr_map; i++ )
-    {
-        if ( (e820.map[i].addr + e820.map[i].size) <= opt_mem )
-            continue;
-        printk("Truncating memory map to %lukB\n",
-               (unsigned long)(opt_mem >> 10));
-        if ( e820.map[i].addr >= opt_mem )
-        {
-            e820.nr_map = i;
-        }
-        else
-        {
-            e820.map[i].size = opt_mem - e820.map[i].addr;
-            e820.nr_map = i + 1;          
-        }
     }
 }
 
@@ -374,8 +345,22 @@ static void __init machine_specific_memo
     sanitize_e820_map(raw, &nr);
     *raw_nr = nr;
     (void)copy_e820_map(raw, nr);
-    clip_4gb();
-    clip_mem();
+
+    if ( opt_mem )
+        clip_to_limit(opt_mem, NULL);
+
+#ifdef __i386__
+    clip_to_limit((1ULL << 30) * MACHPHYS_MBYTES,
+                  "Only the first %u GB of the physical memory map "
+                  "can be accessed by Xen in 32-bit mode.");
+#endif
+
+#ifdef __x86_64__
+    clip_to_limit((uint64_t)(MACH2PHYS_COMPAT_VIRT_END -
+                             __HYPERVISOR_COMPAT_VIRT_START) << 10,
+                  "Only the first %u GB of the physical memory map "
+                  "can be accessed by 32-on-64 guests.");
+#endif
 }
 
 unsigned long __init init_e820(

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.