aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYinghai Lu <yhlu.kernel@gmail.com>2008-06-30 19:20:54 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-08 07:16:14 -0400
commit28bb22379513ca3cac9d13766064a219c5fc21a9 (patch)
treee9b870bf99adbbb58e13c454a78366ff83292982
parent102d0a4b56d94e9b7eedfdfb488400271235543f (diff)
x86: move reserve_setup_data to setup.c
Ying Huang would like setup_data to be reserved, but not included in the no save range. Here we try to modify the e820 table to reserve that range early. also add that in early_res in case bootloader messes up with the ramdisk. other solution would be 1. add early_res_to_highmem... 2. early_res_to_e820... but they could reserve another type memory wrongly, if early_res has some resource reserved early, and not needed later, but it is not removed from early_res in time. Like the RAMDISK (already handled). Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com> Cc: andi@firstfloor.org Tested-by: Huang, Ying <ying.huang@intel.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--arch/x86/kernel/e820.c4
-rw-r--r--arch/x86/kernel/head.c18
-rw-r--r--arch/x86/kernel/head64.c1
-rw-r--r--arch/x86/kernel/setup.c34
-rw-r--r--include/asm-x86/bootparam.h2
-rw-r--r--include/asm-x86/e820.h3
6 files changed, 34 insertions, 28 deletions
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index ba5ac880ea1e..e03b89ac8f2b 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -120,6 +120,7 @@ void __init e820_print_map(char *who)
120 (e820.map[i].addr + e820.map[i].size)); 120 (e820.map[i].addr + e820.map[i].size));
121 switch (e820.map[i].type) { 121 switch (e820.map[i].type) {
122 case E820_RAM: 122 case E820_RAM:
123 case E820_RESERVED_KERN:
123 printk(KERN_CONT "(usable)\n"); 124 printk(KERN_CONT "(usable)\n");
124 break; 125 break;
125 case E820_RESERVED: 126 case E820_RESERVED:
@@ -611,7 +612,7 @@ void __init e820_mark_nosave_regions(unsigned long limit_pfn)
611 register_nosave_region(pfn, PFN_UP(ei->addr)); 612 register_nosave_region(pfn, PFN_UP(ei->addr));
612 613
613 pfn = PFN_DOWN(ei->addr + ei->size); 614 pfn = PFN_DOWN(ei->addr + ei->size);
614 if (ei->type != E820_RAM) 615 if (ei->type != E820_RAM && ei->type != E820_RESERVED_KERN)
615 register_nosave_region(PFN_UP(ei->addr), pfn); 616 register_nosave_region(PFN_UP(ei->addr), pfn);
616 617
617 if (pfn >= limit_pfn) 618 if (pfn >= limit_pfn)
@@ -1207,6 +1208,7 @@ void __init e820_reserve_resources(void)
1207 res = alloc_bootmem_low(sizeof(struct resource) * e820.nr_map); 1208 res = alloc_bootmem_low(sizeof(struct resource) * e820.nr_map);
1208 for (i = 0; i < e820.nr_map; i++) { 1209 for (i = 0; i < e820.nr_map; i++) {
1209 switch (e820.map[i].type) { 1210 switch (e820.map[i].type) {
1211 case E820_RESERVED_KERN:
1210 case E820_RAM: res->name = "System RAM"; break; 1212 case E820_RAM: res->name = "System RAM"; break;
1211 case E820_ACPI: res->name = "ACPI Tables"; break; 1213 case E820_ACPI: res->name = "ACPI Tables"; break;
1212 case E820_NVS: res->name = "ACPI Non-volatile Storage"; break; 1214 case E820_NVS: res->name = "ACPI Non-volatile Storage"; break;
diff --git a/arch/x86/kernel/head.c b/arch/x86/kernel/head.c
index a6816be01cd6..3e66bd364a9d 100644
--- a/arch/x86/kernel/head.c
+++ b/arch/x86/kernel/head.c
@@ -53,21 +53,3 @@ void __init reserve_ebda_region(void)
53 /* reserve all memory between lowmem and the 1MB mark */ 53 /* reserve all memory between lowmem and the 1MB mark */
54 reserve_early_overlap_ok(lowmem, 0x100000, "BIOS reserved"); 54 reserve_early_overlap_ok(lowmem, 0x100000, "BIOS reserved");
55} 55}
56
57void __init reserve_setup_data(void)
58{
59 struct setup_data *data;
60 u64 pa_data;
61 char buf[32];
62
63 if (boot_params.hdr.version < 0x0209)
64 return;
65 pa_data = boot_params.hdr.setup_data;
66 while (pa_data) {
67 data = early_ioremap(pa_data, sizeof(*data));
68 sprintf(buf, "setup data %x", data->type);
69 reserve_early(pa_data, pa_data+sizeof(*data)+data->len, buf);
70 pa_data = data->next;
71 early_iounmap(data, sizeof(*data));
72 }
73}
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
index f684e3b3de4e..c97819829146 100644
--- a/arch/x86/kernel/head64.c
+++ b/arch/x86/kernel/head64.c
@@ -128,7 +128,6 @@ void __init x86_64_start_reservations(char *real_mode_data)
128#endif 128#endif
129 129
130 reserve_ebda_region(); 130 reserve_ebda_region();
131 reserve_setup_data();
132 131
133 /* 132 /*
134 * At this point everything still needed from the boot loader 133 * At this point everything still needed from the boot loader
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index caec79fb83a3..2ca12d4c88fb 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -389,14 +389,34 @@ static void __init parse_setup_data(void)
389 default: 389 default:
390 break; 390 break;
391 } 391 }
392#ifndef CONFIG_DEBUG_BOOT_PARAMS
393 free_early(pa_data, pa_data+sizeof(*data)+data->len);
394#endif
395 pa_data = data->next; 392 pa_data = data->next;
396 early_iounmap(data, PAGE_SIZE); 393 early_iounmap(data, PAGE_SIZE);
397 } 394 }
398} 395}
399 396
397static void __init reserve_setup_data(void)
398{
399 struct setup_data *data;
400 u64 pa_data;
401 char buf[32];
402
403 if (boot_params.hdr.version < 0x0209)
404 return;
405 pa_data = boot_params.hdr.setup_data;
406 while (pa_data) {
407 data = early_ioremap(pa_data, sizeof(*data));
408 sprintf(buf, "setup data %x", data->type);
409 reserve_early(pa_data, pa_data+sizeof(*data)+data->len, buf);
410 e820_update_range(pa_data, sizeof(*data)+data->len,
411 E820_RAM, E820_RESERVED_KERN);
412 pa_data = data->next;
413 early_iounmap(data, sizeof(*data));
414 }
415 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
416 printk(KERN_INFO "extended physical RAM map:\n");
417 e820_print_map("reserve setup_data");
418}
419
400/* 420/*
401 * --------- Crashkernel reservation ------------------------------ 421 * --------- Crashkernel reservation ------------------------------
402 */ 422 */
@@ -523,7 +543,6 @@ void __init setup_arch(char **cmdline_p)
523 memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data)); 543 memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data));
524 pre_setup_arch_hook(); 544 pre_setup_arch_hook();
525 early_cpu_init(); 545 early_cpu_init();
526 reserve_setup_data();
527#else 546#else
528 printk(KERN_INFO "Command line: %s\n", boot_command_line); 547 printk(KERN_INFO "Command line: %s\n", boot_command_line);
529#endif 548#endif
@@ -567,6 +586,8 @@ void __init setup_arch(char **cmdline_p)
567 ARCH_SETUP 586 ARCH_SETUP
568 587
569 setup_memory_map(); 588 setup_memory_map();
589 parse_setup_data();
590
570 copy_edd(); 591 copy_edd();
571 592
572 if (!boot_params.hdr.root_flags) 593 if (!boot_params.hdr.root_flags)
@@ -593,10 +614,11 @@ void __init setup_arch(char **cmdline_p)
593 strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE); 614 strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
594 *cmdline_p = command_line; 615 *cmdline_p = command_line;
595 616
596 parse_setup_data();
597
598 parse_early_param(); 617 parse_early_param();
599 618
619 /* after early param, so could get panic from serial */
620 reserve_setup_data();
621
600 if (acpi_mps_check()) { 622 if (acpi_mps_check()) {
601#ifdef CONFIG_X86_LOCAL_APIC 623#ifdef CONFIG_X86_LOCAL_APIC
602 disable_apic = 1; 624 disable_apic = 1;
diff --git a/include/asm-x86/bootparam.h b/include/asm-x86/bootparam.h
index 6eeba3b2812b..ae22bdf0ab14 100644
--- a/include/asm-x86/bootparam.h
+++ b/include/asm-x86/bootparam.h
@@ -108,6 +108,4 @@ struct boot_params {
108 __u8 _pad9[276]; /* 0xeec */ 108 __u8 _pad9[276]; /* 0xeec */
109} __attribute__((packed)); 109} __attribute__((packed));
110 110
111void reserve_setup_data(void);
112
113#endif /* _ASM_BOOTPARAM_H */ 111#endif /* _ASM_BOOTPARAM_H */
diff --git a/include/asm-x86/e820.h b/include/asm-x86/e820.h
index f622685c9af8..45e904fe4076 100644
--- a/include/asm-x86/e820.h
+++ b/include/asm-x86/e820.h
@@ -44,6 +44,9 @@
44#define E820_ACPI 3 44#define E820_ACPI 3
45#define E820_NVS 4 45#define E820_NVS 4
46 46
47/* reserved RAM used by kernel itself */
48#define E820_RESERVED_KERN 128
49
47#ifndef __ASSEMBLY__ 50#ifndef __ASSEMBLY__
48struct e820entry { 51struct e820entry {
49 __u64 addr; /* start of memory segment */ 52 __u64 addr; /* start of memory segment */