mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] riscv: Keep helpers used by noinstr code in noinstr text
@ 2026-11-07  7:16 Jisheng Zhang
  2026-11-07  7:16 ` [PATCH 1/2] riscv/traps: Mark do_trap_misaligned() with __trap_section Jisheng Zhang
  2026-11-07  7:16 ` [PATCH 2/2] riscv: Keep helpers used by noinstr code in non-instrumentable text Jisheng Zhang
  0 siblings, 2 replies; 3+ messages in thread
From: Jisheng Zhang @ 2026-11-07  7:16 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti
  Cc: linux-riscv, linux-kernel

A plain inline annotation does not guarantee inlining. In particular,
size optimization can cause helpers called from noinstr functions to
be emitted out of line in .text. Such copies do not inherit the
caller's instrumentation restrictions.

Use __always_inline for the IRQ, idle, stack-check and vector helpers
reachable from non-instrumentable entry paths, including their nested
helpers. Also force inline arch_exit_to_user_mode_prepare().

do_trap_misaligned() is called by some '__trap_section' functions such
as do_trap_load_misaligned() and do_trap_store_misaligned() which are
noinstr code. So we also need to mark do_trap_misaligned() with
__trap_section to keep it in non-instrumentable text as well.

Build-tested the affected entry, trap, idle, stacktrace and KVM objects
with GCC and CONFIG_CC_OPTIMIZE_FOR_SIZE=y. Inspected object symbols
and relocations.


Jisheng Zhang (2):
  riscv/traps: Mark do_trap_misaligned() with __trap_section
  riscv: Keep helpers used by noinstr code in non-instrumentable text

 arch/riscv/include/asm/cpuidle.h      |  2 +-
 arch/riscv/include/asm/entry-common.h |  4 ++--
 arch/riscv/include/asm/irqflags.h     | 14 +++++++-------
 arch/riscv/include/asm/processor.h    |  2 +-
 arch/riscv/include/asm/stacktrace.h   |  2 +-
 arch/riscv/include/asm/vector.h       | 16 ++++++++--------
 arch/riscv/kernel/traps.c             |  3 ++-
 7 files changed, 22 insertions(+), 21 deletions(-)

-- 
2.55.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-07  7:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-07  7:16 [PATCH 0/2] riscv: Keep helpers used by noinstr code in noinstr text Jisheng Zhang
2026-11-07  7:16 ` [PATCH 1/2] riscv/traps: Mark do_trap_misaligned() with __trap_section Jisheng Zhang
2026-11-07  7:16 ` [PATCH 2/2] riscv: Keep helpers used by noinstr code in non-instrumentable text Jisheng Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®