Skip to content

riscv: Keep helpers used by noinstr code in noinstr text

Jisheng Zhang linux-riscv lkml 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 0 repliesNew
  2. v12 patches 0 repliesSuperseded

Changes in v2 from the cover letter

- add Fixes tag to patch1
- add more missing __always_inline or noinstr to vector.h and kernel_mode_vector.c, these are missing in v1.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2riscv/traps: Mark do_trap_misaligned() with __trap_sectionarch/riscv/kernel/traps.c+2 -10 replies
2/2riscv: Keep helpers used by noinstr code in non-instrumentable textarch/riscv/include/asm/cpuidle.h arch/riscv/include/asm/entry-common.h arch/riscv/include/asm/irqflags.h +4 more+32 -310 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/2] riscv: Keep helpers used by noinstr code in noinstr text

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.

Since v1:
- add Fixes tag to patch1
- add more missing __always_inline or noinstr to vector.h and kernel_mode_vector.c, these are missing in v1.

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        | 22 +++++++++++-----------
 arch/riscv/kernel/kernel_mode_vector.c | 17 +++++++++--------
 arch/riscv/kernel/traps.c              |  3 ++-
 8 files changed, 34 insertions(+), 32 deletions(-)
Signature · 1 line
2.55.0