Skip to contentSkip to conversation

new objtool warnings again...

PATCH In review Linus Torvalds 4 participants 11 messages Sep 23, 2016 – Sep 27, 2016 x86

lore
Share & tools
lore
#0 lore raw

Josh,

the current F24 toolchain causes

    kernel/signal.o: warning: objtool: .altinstr_replacement+0x54:

call without frame pointer save/setup

during a regular allmodconfig build.

Doing an objdump says:

...
54: e8 00 00 00 00 callq 59 <.altinstr_replacement+0x59>

                        55: R_X86_64_PC32       copy_user_generic_string-0x4
  59:   e8 00 00 00 00          callq  5e <.altinstr_replacement+0x5e>
                        5a: R_X86_64_PC32

copy_user_enhanced_fast_string-0x4
...

so it seems to come from the alternative_call_2() in copy_user_generic().

It's somewhere in copy_siginfo_to_user(), so I assume it's just the

        if (from->si_code < 0)
                return __copy_to_user(to, from, sizeof(siginfo_t))
                        ? -EFAULT : 0;

case. Looking at the code generation, it looks like the frame pointer generation in that function has been moved down past this code, so the objtool warning seems to be correct, but this indicates that gcc has decided that we don't need a frame for that alternative_call_2() thing.

So this code is clearly missing the magic to tell gcc that the asm needs a frame pointer.

What was that magic again? Mind sending a patch?

Linus

#1 lore raw
Quoted 3 lines · Linus Torvalds

So this code is clearly missing the magic to tell gcc that the asm needs a frame pointer.

Independently of that, the objtool build seems racy or somehow fragile. I've now twice gotten into a situation where I end up getting

cat: /home/torvalds/v2.6/linux/tools/objtool/.fixdep.o.d: No such
file or directory
make[4]: *** [/home/torvalds/v2.6/linux/tools/objtool/fixdep.o] Error 1 make[3]: *** [/home/torvalds/v2.6/linux/tools/objtool/fixdep-in.o] Error 2 make[2]: *** [fixdep] Error 2
make[1]: *** [objtool] Error 2
make: *** [tools/objtool] Error 2

with just the right timings, and then ccache ends up remembering that as a build failure and causing that to be "sticky" even across "git clean -dqfx" builds (and the "ccache -C" clears it).

Adding Michal to the cc, in case he can see what the problem is.

Linus

#2 lore raw
Quoted 17 lines · Linus Torvalds
Quoted 3 lines · Linus Torvalds

So this code is clearly missing the magic to tell gcc that the asm needs a frame pointer.

Independently of that, the objtool build seems racy or somehow fragile. I've now twice gotten into a situation where I end up getting

cat: /home/torvalds/v2.6/linux/tools/objtool/.fixdep.o.d: No such
file or directory
make[4]: *** [/home/torvalds/v2.6/linux/tools/objtool/fixdep.o] Error 1 make[3]: *** [/home/torvalds/v2.6/linux/tools/objtool/fixdep-in.o] Error 2 make[2]: *** [fixdep] Error 2
make[1]: *** [objtool] Error 2
make: *** [tools/objtool] Error 2

Quoted 5 lines

with just the right timings, and then ccache ends up remembering that as a build failure and causing that to be "sticky" even across "git clean -dqfx" builds (and the "ccache -C" clears it).

Adding Michal to the cc, in case he can see what the problem is.

I just started seeing this problem today. I suspect it's a ccache issue, since it only showed up after ccache was updated. I "fixed" it with:

yum downgrade ccache

I'll open a bug...

Signature · 1 line
Josh
#3 lore raw
Quoted 3 lines · Josh Poimboeuf

I just started seeing this problem today. I suspect it's a ccache issue, since it only showed up after ccache was updated.

Ahh, I didn't even notice that ccache got updated, but yeah, that makes sense.

Linus

#4 lore raw

Em Fri, Sep 23, 2016 at 02:19:04PM -0700, Linus Torvalds escreveu:

Quoted 6 lines · Josh Poimboeuf
Quoted 3 lines

I just started seeing this problem today. I suspect it's a ccache issue, since it only showed up after ccache was updated.

Ahh, I didn't even notice that ccache got updated, but yeah, that makes sense.

yeah, that explains the problems on my side as well, I "fixed" it by uninstalling ccache, will get the older version..

- Arnaldo

#5 lore raw
Quoted 10 lines · Arnaldo Carvalho de Melo

Em Fri, Sep 23, 2016 at 02:19:04PM -0700, Linus Torvalds escreveu:

Quoted 6 lines · Josh Poimboeuf
Quoted 3 lines

I just started seeing this problem today. I suspect it's a ccache issue, since it only showed up after ccache was updated.

Ahh, I didn't even notice that ccache got updated, but yeah, that makes sense.

yeah, that explains the problems on my side as well, I "fixed" it by uninstalling ccache, will get the older version..

FYI, here's the upstream ccache github issue:

https://github.com/ccache/ccache/issues/133

and possibly related:

https://github.com/ccache/ccache/issues/134

Signature · 1 line
Josh
#6 lore raw
In reply to Linus Torvalds
Quoted 33 lines · Linus Torvalds

Josh,

the current F24 toolchain causes

    kernel/signal.o: warning: objtool: .altinstr_replacement+0x54:

call without frame pointer save/setup

during a regular allmodconfig build.

Doing an objdump says:

...
54: e8 00 00 00 00 callq 59 <.altinstr_replacement+0x59>

                        55: R_X86_64_PC32       copy_user_generic_string-0x4
  59:   e8 00 00 00 00          callq  5e <.altinstr_replacement+0x5e>
                        5a: R_X86_64_PC32

