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

[Xen-changelog] [xen-unstable] [IA64] free initmem and add __init and __initdata.



# HG changeset patch
# User Alex Williamson <alex.williamson@xxxxxx>
# Date 1179931902 21600
# Node ID 26492c6476f056e2940c1dc6c59e6f7aaec40bd3
# Parent  d305761238924735fc00fc091b3cf0bb5949517d
[IA64] free initmem and add __init and __initdata.

ia64 counter part of xen-unstable.hg 15043:759d924af6d8.
By freeing init area, un/pickle_domain() is broken because
__init_begin < xen_heap_start. This is fixed by introducing xen_pickle_offset.

Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
---
 xen/arch/ia64/xen/domain.c    |   20 +++++++++---------
 xen/arch/ia64/xen/faults.c    |    2 -
 xen/arch/ia64/xen/mm.c        |    4 +--
 xen/arch/ia64/xen/mm_init.c   |    2 -
 xen/arch/ia64/xen/regionreg.c |    2 -
 xen/arch/ia64/xen/vhpt.c      |    2 -
 xen/arch/ia64/xen/xenmem.c    |   14 ++++++-------
 xen/arch/ia64/xen/xenpatch.c  |    5 ++--
 xen/arch/ia64/xen/xensetup.c  |   45 ++++++++++++++++++++++++++++++------------
 xen/include/asm-ia64/config.h |    2 -
 xen/include/asm-ia64/mm.h     |    6 ++---
 11 files changed, 62 insertions(+), 42 deletions(-)

diff -r d30576123892 -r 26492c6476f0 xen/arch/ia64/xen/domain.c
--- a/xen/arch/ia64/xen/domain.c        Mon May 21 14:30:09 2007 -0600
+++ b/xen/arch/ia64/xen/domain.c        Wed May 23 08:51:42 2007 -0600
@@ -52,10 +52,10 @@
 #include <asm/perfmon.h>
 #include <public/vcpu.h>
 
-unsigned long dom0_size = 512*1024*1024;
+static unsigned long __initdata dom0_size = 512*1024*1024;
 
 /* dom0_max_vcpus: maximum number of VCPUs to create for dom0.  */
-static unsigned int dom0_max_vcpus = 1;
+static unsigned int __initdata dom0_max_vcpus = 1;
 integer_param("dom0_max_vcpus", dom0_max_vcpus); 
 
 extern unsigned long running_on_sim;
