linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guo Ren <guoren@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: arnd@arndb.de, palmer@rivosinc.com, tglx@linutronix.de,
	luto@kernel.org, conor.dooley@microchip.com, heiko@sntech.de,
	jszhang@kernel.org, lazyparser@gmail.com, falcon@tinylab.org,
	chenhuacai@kernel.org, apatel@ventanamicro.com,
	atishp@atishpatra.org, palmer@dabbelt.com,
	paul.walmsley@sifive.com, bigeasy@linutronix.de,
	linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-riscv@lists.infradead.org,
	Guo Ren <guoren@linux.alibaba.com>
Subject: Re: [PATCH V4 4/8] riscv: traps: Add noinstr to prevent instrumentation inserted
Date: Sat, 10 Sep 2022 17:17:44 +0800	[thread overview]
Message-ID: <CAJF2gTSs4Ycu52DH6NUzdMXQGMT51XU6x-fgQ-_OpRne+vkTqQ@mail.gmail.com> (raw)
In-Reply-To: <Yxmaz7wJPEBQ7Vki@hirez.programming.kicks-ass.net>

On Thu, Sep 8, 2022 at 3:34 PM Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Wed, Sep 07, 2022 at 10:25:02PM -0400, guoren@kernel.org wrote:
> > From: Guo Ren <guoren@linux.alibaba.com>
> >
> > Without noinstr the compiler is free to insert instrumentation (think
> > all the k*SAN, KCov, GCov, ftrace etc..) which can call code we're not
> > yet ready to run this early in the entry path, for instance it could
> > rely on RCU which isn't on yet, or expect lockdep state. (by peterz)
> >
> > Link: https://lore.kernel.org/linux-riscv/YxcQ6NoPf3AH0EXe@hirez.programming.kicks-ass.net/raw
> > Suggested-by: Peter Zijlstra <peterz@infradead.org>
> > Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
> > Signed-off-by: Guo Ren <guoren@kernel.org>
> > ---
> >  arch/riscv/kernel/traps.c | 8 ++++----
> >  arch/riscv/mm/fault.c     | 2 +-
> >  2 files changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
> > index 635e6ec26938..3ed3dbec250d 100644
> > --- a/arch/riscv/kernel/traps.c
> > +++ b/arch/riscv/kernel/traps.c
> > @@ -97,7 +97,7 @@ static void do_trap_error(struct pt_regs *regs, int signo, int code,
> >  #define __trap_section
> >  #endif
> >  #define DO_ERROR_INFO(name, signo, code, str)                                \
> > -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


-- 
Best Regards
 Guo Ren

  reply	other threads:[~2022-09-10  9:19 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-08  2:24 [PATCH V4 0/9] riscv: Add GENERIC_ENTRY, irq stack support guoren
2022-09-08  2:24 ` [PATCH V4 1/8] riscv: elf_kexec: Fixup compile warning guoren
2022-09-08  2:25 ` [PATCH V4 2/8] riscv: compat_syscall_table: " guoren
2022-09-08  2:25 ` [PATCH V4 3/8] riscv: ptrace: Remove duplicate operation guoren
2022-09-08  2:25 ` [PATCH V4 4/8] riscv: traps: Add noinstr to prevent instrumentation inserted guoren
2022-09-08  7:33   ` Peter Zijlstra
2022-09-10  9:17     ` Guo Ren [this message]
2022-09-10 12:46       ` Guo Ren
2022-09-11 15:09       ` Peter Zijlstra
2022-09-11 16:20         ` Guo Ren
2022-09-08  2:25 ` [PATCH V4 5/8] riscv: convert to generic entry guoren
2022-09-15 13:50   ` Yipeng Zou
2022-09-08  2:25 ` [PATCH V4 6/8] riscv: Support HAVE_IRQ_EXIT_ON_IRQ_STACK guoren
2022-09-08 16:08   ` Sebastian Andrzej Siewior
2022-09-09  7:30     ` David Laight
2022-09-11  1:13       ` Guo Ren
2022-09-08  2:25 ` [PATCH V4 7/8] riscv: Support HAVE_SOFTIRQ_ON_OWN_STACK guoren
2022-09-08 16:01   ` Sebastian Andrzej Siewior
2022-09-18 15:42     ` Guo Ren
2022-09-08  2:25 ` [PATCH V4 8/8] riscv: Add config of thread stack size guoren
2022-09-08  7:35   ` Arnd Bergmann
2022-09-10 12:52     ` Guo Ren
2022-09-10 16:06       ` Arnd Bergmann
2022-09-10 23:35         ` Guo Ren
2022-09-11 18:39           ` Arnd Bergmann
2022-09-12  4:14             ` Guo Ren
2022-09-12  8:23               ` Arnd Bergmann
2022-09-19  8:38                 ` Guo Ren
2022-09-19  8:35         ` Guo Ren
2022-09-20  0:46           ` Guo Ren
2022-09-20  7:15             ` Arnd Bergmann
2022-09-21  6:11               ` Guo Ren
2022-09-20  7:17             ` Arnd Bergmann
2022-09-21  6:13               ` Guo Ren
2022-09-21  8:23                 ` Guo Ren
2022-09-21 10:31                   ` Guo Ren
2022-09-21 10:46                     ` Guo Ren
2022-09-22  5:55                       ` Arnd Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJF2gTSs4Ycu52DH6NUzdMXQGMT51XU6x-fgQ-_OpRne+vkTqQ@mail.gmail.com \
    --to=guoren@kernel.org \
    --cc=apatel@ventanamicro.com \
    --cc=arnd@arndb.de \
    --cc=atishp@atishpatra.org \
    --cc=bigeasy@linutronix.de \
    --cc=chenhuacai@kernel.org \
    --cc=conor.dooley@microchip.com \
    --cc=falcon@tinylab.org \
    --cc=guoren@linux.alibaba.com \
    --cc=heiko@sntech.de \
    --cc=jszhang@kernel.org \
    --cc=lazyparser@gmail.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=luto@kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=palmer@rivosinc.com \
    --cc=paul.walmsley@sifive.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).