Skip to content

Commit fb892bd

Browse files
committed
ARM: kprobes: Eliminate test code's use of BX instruction on ARMv4 CPUs
Non-T variants of ARMv4 CPUs don't support the BX instruction so eliminate its use. Signed-off-by: Jon Medhurst <[email protected]>
1 parent bfc9657 commit fb892bd

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

arch/arm/probes/kprobes/test-arm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,12 @@ void kprobe_arm_test_cases(void)
215215
TEST_UNSUPPORTED("msr cpsr_f, lr")
216216
TEST_UNSUPPORTED("msr spsr, r0")
217217

218+
#if __LINUX_ARM_ARCH__ >= 5 || \
219+
(__LINUX_ARM_ARCH__ == 4 && !defined(CONFIG_CPU_32v4))
218220
TEST_BF_R("bx r",0,2f,"")
219221
TEST_BB_R("bx r",7,2f,"")
220222
TEST_BF_R("bxeq r",14,2f,"")
223+
#endif
221224

222225
#if __LINUX_ARM_ARCH__ >= 5
223226
TEST_R("clz r0, r",0, 0x0,"")

arch/arm/probes/kprobes/test-core.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ static int tests_failed;
236236

237237
#ifndef CONFIG_THUMB2_KERNEL
238238

239+
#define RET(reg) "mov pc, "#reg
240+
239241
long arm_func(long r0, long r1);
240242

241243
static void __used __naked __arm_kprobes_test_func(void)
@@ -245,14 +247,16 @@ static void __used __naked __arm_kprobes_test_func(void)
245247
".type arm_func, %%function \n\t"
246248
"arm_func: \n\t"
247249
"adds r0, r0, r1 \n\t"
248-
"bx lr \n\t"
250+
"mov pc, lr \n\t"
249251
".code "NORMAL_ISA /* Back to Thumb if necessary */
250252
: : : "r0", "r1", "cc"
251253
);
252254
}
253255

254256
#else /* CONFIG_THUMB2_KERNEL */
255257

258+
#define RET(reg) "bx "#reg
259+
256260
long thumb16_func(long r0, long r1);
257261
long thumb32even_func(long r0, long r1);
258262
long thumb32odd_func(long r0, long r1);
@@ -494,7 +498,7 @@ static void __naked benchmark_nop(void)
494498
{
495499
__asm__ __volatile__ (
496500
"nop \n\t"
497-
"bx lr"
501+
RET(lr)" \n\t"
498502
);
499503
}
500504

@@ -977,7 +981,7 @@ void __naked __kprobes_test_case_start(void)
977981
"bic r0, lr, #1 @ r0 = inline data \n\t"
978982
"mov r1, sp \n\t"
979983
"bl kprobes_test_case_start \n\t"
980-
"bx r0 \n\t"
984+
RET(r0)" \n\t"
981985
);
982986
}
983987

0 commit comments

Comments
 (0)