x86_64 boot: Add free_early to early reservation machanism
PATCH 1/4 x86_64 boot: Add free_early to early reservation machanism
Add free_early to early reservation mechanism.
--- arch/x86/kernel/e820_64.c | 17 +++++++++++++++++ include/asm-x86/e820_64.h | 1 + 2 files changed, 18 insertions(+)
arch/x86/kernel/e820_64.c +17 -0
@@ -84,6 +84,23 @@ void __init reserve_early(unsigned longstrncpy (r->name, name,sizeof (r->name) -1 ); } +void __init free_early (unsigned long start,unsigned long end) +{ +int i, j; +struct early_res *r; +for (i =0 ; i <MAX_EARLY_RES && early_res[i].end; i++) { + r = &early_res[i]; +if (start == r->start && end == r->end) +break ; + } +if (i >=MAX_EARLY_RES || !early_res[i].end) +panic ("free_early on not reserved area: %lx-%lx!" , start, end); +for (j = i+1 ; j <MAX_EARLY_RES && early_res[j].end; j++) ; +memcpy (&early_res[i], &early_res[i+1 ], + (j-1 -i) *sizeof (struct early_res )); + early_res[j-1 ].end =0 ; +} +void __init early_res_to_bootmem (void ) {int i;
include/asm-x86/e820_64.h +1 -0
@@ -41,6 +41,7 @@ extern struct e820map e820;extern void update_e820 (void );extern void reserve_early (unsigned long start,unsigned long end,char *name); +extern void free_early (unsigned long start,unsigned long end);extern void early_res_to_bootmem (void );#endif /*!__ASSEMBLY__*/
arch/x86/kernel/e820_64.c void __init reserve_early(unsigned long · line 97
Quoted 1 line · Huang
arch/x86/kernel/e820_64.c +1
-0+panic ("free_early on not reserved area: %lx-%lx!" , start, end);
Should that be 'early_panic', not 'panic' ?
(I see a couple more panics in that file, which I wonder if should be early_panic as well ?)
Signature · 3 lines
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <[email protected]> 1.940.382.4214Quoted 7 lines · Paul Jackson
arch/x86/kernel/e820_64.c void __init reserve_early(unsigned long · line 97
Quoted 1 line · Huang
arch/x86/kernel/e820_64.c +1
-0+panic ("free_early on not reserved area: %lx-%lx!" , start, end);Should that be '
early_panic', not 'panic' ?(I see a couple more panics in that file, which I wonder if should be
early_panicas well ?)
this should be fixed properly btw: panic() should self-select whether it does an early_panic() or a real panic().
Ingo
Quoted 8 lines · Ingo Molnar
Quoted 5 lines · Paul Jackson
arch/x86/kernel/e820_64.c void __init reserve_early(unsigned long · line 97
Quoted 1 line · Huang
arch/x86/kernel/e820_64.c +1
-0+panic ("free_early on not reserved area: %lx-%lx!" , start, end);Should that be '
early_panic', not 'panic' ?
Quoted 5 lines
Quoted 2 lines
(I see a couple more panics in that file, which I wonder if should be
early_panicas well ?)this should be fixed properly btw:
panic()should self-select whether it does anearly_panic()or a realpanic().
There's also need of a EARLY_BUG, but self selection would be a little tricky here.
I still have an old patch for this, but I haven't gotten around to submit it because it turned out the first user of it wasn't a good idea.
-Andi
arch/x86/kernel/e820_64.c void __init reserve_early(unsigned long · line 98
Quoted 1 line · Huang
arch/x86/kernel/e820_64.c +1
-0+for (j = i+1 ; j <MAX_EARLY_RES && early_res[j].end; j++) ;
Could we space this code out a little, as in:
for (j = i + 1; j < MAX_EARLY_RES && early_res[j].end; j++) ;
Signature · 3 lines
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <[email protected]> 1.940.382.4214