Skip to contentSkip to conversation

ix86: fix vDSO build

PATCH In review Jan Beulich 6 participants 9 messages Jul 3, 2014 – Jul 23, 2014 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ix86: fix vDSO build

Relying on static functions used just once to get inlined (and subsequently have dead code paths eliminated) is wrong: Compilers are free to decide whether they do this, regardless of optimization level. With this not happening for vdso_addr() (observed with gcc 4.1.x), an unresolved reference to align_vdso_addr() causes the build to fail.

Cc Andy Lutomirski <[email protected]>
---
 arch/x86/vdso/vma.c    |    4 ++++
 1 file changed, 4 insertions(+)
arch/x86/vdso/vma.c +4 -0
@@ -62,6 +62,9 @@ struct linux_binprm;
    Only used for the 64-bit and x32 vdsos. */
 static unsigned long vdso_addr(unsigned long start, unsigned len)
 {
+#ifdef CONFIG_X86_32
+	return 0;
+#else
 	unsigned long addr, end;
 	unsigned offset;
 	end = (start + PMD_SIZE - 1) & PMD_MASK;
@@ -83,6 +86,7 @@ static unsigned long vdso_addr(unsigned
 	addr = align_vdso_addr(addr);
 
 	return addr;
+#endif
 }
 
 static int map_vdso(const struct vdso_image *image, bool calculate_addr)
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Jan Beulich

Relying on static functions used just once to get inlined (and subsequently have dead code paths eliminated) is wrong: Compilers are free to decide whether they do this, regardless of optimization level. With this not happening for vdso_addr() (observed with gcc 4.1.x), an unresolved reference to align_vdso_addr() causes the build to fail.

Cc Andy Lutomirski <[email protected]>

Any chance you could send a dump of the symbol and relocation tables of a .so.dbg with this problem? I'm curious why checkundef.sh never caught it.

--Andy

#2 lore raw
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 03.07.14 at 17:34, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich

Relying on static functions used just once to get inlined (and subsequently have dead code paths eliminated) is wrong: Compilers are free to decide whether they do this, regardless of optimization level. With this not happening for vdso_addr() (observed with gcc 4.1.x), an unresolved reference to align_vdso_addr() causes the build to fail.

Quoted 4 lines
Quoted 2 lines
Cc Andy Lutomirski <[email protected]>

Thanks (also for the other one).

Quoted 3 lines

Any chance you could send a dump of the symbol and relocation tables of a .so.dbg with this problem? I'm curious why checkundef.sh never caught it.

vma.o is part of the kernel, not the .so.

Jan

#3 lore raw
Quoted 13 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 03.07.14 at 17:34, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich

Relying on static functions used just once to get inlined (and subsequently have dead code paths eliminated) is wrong: Compilers are free to decide whether they do this, regardless of optimization level. With this not happening for vdso_addr() (observed with gcc 4.1.x), an unresolved reference to align_vdso_addr() causes the build to fail.

Quoted 4 lines
Quoted 2 lines
Cc Andy Lutomirski <[email protected]>
Quoted 7 lines

Thanks (also for the other one).

Quoted 3 lines

Any chance you could send a dump of the symbol and relocation tables of a .so.dbg with this problem? I'm curious why checkundef.sh never caught it.

vma.o is part of the kernel, not the .so.

Duh :)

--Andy

Tested-by on v1 1/1
#4 lore raw
In reply to Jan Beulich
Quoted 5 lines · Jan Beulich

Relying on static functions used just once to get inlined (and subsequently have dead code paths eliminated) is wrong: Compilers are free to decide whether they do this, regardless of optimization level. With this not happening for vdso_addr() (observed with gcc 4.1.x), an unresolved reference to align_vdso_addr() causes the build to fail.

Quoted 35 lines
Cc Andy Lutomirski <[email protected]>
---
  arch/x86/vdso/vma.c    |    4 ++++
  1 file changed, 4 insertions(+)
