diff options
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kernel/setup_32.c | 109 |
1 files changed, 55 insertions, 54 deletions
diff --git a/arch/x86/kernel/setup_32.c b/arch/x86/kernel/setup_32.c index 5e919e2b99fc..aa81779db218 100644 --- a/arch/x86/kernel/setup_32.c +++ b/arch/x86/kernel/setup_32.c | |||
@@ -186,43 +186,18 @@ static inline void copy_edd(void) | |||
186 | 186 | ||
187 | #ifdef CONFIG_BLK_DEV_INITRD | 187 | #ifdef CONFIG_BLK_DEV_INITRD |
188 | 188 | ||
189 | static void __init relocate_initrd(void); | 189 | #ifdef CONFIG_X86_32 |
190 | 190 | ||
191 | static void __init reserve_initrd(void) | 191 | #define MAX_MAP_CHUNK (NR_FIX_BTMAPS << PAGE_SHIFT) |
192 | static void __init relocate_initrd(void) | ||
192 | { | 193 | { |
194 | |||
193 | u64 ramdisk_image = boot_params.hdr.ramdisk_image; | 195 | u64 ramdisk_image = boot_params.hdr.ramdisk_image; |
194 | u64 ramdisk_size = boot_params.hdr.ramdisk_size; | 196 | u64 ramdisk_size = boot_params.hdr.ramdisk_size; |
195 | u64 ramdisk_end = ramdisk_image + ramdisk_size; | ||
196 | u64 end_of_lowmem = max_low_pfn << PAGE_SHIFT; | 197 | u64 end_of_lowmem = max_low_pfn << PAGE_SHIFT; |
197 | u64 ramdisk_here; | 198 | u64 ramdisk_here; |
198 | 199 | unsigned long slop, clen, mapaddr; | |
199 | if (!boot_params.hdr.type_of_loader || | 200 | char *p, *q; |
200 | !ramdisk_image || !ramdisk_size) | ||
201 | return; /* No initrd provided by bootloader */ | ||
202 | |||
203 | initrd_start = 0; | ||
204 | |||
205 | if (ramdisk_size >= (end_of_lowmem>>1)) { | ||
206 | free_early(ramdisk_image, ramdisk_end); | ||
207 | printk(KERN_ERR "initrd too large to handle, " | ||
208 | "disabling initrd\n"); | ||
209 | return; | ||
210 | } | ||
211 | |||
212 | printk(KERN_INFO "old RAMDISK: %08llx - %08llx\n", ramdisk_image, | ||
213 | ramdisk_end); | ||
214 | |||
215 | |||
216 | if (ramdisk_end <= end_of_lowmem) { | ||
217 | /* All in lowmem, easy case */ | ||
218 | /* | ||
219 | * don't need to reserve again, already reserved early | ||
220 | * in i386_start_kernel | ||
221 | */ | ||
222 | initrd_start = ramdisk_image + PAGE_OFFSET; | ||
223 | initrd_end = initrd_start + ramdisk_size; | ||
224 | return; | ||
225 | } | ||
226 | 201 | ||
227 | /* We need to move the initrd down into lowmem */ | 202 | /* We need to move the initrd down into lowmem */ |
228 | ramdisk_here = find_e820_area(0, end_of_lowmem, ramdisk_size, | 203 | ramdisk_here = find_e820_area(0, end_of_lowmem, ramdisk_size, |
@@ -241,22 +216,6 @@ static void __init reserve_initrd(void) | |||
241 | printk(KERN_INFO "Allocated new RAMDISK: %08llx - %08llx\n", | 216 | printk(KERN_INFO "Allocated new RAMDISK: %08llx - %08llx\n", |
242 | ramdisk_here, ramdisk_here + ramdisk_size); | 217 | ramdisk_here, ramdisk_here + ramdisk_size); |
243 | 218 | ||
244 | relocate_initrd(); | ||
245 | } | ||
246 | |||
247 | #define MAX_MAP_CHUNK (NR_FIX_BTMAPS << PAGE_SHIFT) | ||
248 | |||
249 | static void __init relocate_initrd(void) | ||
250 | { | ||
251 | u64 ramdisk_image = boot_params.hdr.ramdisk_image; | ||
252 | u64 ramdisk_size = boot_params.hdr.ramdisk_size; | ||
253 | u64 end_of_lowmem = max_low_pfn << PAGE_SHIFT; | ||
254 | u64 ramdisk_here; | ||
255 | unsigned long slop, clen, mapaddr; | ||
256 | char *p, *q; | ||
257 | |||
258 | ramdisk_here = initrd_start - PAGE_OFFSET; | ||
259 | |||
260 | q = (char *)initrd_start; | 219 | q = (char *)initrd_start; |
261 | 220 | ||
262 | /* Copy any lowmem portion of the initrd */ | 221 | /* Copy any lowmem portion of the initrd */ |
@@ -286,18 +245,60 @@ static void __init relocate_initrd(void) | |||
286 | /* high pages is not converted by early_res_to_bootmem */ | 245 | /* high pages is not converted by early_res_to_bootmem */ |
287 | ramdisk_image = boot_params.hdr.ramdisk_image; | 246 | ramdisk_image = boot_params.hdr.ramdisk_image; |
288 | ramdisk_size = boot_params.hdr.ramdisk_size; | 247 | ramdisk_size = boot_params.hdr.ramdisk_size; |
289 | printk(KERN_INFO "Copied RAMDISK from %016llx - %016llx to %08llx - %08llx\n", | 248 | printk(KERN_INFO "Move RAMDISK from %016llx - %016llx to" |
249 | " %08llx - %08llx\n", | ||
290 | ramdisk_image, ramdisk_image + ramdisk_size - 1, | 250 | ramdisk_image, ramdisk_image + ramdisk_size - 1, |
291 | ramdisk_here, ramdisk_here + ramdisk_size - 1); | 251 | ramdisk_here, ramdisk_here + ramdisk_size - 1); |
252 | } | ||
253 | #endif | ||
292 | 254 | ||
293 | /* | 255 | static void __init reserve_initrd(void) |
294 | * need to free old one, otherwise init cross max_low_pfn could be | 256 | { |
295 | * converted to bootmem | 257 | u64 ramdisk_image = boot_params.hdr.ramdisk_image; |
296 | */ | 258 | u64 ramdisk_size = boot_params.hdr.ramdisk_size; |
297 | free_early(ramdisk_image, ramdisk_image+ramdisk_size); | 259 | u64 ramdisk_end = ramdisk_image + ramdisk_size; |
260 | u64 end_of_lowmem = max_low_pfn << PAGE_SHIFT; | ||
261 | |||
262 | if (!boot_params.hdr.type_of_loader || | ||
263 | !ramdisk_image || !ramdisk_size) | ||
264 | return; /* No initrd provided by bootloader */ | ||
265 | |||
266 | initrd_start = 0; | ||
267 | |||
268 | if (ramdisk_size >= (end_of_lowmem>>1)) { | ||
269 | free_early(ramdisk_image, ramdisk_end); | ||
270 | printk(KERN_ERR "initrd too large to handle, " | ||
271 | "disabling initrd\n"); | ||
272 | return; | ||
273 | } | ||
274 | |||
275 | printk(KERN_INFO "RAMDISK: %08llx - %08llx\n", ramdisk_image, | ||
276 | ramdisk_end); | ||
277 | |||
278 | |||
279 | if (ramdisk_end <= end_of_lowmem) { | ||
280 | /* All in lowmem, easy case */ | ||
281 | /* | ||
282 | * don't need to reserve again, already reserved early | ||
283 | * in i386_start_kernel | ||
284 | */ | ||
285 | initrd_start = ramdisk_image + PAGE_OFFSET; | ||
286 | initrd_end = initrd_start + ramdisk_size; | ||
287 | return; | ||
288 | } | ||
289 | |||
290 | #ifdef CONFIG_X86_32 | ||
291 | relocate_initrd(); | ||
292 | #else | ||
293 | printk(KERN_ERR "initrd extends beyond end of memory " | ||
294 | "(0x%08llx > 0x%08llx)\ndisabling initrd\n", | ||
295 | ramdisk_end, end_of_lowmem); | ||
296 | initrd_start = 0; | ||
297 | #endif | ||
298 | free_early(ramdisk_image, ramdisk_end); | ||
298 | } | 299 | } |
299 | #else | 300 | #else |
300 | void __init reserve_initrd(void) | 301 | static void __init reserve_initrd(void) |
301 | { | 302 | { |
302 | } | 303 | } |
303 | #endif /* CONFIG_BLK_DEV_INITRD */ | 304 | #endif /* CONFIG_BLK_DEV_INITRD */ |