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] [ia64] efi: allow efi memory regions to be dump

To: xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-ia64-devel] [PATCH] [ia64] efi: allow efi memory regions to be dumped at boot
From: Simon Horman <horms@xxxxxxxxxxxx>
Date: Tue, 26 Feb 2008 13:42:31 +0900
Cc: Alex Williamson <alex.williamson@xxxxxx>
Delivery-date: Mon, 25 Feb 2008 20:46:25 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
In Linux, when EFI_DEBUG in xen/arch/ia64/linux-xen/efi.c is set to
a non-zero value the EFI memory regions, as supplied by the
boot parameter are displayed. Unfortunately this doesn't work
on Xen as the console is not available at this time.

* Allow the memory region printing code (print_md()) used
  to show the virtualised EFI regions used by by domains to also
  be used to show the physical regions.

* Allow print_md() to print a region using a single call to printk -
  previously 2 were used, which seems dubious.

* Enhance print_md() to show TB and GB as well as MB and KB.
  On the rx2620 box I use there us a (reserved) region
  of 8TB in size. 8TB seems much more readable than
  8388608MB to me.

* Pad the size displayed by print_md() with whitespace for readability.

* Wrap the current EFI range dumping code inherited from Linux
  with #ifdef XEN. As mentioned above it doesn't work.

* Add a new efi_dump_mem() call which does nothing unless
  EFI_DEBUG is non-zero. Call this function from within
  start_kernel().

Although its just debugging code, I have found this very useful and
I believe others may too.

Signed-off-by: Simon Horman <horms@xxxxxxxxxxxx>

--- 
The output for the hypervisor memory will look like:

(XEN) mem00: type= 4, attr=0x0000000000000008, 
range=[0x0000000000000000-0x0000000000001000) (   4KB)
(XEN) mem01: type= 7, attr=0x0000000000000008, 
range=[0x0000000000001000-0x00000000000a0000) ( 636KB)
(XEN) mem02: type=11, attr=0x0000000000000003, 
range=[0x00000000000a0000-0x00000000000c0000) ( 128KB)
(XEN) mem03: type= 5, attr=0x8000000000000001, 
range=[0x00000000000c0000-0x0000000000100000) ( 256KB)
(XEN) mem04: type= 7, attr=0x0000000000000008, 
range=[0x0000000000100000-0x0000000004000000) (  63MB)
(XEN) mem05: type= 2, attr=0x0000000000000008, 
range=[0x0000000004000000-0x00000000041f0000) (   1MB)
(XEN) mem06: type= 7, attr=0x0000000000000008, 
range=[0x00000000041f0000-0x000000003e695000) ( 932MB)

The output for domain memory will look like:

(XEN) dom mem00: type=13, attr=0x8000000000000008, 
range=[0x0000000000000000-0x0000000000001000) (   4KB)
(XEN) dom mem01: type=10, attr=0x8000000000000008, 
range=[0x0000000000001000-0x0000000000002000) (   4KB)
(XEN) dom mem02: type= 6, attr=0x8000000000000008, 
range=[0x0000000000002000-0x0000000000003000) (   4KB)
(XEN) dom mem03: type= 7, attr=0x0000000000000008, 
range=[0x0000000000003000-0x00000000000a0000) ( 628KB)
(XEN) dom mem04: type=11, attr=0x0000000000000003, 
range=[0x00000000000a0000-0x00000000000c0000) ( 128KB)
(XEN) dom mem05: type= 5, attr=0x8000000000000001, 
range=[0x00000000000c0000-0x0000000000100000) ( 256KB)
(XEN) dom mem06: type= 7, attr=0x0000000000000008, 
range=[0x0000000000100000-0x0000000004000000) (  63MB)
(XEN) dom mem07: type= 7, attr=0x0000000000000008, 
range=[0x0000000004000000-0x00000000041f0000) (   1MB)
(XEN) dom mem08: type= 7, attr=0x0000000000000008, 
range=[0x00000000041f0000-0x000000003e4a5000) ( 930MB)

Index: xen-unstable.hg/xen/arch/ia64/linux-xen/efi.c
===================================================================
--- xen-unstable.hg.orig/xen/arch/ia64/linux-xen/efi.c  2008-02-26 
12:31:51.000000000 +0900
+++ xen-unstable.hg/xen/arch/ia64/linux-xen/efi.c       2008-02-26 
13:29:44.000000000 +0900
@@ -577,6 +577,7 @@ efi_init (void)
        efi_map_end   = efi_map_start + ia64_boot_param->efi_memmap_size;
        efi_desc_size = ia64_boot_param->efi_memdesc_size;
 
+#ifndef XEN
 #if EFI_DEBUG
        /* print EFI memory map: */
        {
@@ -592,11 +593,67 @@ efi_init (void)
                }
        }
 #endif
+#endif
 
        efi_map_pal_code();
        efi_enter_virtual_mode();
 }
 
