diff options
author | Jon Medhurst <tixy@yxit.co.uk> | 2011-07-06 06:25:18 -0400 |
---|---|---|
committer | Tixy <tixy@medhuaa1.miniserver.com> | 2011-07-13 13:32:41 -0400 |
commit | 0ab4c02ddae2e1d32d686a7773608f6c44fb2a83 (patch) | |
tree | c4555d94262d496fa129a39b02c08d89d135412c /arch/arm/kernel/kprobes-common.c | |
parent | 221bf15ffd2ad6cdc624aa4274f706499501c123 (diff) |
ARM: kprobes: Add kprobes-common.c
This file will contain the instruction decoding and emulation code
which is common to both ARM and Thumb instruction sets.
For now, we will just move over condition_checks from kprobes-arm.c
This table is also renamed to kprobe_condition_checks to avoid polluting
the public namespace with a too generic name.
Signed-off-by: Jon Medhurst <tixy@yxit.co.uk>
Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Diffstat (limited to 'arch/arm/kernel/kprobes-common.c')
-rw-r--r-- | arch/arm/kernel/kprobes-common.c | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/arch/arm/kernel/kprobes-common.c b/arch/arm/kernel/kprobes-common.c new file mode 100644 index 000000000000..794827ec27d7 --- /dev/null +++ b/arch/arm/kernel/kprobes-common.c | |||
@@ -0,0 +1,105 @@ | |||
1 | /* | ||
2 | * arch/arm/kernel/kprobes-common.c | ||
3 | * | ||
4 | * Copyright (C) 2011 Jon Medhurst <tixy@yxit.co.uk>. | ||
5 | * | ||
6 | * 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 | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/kprobes.h> | ||
13 | |||
14 | #include "kprobes.h" | ||
15 | |||
16 | |||
17 | static unsigned long __kprobes __check_eq(unsigned long cpsr) | ||
18 | { | ||
19 | return cpsr & PSR_Z_BIT; | ||
20 | } | ||
21 | |||
22 | static unsigned long __kprobes __check_ne(unsigned long cpsr) | ||
23 | { | ||
24 | return (~cpsr) & PSR_Z_BIT; | ||
25 | } | ||
26 | |||
27 | static unsigned long __kprobes __check_cs(unsigned long cpsr) | ||
28 | { | ||
29 | return cpsr & PSR_C_BIT; | ||
30 | } | ||
31 | |||
32 | static unsigned long __kprobes __check_cc(unsigned long cpsr) | ||
33 | { | ||
34 | return (~cpsr) & PSR_C_BIT; | ||
35 | } | ||
36 | |||
37 | static unsigned long __kprobes __check_mi(unsigned long cpsr) | ||
38 | { | ||
39 | return cpsr & PSR_N_BIT; | ||
40 | } | ||
41 | |||
42 | static unsigned long __kprobes __check_pl(unsigned long cpsr) | ||
43 | { | ||
44 | return (~cpsr) & PSR_N_BIT; | ||
45 | } | ||
46 | |||
47 | static unsigned long __kprobes __check_vs(unsigned long cpsr) | ||
48 | { | ||
49 | return cpsr & PSR_V_BIT; | ||
50 | } | ||
51 | |||
52 | static unsigned long __kprobes __check_vc(unsigned long cpsr) | ||
53 | { | ||
54 | return (~cpsr) & PSR_V_BIT; | ||
55 | } | ||
56 | |||
57 | static unsigned long __kprobes __check_hi(unsigned long cpsr) | ||
58 | { | ||
59 | cpsr &= ~(cpsr >> 1); /* PSR_C_BIT &= ~PSR_Z_BIT */ | ||
60 | return cpsr & PSR_C_BIT; | ||
61 | } | ||
62 | |||
63 | static unsigned long __kprobes __check_ls(unsigned long cpsr) | ||
64 | { | ||
65 | cpsr &= ~(cpsr >> 1); /* PSR_C_BIT &= ~PSR_Z_BIT */ | ||
66 | return (~cpsr) & PSR_C_BIT; | ||
67 | } | ||
68 | |||
69 | static unsigned long __kprobes __check_ge(unsigned long cpsr) | ||
70 | { | ||
71 | cpsr ^= (cpsr << 3); /* PSR_N_BIT ^= PSR_V_BIT */ | ||
72 | return (~cpsr) & PSR_N_BIT; | ||
73 | } | ||
74 | |||
75 | static unsigned long __kprobes __check_lt(unsigned long cpsr) | ||
76 | { | ||
77 | cpsr ^= (cpsr << 3); /* PSR_N_BIT ^= PSR_V_BIT */ | ||
78 | return cpsr & PSR_N_BIT; | ||
79 | } | ||
80 | |||
81 | static unsigned long __kprobes __check_gt(unsigned long cpsr) | ||
82 | { | ||
83 | unsigned long temp = cpsr ^ (cpsr << 3); /* PSR_N_BIT ^= PSR_V_BIT */ | ||
84 | temp |= (cpsr << 1); /* PSR_N_BIT |= PSR_Z_BIT */ | ||
85 | return (~temp) & PSR_N_BIT; | ||
86 | } | ||
87 | |||
88 | static unsigned long __kprobes __check_le(unsigned long cpsr) | ||
89 | { | ||
90 | unsigned long temp = cpsr ^ (cpsr << 3); /* PSR_N_BIT ^= PSR_V_BIT */ | ||
91 | temp |= (cpsr << 1); /* PSR_N_BIT |= PSR_Z_BIT */ | ||
92 | return temp & PSR_N_BIT; | ||
93 | } | ||
94 | |||
95 | static unsigned long __kprobes __check_al(unsigned long cpsr) | ||
96 | { | ||
97 | return true; | ||
98 | } | ||
99 | |||
100 | kprobe_check_cc * const kprobe_condition_checks[16] = { | ||
101 | &__check_eq, &__check_ne, &__check_cs, &__check_cc, | ||
102 | &__check_mi, &__check_pl, &__check_vs, &__check_vc, | ||
103 | &__check_hi, &__check_ls, &__check_ge, &__check_lt, | ||
104 | &__check_gt, &__check_le, &__check_al, &__check_al | ||
105 | }; | ||