Skip to contentSkip to conversation

x86: make relocatable kernel work with new binutils -resend

PATCH In review Shaohua Li 2 participants 5 messages Jan 17, 2011 – Jan 18, 2011 x86

lore
Share & tools
lore

Shaohua Li

author
#0 lore raw

PATCH 1/1 x86: make relocatable kernel work with new binutils -resend

last post is lost, resend it.

The CONFIG_RELOCATABLE is broken with new binutils, which will make boot panic. According to Lu Hongjiu, the affected binutils are from 2.20.51.0.12 to 2.21.51.0.3, which are release since Oct 22 this year. At least ubuntu 10.10 is using such binutils. see:
http://sourceware.org/bugzilla/show_bug.cgi?id=12327
The reason of boot panic is we have 'jiffies = jiffies_64;' in vmlinux.lds.S. The jiffies isn't in any section. In kernel build, there is warning saying jiffies is an absolute address and can't be relocatable. At runtime, jiffies will have virtual address 0.

---
 arch/x86/kernel/vmlinux.lds.S |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
arch/x86/kernel/vmlinux.lds.S +5 -2
Index: linux/arch/x86/kernel/vmlinux.lds.S
===================================================================
@@ -34,11 +34,9 @@ OUTPUT_FORMAT(CONFIG_OUTPUT_FORMAT, CONF
 #ifdef CONFIG_X86_32
 OUTPUT_ARCH(i386)
 ENTRY(phys_startup_32)
-jiffies = jiffies_64;
 #else
 OUTPUT_ARCH(i386:x86-64)
 ENTRY(phys_startup_64)
-jiffies_64 = jiffies;
 #endif
 
 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
@@ -142,6 +140,11 @@ SECTIONS
 		CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
 
 		DATA_DATA
+#ifdef CONFIG_X86_32
+		jiffies = jiffies_64;
+#else
+		jiffies_64 = jiffies;
+#endif
 		CONSTRUCTORS
 
 		/* rarely changed data like cpu maps */
#1 lore raw

arch/x86/kernel/vmlinux.lds.S SECTIONS · line 147

Quoted 9 lines · Shaohua Li
arch/x86/kernel/vmlinux.lds.S +5 -0
@@ -142,6 +140,11 @@ SECTIONS
 		CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
 
 		DATA_DATA
+#ifdef CONFIG_X86_32
+		jiffies = jiffies_64;
+#else
+		jiffies_64 = jiffies;
+#endif

I suspect this needs a comment, as to the unsuspecting reader it looks like black magic :-)

Thanks,

Ingo

author
#2 lore raw
Quoted 5 lines · Ingo Molnar
Quoted 3 lines · Shaohua Li
(quoted diff) +0 -0
@@ -142,6 +140,11 @@ SECTIONS
 		CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
 
Quoted 9 lines

Review SECTIONS · line 147

Quoted 6 lines
(quoted diff) +5 -0
 		DATA_DATA
+#ifdef CONFIG_X86_32
+		jiffies = jiffies_64;
+#else
+		jiffies_64 = jiffies;
+#endif

I suspect this needs a comment, as to the unsuspecting reader it looks like black magic :-)

does this one look better?

The CONFIG_RELOCATABLE is broken with new binutils, which will make boot panic. According to Lu Hongjiu, the affected binutils are from 2.20.51.0.12 to 2.21.51.0.3, which are release since Oct 22 this year. At least ubuntu 10.10 is using such binutils. see:
http://sourceware.org/bugzilla/show_bug.cgi?id=12327
The reason of boot panic is we have 'jiffies = jiffies_64;' in vmlinux.lds.S. The jiffies isn't in any section. In kernel build, there is warning saying jiffies is an absolute address and can't be relocatable. At runtime, jiffies will have virtual address 0.

---
 arch/x86/kernel/vmlinux.lds.S |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
