* [PATCH] x86,bpf: Avoid IBT objtool warning
@ 2022-04-05 7:55 Peter Zijlstra
2022-04-05 16:58 ` Alexei Starovoitov
2022-04-07 9:46 ` [tip: x86/urgent] " tip-bot2 for Peter Zijlstra
0 siblings, 2 replies; 5+ messages in thread
From: Peter Zijlstra @ 2022-04-05 7:55 UTC (permalink / raw)
To: x86, alexei.starovoitov; +Cc: linux-kernel
Clang can inline emit_indirect_jump() and then folds constants, which
results in:
| vmlinux.o: warning: objtool: emit_bpf_dispatcher()+0x6a4: relocation to !ENDBR: .text.__x86.indirect_thunk+0x40
| vmlinux.o: warning: objtool: emit_bpf_dispatcher()+0x67d: relocation to !ENDBR: .text.__x86.indirect_thunk+0x40
| vmlinux.o: warning: objtool: emit_bpf_tail_call_indirect()+0x386: relocation to !ENDBR: .text.__x86.indirect_thunk+0x20
| vmlinux.o: warning: objtool: emit_bpf_tail_call_indirect()+0x35d: relocation to !ENDBR: .text.__x86.indirect_thunk+0x20
Suppress the optimization such that it must emit a code reference to
the __x86_indirect_thunk_array[] base.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/x86/net/bpf_jit_comp.c | 1 +
1 file changed, 1 insertion(+)
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -412,6 +412,7 @@ static void emit_indirect_jump(u8 **ppro
EMIT_LFENCE();
EMIT2(0xFF, 0xE0 + reg);
} else if (cpu_feature_enabled(X86_FEATURE_RETPOLINE)) {
+ OPTIMIZER_HIDE_VAR(reg);
emit_jump(&prog, &__x86_indirect_thunk_array[reg], ip);
} else
#endif
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86,bpf: Avoid IBT objtool warning
2022-04-05 7:55 [PATCH] x86,bpf: Avoid IBT objtool warning Peter Zijlstra
@ 2022-04-05 16:58 ` Alexei Starovoitov
2022-04-06 10:46 ` Peter Zijlstra
2022-04-07 9:46 ` [tip: x86/urgent] " tip-bot2 for Peter Zijlstra
1 sibling, 1 reply; 5+ messages in thread
From: Alexei Starovoitov @ 2022-04-05 16:58 UTC (permalink / raw)
To: Peter Zijlstra, bpf, Daniel Borkmann, Andrii Nakryiko; +Cc: X86 ML, LKML
On Tue, Apr 5, 2022 at 12:55 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
>
> Clang can inline emit_indirect_jump() and then folds constants, which
> results in:
>
> | vmlinux.o: warning: objtool: emit_bpf_dispatcher()+0x6a4: relocation to !ENDBR: .text.__x86.indirect_thunk+0x40
> | vmlinux.o: warning: objtool: emit_bpf_dispatcher()+0x67d: relocation to !ENDBR: .text.__x86.indirect_thunk+0x40
> | vmlinux.o: warning: objtool: emit_bpf_tail_call_indirect()+0x386: relocation to !ENDBR: .text.__x86.indirect_thunk+0x20
> | vmlinux.o: warning: objtool: emit_bpf_tail_call_indirect()+0x35d: relocation to !ENDBR: .text.__x86.indirect_thunk+0x20
>
> Suppress the optimization such that it must emit a code reference to
> the __x86_indirect_thunk_array[] base.
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
> arch/x86/net/bpf_jit_comp.c | 1 +
> 1 file changed, 1 insertion(+)
>
> --- a/arch/x86/net/bpf_jit_comp.c
> +++ b/arch/x86/net/bpf_jit_comp.c
> @@ -412,6 +412,7 @@ static void emit_indirect_jump(u8 **ppro
> EMIT_LFENCE();
> EMIT2(0xFF, 0xE0 + reg);
> } else if (cpu_feature_enabled(X86_FEATURE_RETPOLINE)) {
> + OPTIMIZER_HIDE_VAR(reg);
> emit_jump(&prog, &__x86_indirect_thunk_array[reg], ip);
> } else
> #endif
Looks good. Please cc bpf@vger and all bpf maintainers in the future.
We can take it through the bpf tree if you prefer.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86,bpf: Avoid IBT objtool warning
2022-04-05 16:58 ` Alexei Starovoitov
@ 2022-04-06 10:46 ` Peter Zijlstra
2022-04-06 17:01 ` Alexei Starovoitov
0 siblings, 1 reply; 5+ messages in thread
From: Peter Zijlstra @ 2022-04-06 10:46 UTC (permalink / raw)
To: Alexei Starovoitov; +Cc: bpf, Daniel Borkmann, Andrii Nakryiko, X86 ML, LKML
On Tue, Apr 05, 2022 at 09:58:28AM -0700, Alexei Starovoitov wrote:
> On Tue, Apr 5, 2022 at 12:55 AM Peter Zijlstra <peterz@infradead.org> wrote:
> >
> >
> > Clang can inline emit_indirect_jump() and then folds constants, which
> > results in:
> >
> > | vmlinux.o: warning: objtool: emit_bpf_dispatcher()+0x6a4: relocation to !ENDBR: .text.__x86.indirect_thunk+0x40
> > | vmlinux.o: warning: objtool: emit_bpf_dispatcher()+0x67d: relocation to !ENDBR: .text.__x86.indirect_thunk+0x40
> > | vmlinux.o: warning: objtool: emit_bpf_tail_call_indirect()+0x386: relocation to !ENDBR: .text.__x86.indirect_thunk+0x20
> > | vmlinux.o: warning: objtool: emit_bpf_tail_call_indirect()+0x35d: relocation to !ENDBR: .text.__x86.indirect_thunk+0x20
> >
> > Suppress the optimization such that it must emit a code reference to
> > the __x86_indirect_thunk_array[] base.
> >
> > Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > ---
> > arch/x86/net/bpf_jit_comp.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > --- a/arch/x86/net/bpf_jit_comp.c
> > +++ b/arch/x86/net/bpf_jit_comp.c
> > @@ -412,6 +412,7 @@ static void emit_indirect_jump(u8 **ppro
> > EMIT_LFENCE();
> > EMIT2(0xFF, 0xE0 + reg);
> > } else if (cpu_feature_enabled(X86_FEATURE_RETPOLINE)) {
> > + OPTIMIZER_HIDE_VAR(reg);
> > emit_jump(&prog, &__x86_indirect_thunk_array[reg], ip);
> > } else
> > #endif
>
> Looks good. Please cc bpf@vger and all bpf maintainers in the future.
Oh right, I'll go add an alias for that.
> We can take it through the bpf tree if you prefer.
I'll take it through the x86/urgent tree if you don't mind.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86,bpf: Avoid IBT objtool warning
2022-04-06 10:46 ` Peter Zijlstra
@ 2022-04-06 17:01 ` Alexei Starovoitov
0 siblings, 0 replies; 5+ messages in thread
From: Alexei Starovoitov @ 2022-04-06 17:01 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: bpf, Daniel Borkmann, Andrii Nakryiko, X86 ML, LKML
On Wed, Apr 6, 2022 at 3:46 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Tue, Apr 05, 2022 at 09:58:28AM -0700, Alexei Starovoitov wrote:
> > On Tue, Apr 5, 2022 at 12:55 AM Peter Zijlstra <peterz@infradead.org> wrote:
> > >
> > >
> > > Clang can inline emit_indirect_jump() and then folds constants, which
> > > results in:
> > >
> > > | vmlinux.o: warning: objtool: emit_bpf_dispatcher()+0x6a4: relocation to !ENDBR: .text.__x86.indirect_thunk+0x40
> > > | vmlinux.o: warning: objtool: emit_bpf_dispatcher()+0x67d: relocation to !ENDBR: .text.__x86.indirect_thunk+0x40
> > > | vmlinux.o: warning: objtool: emit_bpf_tail_call_indirect()+0x386: relocation to !ENDBR: .text.__x86.indirect_thunk+0x20
> > > | vmlinux.o: warning: objtool: emit_bpf_tail_call_indirect()+0x35d: relocation to !ENDBR: .text.__x86.indirect_thunk+0x20
> > >
> > > Suppress the optimization such that it must emit a code reference to
> > > the __x86_indirect_thunk_array[] base.
> > >
> > > Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > > ---
> > > arch/x86/net/bpf_jit_comp.c | 1 +
> > > 1 file changed, 1 insertion(+)
> > >
> > > --- a/arch/x86/net/bpf_jit_comp.c
> > > +++ b/arch/x86/net/bpf_jit_comp.c
> > > @@ -412,6 +412,7 @@ static void emit_indirect_jump(u8 **ppro
> > > EMIT_LFENCE();
> > > EMIT2(0xFF, 0xE0 + reg);
> > > } else if (cpu_feature_enabled(X86_FEATURE_RETPOLINE)) {
> > > + OPTIMIZER_HIDE_VAR(reg);
> > > emit_jump(&prog, &__x86_indirect_thunk_array[reg], ip);
> > > } else
> > > #endif
> >
> > Looks good. Please cc bpf@vger and all bpf maintainers in the future.
>
> Oh right, I'll go add an alias for that.
>
> > We can take it through the bpf tree if you prefer.
>
> I'll take it through the x86/urgent tree if you don't mind.
Sure. Then pls add:
Acked-by: Alexei Starovoitov <ast@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [tip: x86/urgent] x86,bpf: Avoid IBT objtool warning
2022-04-05 7:55 [PATCH] x86,bpf: Avoid IBT objtool warning Peter Zijlstra
2022-04-05 16:58 ` Alexei Starovoitov
@ 2022-04-07 9:46 ` tip-bot2 for Peter Zijlstra
1 sibling, 0 replies; 5+ messages in thread
From: tip-bot2 for Peter Zijlstra @ 2022-04-07 9:46 UTC (permalink / raw)
To: linux-tip-commits
Cc: Peter Zijlstra (Intel), Alexei Starovoitov, x86, linux-kernel
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: be8a096521ca1a252bf078b347f96ce94582612e
Gitweb: https://git.kernel.org/tip/be8a096521ca1a252bf078b347f96ce94582612e
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Mon, 28 Mar 2022 13:13:41 +02:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Thu, 07 Apr 2022 11:27:02 +02:00
x86,bpf: Avoid IBT objtool warning
Clang can inline emit_indirect_jump() and then folds constants, which
results in:
| vmlinux.o: warning: objtool: emit_bpf_dispatcher()+0x6a4: relocation to !ENDBR: .text.__x86.indirect_thunk+0x40
| vmlinux.o: warning: objtool: emit_bpf_dispatcher()+0x67d: relocation to !ENDBR: .text.__x86.indirect_thunk+0x40
| vmlinux.o: warning: objtool: emit_bpf_tail_call_indirect()+0x386: relocation to !ENDBR: .text.__x86.indirect_thunk+0x20
| vmlinux.o: warning: objtool: emit_bpf_tail_call_indirect()+0x35d: relocation to !ENDBR: .text.__x86.indirect_thunk+0x20
Suppress the optimization such that it must emit a code reference to
the __x86_indirect_thunk_array[] base.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lkml.kernel.org/r/20220405075531.GB30877@worktop.programming.kicks-ass.net
---
arch/x86/net/bpf_jit_comp.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index 8fe35ed..16b6efa 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -412,6 +412,7 @@ static void emit_indirect_jump(u8 **pprog, int reg, u8 *ip)
EMIT_LFENCE();
EMIT2(0xFF, 0xE0 + reg);
} else if (cpu_feature_enabled(X86_FEATURE_RETPOLINE)) {
+ OPTIMIZER_HIDE_VAR(reg);
emit_jump(&prog, &__x86_indirect_thunk_array[reg], ip);
} else
#endif
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-04-07 9:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-05 7:55 [PATCH] x86,bpf: Avoid IBT objtool warning Peter Zijlstra
2022-04-05 16:58 ` Alexei Starovoitov
2022-04-06 10:46 ` Peter Zijlstra
2022-04-06 17:01 ` Alexei Starovoitov
2022-04-07 9:46 ` [tip: x86/urgent] " tip-bot2 for Peter Zijlstra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox