Re: IBT related objtool warnings

From: Peter Zijlstra
Date: Thu Apr 07 2022 - 12:07:36 EST


On Thu, Apr 07, 2022 at 05:51:06PM +0200, Peter Zijlstra wrote:
> On Wed, Apr 06, 2022 at 10:43:33PM +0000, Edgecombe, Rick P wrote:
> > Hi,
> >
> > After commit:
> > ed53a0d97192 x86/alternative: Use .ibt_endbr_seal to seal indirect calls
> >
> > I am getting objtool "unreachable instruction" warnings.
> >
> > On one system with gcc 8.4.0:
> > vmlinux.o: warning: objtool: start_secondary()+0x10e: unreachable
> > instruction
> >
> > On another with gcc 11.2.1:
> > vmlinux.o: warning: objtool: pvh_start_xen()+0x0: unreachable
> > instruction
> >
> > Let me know if any tests on my end would help.
>
> This seems to make it go on gcc-11.2 tip/x86/urgent..
>
> ---
>
> arch/x86/entry/entry_64.S | 3 +++
> arch/x86/platform/pvh/head.S | 1 +
> 2 files changed, 4 insertions(+)
>
> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
> index 4faac48ebec5..73d958522b6a 100644
> --- a/arch/x86/entry/entry_64.S
> +++ b/arch/x86/entry/entry_64.S
> @@ -337,6 +337,9 @@ SYM_CODE_END(ret_from_fork)
>
> call \cfunc
>
> + /* For some configurations \cfunc ends up being a noreturn. */
> + REACHABLE
> +
> jmp error_return
> .endm
>
> diff --git a/arch/x86/platform/pvh/head.S b/arch/x86/platform/pvh/head.S
> index 72c1e42d121d..7fe564eaf228 100644
> --- a/arch/x86/platform/pvh/head.S
> +++ b/arch/x86/platform/pvh/head.S
> @@ -50,6 +50,7 @@
> #define PVH_DS_SEL (PVH_GDT_ENTRY_DS * 8)
>
> SYM_CODE_START_LOCAL(pvh_start_xen)
> + UNWIND_HINT_EMPTY
> cld
>
> lgdt (_pa(gdt))

And this for gcc-8.4

---
include/linux/cpu.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 9cf51e41e697..54dc2f9a2d56 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -167,7 +167,7 @@ static inline int suspend_disable_secondary_cpus(void) { return 0; }
static inline void suspend_enable_secondary_cpus(void) { }
#endif /* !CONFIG_PM_SLEEP_SMP */

-void cpu_startup_entry(enum cpuhp_state state);
+void __noreturn cpu_startup_entry(enum cpuhp_state state);

void cpu_idle_poll_ctrl(bool enable);