Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm64: insn: always inline hint generation

All users of aarch64_insn_gen_hint() (e.g. aarch64_insn_gen_nop()) pass
a constant argument and generate a constant value. Some of those users
are noinstr code (e.g. for alternatives patching).

For noinstr code it is necessary to either inline these functions or to
ensure the out-of-line versions are noinstr.

Since in all cases these are generating a constant, make them
__always_inline.

There should be no functional change as a result of this patch.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Joey Gouly <joey.gouly@arm.com>
Cc: Will Deacon <will@kernel.org>
Reviewed-by: Joey Gouly <joey.gouly@arm.com>
Link: https://lore.kernel.org/r/20221114135928.3000571-5-mark.rutland@arm.com
Signed-off-by: Will Deacon <will@kernel.org>

authored by

Mark Rutland and committed by
Will Deacon
f750255f 4488f90c

+12 -12
+12 -2
arch/arm64/include/asm/insn.h
··· 552 552 enum aarch64_insn_branch_type type); 553 553 u32 aarch64_insn_gen_cond_branch_imm(unsigned long pc, unsigned long addr, 554 554 enum aarch64_insn_condition cond); 555 - u32 aarch64_insn_gen_hint(enum aarch64_insn_hint_cr_op op); 556 - u32 aarch64_insn_gen_nop(void); 555 + 556 + static __always_inline u32 557 + aarch64_insn_gen_hint(enum aarch64_insn_hint_cr_op op) 558 + { 559 + return aarch64_insn_get_hint_value() | op; 560 + } 561 + 562 + static __always_inline u32 aarch64_insn_gen_nop(void) 563 + { 564 + return aarch64_insn_gen_hint(AARCH64_INSN_HINT_NOP); 565 + } 566 + 557 567 u32 aarch64_insn_gen_branch_reg(enum aarch64_insn_register reg, 558 568 enum aarch64_insn_branch_type type); 559 569 u32 aarch64_insn_gen_load_store_reg(enum aarch64_insn_register reg,
-10
arch/arm64/lib/insn.c
··· 350 350 offset >> 2); 351 351 } 352 352 353 - u32 __kprobes aarch64_insn_gen_hint(enum aarch64_insn_hint_cr_op op) 354 - { 355 - return aarch64_insn_get_hint_value() | op; 356 - } 357 - 358 - u32 __kprobes aarch64_insn_gen_nop(void) 359 - { 360 - return aarch64_insn_gen_hint(AARCH64_INSN_HINT_NOP); 361 - } 362 - 363 353 u32 aarch64_insn_gen_branch_reg(enum aarch64_insn_register reg, 364 354 enum aarch64_insn_branch_type type) 365 355 {