[PATCH V4 4/8] riscv: traps: Add noinstr to prevent instrumentation inserted
Guo Ren
guoren at kernel.org
Sun Sep 11 09:20:56 PDT 2022
On Sun, Sep 11, 2022 at 11:09 PM Peter Zijlstra <peterz at infradead.org> wrote:
>
> On Sat, Sep 10, 2022 at 05:17:44PM +0800, Guo Ren wrote:
>
> > > > -asmlinkage __visible __trap_section void name(struct pt_regs *regs) \
> > > > +asmlinkage __visible __trap_section void noinstr name(struct pt_regs *regs) \
> > >
> > > But now you have __trap_section and noinstr both adding a section
> > > attribute.
> >
> > Oops, thx for correcting. Here is my solution.
> >
> > diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
> > index 635e6ec26938..eba744caa711 100644
> > --- a/arch/riscv/kernel/traps.c
> > +++ b/arch/riscv/kernel/traps.c
> > @@ -92,9 +92,11 @@ static void do_trap_error(struct pt_regs *regs, int
> > signo, int code,
> > }
> >
> > #if defined(CONFIG_XIP_KERNEL) && defined(CONFIG_RISCV_ALTERNATIVE)
> > -#define __trap_section __section(".xip.traps")
> > +#define __trap_section \
> > + noinline notrace __attribute((__section__(".xip.traps"))) \
> > + __no_kcsan __no_sanitize_address __no_profile __no_sanitize_coverage
> > #else
> > -#define __trap_section
> > +#define __trap_section noinstr
> > #endif
>
> This is almost guaranteed to get out of sync when the compiler guys add
> yet another sanitizier. Please consider picking up this patch:
>
> https://lore.kernel.org/all/20211110115736.3776-7-jiangshanlai@gmail.com/
Thx, that is what I want.
>
> and using __noinstr_section(".xip.traps")
--
Best Regards
Guo Ren
More information about the linux-riscv
mailing list