x86/boot: move early_serial_base to .data section
PATCH 1/2 x86/boot: move early_serial_base to .data section
arch/x86/boot/compressed/head_64.S clears BSS after relocated. If early serial is set up before clearing BSS, the early_serial_base will be reset to 0.
Initializing early_serial_base as -1 to push it to .data section.
--- arch/x86/boot/compressed/early_serial_console.c | 2 +- arch/x86/boot/early_serial_console.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/boot/compressed/early_serial_console.c +1 -1
@@ -1,5 +1,5 @@#include "misc.h" -int early_serial_base; +int early_serial_base =-1 ;#include "../early_serial_console.c"
arch/x86/boot/early_serial_console.c +1 -1
@@ -149,6 +149,6 @@ void console_init(void) {parse_earlyprintk (); -if (!early_serial_base) +if (early_serial_base <=0 )parse_console_uart8250 (); }
Signature · 1 line
2.7.4
PATCH 2/2 x86/boot: push console_init forward
At the very early boot stage, early console is badly needed. Push its initialization as early as possible, just after stack is ready.
--- arch/x86/boot/compressed/early_serial_console.c | 7 +++++++ arch/x86/boot/compressed/head_64.S | 4 ++++ arch/x86/boot/compressed/misc.c | 1 - 3 files changed, 11 insertions(+), 1 deletion(-)
arch/x86/boot/compressed/early_serial_console.c +7 -0
@@ -3,3 +3,10 @@int early_serial_base =-1 ;#include "../early_serial_console.c" + +void early_console_init (void *rmode) +{ + boot_params = rmode; +console_init (); +debug_putstr ("early console is ready\n" ); +}
arch/x86/boot/compressed/head_64.S +4 -0
@@ -323,6 +323,10 @@ ENTRY(startup_64) subq $1b, %rdi call adjust_got + pushq %rsi + movq %rsi, %rdi + call early_console_init + popq %rsi /* * At this point we are in long mode with 4-level paging enabled,
arch/x86/boot/compressed/misc.c +0 -1
@@ -368,7 +368,6 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap, lines = boot_params->screen_info.orig_video_lines; cols = boot_params->screen_info.orig_video_cols; -console_init ();debug_putstr ("early console in extract_kernel\n" ); free_mem_ptr = heap;/* Heap */
Signature · 1 line
2.7.4
Quoted 5 lines · Pingfan Liu
arch/x86/boot/compressed/head_64.Sclears BSS after relocated. If early serial is set up before clearing BSS, theearly_serial_basewill be reset to 0.Initializing
early_serial_baseas -1 to push it to .data section.
I'm wondering whether it's wise to clear the BSS after relocation to begin with. It already gets cleared once, and an implicit zeroing of all fields on kernel relocation sounds dubious to me.
Is there a strong reason for that? I.e. is there some uninitialized or otherwise important-to-clear data there?
Thanks,
Ingo
Quoted 8 lines · Ingo Molnar
Quoted 4 lines · Pingfan Liu
arch/x86/boot/compressed/head_64.Sclears BSS after relocated. If early serial is set up before clearing BSS, theearly_serial_basewill be reset to 0.
Quoted 6 lines
Quoted 1 line
Initializing
early_serial_baseas -1 to push it to .data section.I'm wondering whether it's wise to clear the BSS after relocation to begin with. It already gets cleared once, and an implicit zeroing of all fields on kernel relocation sounds dubious to me.
After reading the code more closely, I think that the BSS is not fully initialized to 0, exception the stack and heap.
Furthermore the BSS is not copied to the target address. We just copy [0, _bss).
Quoted 3 lines
Is there a strong reason for that? I.e. is there some uninitialized or otherwise important-to-clear data there?
I guess the reason may be stack or heap can contain some position dependent data. (While in practice, there is no such kind of data in the code now days)
Thanks,
Pingfan