]>
Commit | Line | Data |
---|---|---|
eed62a28 | 1 | diff -urN linux-2.4.20/arch/alpha/kernel/setup.c linux-2.4.20-initrdfix/arch/alpha/kernel/setup.c |
2 | --- linux-2.4.20/arch/alpha/kernel/setup.c 2002-08-02 20:39:42.000000000 -0400 | |
3 | +++ linux-2.4.20-initrdfix/arch/alpha/kernel/setup.c 2003-06-18 13:53:12.000000000 -0400 | |
4 | @@ -243,6 +243,27 @@ | |
5 | return end >> PAGE_SHIFT; /* Return the PFN of the limit. */ | |
6 | } | |
7 | ||
8 | +#ifdef CONFIG_BLK_DEV_INITRD | |
9 | +void * __init | |
10 | +move_initrd(unsigned long mem_limit) | |
11 | +{ | |
12 | + void *start; | |
13 | + unsigned long size; | |
14 | + | |
15 | + size = initrd_end - initrd_start; | |
16 | + start = __alloc_bootmem(PAGE_ALIGN(size), PAGE_SIZE, 0); | |
17 | + if (!start || __pa(start) + size > mem_limit) { | |
18 | + initrd_start = initrd_end = 0; | |
19 | + return NULL; | |
20 | + } | |
21 | + memmove(start, (void *)initrd_start, size); | |
22 | + initrd_start = (unsigned long)start; | |
23 | + initrd_end = initrd_start + size; | |
24 | + printk(KERN_INFO "initrd moved to %p\n", start); | |
25 | + return start; | |
26 | +} | |
27 | +#endif | |
28 | + | |
29 | #ifndef CONFIG_DISCONTIGMEM | |
30 | static void __init | |
31 | setup_memory(void *kernel_end) | |
32 | @@ -371,11 +392,11 @@ | |
33 | (void *) initrd_start, INITRD_SIZE); | |
34 | ||
35 | if ((void *)initrd_end > phys_to_virt(PFN_PHYS(max_low_pfn))) { | |
36 | - printk("initrd extends beyond end of memory " | |
37 | - "(0x%08lx > 0x%p)\ndisabling initrd\n", | |
38 | - initrd_end, | |
39 | - phys_to_virt(PFN_PHYS(max_low_pfn))); | |
40 | - initrd_start = initrd_end = 0; | |
41 | + if (!move_initrd(PFN_PHYS(max_low_pfn))) | |
42 | + printk("initrd extends beyond end of memory " | |
43 | + "(0x%08lx > 0x%p)\ndisabling initrd\n", | |
44 | + initrd_end, | |
45 | + phys_to_virt(PFN_PHYS(max_low_pfn))); | |
46 | } else { | |
47 | reserve_bootmem(virt_to_phys((void *)initrd_start), | |
48 | INITRD_SIZE); | |
49 | diff -urN linux-2.4.20/arch/alpha/mm/init.c linux-2.4.20-initrdfix/arch/alpha/mm/init.c | |
50 | --- linux-2.4.20/arch/alpha/mm/init.c 2002-08-02 20:39:42.000000000 -0400 | |
51 | +++ linux-2.4.20-initrdfix/arch/alpha/mm/init.c 2003-06-18 13:53:09.000000000 -0400 | |
52 | @@ -368,18 +368,23 @@ | |
53 | #endif /* CONFIG_DISCONTIGMEM */ | |
54 | ||
55 | void | |
56 | -free_initmem (void) | |
57 | +free_reserved_mem(void *start, void *end) | |
58 | { | |
59 | - extern char __init_begin, __init_end; | |
60 | - unsigned long addr; | |
61 | - | |
62 | - addr = (unsigned long)(&__init_begin); | |
63 | - for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) { | |
64 | - ClearPageReserved(virt_to_page(addr)); | |
65 | - set_page_count(virt_to_page(addr), 1); | |
66 | - free_page(addr); | |
67 | + void *__start = start; | |
68 | + for (; __start < end; __start += PAGE_SIZE) { | |
69 | + ClearPageReserved(virt_to_page(__start)); | |
70 | + set_page_count(virt_to_page(__start), 1); | |
71 | + free_page((long)__start); | |
72 | totalram_pages++; | |
73 | } | |
74 | +} | |
75 | + | |
76 | +void | |
77 | +free_initmem(void) | |
78 | +{ | |
79 | + extern char __init_begin, __init_end; | |
80 | + | |
81 | + free_reserved_mem(&__init_begin, &__init_end); | |
82 | printk (KERN_INFO "Freeing unused kernel memory: %ldk freed\n", | |
83 | (&__init_end - &__init_begin) >> 10); | |
84 | } | |
85 | @@ -388,14 +393,9 @@ | |
86 | void | |
87 | free_initrd_mem(unsigned long start, unsigned long end) | |
88 | { | |
89 | - unsigned long __start = start; | |
90 | - for (; start < end; start += PAGE_SIZE) { | |
91 | - ClearPageReserved(virt_to_page(start)); | |
92 | - set_page_count(virt_to_page(start), 1); | |
93 | - free_page(start); | |
94 | - totalram_pages++; | |
95 | - } | |
96 | - printk (KERN_INFO "Freeing initrd memory: %ldk freed\n", (end - __start) >> 10); | |
97 | + free_reserved_mem((void *)start, (void *)end); | |
98 | + printk(KERN_INFO "Freeing initrd memory: %ldk freed\n", | |
99 | + (end - start) >> 10); | |
100 | } | |
101 | #endif | |
102 | ||
103 | diff -urN linux-2.4.20/arch/alpha/mm/numa.c linux-2.4.20-initrdfix/arch/alpha/mm/numa.c | |
104 | --- linux-2.4.20/arch/alpha/mm/numa.c 2002-08-02 20:39:42.000000000 -0400 | |
105 | +++ linux-2.4.20-initrdfix/arch/alpha/mm/numa.c 2003-06-18 13:53:09.000000000 -0400 | |
106 | @@ -249,16 +249,18 @@ | |
107 | #ifdef CONFIG_BLK_DEV_INITRD | |
108 | initrd_start = INITRD_START; | |
109 | if (initrd_start) { | |
110 | + extern void *move_initrd(unsigned long); | |
111 | + | |
112 | initrd_end = initrd_start+INITRD_SIZE; | |
113 | printk("Initial ramdisk at: 0x%p (%lu bytes)\n", | |
114 | (void *) initrd_start, INITRD_SIZE); | |
115 | ||
116 | if ((void *)initrd_end > phys_to_virt(PFN_PHYS(max_low_pfn))) { | |
117 | - printk("initrd extends beyond end of memory " | |
118 | - "(0x%08lx > 0x%p)\ndisabling initrd\n", | |
119 | - initrd_end, | |
120 | - phys_to_virt(PFN_PHYS(max_low_pfn))); | |
121 | - initrd_start = initrd_end = 0; | |
122 | + if (!move_initrd(PFN_PHYS(max_low_pfn))) | |
123 | + printk("initrd extends beyond end of memory " | |
124 | + "(0x%08lx > 0x%p)\ndisabling initrd\n", | |
125 | + initrd_end, | |
126 | + phys_to_virt(PFN_PHYS(max_low_pfn))); | |
127 | } else { | |
128 | reserve_bootmem_node(NODE_DATA(KVADDR_TO_NID(initrd_start)), | |
129 | virt_to_phys((void *)initrd_start), |