diff options
author | Jon Medhurst <tixy@yxit.co.uk> | 2011-07-07 05:21:40 -0400 |
---|---|---|
committer | Tixy <tixy@medhuaa1.miniserver.com> | 2011-07-13 13:32:41 -0400 |
commit | 6c8df3300f60cae54aeb2a6dda8efe7ffe16a322 (patch) | |
tree | c7cac1abd0d5a46db1a4b4b3785238874822218b | |
parent | 1b59d874660be7f790861ad849858cc009089515 (diff) |
ARM: kprobes: Move find_str_pc_offset into kprobes-common.c
Move str_pc_offset into kprobes-common.c as it will be needed by common
code later.
Signed-off-by: Jon Medhurst <tixy@yxit.co.uk>
Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
-rw-r--r-- | arch/arm/kernel/kprobes-arm.c | 28 | ||||
-rw-r--r-- | arch/arm/kernel/kprobes-common.c | 33 | ||||
-rw-r--r-- | arch/arm/kernel/kprobes.h | 2 |
3 files changed, 35 insertions, 28 deletions
diff --git a/arch/arm/kernel/kprobes-arm.c b/arch/arm/kernel/kprobes-arm.c index 3c4678edcbf..0262b29163d 100644 --- a/arch/arm/kernel/kprobes-arm.c +++ b/arch/arm/kernel/kprobes-arm.c | |||
@@ -92,29 +92,6 @@ union reg_pair { | |||
92 | }; | 92 | }; |
93 | 93 | ||
94 | /* | 94 | /* |
95 | * For STR and STM instructions, an ARM core may choose to use either | ||
96 | * a +8 or a +12 displacement from the current instruction's address. | ||
97 | * Whichever value is chosen for a given core, it must be the same for | ||
98 | * both instructions and may not change. This function measures it. | ||
99 | */ | ||
100 | |||
101 | static int str_pc_offset; | ||
102 | |||
103 | static void __init find_str_pc_offset(void) | ||
104 | { | ||
105 | int addr, scratch, ret; | ||
106 | |||
107 | __asm__ ( | ||
108 | "sub %[ret], pc, #4 \n\t" | ||
109 | "str pc, %[addr] \n\t" | ||
110 | "ldr %[scr], %[addr] \n\t" | ||
111 | "sub %[ret], %[scr], %[ret] \n\t" | ||
112 | : [ret] "=r" (ret), [scr] "=r" (scratch), [addr] "+m" (addr)); | ||
113 | |||
114 | str_pc_offset = ret; | ||
115 | } | ||
116 | |||
117 | /* | ||
118 | * The insnslot_?arg_r[w]flags() functions below are to keep the | 95 | * The insnslot_?arg_r[w]flags() functions below are to keep the |
119 | * msr -> *fn -> mrs instruction sequences indivisible so that | 96 | * msr -> *fn -> mrs instruction sequences indivisible so that |
120 | * the state of the CPSR flags aren't inadvertently modified | 97 | * the state of the CPSR flags aren't inadvertently modified |
@@ -1569,8 +1546,3 @@ arm_kprobe_decode_insn(kprobe_opcode_t insn, struct arch_specific_insn *asi) | |||
1569 | 1546 | ||
1570 | return space_cccc_11xx(insn, asi); | 1547 | return space_cccc_11xx(insn, asi); |
1571 | } | 1548 | } |
1572 | |||
1573 | void __init arm_kprobe_decode_init(void) | ||
1574 | { | ||
1575 | find_str_pc_offset(); | ||
1576 | } | ||
diff --git a/arch/arm/kernel/kprobes-common.c b/arch/arm/kernel/kprobes-common.c index 794827ec27d..e18576cca6c 100644 --- a/arch/arm/kernel/kprobes-common.c +++ b/arch/arm/kernel/kprobes-common.c | |||
@@ -3,6 +3,9 @@ | |||
3 | * | 3 | * |
4 | * Copyright (C) 2011 Jon Medhurst <tixy@yxit.co.uk>. | 4 | * Copyright (C) 2011 Jon Medhurst <tixy@yxit.co.uk>. |
5 | * | 5 | * |
6 | * Some contents moved here from arch/arm/include/asm/kprobes-arm.c which is | ||
7 | * Copyright (C) 2006, 2007 Motorola Inc. | ||
8 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License version 2 as | 10 | * it under the terms of the GNU General Public License version 2 as |
8 | * published by the Free Software Foundation. | 11 | * published by the Free Software Foundation. |
@@ -14,6 +17,36 @@ | |||
14 | #include "kprobes.h" | 17 | #include "kprobes.h" |
15 | 18 | ||
16 | 19 | ||
20 | /* | ||
21 | * For STR and STM instructions, an ARM core may choose to use either | ||
22 | * a +8 or a +12 displacement from the current instruction's address. | ||
23 | * Whichever value is chosen for a given core, it must be the same for | ||
24 | * both instructions and may not change. This function measures it. | ||
25 | */ | ||
26 | |||
27 | int str_pc_offset; | ||
28 | |||
29 | void __init find_str_pc_offset(void) | ||
30 | { | ||
31 | int addr, scratch, ret; | ||
32 | |||
33 | __asm__ ( | ||
34 | "sub %[ret], pc, #4 \n\t" | ||
35 | "str pc, %[addr] \n\t" | ||
36 | "ldr %[scr], %[addr] \n\t" | ||
37 | "sub %[ret], %[scr], %[ret] \n\t" | ||
38 | : [ret] "=r" (ret), [scr] "=r" (scratch), [addr] "+m" (addr)); | ||
39 | |||
40 | str_pc_offset = ret; | ||
41 | } | ||
42 | |||
43 | |||
44 | void __init arm_kprobe_decode_init(void) | ||
45 | { | ||
46 | find_str_pc_offset(); | ||
47 | } | ||
48 | |||
49 | |||
17 | static unsigned long __kprobes __check_eq(unsigned long cpsr) | 50 | static unsigned long __kprobes __check_eq(unsigned long cpsr) |
18 | { | 51 | { |
19 | return cpsr & PSR_Z_BIT; | 52 | return cpsr & PSR_Z_BIT; |
diff --git a/arch/arm/kernel/kprobes.h b/arch/arm/kernel/kprobes.h index 4de2f37b1a8..43f630d7f03 100644 --- a/arch/arm/kernel/kprobes.h +++ b/arch/arm/kernel/kprobes.h | |||
@@ -36,6 +36,8 @@ void __init arm_kprobe_decode_init(void); | |||
36 | 36 | ||
37 | extern kprobe_check_cc * const kprobe_condition_checks[16]; | 37 | extern kprobe_check_cc * const kprobe_condition_checks[16]; |
38 | 38 | ||
39 | extern int str_pc_offset; | ||
40 | |||
39 | /* | 41 | /* |
40 | * Test if load/store instructions writeback the address register. | 42 | * Test if load/store instructions writeback the address register. |
41 | * if P (bit 24) == 0 or W (bit 21) == 1 | 43 | * if P (bit 24) == 0 or W (bit 21) == 1 |