|
Message-ID: <CABCJKueeL+1ydcZsm2BS4qrX4Wxy7zY7FUQdoN_WLuUxFfqcmQ@mail.gmail.com> Date: Fri, 13 Nov 2020 15:31:34 -0800 From: Sami Tolvanen <samitolvanen@...gle.com> To: Josh Poimboeuf <jpoimboe@...hat.com> Cc: Peter Zijlstra <peterz@...radead.org>, Jann Horn <jannh@...gle.com>, "the arch/x86 maintainers" <x86@...nel.org>, Masahiro Yamada <masahiroy@...nel.org>, Steven Rostedt <rostedt@...dmis.org>, Will Deacon <will@...nel.org>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>, "Paul E. McKenney" <paulmck@...nel.org>, Kees Cook <keescook@...omium.org>, Nick Desaulniers <ndesaulniers@...gle.com>, clang-built-linux <clang-built-linux@...glegroups.com>, Kernel Hardening <kernel-hardening@...ts.openwall.com>, linux-arch <linux-arch@...r.kernel.org>, Linux ARM <linux-arm-kernel@...ts.infradead.org>, linux-kbuild <linux-kbuild@...r.kernel.org>, kernel list <linux-kernel@...r.kernel.org>, linux-pci@...r.kernel.org Subject: Re: [PATCH v6 22/25] x86/asm: annotate indirect jumps On Fri, Nov 13, 2020 at 2:34 PM Josh Poimboeuf <jpoimboe@...hat.com> wrote: > > On Fri, Nov 13, 2020 at 12:24:32PM -0800, Sami Tolvanen wrote: > > > I still don't see this warning for some reason. > > > > Do you have CONFIG_XEN enabled? I can reproduce this on ToT master as follows: > > > > $ git rev-parse HEAD > > 585e5b17b92dead8a3aca4e3c9876fbca5f7e0ba > > $ make defconfig && \ > > ./scripts/config -e HYPERVISOR_GUEST -e PARAVIRT -e XEN && \ > > make olddefconfig && \ > > make -j110 > > ... > > $ ./tools/objtool/objtool check -arfld vmlinux.o 2>&1 | grep secondary > > vmlinux.o: warning: objtool: __startup_secondary_64()+0x2: return with > > modified stack frame > > > > > Is it fixed by adding cpu_bringup_and_idle() to global_noreturns[] in > > > tools/objtool/check.c? > > > > No, that didn't fix the warning. Here's what I tested: > > I think this fixes it: > > From: Josh Poimboeuf <jpoimboe@...hat.com> > Subject: [PATCH] x86/xen: Fix objtool vmlinux.o validation of xen hypercalls > > Objtool vmlinux.o validation is showing warnings like the following: > > # tools/objtool/objtool check -barfld vmlinux.o > vmlinux.o: warning: objtool: __startup_secondary_64()+0x2: return with modified stack frame > vmlinux.o: warning: objtool: xen_hypercall_set_trap_table()+0x0: <=== (sym) > > Objtool falls through all the empty hypercall text and gets confused > when it encounters the first real function afterwards. The empty unwind > hints in the hypercalls aren't working for some reason. Replace them > with a more straightforward use of STACK_FRAME_NON_STANDARD. > > Reported-by: Sami Tolvanen <samitolvanen@...gle.com> > Signed-off-by: Josh Poimboeuf <jpoimboe@...hat.com> > --- > arch/x86/xen/xen-head.S | 9 ++++----- > include/linux/objtool.h | 8 ++++++++ > 2 files changed, 12 insertions(+), 5 deletions(-) > > diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S > index 2d7c8f34f56c..3c538b1ff4a6 100644 > --- a/arch/x86/xen/xen-head.S > +++ b/arch/x86/xen/xen-head.S > @@ -6,6 +6,7 @@ > > #include <linux/elfnote.h> > #include <linux/init.h> > +#include <linux/objtool.h> > > #include <asm/boot.h> > #include <asm/asm.h> > @@ -67,14 +68,12 @@ SYM_CODE_END(asm_cpu_bringup_and_idle) > .pushsection .text > .balign PAGE_SIZE > SYM_CODE_START(hypercall_page) > - .rept (PAGE_SIZE / 32) > - UNWIND_HINT_EMPTY > - .skip 32 > - .endr > + .skip PAGE_SIZE > > #define HYPERCALL(n) \ > .equ xen_hypercall_##n, hypercall_page + __HYPERVISOR_##n * 32; \ > - .type xen_hypercall_##n, @function; .size xen_hypercall_##n, 32 > + .type xen_hypercall_##n, @function; .size xen_hypercall_##n, 32; \ > + STACK_FRAME_NON_STANDARD xen_hypercall_##n > #include <asm/xen-hypercalls.h> > #undef HYPERCALL > SYM_CODE_END(hypercall_page) > diff --git a/include/linux/objtool.h b/include/linux/objtool.h > index 577f51436cf9..746617265236 100644 > --- a/include/linux/objtool.h > +++ b/include/linux/objtool.h > @@ -109,6 +109,12 @@ struct unwind_hint { > .popsection > .endm > > +.macro STACK_FRAME_NON_STANDARD func:req > + .pushsection .discard.func_stack_frame_non_standard > + .long \func - . > + .popsection > +.endm > + > #endif /* __ASSEMBLY__ */ > > #else /* !CONFIG_STACK_VALIDATION */ > @@ -123,6 +129,8 @@ struct unwind_hint { > .macro UNWIND_HINT sp_reg:req sp_offset=0 type:req end=0 > .endm > #endif > +.macro STACK_FRAME_NON_STANDARD func:req > +.endm This macro needs to be before the #endif, so it's defined only for assembly code. This breaks my arm64 builds even though x86 curiously worked just fine. Sami
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.