arch/x86/kernel/vmlinux.lds.S +9 -2
Index: linux/arch/x86/kernel/vmlinux.lds.S
===================================================================
@@ -34,11 +34,9 @@ OUTPUT_FORMAT(CONFIG_OUTPUT_FORMAT, CONF
 #ifdef CONFIG_X86_32
 OUTPUT_ARCH(i386)
 ENTRY(phys_startup_32)
-jiffies = jiffies_64;
 #else
 OUTPUT_ARCH(i386:x86-64)
 ENTRY(phys_startup_64)
-jiffies_64 = jiffies;
 #endif
 
 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
@@ -142,6 +140,15 @@ SECTIONS
 		CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
 
 		DATA_DATA
+		/*
+		 * Workaround a binutils (2.20.51.0.12 to 2.21.51.0.3) bug.
+		 * This makes jiffies relocatable in such binutils
+		 */
+#ifdef CONFIG_X86_32
+		jiffies = jiffies_64;
+#else
+		jiffies_64 = jiffies;
+#endif
 		CONSTRUCTORS
 
 		/* rarely changed data like cpu maps */
#3 lore raw
Quoted 16 lines · Shaohua Li
Quoted 5 lines · Ingo Molnar
Quoted 3 lines · Shaohua Li
arch/x86/kernel/vmlinux.lds.S +0 -0
@@ -142,6 +140,11 @@ SECTIONS
 		CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
 
Quoted 9 lines

arch/x86/kernel/vmlinux.lds.S SECTIONS · line 151

Quoted 6 lines
arch/x86/kernel/vmlinux.lds.S +5 -0
 		DATA_DATA
+#ifdef CONFIG_X86_32
+		jiffies = jiffies_64;
+#else
+		jiffies_64 = jiffies;
+#endif

I suspect this needs a comment, as to the unsuspecting reader it looks like black magic :-)

Quoted 1 line

does this one look better?

Yeah, thanks!

Ingo

#4 lore raw

[tip:x86/urgent] x86: Make relocatable kernel work with new binutils

In reply to Shaohua Li
Commit-ID:  86b1e8dd83cbb0fcbf3d61d2b461df8be1f528cf
Gitweb:     http://git.kernel.org/tip/86b1e8dd83cbb0fcbf3d61d2b461df8be1f528cf
Author:     Shaohua Li <[email protected]>
AuthorDate: Tue, 18 Jan 2011 08:57:49 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 18 Jan 2011 09:05:33 +0100

x86: Make relocatable kernel work with new binutils

The CONFIG_RELOCATABLE=y option is broken with new binutils, which will make boot panic.

According to Lu Hongjiu, the affected binutils are from 2.20.51.0.12 to 2.21.51.0.3, which are release since Oct 22 this year. At least ubuntu 10.10 is using such binutils. See:

    http://sourceware.org/bugzilla/show_bug.cgi?id=12327

The reason of the boot panic is that we have 'jiffies = jiffies_64;' in vmlinux.lds.S. The jiffies isn't in any section. In kernel build, there is warning saying jiffies is an absolute address and can't be relocatable. At runtime, jiffies will have virtual address 0.

Cc Lu Hongjiu<[email protected]>
Cc Huang Ying <[email protected]>
Cc Sam Ravnborg <[email protected]>

LKML-Reference: <1295312269.1949.725.camel@sli10-conroe>

---
 arch/x86/kernel/vmlinux.lds.S |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
arch/x86/kernel/vmlinux.lds.S +9 -2
index bf47007..b34ab80 100644
@@ -34,11 +34,9 @@ OUTPUT_FORMAT(CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT)
 #ifdef CONFIG_X86_32
 OUTPUT_ARCH(i386)
 ENTRY(phys_startup_32)
-jiffies = jiffies_64;
 #else
 OUTPUT_ARCH(i386:x86-64)
 ENTRY(phys_startup_64)
-jiffies_64 = jiffies;
 #endif
 
 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
@@ -142,6 +140,15 @@ SECTIONS
 		CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
 
 		DATA_DATA
+		/*
+		 * Workaround a binutils (2.20.51.0.12 to 2.21.51.0.3) bug.
+		 * This makes jiffies relocatable in such binutils
+		 */
+#ifdef CONFIG_X86_32
+		jiffies = jiffies_64;
+#else
+		jiffies_64 = jiffies;
+#endif
 		CONSTRUCTORS
 
 		/* rarely changed data like cpu maps */