浏览代码

[PATCH] x86_64: Patch to make the head.S-must-be-first-in-vmlinux order explicit

This patch puts the code from head.S in a special .bootstrap.text
section.

I'm working on a patch to reorder the functions in the kernel (I'll post
that later), but for x86-64 at least the kernel bootstrap requires that
the head.S functions are on the very first page/pages of the kernel
text.  This is understandable since the bootstrap is complex enough
already and not a problem at all, it just means they aren't allowed to
be reordered.  This patch puts these special functions into a separate
section to document this, and to guarantee this in the light of possibly
reordering the rest later.

(So this patch doesn't fix a bug per se, but makes things more robust by
making the order of these functions explicit)

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Arjan van de Ven 19 年之前
父节点
当前提交
eaeae0cc98
共有 2 个文件被更改,包括 2 次插入0 次删除
  1. 1 0
      arch/x86_64/kernel/head.S
  2. 1 0
      arch/x86_64/kernel/vmlinux.lds.S

+ 1 - 0
arch/x86_64/kernel/head.S

@@ -26,6 +26,7 @@
  */
  */
 
 
 	.text
 	.text
+	.section .bootstrap.text
 	.code32
 	.code32
 	.globl startup_32
 	.globl startup_32
 /* %bx:	 1 if coming from smp trampoline on secondary cpu */ 
 /* %bx:	 1 if coming from smp trampoline on secondary cpu */ 

+ 1 - 0
arch/x86_64/kernel/vmlinux.lds.S

@@ -20,6 +20,7 @@ SECTIONS
   phys_startup_64 = startup_64 - LOAD_OFFSET;
   phys_startup_64 = startup_64 - LOAD_OFFSET;
   _text = .;			/* Text and read-only data */
   _text = .;			/* Text and read-only data */
   .text :  AT(ADDR(.text) - LOAD_OFFSET) {
   .text :  AT(ADDR(.text) - LOAD_OFFSET) {
+	*(.bootstrap.text)
 	*(.text)
 	*(.text)
 	SCHED_TEXT
 	SCHED_TEXT
 	LOCK_TEXT
 	LOCK_TEXT