WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ia64-devel

[Xen-ia64-devel] [PATCH] GFW: Install biggest memory range last to avoid

To: tgingold@xxxxxxx, xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-ia64-devel] [PATCH] GFW: Install biggest memory range last to avoid out of memory.
From: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
Date: Thu, 25 Sep 2008 14:27:09 +0900
Cc:
Delivery-date: Wed, 24 Sep 2008 22:27:15 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ia64-devel-request@lists.xensource.com?subject=help>
List-id: Discussion of the ia64 port of Xen <xen-ia64-devel.lists.xensource.com>
List-post: <mailto:xen-ia64-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.6i
This pach is same as the one I sent yesterday except commit log message.
I can see EFH shell with memory of 3098MB, 3094MB, 3079MB, 3077MB
and 3073MB. (With one more patch I sent out already.)

thanks,

Install biggest memory range last to avoid out of memory.

This patch fixes the issues that guest domain panic happens
when one of memory of 3073-3077, 3079-3094, 3098MB is
assigned to HVM guest.

Details:
The available memory is registered by PeiInstallPeiMemory()
in EdkXenPkg/Pei/XenMemoryScan/XenMemoryScan.c.
Then, the PEI page allocator, PeiAllocatePages(), allocates pages
from the area which is lastly registered.
The stack is allocated at the beginning (lowest address) of the lastly
registered area.
PeiAllocatePages() allocates pages from the end (highest address) of
the area and it doesn't check overlapping with stack. So if the last
registered area isn't large enough, it happens to use the stack page
and causes guest panic.
This looks like PEI memory allocator limitation.

On the other hand, Xen HVM domain memory is allocated as
[0, 0xA000) [VGA hole) [0xC000, 3GB) [hole for GFW) [4GB, end)
and those areas are registered in lower to higher order.
So if the memory assigned to the HVM domain is 3GB + small amount,
the last area, [4GB, end), happens to be very small and so the stack
is used.

Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>

diff -r dd0ca9fcc64a edk2-sparse/EdkXenPkg/Pei/XenMemoryScan/XenMemoryScan.c
--- a/edk2-sparse/EdkXenPkg/Pei/XenMemoryScan/XenMemoryScan.c   Wed Sep 24 
18:13:43 2008 +0900
+++ b/edk2-sparse/EdkXenPkg/Pei/XenMemoryScan/XenMemoryScan.c   Thu Sep 25 
14:25:55 2008 +0900
@@ -89,6 +89,8 @@
 
   UINT8 *hob = (UINT8 *)GFW_HOB_START;
   struct XenHobHeader *hdr;
+  UINT64 BaseOfMaxLen;
+  UINT64 MaxLen = 0UL;
 
   do
     {
@@ -101,6 +103,9 @@
       data = (UINT64 *)(hdr + 1);
       data_len = hdr->length - sizeof (struct XenHobHeader);
       if (hdr->type == HOB_TYPE_MEM && data_len == 16) {
+       UINT64 mem_start;
+       UINT64 mem_len = 0;
+
         Base = data[0];
         Len = data[1];
 
@@ -109,8 +114,6 @@
         // VGA RAM (0xA0000 ~ 0xBFFFF) + VGA ROM (0xC0000 ~ 0xDFFFF)
         //
         if (Base < VGA_END && (Base + Len) >= VGA_BASE) {
-          UINT64 mem_start;
-          UINT64 mem_len;
 
           if (Base < VGA_BASE) {
             mem_start = Base;
@@ -119,25 +122,45 @@
             RegisterMemoryArea(PeiServices, mem_start, mem_len);
             DEBUG((EFI_D_ERROR, "Build memory hob at 0x%lx, len is 0x%lx\n",
                    mem_start, mem_len));
+
+           mem_len = 0;
           }
 
           if (Base + Len > VGA_END) {
             mem_start = VGA_END;
             mem_len = (Base + Len) - VGA_END;
-
-            RegisterMemoryArea(PeiServices, mem_start, mem_len);
-            DEBUG((EFI_D_ERROR, "Build memory hob at 0x%lx, len is 0x%lx\n",
-                   mem_start, mem_len));
           }
         } else {
-          RegisterMemoryArea(PeiServices, Base, Len);
-          DEBUG((EFI_D_ERROR, "Build memory hob at 0x%lx, len is 0x%lx\n",
-                 Base, Len));
+         mem_start = Base;
+         mem_len = Len;
         }
+
+
+       if (mem_len > MaxLen) {
+         UINT64 tmp_mem_start = mem_start;
+         UINT64 tmp_mem_len = mem_len;
+
+         mem_start = BaseOfMaxLen;
+         mem_len = MaxLen;
+         
+         BaseOfMaxLen = tmp_mem_start;
+         MaxLen = tmp_mem_len;
+       }
+       if (mem_len > 0) {
+         RegisterMemoryArea(PeiServices, mem_start, mem_len);
+         DEBUG((EFI_D_ERROR, "Build memory hob at 0x%lx, len is 0x%lx\n",
+                mem_start, mem_len));
+       }
       }
       hob += hdr->length;
     }
   while (hdr->type != HOB_TYPE_TERMINAL);
+
+  if (MaxLen > 0) {
+    RegisterMemoryArea(PeiServices, BaseOfMaxLen, MaxLen);
+    DEBUG((EFI_D_ERROR, "Build memory hob at 0x%lx, len is 0x%lx\n",
+          BaseOfMaxLen, MaxLen));
+  }
 
   //
   // Build the CPU hob with 44-bit addressing and 16-bits of IO space.


-- 
yamahata

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-ia64-devel] [PATCH] GFW: Install biggest memory range last to avoid out of memory., Isaku Yamahata <=