Re: [PATCH 1/3] Revert "x86/retpoline: Remove .text..__x86.return_thunk section"

From: Josh Poimboeuf
Date: Tue Oct 10 2023 - 15:57:27 EST


On Tue, Oct 10, 2023 at 07:48:33PM +0200, Peter Zijlstra wrote:
> On Tue, Oct 10, 2023 at 12:10:18PM -0500, David Kaplan wrote:
>
> > arch/x86/kernel/vmlinux.lds.S | 3 +++
> > arch/x86/lib/retpoline.S | 2 ++
> > 2 files changed, 5 insertions(+)
> >
> > diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
> > index 9cdb1a7332c4..54a5596adaa6 100644
> > --- a/arch/x86/kernel/vmlinux.lds.S
> > +++ b/arch/x86/kernel/vmlinux.lds.S
> > @@ -132,7 +132,10 @@ SECTIONS
> > LOCK_TEXT
> > KPROBES_TEXT
> > SOFTIRQENTRY_TEXT
> > +#ifdef CONFIG_RETPOLINE
> > *(.text..__x86.indirect_thunk)
> > + *(.text..__x86.return_thunk)
> > +#endif
> > STATIC_CALL_TEXT
> >
> > ALIGN_ENTRY_TEXT_BEGIN
> > diff --git a/arch/x86/lib/retpoline.S b/arch/x86/lib/retpoline.S
> > index db813113e637..3da768a71cf9 100644
> > --- a/arch/x86/lib/retpoline.S
> > +++ b/arch/x86/lib/retpoline.S
> > @@ -129,6 +129,8 @@ SYM_CODE_END(__x86_indirect_jump_thunk_array)
> >
> > #ifdef CONFIG_RETHUNK
>
> Perhaps elucidate the future reader with a comment here? Lest someone
> tries removing it again.

Yes, please.

Also we could make objtool properly detect the non-relocated jump
target. But this works for now.

--
Josh