+#ifdef XEN
+/* print EFI memory map: */
+void __init
+efi_dump_mem (void)
+{
+#if EFI_DEBUG
+       void *efi_map_start;
+       void *efi_map_end;
+       u64 efi_desc_size;
+       void *p;
+       int i;
+
+       efi_map_start = __va(ia64_boot_param->efi_memmap);
+       efi_map_end   = efi_map_start + ia64_boot_param->efi_memmap_size;
+       efi_desc_size = ia64_boot_param->efi_memdesc_size;
+
+       for (i = 0, p = efi_map_start; p < efi_map_end;
+            ++i, p += efi_desc_size)
+               print_md("mem", i, p);
+#endif
+}
+
+void
+print_md(const char *prefix, int index, efi_memory_desc_t *md)
+{
+       uint64_t size = md->num_pages << EFI_PAGE_SHIFT;
+       const char *unit;
+
+       size = md->num_pages << EFI_PAGE_SHIFT;
+
+       if ((size >> 40) > 0) {
+               size >>= 40;
+               unit ="TB";
+       }
+       else if ((size >> 30) > 0) {
+               size >>= 30;
+               unit ="GB";
+       }
+       else if ((size >> 20) > 0) {
+               size >>= 20;
+               unit ="MB";
+       }
+       else {
+               size >>= 10;
+               unit ="KB";
+       }
+
+       printk(KERN_INFO "%s%02d: type=%2u, attr=0x%016lx, "
+              "range=[0x%016lx-0x%016lx) (%4lu%s)\n", prefix, index,
+              md->type, md->attribute, md->phys_addr,
+              md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT), size, unit);
+
+}
+#endif
+
 void
 efi_enter_virtual_mode (void)
 {
Index: xen-unstable.hg/xen/arch/ia64/xen/dom_fw_common.c
===================================================================
--- xen-unstable.hg.orig/xen/arch/ia64/xen/dom_fw_common.c      2008-02-26 
12:31:51.000000000 +0900
+++ xen-unstable.hg/xen/arch/ia64/xen/dom_fw_common.c   2008-02-26 
13:29:44.000000000 +0900
@@ -190,23 +190,6 @@ dom_fw_pal_hypercall_patch(uint64_t brki
                                    brkimm, FW_HYPERCALL_PAL_CALL);
 }
 
-static inline void
-print_md(efi_memory_desc_t *md)
-{
-       uint64_t size;
-       
-       printk(XENLOG_INFO "dom mem: type=%2u, attr=0x%016lx, "
-              "range=[0x%016lx-0x%016lx) ",
-              md->type, md->attribute, md->phys_addr,
-              md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT));
-
-       size = md->num_pages << EFI_PAGE_SHIFT;
-       if (size > ONE_MB)
-               printk("(%luMB)\n", size >> 20);
-       else
-               printk("(%luKB)\n", size >> 10);
-}
-
 struct fake_acpi_tables {
        struct acpi20_table_rsdp rsdp;
        struct xsdt_descriptor_rev2 xsdt;
@@ -543,7 +526,7 @@ dom_fw_init(domain_t *d,
 
        /* Display memmap.  */
        for (i = 0 ; i < tables->num_mds; i++)
-               print_md(&tables->efi_memmap[i]);
+               print_md("dom mem", i, &tables->efi_memmap[i]);
 
        /* Fill boot_param  */
        bp->efi_systab = FW_FIELD_MPA(efi_systab);
Index: xen-unstable.hg/xen/include/asm-ia64/linux-xen/linux/efi.h
===================================================================
--- xen-unstable.hg.orig/xen/include/asm-ia64/linux-xen/linux/efi.h     
2008-02-26 12:31:51.000000000 +0900
+++ xen-unstable.hg/xen/include/asm-ia64/linux-xen/linux/efi.h  2008-02-26 
13:29:44.000000000 +0900
@@ -309,6 +309,10 @@ efi_guid_unparse(efi_guid_t *guid, char 
 }
 
 extern void efi_init (void);
+#if XEN
+extern void efi_dump_mem (void);
+extern void print_md(const char *prefix, int index, efi_memory_desc_t *md);
+#endif
 extern void *efi_get_pal_addr (void);
 extern void efi_map_pal_code (void);
 extern void efi_map_memmap(void);
Index: xen-unstable.hg/xen/arch/ia64/xen/xensetup.c
===================================================================
--- xen-unstable.hg.orig/xen/arch/ia64/xen/xensetup.c   2008-02-26 
12:31:51.000000000 +0900
+++ xen-unstable.hg/xen/arch/ia64/xen/xensetup.c        2008-02-26 
13:29:44.000000000 +0900
@@ -403,6 +403,8 @@ void __init start_kernel(void)
     printk("xen image pstart: 0x%lx, xenheap pend: 0x%lx\n",
            xen_pstart, xenheap_phys_end);
 
+    efi_dump_mem();
+
     xen_patch_kernel();
 
     kern_md = md = efi_get_md(xen_pstart);

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