Skip to content

Commit c56c599

Browse files
kristina-martsenkoctmarinas
authored andcommitted
arm64: probes: Disable kprobes/uprobes on MOPS instructions
FEAT_MOPS instructions require that all three instructions (prologue, main and epilogue) appear consecutively in memory. Placing a kprobe/uprobe on one of them doesn't work as only a single instruction gets executed out-of-line or simulated. So don't allow placing a probe on a MOPS instruction. Fixes: b756412 ("arm64: mops: detect and enable FEAT_MOPS") Signed-off-by: Kristina Martsenko <kristina.martsenko@arm.com> Link: https://lore.kernel.org/r/20240930161051.3777828-2-kristina.martsenko@arm.com Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 9852d85 commit c56c599

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

arch/arm64/include/asm/insn.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ __AARCH64_INSN_FUNCS(ldrsw_lit, 0xFF000000, 0x98000000)
353353
__AARCH64_INSN_FUNCS(exclusive, 0x3F800000, 0x08000000)
354354
__AARCH64_INSN_FUNCS(load_ex, 0x3F400000, 0x08400000)
355355
__AARCH64_INSN_FUNCS(store_ex, 0x3F400000, 0x08000000)
356+
__AARCH64_INSN_FUNCS(mops, 0x3B200C00, 0x19000400)
356357
__AARCH64_INSN_FUNCS(stp, 0x7FC00000, 0x29000000)
357358
__AARCH64_INSN_FUNCS(ldp, 0x7FC00000, 0x29400000)
358359
__AARCH64_INSN_FUNCS(stp_post, 0x7FC00000, 0x28800000)

arch/arm64/kernel/probes/decode-insn.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,13 @@ static bool __kprobes aarch64_insn_is_steppable(u32 insn)
5858
* Instructions which load PC relative literals are not going to work
5959
* when executed from an XOL slot. Instructions doing an exclusive
6060
* load/store are not going to complete successfully when single-step
61-
* exception handling happens in the middle of the sequence.
61+
* exception handling happens in the middle of the sequence. Memory
62+
* copy/set instructions require that all three instructions be placed
63+
* consecutively in memory.
6264
*/
6365
if (aarch64_insn_uses_literal(insn) ||
64-
aarch64_insn_is_exclusive(insn))
66+
aarch64_insn_is_exclusive(insn) ||
67+
aarch64_insn_is_mops(insn))
6568
return false;
6669

6770
return true;

0 commit comments

Comments
 (0)