arch/x86/vdso/vma.c +4 -1
@@ -62,6 +62,9 @@ struct linux_binprm;
     Only used for the 64-bit and x32 vdsos. */
  static unsigned long vdso_addr(unsigned long start, unsigned len)
  {
+#ifdef CONFIG_X86_32
+	return 0;
+#else
  	unsigned long addr, end;
  	unsigned offset;
  	end = (start + PMD_SIZE - 1) & PMD_MASK;
@@ -83,6 +86,7 @@ static unsigned long vdso_addr(unsigned
  	addr = align_vdso_addr(addr);
 
  	return addr;
+#endif
  }
 
  static int map_vdso(const struct vdso_image *image, bool calculate_addr)
 
 
 
--

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Tested-by on v1 1/1
#5 lore raw
In reply to Jan Beulich
Quoted 25 lines · On Thu, 03 Jul 2014 15:35:07 +0100 "Jan Beulich" <[email protected]> wrote:

Relying on static functions used just once to get inlined (and subsequently have dead code paths eliminated) is wrong: Compilers are free to decide whether they do this, regardless of optimization level. With this not happening for vdso_addr() (observed with gcc 4.1.x), an unresolved reference to align_vdso_addr() causes the build to fail.

Cc Andy Lutomirski <[email protected]>
---
 arch/x86/vdso/vma.c    |    4 ++++
 1 file changed, 4 insertions(+)
arch/x86/vdso/vma.c +3 -0
@@ -62,6 +62,9 @@ struct linux_binprm;
    Only used for the 64-bit and x32 vdsos. */
 static unsigned long vdso_addr(unsigned long start, unsigned len)
 {
+#ifdef CONFIG_X86_32
+	return 0;
+#else
 	unsigned long addr, end;
 	unsigned offset;
 	end = (start + PMD_SIZE - 1) & PMD_MASK;

arch/x86/vdso/vma.c static unsigned long vdso_addr(unsigned · line 92

Quoted 7 lines
arch/x86/vdso/vma.c +1 -0
@@ -83,6 +86,7 @@ static unsigned long vdso_addr(unsigned
 	addr = align_vdso_addr(addr);
 
 	return addr;
+#endif
 }
 
 static int map_vdso(const struct vdso_image *image, bool calculate_addr)
#6 lore raw
In reply to Jan Beulich
Quoted 5 lines · Jan Beulich

Relying on static functions used just once to get inlined (and subsequently have dead code paths eliminated) is wrong: Compilers are free to decide whether they do this, regardless of optimization level. With this not happening for vdso_addr() (observed with gcc 4.1.x), an unresolved reference to align_vdso_addr() causes the build to fail.

The fix seems odd... more of the flavor of "happens to work" unless I'm misunderstanding something. If this needs to be inlined, wouldn't __always_inline make more sense?

What am I missing?

-hpa

#7 lore raw
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 11.07.14 at 00:58, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich

Relying on static functions used just once to get inlined (and subsequently have dead code paths eliminated) is wrong: Compilers are free to decide whether they do this, regardless of optimization level. With this not happening for vdso_addr() (observed with gcc 4.1.x), an unresolved reference to align_vdso_addr() causes the build to fail.

Quoted 5 lines

The fix seems odd... more of the flavor of "happens to work" unless I'm misunderstanding something. If this needs to be inlined, wouldn't __always_inline make more sense?

What am I missing?

I think this is a matter of taste: Personally I think __always_inline should be used rather rarely, as it takes away decisions from the compiler that it would (generally) be in the better position to make.

Sorry for the late reply (was on vacation),
Jan

#8 lore raw

[tip:x86/urgent] x86-32, vdso: Fix vDSO build error due to missing align_vdso_addr()

In reply to Jan Beulich
x86-32, vdso: Fix vDSO build error due to missing align_vdso_addr()
Commit-ID:  d093601be5e97d2729614419d0d256ed3b6a56b0
Gitweb:     http://git.kernel.org/tip/d093601be5e97d2729614419d0d256ed3b6a56b0
Author:     Jan Beulich <[email protected]>
AuthorDate: Thu, 3 Jul 2014 15:35:07 +0100
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Thu, 10 Jul 2014 16:06:04 -0700

x86-32, vdso: Fix vDSO build error due to missing align_vdso_addr()

Relying on static functions used just once to get inlined (and subsequently have dead code paths eliminated) is wrong: Compilers are free to decide whether they do this, regardless of optimization level. With this not happening for vdso_addr() (observed with gcc 4.1.x), an unresolved reference to align_vdso_addr() causes the build to fail.

[ hpa: vdso_addr() is never actually used on x86-32, as calculate_addr
in map_vdso() is always false. It ought to be possible to clean this up further, but this fixes the immediate problem. ]

---
 arch/x86/vdso/vma.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/x86/vdso/vma.c +4 -0
index e1513c4..5a5176d 100644
@@ -62,6 +62,9 @@ struct linux_binprm;
    Only used for the 64-bit and x32 vdsos. */
 static unsigned long vdso_addr(unsigned long start, unsigned len)
 {
+#ifdef CONFIG_X86_32
+	return 0;
+#else
 	unsigned long addr, end;
 	unsigned offset;
 	end = (start + PMD_SIZE - 1) & PMD_MASK;
@@ -83,6 +86,7 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
 	addr = align_vdso_addr(addr);
 
 	return addr;
+#endif
 }
 
 static int map_vdso(const struct vdso_image *image, bool calculate_addr)