copy_user_enhanced_fast_string-0x4
...

so it seems to come from the alternative_call_2() in copy_user_generic().

It's somewhere in copy_siginfo_to_user(), so I assume it's just the

        if (from->si_code < 0)
                return __copy_to_user(to, from, sizeof(siginfo_t))
                        ? -EFAULT : 0;

case. Looking at the code generation, it looks like the frame pointer generation in that function has been moved down past this code, so the objtool warning seems to be correct, but this indicates that gcc has decided that we don't need a frame for that alternative_call_2() thing.

Quoted 4 lines

So this code is clearly missing the magic to tell gcc that the asm needs a frame pointer.

What was that magic again? Mind sending a patch?

Is this with your latest pushed master branch? I have F24, but I don't see the warning.

In any case, I'll come up with a patch for you to test.

Signature · 1 line
Josh
#7 lore raw
Quoted 3 lines · Josh Poimboeuf

Is this with your latest pushed master branch? I have F24, but I don't see the warning.

It is with the latest branch, but I was wrong - it doesn't show up for "allmodconfig", it only shows up for my fairly-minimal config on this laptop.

Quoted 1 line

In any case, I'll come up with a patch for you to test.

I can send you my odd config in case you want it, but I'm assuming you just went "ahh, I know what's up" and don't even need it.

Linus

#8 lore raw

PATCH 1/1 x86/alternatives: add stack frame dependency to alternative_call_2()

Linus reported the following objtool warning:

kernel/signal.o: warning: objtool: .altinstr_replacement+0x54: call without frame pointer save/setup

The warning is valid. It's caused by the fact that gcc placed the call instruction in alternative_call_2()'s inline asm before the frame pointer setup, which breaks frame pointer convention and can result in a bad stack trace.

Force a stack frame to be created before the call instruction by listing the stack pointer as an output operand in the inline asm statement.

---
 arch/x86/include/asm/alternative.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
arch/x86/include/asm/alternative.h +6 -2
index e77a644..1b02038 100644
@@ -217,10 +217,14 @@ static inline int alternatives_text_reserved(void *start, void *end)
  */
 #define alternative_call_2(oldfunc, newfunc1, feature1, newfunc2, feature2,   \
 			   output, input...)				      \
+{									      \
+	register void *__sp asm(_ASM_SP);				      \
 	asm volatile (ALTERNATIVE_2("call %P[old]", "call %P[new1]", feature1,\
 		"call %P[new2]", feature2)				      \
-		: output : [old] "i" (oldfunc), [new1] "i" (newfunc1),	      \
-		[new2] "i" (newfunc2), ## input)
+		: output, "+r" (__sp)					      \
+		: [old] "i" (oldfunc), [new1] "i" (newfunc1),		      \
+		  [new2] "i" (newfunc2), ## input);			      \
+}
 
 /*
  * use this macro(s) if you need more than one output parameter
Signature · 1 line
2.7.4
#9 lore raw

Re: [PATCH] x86/alternatives: add stack frame dependency to alternative_call_2()

Quoted 2 lines · Josh Poimboeuf

Works for me. So:

but I don't think I'll apply this to my tree now, since it's largely harmless, and we're already going to do an rc8 and I worry that it will end up showing something else. But it probably would be good to queue for the x86 tree for 4.9

Linus

#10 lore raw

[tip:x86/asm] x86/alternatives: Add stack frame dependency to alternative_call_2()

In reply to Josh Poimboeuf
x86/alternatives: Add stack frame dependency to alternative_call_2()
Commit-ID:  317c2ce77d8ab73c24f4fb9c75e5bb441fbe3e30
Gitweb:     http://git.kernel.org/tip/317c2ce77d8ab73c24f4fb9c75e5bb441fbe3e30
Author:     Josh Poimboeuf <[email protected]>
AuthorDate: Fri, 23 Sep 2016 16:49:39 -0500
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 24 Sep 2016 09:30:03 +0200

x86/alternatives: Add stack frame dependency to alternative_call_2()

Linus reported the following objtool warning:

kernel/signal.o: warning: objtool: .altinstr_replacement+0x54: call without frame pointer save/setup

The warning is valid. It's caused by the fact that gcc placed the call instruction in alternative_call_2()'s inline asm before the frame pointer setup, which breaks frame pointer convention and can result in a bad stack trace.

Force a stack frame to be created before the call instruction by listing the stack pointer as an output operand in the inline asm statement.

Cc Andy Lutomirski <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Brian Gerst <[email protected]>
Cc Denys Vlasenko <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 arch/x86/include/asm/alternative.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
arch/x86/include/asm/alternative.h +6 -2
index e77a644..1b02038 100644
@@ -217,10 +217,14 @@ static inline int alternatives_text_reserved(void *start, void *end)
  */
 #define alternative_call_2(oldfunc, newfunc1, feature1, newfunc2, feature2,   \
 			   output, input...)				      \
+{									      \
+	register void *__sp asm(_ASM_SP);				      \
 	asm volatile (ALTERNATIVE_2("call %P[old]", "call %P[new1]", feature1,\
 		"call %P[new2]", feature2)				      \
-		: output : [old] "i" (oldfunc), [new1] "i" (newfunc1),	      \
-		[new2] "i" (newfunc2), ## input)
+		: output, "+r" (__sp)					      \
+		: [old] "i" (oldfunc), [new1] "i" (newfunc1),		      \
+		  [new2] "i" (newfunc2), ## input);			      \
+}
 
 /*
  * use this macro(s) if you need more than one output parameter