@@ -1109,7 +1109,7 @@ int shadow_mode_control(struct domain *d
 #define        privify_memory(x,y) do {} while(0)
 #endif
 
-static void loaddomainelfimage(struct domain *d, struct elf_binary *elf)
+static void __init loaddomainelfimage(struct domain *d, struct elf_binary *elf)
 {
        const elf_phdr *phdr;
        int phnum, h, filesz, memsz;
@@ -1163,7 +1163,7 @@ static void loaddomainelfimage(struct do
        }
 }
 
-void alloc_dom0(void)
+void __init alloc_dom0(void)
 {
        /* Check dom0 size.  */
        if (dom0_size < 4 * 1024 * 1024) {
@@ -1187,7 +1187,7 @@ void alloc_dom0(void)
  * handled with order > 0 request. Dom0 requires that bit set to
  * allocate memory for other domains.
  */
-static void physdev_init_dom0(struct domain *d)
+static void __init physdev_init_dom0(struct domain *d)
 {
        if (iomem_permit_access(d, 0UL, ~0UL))
                BUG();
@@ -1197,10 +1197,10 @@ static void physdev_init_dom0(struct dom
                BUG();
 }
 
-int construct_dom0(struct domain *d, 
-                      unsigned long image_start, unsigned long image_len, 
-                      unsigned long initrd_start, unsigned long initrd_len,
-                      char *cmdline)
+int __init construct_dom0(struct domain *d, 
+                         unsigned long image_start, unsigned long image_len, 
+                         unsigned long initrd_start, unsigned long initrd_len,
+                         char *cmdline)
 {
        int i, rc;
        start_info_t *si;
@@ -1464,7 +1464,7 @@ arch_do_vcpu_op(int cmd, struct vcpu *v,
        return rc;
 }
 
-static void parse_dom0_mem(char *s)
+static void __init parse_dom0_mem(char *s)
 {
        dom0_size = parse_size_and_unit(s, NULL);
 }
diff -r d30576123892 -r 26492c6476f0 xen/arch/ia64/xen/faults.c
--- a/xen/arch/ia64/xen/faults.c        Mon May 21 14:30:09 2007 -0600
+++ b/xen/arch/ia64/xen/faults.c        Wed May 23 08:51:42 2007 -0600
@@ -252,7 +252,7 @@ void ia64_do_page_fault(unsigned long ad
 
 fpswa_interface_t *fpswa_interface = 0;
 
-void trap_init(void)
+void __init trap_init(void)
 {
        if (ia64_boot_param->fpswa)
                /* FPSWA fixup: make the interface pointer a virtual address */
diff -r d30576123892 -r 26492c6476f0 xen/arch/ia64/xen/mm.c
--- a/xen/arch/ia64/xen/mm.c    Mon May 21 14:30:09 2007 -0600
+++ b/xen/arch/ia64/xen/mm.c    Wed May 23 08:51:42 2007 -0600
@@ -779,7 +779,7 @@ assign_new_domain_page(struct domain *d,
     return __assign_new_domain_page(d, mpaddr, pte);
 }
 
-void
+void __init
 assign_new_domain0_page(struct domain *d, unsigned long mpaddr)
 {
     volatile pte_t *pte;
@@ -1360,7 +1360,7 @@ dom0vp_add_physmap_with_gmfn(struct doma
 #ifdef CONFIG_XEN_IA64_EXPOSE_P2M
 static struct page_info* p2m_pte_zero_page = NULL;
 
-void
+void __init
 expose_p2m_init(void)
 {
     pte_t* pte;
diff -r d30576123892 -r 26492c6476f0 xen/arch/ia64/xen/mm_init.c
--- a/xen/arch/ia64/xen/mm_init.c       Mon May 21 14:30:09 2007 -0600
+++ b/xen/arch/ia64/xen/mm_init.c       Wed May 23 08:51:42 2007 -0600
@@ -115,7 +115,7 @@ ia64_mmu_init (void *my_cpu_data)
 #endif
 }
 
-void
+void __init
 mem_init (void)
 {
 #ifdef CONFIG_PCI
diff -r d30576123892 -r 26492c6476f0 xen/arch/ia64/xen/regionreg.c
--- a/xen/arch/ia64/xen/regionreg.c     Mon May 21 14:30:09 2007 -0600
+++ b/xen/arch/ia64/xen/regionreg.c     Wed May 23 08:51:42 2007 -0600
@@ -87,7 +87,7 @@ static int mp_rid_shift;
 static int mp_rid_shift;
 static struct domain *ridblock_owner[MAX_RID_BLOCKS] = { 0 };
 
-void init_rid_allocator (void)
+void __init init_rid_allocator (void)
 {
        int log_blocks;
        pal_vm_info_2_u_t vm_info_2;
diff -r d30576123892 -r 26492c6476f0 xen/arch/ia64/xen/vhpt.c
--- a/xen/arch/ia64/xen/vhpt.c  Mon May 21 14:30:09 2007 -0600
+++ b/xen/arch/ia64/xen/vhpt.c  Wed May 23 08:51:42 2007 -0600
@@ -117,7 +117,7 @@ void vhpt_multiple_insert(unsigned long 
        }
 }
 
-void vhpt_init(void)
+void __init vhpt_init(void)
 {
        unsigned long paddr;
        struct page_info *page;
diff -r d30576123892 -r 26492c6476f0 xen/arch/ia64/xen/xenmem.c
--- a/xen/arch/ia64/xen/xenmem.c        Mon May 21 14:30:09 2007 -0600
+++ b/xen/arch/ia64/xen/xenmem.c        Wed May 23 08:51:42 2007 -0600
@@ -46,7 +46,7 @@ unsigned long max_page;
  */
 volatile unsigned long *mpt_table __read_mostly;
 
-void
+void __init
 paging_init (void)
 {
        unsigned int mpt_order;
@@ -81,7 +81,7 @@ paging_init (void)
 
 #ifdef CONFIG_VIRTUAL_FRAME_TABLE
 
-static unsigned long
+static unsigned long __init
 alloc_dir_page(void)
 {
        unsigned long mfn = alloc_boot_pages(1, 1);
@@ -94,7 +94,7 @@ alloc_dir_page(void)
        return dir;
 }
 
-static inline unsigned long
+static inline unsigned long __init
 alloc_table_page(unsigned long fill)
 {
        unsigned long mfn = alloc_boot_pages(1, 1);
@@ -109,7 +109,7 @@ alloc_table_page(unsigned long fill)
        return mfn;
 }
 
-static void
+static void __init
 create_page_table(unsigned long start_page, unsigned long end_page,
                   unsigned long fill)
 {
@@ -131,7 +131,7 @@ create_page_table(unsigned long start_pa
        }
 }
 
-static int
+static int __init
 create_frametable_page_table (u64 start, u64 end, void *arg)
 {
        struct page_info *map_start, *map_end;
@@ -147,7 +147,7 @@ create_frametable_page_table (u64 start,
        return 0;
 }
 
-static int
+static int __init
 create_mpttable_page_table (u64 start, u64 end, void *arg)
 {
        unsigned long map_start, map_end;
@@ -163,7 +163,7 @@ create_mpttable_page_table (u64 start, u
        return 0;
 }
 
-void init_virtual_frametable(void)
+void __init init_virtual_frametable(void)
 {
        /* Allocate virtual frame_table */
        frame_table = (struct page_info *) VIRT_FRAME_TABLE_ADDR;
diff -r d30576123892 -r 26492c6476f0 xen/arch/ia64/xen/xenpatch.c
--- a/xen/arch/ia64/xen/xenpatch.c      Mon May 21 14:30:09 2007 -0600
+++ b/xen/arch/ia64/xen/xenpatch.c      Wed May 23 08:51:42 2007 -0600
@@ -21,6 +21,7 @@
 
 #include <xen/config.h>
 #include <xen/lib.h>
+#include <xen/init.h>
 #include <asm/xensystem.h>
 #include <asm/intrinsics.h>
 
@@ -96,7 +97,7 @@ extern unsigned long xen_pstart;
  * Add more patch points in seperate functions as appropriate
  */
 
-static void xen_patch_frametable_miss(u64 offset)
+static void __init xen_patch_frametable_miss(u64 offset)
 {
        u64 addr, val;
 
@@ -106,7 +107,7 @@ static void xen_patch_frametable_miss(u6
 }
 
 
-void xen_patch_kernel(void)
+void __init xen_patch_kernel(void)
 {
        unsigned long patch_offset;
 
diff -r d30576123892 -r 26492c6476f0 xen/arch/ia64/xen/xensetup.c
--- a/xen/arch/ia64/xen/xensetup.c      Mon May 21 14:30:09 2007 -0600
+++ b/xen/arch/ia64/xen/xensetup.c      Wed May 23 08:51:42 2007 -0600
@@ -33,7 +33,7 @@ unsigned long xenheap_phys_end, total_pa
 unsigned long xenheap_phys_end, total_pages;
 
 char saved_command_line[COMMAND_LINE_SIZE];
-char dom0_command_line[COMMAND_LINE_SIZE];
+char __initdata dom0_command_line[COMMAND_LINE_SIZE];
 
 cpumask_t cpu_present_map;
 
@@ -58,17 +58,17 @@ boolean_param("nosmp", opt_nosmp);
 boolean_param("nosmp", opt_nosmp);
 
 /* maxcpus: maximum number of CPUs to activate. */
-static unsigned int max_cpus = NR_CPUS;
+static unsigned int __initdata max_cpus = NR_CPUS;
 integer_param("maxcpus", max_cpus); 
 
 /* xencons: if true enable xenconsole input (and irq).
    Note: you have to disable 8250 serials in domains (to avoid use of the
    same resource).  */
-static int opt_xencons = 1;
+static int __initdata opt_xencons = 1;
 integer_param("xencons", opt_xencons);
 
 /* Toggle to allow non-legacy xencons UARTs to run in polling mode */
-static int opt_xencons_poll;
+static int __initdata opt_xencons_poll;
 boolean_param("xencons_poll", opt_xencons_poll);
 
 /*
@@ -85,9 +85,9 @@ unsigned long xenheap_size = XENHEAP_DEF
 unsigned long xenheap_size = XENHEAP_DEFAULT_SIZE;
 extern long running_on_sim;
 unsigned long xen_pstart;
-void *xen_heap_start __read_mostly;
-
-static int
+void *xen_pickle_offset __read_mostly;
+
+static int __init
 xen_count_pages(u64 start, u64 end, void *arg)
 {
     unsigned long *count = arg;
@@ -119,7 +119,7 @@ static void __init do_initcalls(void)
  */
 static char null[4] = { 0 };
 
-void early_cmdline_parse(char **cmdline_p)
+void __init early_cmdline_parse(char **cmdline_p)
 {
     char *guest_cmd;
     static const char * const split = "--";
@@ -164,11 +164,11 @@ struct ns16550_defaults ns16550_com2 = {
 };
 
 /* efi_print: print efi table at boot */
-static int opt_efi_print;
+static int __initdata opt_efi_print;
 boolean_param("efi_print", opt_efi_print);
 
 /* print EFI memory map: */
-static void
+static void __init
 efi_print(void)
 {
     void *efi_map_start, *efi_map_end;
@@ -242,7 +242,19 @@ md_overlaps(efi_memory_desc_t *md, unsig
 
 #define MD_SIZE(md) (md->num_pages << EFI_PAGE_SHIFT)
 
-void start_kernel(void)
+extern char __init_begin[], __init_end[];
+static void noinline init_done(void)
+{
+    memset(__init_begin, 0, __init_end - __init_begin);
+    flush_icache_range((unsigned long)__init_begin, (unsigned long)__init_end);
+    init_xenheap_pages(__pa(__init_begin), __pa(__init_end));
+    printk("Freed %ldkB init memory.\n",
+           (long)(__init_end-__init_begin)>>10);
+    
+    startup_cpu_idle_loop();
+}
+
+void __init start_kernel(void)
 {
     char *cmdline;
     unsigned long nr_pages;
@@ -252,6 +264,7 @@ void start_kernel(void)
     struct domain *idle_domain;
     struct vcpu *dom0_vcpu0;
     efi_memory_desc_t *kern_md, *last_md, *md;
+    void *xen_heap_start;
 #ifdef CONFIG_SMP
     int i;
 #endif
@@ -391,6 +404,14 @@ void start_kernel(void)
     efi_memmap_walk(find_max_pfn, &max_page);
     printk("find_memory: efi_memmap_walk returns max_page=%lx\n",max_page);
     efi_print();
+    
+    /*
+     * later [__init_begin, __init_end) will be freed up as xen heap
+     * so that struct domain might be allocated from the init area
+     * which is < xen_heap_start. so we can't simply set
+     * xen_pickle_offset = xen_heap_start.
+     */
+    xen_pickle_offset = ia64_imva(__init_begin);
 
     xen_heap_start = memguard_init(ia64_imva(&_end));
     printk("Before xen_heap_start: %p\n", xen_heap_start);
@@ -546,7 +567,7 @@ printk("num_online_cpus=%d, max_cpus=%d\
 
     domain_unpause_by_systemcontroller(dom0);
 
-    startup_cpu_idle_loop();
+    init_done();
 }
 
 void arch_get_xen_caps(xen_capabilities_info_t *info)
diff -r d30576123892 -r 26492c6476f0 xen/include/asm-ia64/config.h
--- a/xen/include/asm-ia64/config.h     Mon May 21 14:30:09 2007 -0600
+++ b/xen/include/asm-ia64/config.h     Wed May 23 08:51:42 2007 -0600
@@ -83,8 +83,6 @@ extern unsigned long xenheap_phys_end;
 extern unsigned long xenheap_phys_end;
 extern unsigned long xen_pstart;
 extern unsigned long xenheap_size;
-//extern struct domain *dom0;
-extern unsigned long dom0_size;
 
 // from linux/include/linux/mm.h
 extern struct page_info *mem_map;
diff -r d30576123892 -r 26492c6476f0 xen/include/asm-ia64/mm.h
--- a/xen/include/asm-ia64/mm.h Mon May 21 14:30:09 2007 -0600
+++ b/xen/include/asm-ia64/mm.h Wed May 23 08:51:42 2007 -0600
@@ -118,9 +118,9 @@ struct page_info
 #define is_xen_heap_frame(pfn) ((page_to_maddr(pfn) < xenheap_phys_end) \
                                 && (page_to_maddr(pfn) >= xen_pstart))
 
-extern void *xen_heap_start;
-#define __pickle(a)    ((unsigned long)a - (unsigned long)xen_heap_start)
-#define __unpickle(a)  (void *)(a + xen_heap_start)
+extern void* xen_pickle_offset;
+#define __pickle(a)    ((unsigned long)a - (unsigned long)xen_pickle_offset)
+#define __unpickle(a)  (void *)(a + xen_pickle_offset)
 
 static inline struct domain *unpickle_domptr(u64 _d)
 { return (_d == 0) ? NULL : __unpickle(_d); }

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