x86 boot: add E820_RESVD_KERN
PATCH 1/2 x86 boot: add E820_RESVD_KERN
This patch add a new type to E820 table named E820_RESVD_KERN, which is used for memory area reserved for kernel itself instead of BIOS.
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 | 6 ++++-- include/asm-x86/e820.h | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-)
include/asm-x86/e820.h +3 -0
@@ -44,6 +44,9 @@#define E820_ACPI 3#define E820_NVS 4 +/* reserved RAM used by kernel itself */ +#define E820_RESVD_KERN 128 + #ifndef __ASSEMBLY__ struct e820entry { __u64 addr; /* start of memory segment */
arch/x86/kernel/e820.c +4 -2
@@ -120,6 +120,7 @@ void __init e820_print_map(char *who) (e820.map[i].addr + e820.map[i].size));switch (e820.map[i].type) {case E820_RAM : +case E820_RESVD_KERN :printk (KERN_CONT "(usable)\n" );break ;case E820_RESERVED :
@@ -611,7 +612,7 @@ void __init e820_mark_nosave_regions(unsregister_nosave_region (pfn,PFN_UP (ei->addr)); pfn =PFN_DOWN (ei->addr + ei->size); -if (ei->type !=E820_RAM ) +if (ei->type !=E820_RAM && ei->type !=E820_RESVD_KERN )register_nosave_region (PFN_UP (ei->addr), pfn);if (pfn >= limit_pfn)
@@ -977,7 +978,7 @@ u64 __init early_reserve_e820(u64 starttreturn 0 ; addr =round_down (start + size - sizet, align); -e820_update_range (addr, sizet,E820_RAM ,E820_RESERVED ); +e820_update_range (addr, sizet,E820_RAM ,E820_RESVD_KERN );printk (KERN_INFO "update e820 for early_reserve_e820\n" );update_e820 ();
@@ -1191,6 +1192,7 @@ void __init e820_reserve_resources(void) res =alloc_bootmem_low (sizeof (struct resource ) * e820.nr_map);for (i =0 ; i < e820.nr_map; i++) {switch (e820.map[i].type) { +case E820_RESVD_KERN :case E820_RAM : res->name ="System RAM" ;break ;case E820_ACPI : res->name ="ACPI Tables" ;break ;case E820_NVS : res->name ="ACPI Non-volatile Storage" ;break ;
Quoted 45 lines · Ying
This patch add a new type to E820 table named
E820_RESVD_KERN, which is used for memory area reserved for kernel itself instead of BIOS.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 | 6 ++++-- include/asm-x86/e820.h | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-)include/asm-x86/e820.h +3
-0@@ -44,6 +44,9 @@#define E820_ACPI 3#define E820_NVS 4 +/* reserved RAM used by kernel itself */ +#define E820_RESVD_KERN 128 + #ifndef __ASSEMBLY__ struct e820entry { __u64 addr; /* start of memory segment */arch/x86/kernel/e820.c +2
-1@@ -120,6 +120,7 @@ void __init e820_print_map(char *who) (e820.map[i].addr + e820.map[i].size));switch (e820.map[i].type) {case E820_RAM : +case E820_RESVD_KERN :printk (KERN_CONT "(usable)\n" );break ;case E820_RESERVED :@@ -611,7 +612,7 @@ void __init e820_mark_nosave_regions(unsregister_nosave_region (pfn,PFN_UP (ei->addr)); pfn =PFN_DOWN (ei->addr + ei->size); -if (ei->type !=E820_RAM ) +if (ei->type !=E820_RAM && ei->type !=E820_RESVD_KERN )register_nosave_region (PFN_UP (ei->addr), pfn);if (pfn >= limit_pfn)
arch/x86/kernel/e820.c u64 __init early_reserve_e820(u64 startt · line 981
Quoted 5 lines
arch/x86/kernel/e820.c +1
-1@@ -977,7 +978,7 @@ u64 __init early_reserve_e820(u64 starttreturn 0 ; addr =round_down (start + size - sizet, align); -e820_update_range (addr, sizet,E820_RAM ,E820_RESERVED ); +e820_update_range (addr, sizet,E820_RAM ,E820_RESVD_KERN );
this line is not needed.
arch/x86/kernel/e820.c void __init e820_reserve_resources(void)
Quoted 13 lines
arch/x86/kernel/e820.c +1
-1printk (KERN_INFO "update e820 for early_reserve_e820\n" );update_e820 ();@@ -1191,6 +1192,7 @@ void __init e820_reserve_resources(void) res =alloc_bootmem_low (sizeof (struct resource ) * e820.nr_map);for (i =0 ; i < e820.nr_map; i++) {switch (e820.map[i].type) { +case E820_RESVD_KERN :case E820_RAM : res->name ="System RAM" ;break ;case E820_ACPI : res->name ="ACPI Tables" ;break ;case E820_NVS : res->name ="ACPI Non-volatile Storage" ;break ; --
please move reserve_setup_data() from head.c/head64.c to setup32/64.c or merged setup.c
also need to change reserve_early in reserve_setup_data to e820_update_range(,,E820_RAM, E820_RESEVED_EXTRA).
calling reserve_setup_data() should around early_reserve_e820_mpc_new.
we don't need early_res_to_e820.
YH
On Thu, 2008-06-26 at 00:25 -0700, Yinghai Lu wrote:
[...]
Quoted 9 lines
arch/x86/kernel/e820.c u64 __init early_reserve_e820(u64 startt · line 981
Quoted 7 lines
if (pfn >=
limit_pfn)arch/x86/kernel/e820.c +1
-1@@ -977,7 +978,7 @@ u64 __init early_reserve_e820(u64 starttreturn 0 ; addr =round_down (start + size - sizet, align); -e820_update_range (addr, sizet,E820_RAM ,E820_RESERVED ); +e820_update_range (addr, sizet,E820_RAM ,E820_RESVD_KERN );this line is not needed.
Why? Memory reserved by early_rserved_e820 should not be saved during hibernation? shoudl not be saved by kdump?
Quoted 12 lines
Quoted 12 lines
arch/x86/kernel/e820.c +1
-0printk (KERN_INFO "update e820 for early_reserve_e820\n" );update_e820 ();@@ -1191,6 +1192,7 @@ void __init e820_reserve_resources(void) res =alloc_bootmem_low (sizeof (struct resource ) * e820.nr_map);for (i =0 ; i < e820.nr_map; i++) {switch (e820.map[i].type) { +case E820_RESVD_KERN :case E820_RAM : res->name ="System RAM" ;break ;case E820_ACPI : res->name ="ACPI Tables" ;break ;case E820_NVS : res->name ="ACPI Non-volatile Storage" ;break ;
Quoted 4 lines
Quoted 1 line
--
please move
reserve_setup_data()fromhead.c/head64.cto setup32/64.c or mergedsetup.c
OK.
Quoted 2 lines
also need to change
reserve_earlyinreserve_setup_datatoe820_update_range(,,E820_RAM, E820_RESEVED_EXTRA).
Does this means reserve_early() should be replaced by e820_update_range()?
Quoted 1 line
calling
reserve_setup_data()should aroundearly_reserve_e820_mpc_new.
I think reserve_xxx should be called before first find_e820_area() to minimize the possibility of conflict.
Quoted 1 line
we don't need
early_res_to_e820.
Best Regards,
Huang Ying
On Thu, Jun 26, 2008 at 12:48 AM, Huang, Ying <[email protected]> wrote:> On Thu, 2008-06-26 at 00:25 -0700, Yinghai Lu wrote:> [...]>> > if (pfn >= limit_pfn)>> > @@ -977,7 +978,7 @@ u64 __init early_reserve_e820(u64 startt>> > return 0;>> >>> > addr = round_down(start + size - sizet, align);>> > - e820_update_range(addr, sizet, E820_RAM, E820_RESERVED);>> > + e820_update_range(addr, sizet, E820_RAM, E820_RESVD_KERN);>>>> this line is not needed.>> Why? Memory reserved by early_rserved_e820 should not be saved during> hibernation? shoudl not be saved by kdump?>>> > printk(KERN_INFO "update e820 for early_reserve_e820\n");>> > update_e820();>> >>> > @@ -1191,6 +1192,7 @@ void __init e820_reserve_resources(void)>> > res = alloc_bootmem_low(sizeof(struct resource) * e820.nr_map);>> > for (i = 0; i < e820.nr_map; i++) {>> > switch (e820.map[i].type) {>> > + case E820_RESVD_KERN:>> > case E820_RAM: res->name = "System RAM"; break;>> > case E820_ACPI: res->name = "ACPI Tables"; break;>> > case E820_NVS: res->name = "ACPI Non-volatile Storage"; break;>> >>> > -->>>> please move reserve_setup_data() from head.c/head64.c to setup32/64.c>> or merged setup.c>> OK.>>> also need to change reserve_early in reserve_setup_data to>> e820_update_range(,,E820_RAM, E820_RESEVED_EXTRA).>> Does this means reserve_early() should be replaced by> e820_update_range()?
Yes. in your case.
Quoted 1 line
Quoted 1 line
Quoted 1 line
calling
reserve_setup_data()should aroundearly_reserve_e820_mpc_new.>> I thinkreserve_xxxshould be called before firstfind_e820_area()to> minimize the possibility of conflict.You already calle820_update_range, that could preventfind_e820_areatoget confused.
YH���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Quoted 44 lines · Yinghai Lu
Quoted 32 lines · Ying
On Thu, 2008-06-26 at 00:25 -0700, Yinghai Lu wrote:
[...]Quoted 9 lines
Review u64 __init early_reserve_e820(u64 startt · line 981
Quoted 7 lines
if (pfn >=
limit_pfn)(quoted diff) +1
-1@@ -977,7 +978,7 @@ u64 __init early_reserve_e820(u64 startt return 0; addr = round_down(start + size - sizet, align); - e820_update_range(addr, sizet, E820_RAM, E820_RESERVED); + e820_update_range(addr, sizet, E820_RAM, E820_RESVD_KERN);this line is not needed.
Why? Memory reserved by
early_rserved_e820should not be saved during hibernation? shoudl not be saved by kdump?Quoted 12 lines
Quoted 12 lines
(quoted diff) +1
-0printk(KERN_INFO "update e820 for early_reserve_e820\n"); update_e820();@@ -1191,6 +1192,7 @@ void __init e820_reserve_resources(void) res = alloc_bootmem_low(sizeof(struct resource) * e820.nr_map); for (i = 0; i < e820.nr_map; i++) { switch (e820.map[i].type) { + case E820_RESVD_KERN: case E820_RAM: res->name = "System RAM"; break; case E820_ACPI: res->name = "ACPI Tables"; break; case E820_NVS: res->name = "ACPI Non-volatile Storage"; break;Quoted 4 lines
Quoted 1 line
--
please move
reserve_setup_data()fromhead.c/head64.cto setup32/64.c or mergedsetup.cQuoted 7 lines
OK.
Quoted 2 lines
also need to change
reserve_earlyinreserve_setup_datatoe820_update_range(,,E820_RAM, E820_RESEVED_EXTRA).Does this means
reserve_early()should be replaced bye820_update_range()?Yes. in your case.
Quoted 1 line
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
calling
reserve_setup_data()should aroundearly_reserve_e820_mpc_new.I think
reserve_xxxshould be called before firstfind_e820_area()to minimize the possibility of conflict.You already call
e820_update_range, that could preventfind_e820_areato get confused.
some like the attach patch...
you still can merge parse_setup_data parse_e820_ext
also entries in parse_e820_ext is not initialized..., __copy_e820_map will do nothing.
YH
arch/x86/kernel/e820.c +3 -1
@@ -120,6 +120,7 @@ void __init e820_print_map(char *who) (e820.map[i].addr + e820.map[i].size));switch (e820.map[i].type) {case E820_RAM : +case E820_RESERVED_KERN :printk (KERN_CONT "(usable)\n" );break ;case E820_RESERVED :
@@ -611,7 +612,7 @@ void __init e820_mark_nosave_regions(unsigned long limit_pfn)register_nosave_region (pfn,PFN_UP (ei->addr)); pfn =PFN_DOWN (ei->addr + ei->size); -if (ei->type !=E820_RAM ) +if (ei->type !=E820_RAM && ei->type !=E820_RESERVED_KERN )register_nosave_region (PFN_UP (ei->addr), pfn);if (pfn >= limit_pfn)
@@ -1196,6 +1197,7 @@ void __init e820_reserve_resources(void) res =alloc_bootmem_low (sizeof (struct resource ) * e820.nr_map);for (i =0 ; i < e820.nr_map; i++) {switch (e820.map[i].type) { +case E820_RESERVED_KERN :case E820_RAM : res->name ="System RAM" ;break ;case E820_ACPI : res->name ="ACPI Tables" ;break ;case E820_NVS : res->name ="ACPI Non-volatile Storage" ;break ;
arch/x86/kernel/head.c +0 -18
@@ -53,21 +53,3 @@ void __init reserve_ebda_region(void)/* reserve all memory between lowmem and the 1MB mark */ reserve_early_overlap_ok (lowmem,0x100000 ,"BIOS reserved" ); } - -void __init reserve_setup_data (void ) -{ -struct setup_data *data; -u64 pa_data; -char buf[32 ]; - -if (boot_params.hdr.version <0x0209 ) -return ; - pa_data = boot_params.hdr.setup_data; -while (pa_data) { - data =early_ioremap (pa_data,sizeof (*data)); -sprintf (buf,"setup data %x" , data->type); -reserve_early (pa_data, pa_data+sizeof (*data)+data->len, buf); - pa_data = data->next; -early_iounmap (data,sizeof (*data)); - } -}
arch/x86/kernel/head64.c +0 -1
@@ -123,7 +123,6 @@ void __init x86_64_start_kernel(char * real_mode_data)#endif reserve_ebda_region (); -reserve_setup_data ();/* * At this point everything still needed from the boot loader
arch/x86/kernel/setup.c +24 -3
@@ -389,14 +389,33 @@ static void __init parse_setup_data(void)default :break ; } -#ifndef CONFIG_DEBUG_BOOT_PARAMS -free_early (pa_data, pa_data+sizeof (*data)+data->len); -#endif pa_data = data->next;early_iounmap (data,PAGE_SIZE ); } } +static void __init reserve_setup_data (void ) +{ +struct setup_data *data; +u64 pa_data; +char buf[32 ]; + +if (boot_params.hdr.version <0x0209 ) +return ; + pa_data = boot_params.hdr.setup_data; +while (pa_data) { + data =early_ioremap (pa_data,sizeof (*data)); +sprintf (buf,"setup data %x" , data->type); +e820_update_range (pa_data,sizeof (*data)+data->len, +E820_RAM ,E820_RESERVED_KERN ); + pa_data = data->next; +early_iounmap (data,sizeof (*data)); + } +sanitize_e820_map (e820.map,ARRAY_SIZE (e820.map), &e820.nr_map); +printk (KERN_INFO "extended physical RAM map:\n" ); +e820_print_map ("extended" ); +} +/* * --------- Crashkernel reservation ------------------------------ */
@@ -640,6 +659,8 @@ void __init setup_arch(char **cmdline_p)*/ max_pfn =e820_end_of_ram (); +reserve_setup_data (); +/* preallocate 4k for mptable mpc */ early_reserve_e820_mpc_new ();/* update e820 for memory not covered by WB MTRRs */
include/asm-x86/bootparam.h +0 -2
@@ -108,6 +108,4 @@ struct boot_params {__u8 _pad9[276 ];/* 0xeec */ } __attribute__((packed)); -void reserve_setup_data (void ); -#endif /* _ASM_BOOTPARAM_H */
include/asm-x86/e820.h +3 -0
@@ -44,6 +44,9 @@#define E820_ACPI 3#define E820_NVS 4 +/* reserved RAM used by kernel itself */ +#define E820_RESERVED_KERN 128 + #ifndef __ASSEMBLY__ struct e820entry { __u64 addr; /* start of memory segment */
Quoted 14 lines · Yinghai Lu
Quoted 13 lines · Yinghai Lu
Quoted 12 lines · Ying
On Thu, 2008-06-26 at 00:25 -0700, Yinghai Lu wrote:
[...]Quoted 9 lines
Review u64 __init early_reserve_e820(u64 startt · line 981
Quoted 7 lines
if (pfn >=
limit_pfn)(quoted diff) +1
-1@@ -977,7 +978,7 @@ u64 __init early_reserve_e820(u64 startt return 0; addr = round_down(start + size - sizet, align); - e820_update_range(addr, sizet, E820_RAM, E820_RESERVED); + e820_update_range(addr, sizet, E820_RAM, E820_RESVD_KERN);this line is not needed.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Why? Memory reserved by
early_rserved_e820should not be saved during hibernation? shoudl not be saved by kdump?
Can you tell me why this line is not needed?
[...]
Quoted 5 lines
some like the attach patch...
you still can merge
parse_setup_dataparse_e820_ext
also entries inparse_e820_extis not initialized...,__copy_e820_mapwill do nothing.
OK. Because some E820 entries are available after parse_setup_data(), it is better to call reserve_setup_data() after calling parse_setup_data() if update_e820_range() is used instead of reserve_early().
Best Regards,
Huang Ying
On Thu, Jun 26, 2008 at 7:48 PM, Huang, Ying <[email protected]> wrote:> On Thu, 2008-06-26 at 19:22 -0700, Yinghai Lu wrote:>> On Thu, Jun 26, 2008 at 2:47 AM, Yinghai Lu <[email protected]> wrote:>> > On Thu, Jun 26, 2008 at 12:48 AM, Huang, Ying <[email protected]> wrote:>> >> On Thu, 2008-06-26 at 00:25 -0700, Yinghai Lu wrote:>> >> [...]>> >>> > if (pfn >= limit_pfn)>> >>> > @@ -977,7 +978,7 @@ u64 __init early_reserve_e820(u64 startt>> >>> > return 0;>> >>> >>> >>> > addr = round_down(start + size - sizet, align);>> >>> > - e820_update_range(addr, sizet, E820_RAM, E820_RESERVED);>> >>> > + e820_update_range(addr, sizet, E820_RAM, E820_RESVD_KERN);>> >>>>> >>> this line is not needed.>> >>>> >> Why? Memory reserved by early_rserved_e820 should not be saved during>> >> hibernation? shoudl not be saved by kdump?>> >>>> Can you tell me why this line is not needed?
that function only have one user. the mpc reserve_new, so we want itto be E820_RESERVED, and kexec tools could have that range reserved,the next kernel will not overwrite the updated mptable.
Quoted 1 line
Quoted 1 line
[...]>> some like the attach patch...>>>> you still can merge
parse_setup_dataparse_e820_ext>> also entries inparse_e820_extis not initialized...,__copy_e820_map>> will do nothing.>> OK. Because some E820 entries are available afterparse_setup_data(),> it is better to callreserve_setup_data()after calling>parse_setup_data()ifupdate_e820_range()is used instead of>reserve_early().
can you double check parse_e820_ext()?it seems entries is not initialized properly,
void __init parse_e820_ext(struct setup_data *sdata, unsigned long pa_data){ u32 map_len; int entries; struct e820entry *extmap;
entries = sdata->len / sizeof(struct e820entry); map_len = sdata->len + sizeof(struct setup_data); if (map_len > PAGE_SIZE) sdata = early_ioremap(pa_data, map_len); extmap = (struct e820entry *)(sdata->data); __copy_e820_map(extmap, entries);===========> what is value for entries? sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); if (map_len > PAGE_SIZE) early_iounmap(sdata, map_len); printk(KERN_INFO "extended physical RAM map:\n"); e820_print_map("extended");}YH���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Quoted 20 lines · Yinghai Lu
Quoted 19 lines · Ying
Quoted 17 lines · Yinghai Lu
Quoted 16 lines · Yinghai Lu
Quoted 15 lines · Ying
On Thu, 2008-06-26 at 00:25 -0700, Yinghai Lu wrote:
[...]Quoted 9 lines
Review u64 __init early_reserve_e820(u64 startt · line 981
Quoted 7 lines
if (pfn >=
limit_pfn)(quoted diff) +1
-1@@ -977,7 +978,7 @@ u64 __init early_reserve_e820(u64 startt return 0; addr = round_down(start + size - sizet, align); - e820_update_range(addr, sizet, E820_RAM, E820_RESERVED); + e820_update_range(addr, sizet, E820_RAM, E820_RESVD_KERN);this line is not needed.
Why? Memory reserved by
early_rserved_e820should not be saved during hibernation? shoudl not be saved by kdump?
Quoted 5 lines
Quoted 1 line
Can you tell me why this line is not needed?
that function only have one user. the mpc
reserve_new, so we want it to beE820_RESERVED, and kexec tools could have that range reserved, the next kernel will not overwrite the updated mptable.
This is OK for kexec. Does it need to be saved by kdump? Does it need to be saved by hibernation (suspend to disk)?
Quoted 16 lines
Quoted 4 lines
[...]
Quoted 2 lines
some like the attach patch...
Quoted 8 lines
Quoted 3 lines
you still can merge
parse_setup_dataparse_e820_ext
also entries inparse_e820_extis not initialized...,__copy_e820_mapwill do nothing.OK. Because some E820 entries are available after
parse_setup_data(), it is better to callreserve_setup_data()after callingparse_setup_data()ifupdate_e820_range()is used instead ofreserve_early().can you double check
parse_e820_ext()?
it seems entries is not initialized properly,
Quoted 7 lines
void
__initparse_e820_ext(struct setup_data *sdata, unsigned long pa_data){ u32 map_len; int entries; struct e820entry *extmap; entries = sdata->len / sizeof(struct e820entry);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ here entries are initialized to be the number of entries in extended E820 table.
Quoted 11 lines
map_len = sdata->len + sizeof(struct setup_data);
if (map_len > PAGE_SIZE)
sdata = early_ioremap(pa_data, map_len);
extmap = (struct e820entry *)(sdata->data);
__copy_e820_map(extmap, entries);===========> what is value for entries?
sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
if (map_len > PAGE_SIZE)
early_iounmap(sdata, map_len);
printk(KERN_INFO "extended physical RAM map:\n");
e820_print_map("extended");
}Best Regards,
Huang Ying
Quoted 21 lines · Ying
Quoted 20 lines · Yinghai Lu
Quoted 19 lines · Ying
Quoted 17 lines · Yinghai Lu
Quoted 16 lines · Yinghai Lu
Quoted 15 lines · Ying
On Thu, 2008-06-26 at 00:25 -0700, Yinghai Lu wrote:
[...]Quoted 9 lines
Review u64 __init early_reserve_e820(u64 startt · line 981
Quoted 7 lines
if (pfn >=
limit_pfn)(quoted diff) +1
-1@@ -977,7 +978,7 @@ u64 __init early_reserve_e820(u64 startt return 0; addr = round_down(start + size - sizet, align); - e820_update_range(addr, sizet, E820_RAM, E820_RESERVED); + e820_update_range(addr, sizet, E820_RAM, E820_RESVD_KERN);this line is not needed.
Why? Memory reserved by
early_rserved_e820should not be saved during hibernation? shoudl not be saved by kdump?
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Can you tell me why this line is not needed?
that function only have one user. the mpc
reserve_new, so we want it to beE820_RESERVED, and kexec tools could have that range reserved, the next kernel will not overwrite the updated mptable.This is OK for kexec. Does it need to be saved by kdump? Does it need to be saved by hibernation (suspend to disk)?
the function is only called when alloc_mptable is specified in command line.
YH
On Thu, Jun 26, 2008 at 7:48 PM, Huang, Ying <[email protected]> wrote:> On Thu, 2008-06-26 at 19:22 -0700, Yinghai Lu wrote:>> On Thu, Jun 26, 2008 at 2:47 AM, Yinghai Lu <[email protected]> wrote:>> > On Thu, Jun 26, 2008 at 12:48 AM, Huang, Ying <[email protected]> wrote:>> >> On Thu, 2008-06-26 at 00:25 -0700, Yinghai Lu wrote:>> >> [...]>> >>> > if (pfn >= limit_pfn)>> >>> > @@ -977,7 +978,7 @@ u64 __init early_reserve_e820(u64 startt>> >>> > return 0;>> >>> >>> >>> > addr = round_down(start + size - sizet, align);>> >>> > - e820_update_range(addr, sizet, E820_RAM, E820_RESERVED);>> >>> > + e820_update_range(addr, sizet, E820_RAM, E820_RESVD_KERN);>> >>>>> >>> this line is not needed.>> >>>> >> Why? Memory reserved by early_rserved_e820 should not be saved during>> >> hibernation? shoudl not be saved by kdump?>> >>>> Can you tell me why this line is not needed?>> [...]>> some like the attach patch...>>>> you still can merge parse_setup_data parse_e820_ext>> also entries in parse_e820_ext is not initialized..., __copy_e820_map>> will do nothing.>> OK. Because some E820 entries are available after parse_setup_data(),> it is better to call reserve_setup_data() after calling> parse_setup_data() if update_e820_range() is used instead of> reserve_early().
please modify it and test on your platforms then submit to Ingo..
Thanks YH���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Quoted 29 lines · Yinghai Lu
Quoted 28 lines · Ying
Quoted 14 lines · Yinghai Lu
Quoted 13 lines · Yinghai Lu
Quoted 12 lines · Ying
On Thu, 2008-06-26 at 00:25 -0700, Yinghai Lu wrote:
[...]Quoted 9 lines
Review u64 __init early_reserve_e820(u64 startt · line 981
Quoted 7 lines
if (pfn >=
limit_pfn)(quoted diff) +1
-1@@ -977,7 +978,7 @@ u64 __init early_reserve_e820(u64 startt return 0; addr = round_down(start + size - sizet, align); - e820_update_range(addr, sizet, E820_RAM, E820_RESERVED); + e820_update_range(addr, sizet, E820_RAM, E820_RESVD_KERN);this line is not needed.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Why? Memory reserved by
early_rserved_e820should not be saved during hibernation? shoudl not be saved by kdump?Can you tell me why this line is not needed?
[...]
Quoted 5 lines
some like the attach patch...
you still can merge
parse_setup_dataparse_e820_ext
also entries inparse_e820_extis not initialized...,__copy_e820_mapwill do nothing.
Quoted 6 lines
Quoted 4 lines
OK. Because some E820 entries are available after
parse_setup_data(), it is better to callreserve_setup_data()after callingparse_setup_data()ifupdate_e820_range()is used instead ofreserve_early().please modify it and test on your platforms then submit to Ingo..
It seems that there is an issue:
- If parse_setup_data() is called before reserve_setup_data(), and there is a conflict between memory area used by setup_data and other memory area, it is possible that the contents of setup_data is changed. So that system may panic before reporting memory area conflict. And it seems that memory area conflict is not checked by e820_update_range().
So maybe it is better to use reserve_early() instead of e820_update_range() for setup_data.
Best Regards,
Huang Ying
On Mon, Jun 30, 2008 at 12:03 AM, Huang, Ying <[email protected]> wrote:> On Fri, 2008-06-27 at 15:05 -0700, Yinghai Lu wrote:>> On Thu, Jun 26, 2008 at 7:48 PM, Huang, Ying <[email protected]> wrote:>> > On Thu, 2008-06-26 at 19:22 -0700, Yinghai Lu wrote:>> >> On Thu, Jun 26, 2008 at 2:47 AM, Yinghai Lu <[email protected]> wrote:>> >> > On Thu, Jun 26, 2008 at 12:48 AM, Huang, Ying <[email protected]> wrote:>> >> >> On Thu, 2008-06-26 at 00:25 -0700, Yinghai Lu wrote:>> >> >> [...]>> >> >>> > if (pfn >= limit_pfn)>> >> >>> > @@ -977,7 +978,7 @@ u64 __init early_reserve_e820(u64 startt>> >> >>> > return 0;>> >> >>> >>> >> >>> > addr = round_down(start + size - sizet, align);>> >> >>> > - e820_update_range(addr, sizet, E820_RAM, E820_RESERVED);>> >> >>> > + e820_update_range(addr, sizet, E820_RAM, E820_RESVD_KERN);>> >> >>>>> >> >>> this line is not needed.>> >> >>>> >> >> Why? Memory reserved by early_rserved_e820 should not be saved during>> >> >> hibernation? shoudl not be saved by kdump?>> >> >>>> >>> > Can you tell me why this line is not needed?>> >>> > [...]>> >> some like the attach patch...>> >>>> >> you still can merge parse_setup_data parse_e820_ext>> >> also entries in parse_e820_ext is not initialized..., __copy_e820_map>> >> will do nothing.>> >>> > OK. Because some E820 entries are available after parse_setup_data(),>> > it is better to call reserve_setup_data() after calling>> > parse_setup_data() if update_e820_range() is used instead of>> > reserve_early().>>>> please modify it and test on your platforms then submit to Ingo..>> It seems that there is an issue:>> - If parse_setup_data() is called before reserve_setup_data(), and there> is a conflict between memory area used by setup_data and other memory> area, it is possible that the contents of setup_data is changed. So that> system may panic before reporting memory area conflict. And it seems> that memory area conflict is not checked by e820_update_range().
what is "other memory area"? returned from find_e820_area? no one use that yet. YH���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Quoted 40 lines · Yinghai Lu
Quoted 39 lines · Ying
Quoted 29 lines · Yinghai Lu
Quoted 28 lines · Ying
Quoted 14 lines · Yinghai Lu
Quoted 13 lines · Yinghai Lu
Quoted 12 lines · Ying
On Thu, 2008-06-26 at 00:25 -0700, Yinghai Lu wrote:
[...]Quoted 9 lines
Review u64 __init early_reserve_e820(u64 startt · line 981
Quoted 7 lines
if (pfn >=
limit_pfn)(quoted diff) +1
-1@@ -977,7 +978,7 @@ u64 __init early_reserve_e820(u64 startt return 0; addr = round_down(start + size - sizet, align); - e820_update_range(addr, sizet, E820_RAM, E820_RESERVED); + e820_update_range(addr, sizet, E820_RAM, E820_RESVD_KERN);this line is not needed.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Why? Memory reserved by
early_rserved_e820should not be saved during hibernation? shoudl not be saved by kdump?Can you tell me why this line is not needed?
[...]
Quoted 5 lines
some like the attach patch...
you still can merge
parse_setup_dataparse_e820_ext
also entries inparse_e820_extis not initialized...,__copy_e820_mapwill do nothing.Quoted 6 lines
Quoted 4 lines
OK. Because some E820 entries are available after
parse_setup_data(), it is better to callreserve_setup_data()after callingparse_setup_data()ifupdate_e820_range()is used instead ofreserve_early().please modify it and test on your platforms then submit to Ingo..
It seems that there is an issue:
Quoted 7 lines
Quoted 5 lines
- If
parse_setup_data()is called beforereserve_setup_data(), and there is a conflict between memory area used bysetup_dataand other memory area, it is possible that the contents ofsetup_datais changed. So that system may panic before reporting memory area conflict. And it seems that memory area conflict is not checked bye820_update_range().what is "other memory area"? returned from
find_e820_area? no one use that yet.
I mean memory area reserved with reserved_early() or e820_update_range() before reserve_setup_data() is called.
And because there is no conflict check in e820_update_range(), what to deal with potential conflict between setup_data and other memory area regardless which one is reserved earlier?
Another issue related:
Because some memmap entries are available via extended E820 memmap (SETUP_E820_EXT), it is not strictly safe to use e820_update_range() between setup_memory_map() and parse_setup_data(). It may be better to parse extended E820 memmap right after setup_memory_map().
Best Regards,
Huang Ying
On Mon, Jun 30, 2008 at 12:51 AM, Huang, Ying <[email protected]> wrote:> On Mon, 2008-06-30 at 00:34 -0700, Yinghai Lu wrote:>> On Mon, Jun 30, 2008 at 12:03 AM, Huang, Ying <[email protected]> wrote:>> > On Fri, 2008-06-27 at 15:05 -0700, Yinghai Lu wrote:>> >> On Thu, Jun 26, 2008 at 7:48 PM, Huang, Ying <[email protected]> wrote:>> >> > On Thu, 2008-06-26 at 19:22 -0700, Yinghai Lu wrote:>> >> >> On Thu, Jun 26, 2008 at 2:47 AM, Yinghai Lu <[email protected]> wrote:>> >> >> > On Thu, Jun 26, 2008 at 12:48 AM, Huang, Ying <[email protected]> wrote:>> >> >> >> On Thu, 2008-06-26 at 00:25 -0700, Yinghai Lu wrote:>> >> >> >> [...]>> >> >> >>> > if (pfn >= limit_pfn)>> >> >> >>> > @@ -977,7 +978,7 @@ u64 __init early_reserve_e820(u64 startt>> >> >> >>> > return 0;>> >> >> >>> >>> >> >> >>> > addr = round_down(start + size - sizet, align);>> >> >> >>> > - e820_update_range(addr, sizet, E820_RAM, E820_RESERVED);>> >> >> >>> > + e820_update_range(addr, sizet, E820_RAM, E820_RESVD_KERN);>> >> >> >>>>> >> >> >>> this line is not needed.>> >> >> >>>> >> >> >> Why? Memory reserved by early_rserved_e820 should not be saved during>> >> >> >> hibernation? shoudl not be saved by kdump?>> >> >> >>>> >> >>> >> > Can you tell me why this line is not needed?>> >> >>> >> > [...]>> >> >> some like the attach patch...>> >> >>>> >> >> you still can merge parse_setup_data parse_e820_ext>> >> >> also entries in parse_e820_ext is not initialized..., __copy_e820_map>> >> >> will do nothing.>> >> >>> >> > OK. Because some E820 entries are available after parse_setup_data(),>> >> > it is better to call reserve_setup_data() after calling>> >> > parse_setup_data() if update_e820_range() is used instead of>> >> > reserve_early().>> >>>> >> please modify it and test on your platforms then submit to Ingo..>> >>> > It seems that there is an issue:>> >>> > - If parse_setup_data() is called before reserve_setup_data(), and there>> > is a conflict between memory area used by setup_data and other memory>> > area, it is possible that the contents of setup_data is changed. So that>> > system may panic before reporting memory area conflict. And it seems>> > that memory area conflict is not checked by e820_update_range().>>>> what is "other memory area"? returned from find_e820_area? no one use that yet.>> I mean memory area reserved with reserved_early() or e820_update_range()> before reserve_setup_data() is called.
before parse_setup_data, reserve_early is called for1. kernel text/data/bss + initial pgt2. ramdisk3. ebdae820_update_range is not called.at this time early_res have RAM reserved by kernel. then setup_memory_map is called, so e820 have some ranges...directlyfrom e820 table
next need to call parse_setup_datait will add some entries in e820
then reserve_setup_data is called, it will use e820_update_range toreserve setup_data itself directly in e820
...
Quoted 1 line
Quoted 1 line
And because there is no conflict check in
e820_update_range(), what to> deal with potential conflict betweensetup_dataand other memory area> regardless which one is reserved earlier?
find_e820_area will make sure it only find ram from e820 and it is notconflict with early_res
Quoted 1 line
Quoted 1 line
Quoted 1 line
Another issue related:>> Because some memmap entries are available via extended E820 memmap> (
SETUP_E820_EXT), it is not strictly safe to usee820_update_range()> betweensetup_memory_map()andparse_setup_data(). It may be better to> parse extended E820 memmap right aftersetup_memory_map().
will look at the code again.. YH���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Quoted 82 lines · Yinghai Lu
Quoted 47 lines · Ying
Quoted 46 lines · Yinghai Lu
Quoted 44 lines · Ying
Quoted 29 lines · Yinghai Lu
Quoted 28 lines · Ying
Quoted 14 lines · Yinghai Lu
Quoted 13 lines · Yinghai Lu
Quoted 12 lines · Ying
On Thu, 2008-06-26 at 00:25 -0700, Yinghai Lu wrote:
[...]Quoted 9 lines
Review u64 __init early_reserve_e820(u64 startt · line 981
Quoted 7 lines
if (pfn >=
limit_pfn)(quoted diff) +1
-1@@ -977,7 +978,7 @@ u64 __init early_reserve_e820(u64 startt return 0; addr = round_down(start + size - sizet, align); - e820_update_range(addr, sizet, E820_RAM, E820_RESERVED); + e820_update_range(addr, sizet, E820_RAM, E820_RESVD_KERN);this line is not needed.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Why? Memory reserved by
early_rserved_e820should not be saved during hibernation? shoudl not be saved by kdump?Can you tell me why this line is not needed?
[...]
Quoted 5 lines
some like the attach patch...
you still can merge
parse_setup_dataparse_e820_ext
also entries inparse_e820_extis not initialized...,__copy_e820_mapwill do nothing.Quoted 6 lines
Quoted 4 lines
OK. Because some E820 entries are available after
parse_setup_data(), it is better to callreserve_setup_data()after callingparse_setup_data()ifupdate_e820_range()is used instead ofreserve_early().please modify it and test on your platforms then submit to Ingo..
It seems that there is an issue:
- If
parse_setup_data()is called beforereserve_setup_data(), and there is a conflict between memory area used bysetup_dataand other memory area, it is possible that the contents ofsetup_datais changed. So that system may panic before reporting memory area conflict. And it seems that memory area conflict is not checked bye820_update_range().Quoted 4 lines
Quoted 1 line
what is "other memory area"? returned from
find_e820_area? no one use that yet.I mean memory area reserved with
reserved_early()ore820_update_range()beforereserve_setup_data()is called.before
parse_setup_data,reserve_earlyis called for
1. kernel text/data/bss + initial pgt
2. ramdisk
3. ebdae820_update_rangeis not called.
at this timeearly_reshave RAM reserved by kernel.then
setup_memory_mapis called, so e820 have some ranges...directly from e820 tablenext need to call
parse_setup_data
it will add some entries in e820then
reserve_setup_datais called, it will usee820_update_rangeto reservesetup_dataitself directly in e820...
Quoted 4 lines
And because there is no conflict check in
e820_update_range(), what to deal with potential conflict betweensetup_dataand other memory area regardless which one is reserved earlier?
find_e820_areawill make sure it only find ram from e820 and it is not conflict withearly_resQuoted 2 lines
Quoted 8 lines
Quoted 6 lines
Another issue related:
Because some memmap entries are available via extended E820 memmap (
SETUP_E820_EXT), it is not strictly safe to usee820_update_range()betweensetup_memory_map()andparse_setup_data(). It may be better to parse extended E820 memmap right aftersetup_memory_map().will look at the code again..
Ying,
please check attach the v2 patch...
remove one left over reserve_setup_data for 32 bit
YH
arch/x86/kernel/e820.c +3 -1
@@ -120,6 +120,7 @@ void __init e820_print_map(char *who) (e820.map[i].addr + e820.map[i].size));switch (e820.map[i].type) {case E820_RAM : +case E820_RESERVED_KERN :printk (KERN_CONT "(usable)\n" );break ;case E820_RESERVED :
@@ -611,7 +612,7 @@ void __init e820_mark_nosave_regions(unsigned long limit_pfn)register_nosave_region (pfn,PFN_UP (ei->addr)); pfn =PFN_DOWN (ei->addr + ei->size); -if (ei->type !=E820_RAM ) +if (ei->type !=E820_RAM && ei->type !=E820_RESERVED_KERN )register_nosave_region (PFN_UP (ei->addr), pfn);if (pfn >= limit_pfn)
@@ -1207,6 +1208,7 @@ void __init e820_reserve_resources(void) res =alloc_bootmem_low (sizeof (struct resource ) * e820.nr_map);for (i =0 ; i < e820.nr_map; i++) {switch (e820.map[i].type) { +case E820_RESERVED_KERN :case E820_RAM : res->name ="System RAM" ;break ;case E820_ACPI : res->name ="ACPI Tables" ;break ;case E820_NVS : res->name ="ACPI Non-volatile Storage" ;break ;
arch/x86/kernel/head.c +0 -18
@@ -53,21 +53,3 @@ void __init reserve_ebda_region(void)/* reserve all memory between lowmem and the 1MB mark */ reserve_early_overlap_ok (lowmem,0x100000 ,"BIOS reserved" ); } - -void __init reserve_setup_data (void ) -{ -struct setup_data *data; -u64 pa_data; -char buf[32 ]; - -if (boot_params.hdr.version <0x0209 ) -return ; - pa_data = boot_params.hdr.setup_data; -while (pa_data) { - data =early_ioremap (pa_data,sizeof (*data)); -sprintf (buf,"setup data %x" , data->type); -reserve_early (pa_data, pa_data+sizeof (*data)+data->len, buf); - pa_data = data->next; -early_iounmap (data,sizeof (*data)); - } -}
arch/x86/kernel/head64.c +0 -1
@@ -123,7 +123,6 @@ void __init x86_64_start_kernel(char * real_mode_data)#endif reserve_ebda_region (); -reserve_setup_data ();/* * At this point everything still needed from the boot loader
arch/x86/kernel/setup.c +25 -6
@@ -389,14 +389,33 @@ static void __init parse_setup_data(void)default :break ; } -#ifndef CONFIG_DEBUG_BOOT_PARAMS -free_early (pa_data, pa_data+sizeof (*data)+data->len); -#endif pa_data = data->next;early_iounmap (data,PAGE_SIZE ); } } +static void __init reserve_setup_data (void ) +{ +struct setup_data *data; +u64 pa_data; +char buf[32 ]; + +if (boot_params.hdr.version <0x0209 ) +return ; + pa_data = boot_params.hdr.setup_data; +while (pa_data) { + data =early_ioremap (pa_data,sizeof (*data)); +sprintf (buf,"setup data %x" , data->type); +e820_update_range (pa_data,sizeof (*data)+data->len, +E820_RAM ,E820_RESERVED_KERN ); + pa_data = data->next; +early_iounmap (data,sizeof (*data)); + } +sanitize_e820_map (e820.map,ARRAY_SIZE (e820.map), &e820.nr_map); +printk (KERN_INFO "extended physical RAM map:\n" ); +e820_print_map ("extended" ); +} +/* * --------- Crashkernel reservation ------------------------------ */
@@ -524,7 +543,6 @@ void __init setup_arch(char **cmdline_p)pre_setup_arch_hook ();early_cpu_init ();early_ioremap_init (); -reserve_setup_data ();#else printk (KERN_INFO "Command line: %s\n" , boot_command_line);#endif
@@ -566,6 +584,9 @@ void __init setup_arch(char **cmdline_p)ARCH_SETUP setup_memory_map (); +parse_setup_data (); +reserve_setup_data (); +copy_edd ();if (!boot_params.hdr.root_flags)
@@ -592,8 +613,6 @@ void __init setup_arch(char **cmdline_p)strlcpy (command_line, boot_command_line,COMMAND_LINE_SIZE ); *cmdline_p = command_line; -parse_setup_data (); -parse_early_param ();if (acpi_mps_check ()) {
include/asm-x86/bootparam.h +0 -2
@@ -108,6 +108,4 @@ struct boot_params {__u8 _pad9[276 ];/* 0xeec */ } __attribute__((packed)); -void reserve_setup_data (void ); -#endif /* _ASM_BOOTPARAM_H */
include/asm-x86/e820.h +3 -0
@@ -44,6 +44,9 @@#define E820_ACPI 3#define E820_NVS 4 +/* reserved RAM used by kernel itself */ +#define E820_RESERVED_KERN 128 + #ifndef __ASSEMBLY__ struct e820entry { __u64 addr; /* start of memory segment */
On Mon, 2008-06-30 at 02:15 -0700, Yinghai Lu wrote:
[...]
Quoted 14 lines
Quoted 3 lines
I mean memory area reserved with
reserved_early()ore820_update_range()beforereserve_setup_data()is called.before
parse_setup_data,reserve_earlyis called for
1. kernel text/data/bss + initial pgt
2. ramdisk
3. ebdae820_update_rangeis not called.
at this timeearly_reshave RAM reserved by kernel.then
setup_memory_mapis called, so e820 have some ranges...directly from e820 table
Quoted 7 lines
next need to call
parse_setup_data
it will add some entries in e820then
reserve_setup_datais called, it will usee820_update_rangeto reservesetup_dataitself directly in e820...
Yes. There is no real conflict now. I think a better rule is:
- Reserve memory area (directly from BIOS or boot-loader, not from find_e820_area) needed as early as possible.
- Don't touch reserved area until all possible reservation is made, that is, before conflict check is done.
Quoted 7 lines
Quoted 4 lines
And because there is no conflict check in
e820_update_range(), what to deal with potential conflict betweensetup_dataand other memory area regardless which one is reserved earlier?
find_e820_areawill make sure it only find ram from e820 and it is not conflict withearly_res
For find_e820_area, this is safe enough. But what about conflict between setup_data and ebda or ramdisk?
Best Regards,
Huang Ying
Quoted 22 lines · Ying
On Mon, 2008-06-30 at 02:15 -0700, Yinghai Lu wrote:
[...]Quoted 20 lines
Quoted 3 lines
I mean memory area reserved with
reserved_early()ore820_update_range()beforereserve_setup_data()is called.before
parse_setup_data,reserve_earlyis called for
1. kernel text/data/bss + initial pgt
2. ramdisk
3. ebdae820_update_rangeis not called.
at this timeearly_reshave RAM reserved by kernel.then
setup_memory_mapis called, so e820 have some ranges...directly from e820 tablenext need to call
parse_setup_data
it will add some entries in e820then
reserve_setup_datais called, it will usee820_update_rangeto reservesetup_dataitself directly in e820
Quoted 8 lines
Quoted 1 line
...
Yes. There is no real conflict now. I think a better rule is:
- Reserve memory area (directly from BIOS or boot-loader, not from
find_e820_area) needed as early as possible.
- Don't touch reserved area until all possible reservation is made, that is, before conflict check is done.
no one touch the reserved area. before all reserved in early_res or e820.
Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
And because there is no conflict check in
e820_update_range(), what to deal with potential conflict betweensetup_dataand other memory area regardless which one is reserved earlier?
find_e820_areawill make sure it only find ram from e820 and it is not conflict withearly_resFor
find_e820_area, this is safe enough. But what about conflict betweensetup_dataand ebda or ramdisk?
can you have setup_data and ebda at the same time?
setup_data and ramdisk should be ok, because bootloader is supposed to make them not to be conflicts.
YH
Quoted 7 lines · Yinghai Lu
Quoted 2 lines
For
find_e820_area, this is safe enough. But what about conflict betweensetup_dataand ebda or ramdisk?can you have
setup_dataand ebda at the same time?
setup_dataand ramdisk should be ok, because bootloader is supposed to make them not to be conflicts.
the more sanity checks we do before relying on some crutial data, the better. It's easier to panic or sanitize data in some structured way and complain about it in the syslog than to let things get corrupted. Boot loaders are ... not unknown to be have bugs too, at times.
Ingo
Quoted 8 lines · Ingo Molnar
Quoted 5 lines · Yinghai Lu
Quoted 2 lines
For
find_e820_area, this is safe enough. But what about conflict betweensetup_dataand ebda or ramdisk?can you have
setup_dataand ebda at the same time?
Quoted 7 lines
Quoted 2 lines
setup_dataand ramdisk should be ok, because bootloader is supposed to make them not to be conflicts.the more sanity checks we do before relying on some crutial data, the better. It's easier to panic or sanitize data in some structured way and complain about it in the syslog than to let things get corrupted. Boot loaders are ... not unknown to be have bugs too, at times.
to address Ying's concern, we could let reserve_setup_data call reserve_early in addition to e820_update_range...
reserve_early will panic if RAMDISK overlap efi setup_data...
YH
Quoted 17 lines · Yinghai Lu
Quoted 8 lines · Ingo Molnar
Quoted 5 lines · Yinghai Lu
Quoted 2 lines
For
find_e820_area, this is safe enough. But what about conflict betweensetup_dataand ebda or ramdisk?can you have
setup_dataand ebda at the same time?Quoted 7 lines
Quoted 2 lines
setup_dataand ramdisk should be ok, because bootloader is supposed to make them not to be conflicts.the more sanity checks we do before relying on some crutial data, the better. It's easier to panic or sanitize data in some structured way and complain about it in the syslog than to let things get corrupted. Boot loaders are ... not unknown to be have bugs too, at times.
Quoted 5 lines
to address Ying's concern, we could let
reserve_setup_datacallreserve_earlyin addition toe820_update_range...
reserve_earlywill panic if RAMDISK overlap efisetup_data...
Ying,
please check the attached patch
YH
[PATCH] x86: move reserve_setup_data to setup.c
Ying Huang want to setup_data to be reserved, but not included in no save range.
here try to modify e820 table to reserve that range as early. also add that in early_res in case bootloader mess up it with ramdisk.
other solution would be
1. add early_res_to_highmem...
2. early_res_to_e820...
but they could reserve wrongly other type memory, if early_res has some resource reserved early, and not need later, but it is not removed from early_res in time.
like the RAMDISK (already handled).
--- arch/x86/kernel/e820.c | 4 +++- arch/x86/kernel/head.c | 18 ------------------ arch/x86/kernel/head64.c | 1 - arch/x86/kernel/setup.c | 34 ++++++++++++++++++++++++++++------ include/asm-x86/bootparam.h | 2 -- include/asm-x86/e820.h | 3 +++ 6 files changed, 34 insertions(+), 28 deletions(-)
arch/x86/kernel/e820.c +3 -1
@@ -120,6 +120,7 @@ void __init e820_print_map(char *who) (e820.map[i].addr + e820.map[i].size));switch (e820.map[i].type) {case E820_RAM : +case E820_RESERVED_KERN :printk (KERN_CONT "(usable)\n" );break ;case E820_RESERVED :
@@ -611,7 +612,7 @@ void __init e820_mark_nosave_regions(unsregister_nosave_region (pfn,PFN_UP (ei->addr)); pfn =PFN_DOWN (ei->addr + ei->size); -if (ei->type !=E820_RAM ) +if (ei->type !=E820_RAM && ei->type !=E820_RESERVED_KERN )register_nosave_region (PFN_UP (ei->addr), pfn);if (pfn >= limit_pfn)
@@ -1207,6 +1208,7 @@ void __init e820_reserve_resources(void) res =alloc_bootmem_low (sizeof (struct resource ) * e820.nr_map);for (i =0 ; i < e820.nr_map; i++) {switch (e820.map[i].type) { +case E820_RESERVED_KERN :case E820_RAM : res->name ="System RAM" ;break ;case E820_ACPI : res->name ="ACPI Tables" ;break ;case E820_NVS : res->name ="ACPI Non-volatile Storage" ;break ;
arch/x86/kernel/head.c +0 -18
@@ -53,21 +53,3 @@ void __init reserve_ebda_region(void)/* reserve all memory between lowmem and the 1MB mark */ reserve_early_overlap_ok (lowmem,0x100000 ,"BIOS reserved" ); } - -void __init reserve_setup_data (void ) -{ -struct setup_data *data; -u64 pa_data; -char buf[32 ]; - -if (boot_params.hdr.version <0x0209 ) -return ; - pa_data = boot_params.hdr.setup_data; -while (pa_data) { - data =early_ioremap (pa_data,sizeof (*data)); -sprintf (buf,"setup data %x" , data->type); -reserve_early (pa_data, pa_data+sizeof (*data)+data->len, buf); - pa_data = data->next; -early_iounmap (data,sizeof (*data)); - } -}
arch/x86/kernel/head64.c +0 -1
@@ -123,7 +123,6 @@ void __init x86_64_start_kernel(char * r#endif reserve_ebda_region (); -reserve_setup_data ();/* * At this point everything still needed from the boot loader
arch/x86/kernel/setup.c +28 -6
@@ -389,14 +389,34 @@ static void __init parse_setup_data(voiddefault :break ; } -#ifndef CONFIG_DEBUG_BOOT_PARAMS -free_early (pa_data, pa_data+sizeof (*data)+data->len); -#endif pa_data = data->next;early_iounmap (data,PAGE_SIZE ); } } +static void __init reserve_setup_data (void ) +{ +struct setup_data *data; +u64 pa_data; +char buf[32 ]; + +if (boot_params.hdr.version <0x0209 ) +return ; + pa_data = boot_params.hdr.setup_data; +while (pa_data) { + data =early_ioremap (pa_data,sizeof (*data)); +sprintf (buf,"setup data %x" , data->type); +reserve_early (pa_data, pa_data+sizeof (*data)+data->len, buf); +e820_update_range (pa_data,sizeof (*data)+data->len, +E820_RAM ,E820_RESERVED_KERN ); + pa_data = data->next; +early_iounmap (data,sizeof (*data)); + } +sanitize_e820_map (e820.map,ARRAY_SIZE (e820.map), &e820.nr_map); +printk (KERN_INFO "extended physical RAM map:\n" ); +e820_print_map ("reserve setup_data" ); +} +/* * --------- Crashkernel reservation ------------------------------ */
@@ -524,7 +544,6 @@ void __init setup_arch(char **cmdline_p)pre_setup_arch_hook ();early_cpu_init ();early_ioremap_init (); -reserve_setup_data ();#else printk (KERN_INFO "Command line: %s\n" , boot_command_line);#endif
@@ -566,6 +585,8 @@ void __init setup_arch(char **cmdline_p)ARCH_SETUP setup_memory_map (); +parse_setup_data (); +copy_edd ();if (!boot_params.hdr.root_flags)
@@ -592,10 +613,11 @@ void __init setup_arch(char **cmdline_p)strlcpy (command_line, boot_command_line,COMMAND_LINE_SIZE ); *cmdline_p = command_line; -parse_setup_data (); -parse_early_param (); +/* after early param, so could get panic from serial */ +reserve_setup_data (); +if (acpi_mps_check ()) {#ifdef CONFIG_X86_LOCAL_APIC disable_apic =1 ;
include/asm-x86/bootparam.h +0 -2
@@ -108,6 +108,4 @@ struct boot_params {__u8 _pad9[276 ];/* 0xeec */ } __attribute__((packed)); -void reserve_setup_data (void ); -#endif /* _ASM_BOOTPARAM_H */
include/asm-x86/e820.h +3 -0
@@ -44,6 +44,9 @@#define E820_ACPI 3#define E820_NVS 4 +/* reserved RAM used by kernel itself */ +#define E820_RESERVED_KERN 128 + #ifndef __ASSEMBLY__ struct e820entry { __u64 addr; /* start of memory segment */
Hi, Yinghai,
Quoted 18 lines · Yinghai Lu
Quoted 17 lines · Yinghai Lu
Quoted 15 lines · Ingo Molnar
Quoted 7 lines · Yinghai Lu
Quoted 2 lines
For
find_e820_area, this is safe enough. But what about conflict betweensetup_dataand ebda or ramdisk?can you have
setup_dataand ebda at the same time?
setup_dataand ramdisk should be ok, because bootloader is supposed to make them not to be conflicts.the more sanity checks we do before relying on some crutial data, the better. It's easier to panic or sanitize data in some structured way and complain about it in the syslog than to let things get corrupted. Boot loaders are ... not unknown to be have bugs too, at times.
Quoted 8 lines
Quoted 5 lines
to address Ying's concern, we could let
reserve_setup_datacallreserve_earlyin addition toe820_update_range...
reserve_earlywill panic if RAMDISK overlap efisetup_data...Ying,
please check the attached patch
Which git-x86 head should I use to test the patch? It can not be applied to x86/master.
Best Regards,
Huang Ying
Quoted 24 lines · Ying
Hi, Yinghai,
Quoted 21 lines · Yinghai Lu
Quoted 20 lines · Yinghai Lu
Quoted 8 lines · Ingo Molnar
Quoted 5 lines · Yinghai Lu
Quoted 2 lines
For
find_e820_area, this is safe enough. But what about conflict betweensetup_dataand ebda or ramdisk?can you have
setup_dataand ebda at the same time?Quoted 7 lines
Quoted 2 lines
setup_dataand ramdisk should be ok, because bootloader is supposed to make them not to be conflicts.the more sanity checks we do before relying on some crutial data, the better. It's easier to panic or sanitize data in some structured way and complain about it in the syslog than to let things get corrupted. Boot loaders are ... not unknown to be have bugs too, at times.
to address Ying's concern, we could let
reserve_setup_datacallreserve_earlyin addition toe820_update_range...
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
reserve_earlywill panic if RAMDISK overlap efisetup_data...Ying,
please check the attached patchWhich git-x86 head should I use to test the patch? It can not be applied to x86/master.
tip/master
YH
Quoted 7 lines · Yinghai Lu
Quoted 5 lines
Quoted 2 lines
Ying,
please check the attached patchWhich git-x86 head should I use to test the patch? It can not be applied to x86/master.
tip/master
hm, tip/master should be exactly the same thing as x86/master. (the x86.git repository is a symlink to tip.git on kernel.org)
Ingo
Huang, Ying
Tested-byQuoted 18 lines · Yinghai Lu
Quoted 17 lines · Yinghai Lu
Quoted 15 lines · Ingo Molnar
Quoted 7 lines · Yinghai Lu
Quoted 2 lines
For
find_e820_area, this is safe enough. But what about conflict betweensetup_dataand ebda or ramdisk?can you have
setup_dataand ebda at the same time?
setup_dataand ramdisk should be ok, because bootloader is supposed to make them not to be conflicts.the more sanity checks we do before relying on some crutial data, the better. It's easier to panic or sanitize data in some structured way and complain about it in the syslog than to let things get corrupted. Boot loaders are ... not unknown to be have bugs too, at times.
Quoted 9 lines
Quoted 5 lines
to address Ying's concern, we could let
reserve_setup_datacallreserve_earlyin addition toe820_update_range...
reserve_earlywill panic if RAMDISK overlap efisetup_data...Ying,
please check the attached patch
Best Regards
Huang Ying
Ingo Molnar
AppliedQuoted 6 lines · Huang, Ying
Quoted 3 lines · Yinghai Lu
Ying,
please check the attached patchTested-by Huang, Ying <[email protected]>
applied to tip/x86/unify-setup - thanks!
Ingo
Quoted 6 lines · Yinghai Lu
Quoted 4 lines
OK. Because some E820 entries are available after
parse_setup_data(), it is better to callreserve_setup_data()after callingparse_setup_data()ifupdate_e820_range()is used instead ofreserve_early().please modify it and test on your platforms then submit to Ingo..
btw, a small suggestion: it is a bit easier on the maintainer side if you also send Acked-by lines in such cases (which can be picked up for the next iteration of these patches) - that way we can see which patches have been reviewed and acked by you and which ones are still under discussion.
Ingo