x86 boot: early_res_to_e820
PATCH 2/2 x86 boot: early_res_to_e820
This patch reserves some memory areas of early_res in E820 as E820_RESVD_KERN. This is used mainly on i386, for some memory area from boot-loader and in highmem, such as linked list of setup_data, EFI memory map, etc.
This patch is based on latest x86/master branch of git-x86 tree and has been tested on i386 and x86_64 platform.
--- arch/x86/kernel/e820.c | 22 ++++++++++++++++++++++ arch/x86/kernel/setup_32.c | 2 ++ include/asm-x86/e820.h | 1 + 3 files changed, 25 insertions(+)
arch/x86/kernel/e820.c +22 -0
@@ -844,6 +844,28 @@ void __init early_res_to_bootmem(u64 sta } } +void __init early_res_to_e820 (u64 start,u64 end) +{ +int i, changed =0 ; +u64 final_start, final_end; +for (i =0 ; i <MAX_EARLY_RES && early_res[i].end; i++) { +struct early_res *r = &early_res[i]; + final_start =max (start, r->start); + final_end =min (end, r->end); +if (final_start >= final_end) +continue ; +printk (KERN_INFO " early res: %d [%llx-%llx] %s\n" , i, + final_start, final_end -1 , r->name); +e820_update_range (final_start, final_end - final_start, +E820_RAM ,E820_RESVD_KERN ); + changed =1 ; + } +if (changed) { +printk (KERN_INFO "update e820 for early_res\n" ); +update_e820 (); + } +} +/* Check for already reserved areas */ static inline int __init bad_addr (u64 *addrp,u64 size,u64 align) {
include/asm-x86/e820.h +1 -0
@@ -96,6 +96,7 @@ extern void reserve_early(u64 start, u64extern void reserve_early_overlap_ok (u64 start,u64 end,char *name);extern void free_early (u64 start,u64 end);extern void early_res_to_bootmem (u64 start,u64 end); +extern void early_res_to_e820 (u64 start,u64 end);extern u64 early_reserve_e820 (u64 startt,u64 sizet,u64 align);extern unsigned long e820_end_of_ram (void );
arch/x86/kernel/setup_32.c +2 -0
@@ -447,6 +447,8 @@ void __init setup_arch(char **cmdline_p)acpi_numa_init ();#endif +early_res_to_e820 (max_low_pfn<<PAGE_SHIFT ,-1 ); +initmem_init (0 , max_pfn);#ifdef CONFIG_ACPI_SLEEP
Quoted 60 lines · Ying
This patch reserves some memory areas of
early_resin E820 asE820_RESVD_KERN. This is used mainly on i386, for some memory area from boot-loader and in highmem, such as linked list ofsetup_data, EFI memory map, etc.This patch is based on latest x86/master branch of git-x86 tree and has been tested on i386 and
x86_64platform.Signed-off-by Huang Ying <[email protected]>--- arch/x86/kernel/e820.c | 22 ++++++++++++++++++++++ arch/x86/kernel/setup_32.c | 2 ++ include/asm-x86/e820.h | 1 + 3 files changed, 25 insertions(+)arch/x86/kernel/e820.c +22
-0@@ -844,6 +844,28 @@ void __init early_res_to_bootmem(u64 sta } } +void __init early_res_to_e820 (u64 start,u64 end) +{ +int i, changed =0 ; +u64 final_start, final_end; +for (i =0 ; i <MAX_EARLY_RES && early_res[i].end; i++) { +struct early_res *r = &early_res[i]; + final_start =max (start, r->start); + final_end =min (end, r->end); +if (final_start >= final_end) +continue ; +printk (KERN_INFO " early res: %d [%llx-%llx] %s\n" , i, + final_start, final_end -1 , r->name); +e820_update_range (final_start, final_end - final_start, +E820_RAM ,E820_RESVD_KERN ); + changed =1 ; + } +if (changed) { +printk (KERN_INFO "update e820 for early_res\n" ); +update_e820 (); + } +} +/* Check for already reserved areas */ static inline int __init bad_addr (u64 *addrp,u64 size,u64 align) {include/asm-x86/e820.h +1
-0@@ -96,6 +96,7 @@ extern void reserve_early(u64 start, u64extern void reserve_early_overlap_ok (u64 start,u64 end,char *name);extern void free_early (u64 start,u64 end);extern void early_res_to_bootmem (u64 start,u64 end); +extern void early_res_to_e820 (u64 start,u64 end);extern u64 early_reserve_e820 (u64 startt,u64 sizet,u64 align);extern unsigned long e820_end_of_ram (void );
arch/x86/kernel/setup_32.c void __init setup_arch(char **cmdline_p)
Quoted 10 lines
arch/x86/kernel/setup_32.c +2
-1@@ -447,6 +447,8 @@ void __init setup_arch(char **cmdline_p)acpi_numa_init ();#endif +early_res_to_e820 (max_low_pfn<<PAGE_SHIFT ,-1 ); +initmem_init (0 , max_pfn);#ifdef CONFIG_ACPI_SLEEP --
this one is not needed.
YH
Quoted 68 lines · Yinghai Lu
Quoted 67 lines · Ying
This patch reserves some memory areas of
early_resin E820 asE820_RESVD_KERN. This is used mainly on i386, for some memory area from boot-loader and in highmem, such as linked list ofsetup_data, EFI memory map, etc.This patch is based on latest x86/master branch of git-x86 tree and has been tested on i386 and
x86_64platform.Signed-off-by Huang Ying <[email protected]>--- arch/x86/kernel/e820.c | 22 ++++++++++++++++++++++ arch/x86/kernel/setup_32.c | 2 ++ include/asm-x86/e820.h | 1 + 3 files changed, 25 insertions(+)arch/x86/kernel/e820.c +22
-0@@ -844,6 +844,28 @@ void __init early_res_to_bootmem(u64 sta } } +void __init early_res_to_e820 (u64 start,u64 end) +{ +int i, changed =0 ; +u64 final_start, final_end; +for (i =0 ; i <MAX_EARLY_RES && early_res[i].end; i++) { +struct early_res *r = &early_res[i]; + final_start =max (start, r->start); + final_end =min (end, r->end); +if (final_start >= final_end) +continue ; +printk (KERN_INFO " early res: %d [%llx-%llx] %s\n" , i, + final_start, final_end -1 , r->name); +e820_update_range (final_start, final_end - final_start, +E820_RAM ,E820_RESVD_KERN ); + changed =1 ; + } +if (changed) { +printk (KERN_INFO "update e820 for early_res\n" ); +update_e820 (); + } +} +/* Check for already reserved areas */ static inline int __init bad_addr (u64 *addrp,u64 size,u64 align) {include/asm-x86/e820.h +1
-0@@ -96,6 +96,7 @@ extern void reserve_early(u64 start, u64extern void reserve_early_overlap_ok (u64 start,u64 end,char *name);extern void free_early (u64 start,u64 end);extern void early_res_to_bootmem (u64 start,u64 end); +extern void early_res_to_e820 (u64 start,u64 end);extern u64 early_reserve_e820 (u64 startt,u64 sizet,u64 align);extern unsigned long e820_end_of_ram (void );arch/x86/kernel/setup_32.c +2
-0@@ -447,6 +447,8 @@ void __init setup_arch(char **cmdline_p)acpi_numa_init ();#endif +early_res_to_e820 (max_low_pfn<<PAGE_SHIFT ,-1 ); +initmem_init (0 , max_pfn);
Quoted 5 lines
arch/x86/kernel/setup_32.c void __init setup_arch(char **cmdline_p)
Quoted 3 lines
arch/x86/kernel/setup_32.c +0
-1#ifdef CONFIG_ACPI_SLEEP --this one is not needed.
For example, if EFI memory map is allocated in highmem area by boot-loader, it need to be reserved in kernel. But on i386, bootmem can only reserve memory area below max_low_pfn. So I think this is needed.
In general, I think it is needed to provide a reservation mechanism for highmem area on i386. Because some memory area from BIOS or boot-loader may in highmem area.
Best Regards,
Huang Ying
Quoted 75 lines · Ying
Quoted 68 lines · Yinghai Lu
Quoted 67 lines · Ying
This patch reserves some memory areas of
early_resin E820 asE820_RESVD_KERN. This is used mainly on i386, for some memory area from boot-loader and in highmem, such as linked list ofsetup_data, EFI memory map, etc.This patch is based on latest x86/master branch of git-x86 tree and has been tested on i386 and
x86_64platform.Signed-off-by Huang Ying <[email protected]>--- arch/x86/kernel/e820.c | 22 ++++++++++++++++++++++ arch/x86/kernel/setup_32.c | 2 ++ include/asm-x86/e820.h | 1 + 3 files changed, 25 insertions(+)arch/x86/kernel/e820.c +22
-0@@ -844,6 +844,28 @@ void __init early_res_to_bootmem(u64 sta } } +void __init early_res_to_e820 (u64 start,u64 end) +{ +int i, changed =0 ; +u64 final_start, final_end; +for (i =0 ; i <MAX_EARLY_RES && early_res[i].end; i++) { +struct early_res *r = &early_res[i]; + final_start =max (start, r->start); + final_end =min (end, r->end); +if (final_start >= final_end) +continue ; +printk (KERN_INFO " early res: %d [%llx-%llx] %s\n" , i, + final_start, final_end -1 , r->name); +e820_update_range (final_start, final_end - final_start, +E820_RAM ,E820_RESVD_KERN ); + changed =1 ; + } +if (changed) { +printk (KERN_INFO "update e820 for early_res\n" ); +update_e820 (); + } +} +/* Check for already reserved areas */ static inline int __init bad_addr (u64 *addrp,u64 size,u64 align) {include/asm-x86/e820.h +1
-0@@ -96,6 +96,7 @@ extern void reserve_early(u64 start, u64extern void reserve_early_overlap_ok (u64 start,u64 end,char *name);extern void free_early (u64 start,u64 end);extern void early_res_to_bootmem (u64 start,u64 end); +extern void early_res_to_e820 (u64 start,u64 end);extern u64 early_reserve_e820 (u64 startt,u64 sizet,u64 align);extern unsigned long e820_end_of_ram (void );arch/x86/kernel/setup_32.c +2
-0@@ -447,6 +447,8 @@ void __init setup_arch(char **cmdline_p)acpi_numa_init ();#endif +early_res_to_e820 (max_low_pfn<<PAGE_SHIFT ,-1 ); +initmem_init (0 , max_pfn);Quoted 5 lines
arch/x86/kernel/setup_32.c void __init setup_arch(char **cmdline_p)
Quoted 3 lines
arch/x86/kernel/setup_32.c +0
-1#ifdef CONFIG_ACPI_SLEEP --this one is not needed.
Quoted 7 lines
For example, if EFI memory map is allocated in highmem area by boot-loader, it need to be reserved in kernel. But on i386, bootmem can only reserve memory area below
max_low_pfn. So I think this is needed.In general, I think it is needed to provide a reservation mechanism for highmem area on i386. Because some memory area from BIOS or boot-loader may in highmem area.
I mean call reserve_setup_data right after finish_e820_parsing, and it could call e820_update_range directly.
YH
On Thu, 2008-06-26 at 00:29 -0700, Yinghai Lu wrote:
[...]
Quoted 11 lines
Quoted 8 lines
For example, if EFI memory map is allocated in highmem area by boot-loader, it need to be reserved in kernel. But on i386, bootmem can only reserve memory area below
max_low_pfn. So I think this is needed.In general, I think it is needed to provide a reservation mechanism for highmem area on i386. Because some memory area from BIOS or boot-loader may in highmem area.
I mean call
reserve_setup_dataright afterfinish_e820_parsing, and it could calle820_update_rangedirectly.
e820_update_range() can only be used after finish_e820_parsing()?
parse_setup_data() should be called before parse_early_param() to let early_param override settings in setup_data. Which is before finish_e820_parsing(). It seems a little wired to use the data before reserve it.
And this means find_e820_area() should not be called before e820_update_range()?
Best Regards,
Huang Ying
Quoted 7 lines · Ying
On Thu, 2008-06-26 at 00:29 -0700, Yinghai Lu wrote:
[...]Quoted 5 lines
Quoted 5 lines
For example, if EFI memory map is allocated in highmem area by boot-loader, it need to be reserved in kernel. But on i386, bootmem can only reserve memory area below
max_low_pfn. So I think this is needed.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
In general, I think it is needed to provide a reservation mechanism for highmem area on i386. Because some memory area from BIOS or boot-loader may in highmem area.
I mean call
reserve_setup_dataright afterfinish_e820_parsing, and it could calle820_update_rangedirectly.
e820_update_range()can only be used afterfinish_e820_parsing()?
you could call that just after setup_memory_map
Quoted 5 lines
parse_setup_data()should be called beforeparse_early_param()to letearly_paramoverride settings insetup_data. Which is beforefinish_e820_parsing(). It seems a little wired to use the data before reserve it.
that is ok, because no one use find_e820_area yet and e820 is a static array. so it is safe.
Quoted 3 lines
And this means
find_e820_area()should not be called beforee820_update_range()?
Yes.. no one use it....first user is supposed for bootmap?
YH