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

[Xen-changelog] Important domU/vbd fix. Reserve top granule of machine memory for dom0.



# HG changeset patch
# User djm@xxxxxxxxxxxxxxx
# Node ID 545ba1b126ca2f06861c3982c4da33dd310e7717
# Parent  9a72d15cc3a57d1a9aa14f6a93ccad6afd13f336
Important domU/vbd fix.  Reserve top granule of machine memory for dom0.

diff -r 9a72d15cc3a5 -r 545ba1b126ca xen/arch/ia64/xen/dom_fw.c
--- a/xen/arch/ia64/xen/dom_fw.c        Mon Dec 19 21:18:54 2005
+++ b/xen/arch/ia64/xen/dom_fw.c        Tue Dec 20 20:11:17 2005
@@ -13,6 +13,7 @@
 #include <asm/io.h>
 #include <asm/pal.h>
 #include <asm/sal.h>
+#include <asm/meminit.h>
 #include <xen/compile.h>
 #include <xen/acpi.h>
 
@@ -95,12 +96,7 @@
 #define MB     (1024*1024UL)
 
 #define NUM_EFI_SYS_TABLES 6
-#define PASS_THRU_IOPORT_SPACE
-#ifdef PASS_THRU_IOPORT_SPACE
-# define NUM_MEM_DESCS 4
-#else
-# define NUM_MEM_DESCS 3
-#endif
+# define NUM_MEM_DESCS 5
 
 
 #define SECS_PER_HOUR   (60 * 60)
@@ -806,30 +802,53 @@
 
        sal_systab->checksum = -checksum;
 
-       /* simulate 1MB free memory at physical address zero */
        i = 0;
-       MAKE_MD(EFI_BOOT_SERVICES_DATA,EFI_MEMORY_WB,0*MB,1*MB, 0);
-       /* hypercall patches live here, masquerade as reserved PAL memory */
-       MAKE_MD(EFI_PAL_CODE,EFI_MEMORY_WB,HYPERCALL_START,HYPERCALL_END, 0);
-       MAKE_MD(EFI_CONVENTIONAL_MEMORY,EFI_MEMORY_WB,HYPERCALL_END,maxmem, 0);
-#ifdef PASS_THRU_IOPORT_SPACE
-       if (d == dom0 && !running_on_sim) {
+       if (d == dom0) {
+               /*
+                * This is a bad hack.  Dom0 may share other domains' memory
+                * through a dom0 physical address.  Unfortunately, this
+                * address may be used in phys_to_page (e.g. in the loopback
+                * driver) but when Linux initializes memory it only creates
+                * page structs for the physical memory it knows about.  And
+                * on ia64, only for full writeback granules.  So, we reserve
+                * the last full granule of Xen's memory for dom0 (in
+                * start_kernel) to ensure dom0 creates a large enough memmap
+                */
+               unsigned long last_start = max_page << PAGE_SHIFT;
+               unsigned long last_end = last_start + IA64_GRANULE_SIZE;
+
+               /* simulate 1MB free memory at physical address zero */
+               MAKE_MD(EFI_LOADER_DATA,EFI_MEMORY_WB,0*MB,1*MB, 0);
+               /* hypercall patches live here, masquerade as reserved PAL 
memory */
+               
MAKE_MD(EFI_PAL_CODE,EFI_MEMORY_WB,HYPERCALL_START,HYPERCALL_END, 0);
+               
MAKE_MD(EFI_CONVENTIONAL_MEMORY,EFI_MEMORY_WB,HYPERCALL_END,maxmem-IA64_GRANULE_SIZE,
 0);
+/* hack */     
MAKE_MD(EFI_CONVENTIONAL_MEMORY,EFI_MEMORY_WB,last_start,last_end,1);
+
                /* pass through the I/O port space */
-               efi_memory_desc_t *efi_get_io_md(void);
-               efi_memory_desc_t *ia64_efi_io_md = efi_get_io_md();
-               u32 type;
-               u64 iostart, ioend, ioattr;
-               
-               type = ia64_efi_io_md->type;
-               iostart = ia64_efi_io_md->phys_addr;
-               ioend = ia64_efi_io_md->phys_addr +
-                       (ia64_efi_io_md->num_pages << 12);
-               ioattr = ia64_efi_io_md->attribute;
-               MAKE_MD(type,ioattr,iostart,ioend, 1);
-       }
-       else
+               if (!running_on_sim) {
+                       efi_memory_desc_t *efi_get_io_md(void);
+                       efi_memory_desc_t *ia64_efi_io_md;
+                       u32 type;
+                       u64 iostart, ioend, ioattr;
+
+                       ia64_efi_io_md = efi_get_io_md();
+                       type = ia64_efi_io_md->type;
+                       iostart = ia64_efi_io_md->phys_addr;
+                       ioend = ia64_efi_io_md->phys_addr +
+                               (ia64_efi_io_md->num_pages << 12);
+                       ioattr = ia64_efi_io_md->attribute;
+                       MAKE_MD(type,ioattr,iostart,ioend, 1);
+               }
+               else MAKE_MD(EFI_RESERVED_TYPE,0,0,0,0);
+       }
+       else {
+               MAKE_MD(EFI_LOADER_DATA,EFI_MEMORY_WB,0*MB,1*MB, 1);
+               /* hypercall patches live here, masquerade as reserved PAL 
memory */
+               
MAKE_MD(EFI_PAL_CODE,EFI_MEMORY_WB,HYPERCALL_START,HYPERCALL_END, 1);
+               
MAKE_MD(EFI_CONVENTIONAL_MEMORY,EFI_MEMORY_WB,HYPERCALL_END,maxmem, 1);
                MAKE_MD(EFI_RESERVED_TYPE,0,0,0,0);
-#endif
+               MAKE_MD(EFI_RESERVED_TYPE,0,0,0,0);
+       }
 
        bp->efi_systab = dom_pa(fw_mem);
        bp->efi_memmap = dom_pa(efi_memmap);
diff -r 9a72d15cc3a5 -r 545ba1b126ca xen/arch/ia64/xen/xensetup.c
--- a/xen/arch/ia64/xen/xensetup.c      Mon Dec 19 21:18:54 2005
+++ b/xen/arch/ia64/xen/xensetup.c      Tue Dec 20 20:11:17 2005
@@ -247,6 +247,11 @@
     max_page = 0;
     efi_memmap_walk(find_max_pfn, &max_page);
     printf("find_memory: efi_memmap_walk returns max_page=%lx\n",max_page);
+    /* this is a bad hack.  see dom_fw.c creation of EFI map for dom0 */
+    max_page = (GRANULEROUNDDOWN(max_page << PAGE_SHIFT)
+       - IA64_GRANULE_SIZE) >> PAGE_SHIFT;
+    printf("find_memory: last granule reserved for dom0; xen max_page=%lx\n",
+       max_page);
 
     heap_start = memguard_init(ia64_imva(&_end));
     printf("Before heap_start: 0x%lx\n", heap_start);

_______________________________________________
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®.