diff options
-rw-r--r-- | arch/tile/include/asm/backtrace.h | 82 | ||||
-rw-r--r-- | arch/tile/include/asm/opcode-tile_32.h | 7 | ||||
-rw-r--r-- | arch/tile/include/asm/opcode-tile_64.h | 7 | ||||
-rw-r--r-- | arch/tile/kernel/backtrace.c | 103 | ||||
-rw-r--r-- | arch/tile/kernel/stack.c | 14 | ||||
-rw-r--r-- | arch/tile/kernel/tile-desc_32.c | 11 |
6 files changed, 93 insertions, 131 deletions
diff --git a/arch/tile/include/asm/backtrace.h b/arch/tile/include/asm/backtrace.h index f18887d82399..bd5399a69edf 100644 --- a/arch/tile/include/asm/backtrace.h +++ b/arch/tile/include/asm/backtrace.h | |||
@@ -12,80 +12,41 @@ | |||
12 | * more details. | 12 | * more details. |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #ifndef _TILE_BACKTRACE_H | 15 | #ifndef _ASM_TILE_BACKTRACE_H |
16 | #define _TILE_BACKTRACE_H | 16 | #define _ASM_TILE_BACKTRACE_H |
17 | |||
18 | |||
19 | 17 | ||
20 | #include <linux/types.h> | 18 | #include <linux/types.h> |
21 | 19 | ||
22 | #include <arch/chip.h> | 20 | /* Reads 'size' bytes from 'address' and writes the data to 'result'. |
23 | |||
24 | #if defined(__tile__) | ||
25 | typedef unsigned long VirtualAddress; | ||
26 | #elif CHIP_VA_WIDTH() > 32 | ||
27 | typedef unsigned long long VirtualAddress; | ||
28 | #else | ||
29 | typedef unsigned int VirtualAddress; | ||
30 | #endif | ||
31 | |||
32 | |||
33 | /** Reads 'size' bytes from 'address' and writes the data to 'result'. | ||
34 | * Returns true if successful, else false (e.g. memory not readable). | 21 | * Returns true if successful, else false (e.g. memory not readable). |
35 | */ | 22 | */ |
36 | typedef bool (*BacktraceMemoryReader)(void *result, | 23 | typedef bool (*BacktraceMemoryReader)(void *result, |
37 | VirtualAddress address, | 24 | unsigned long address, |
38 | unsigned int size, | 25 | unsigned int size, |
39 | void *extra); | 26 | void *extra); |
40 | 27 | ||
41 | typedef struct { | 28 | typedef struct { |
42 | /** Current PC. */ | 29 | /* Current PC. */ |
43 | VirtualAddress pc; | 30 | unsigned long pc; |
44 | 31 | ||
45 | /** Current stack pointer value. */ | 32 | /* Current stack pointer value. */ |
46 | VirtualAddress sp; | 33 | unsigned long sp; |
47 | 34 | ||
48 | /** Current frame pointer value (i.e. caller's stack pointer) */ | 35 | /* Current frame pointer value (i.e. caller's stack pointer) */ |
49 | VirtualAddress fp; | 36 | unsigned long fp; |
50 | 37 | ||
51 | /** Internal use only: caller's PC for first frame. */ | 38 | /* Internal use only: caller's PC for first frame. */ |
52 | VirtualAddress initial_frame_caller_pc; | 39 | unsigned long initial_frame_caller_pc; |
53 | 40 | ||
54 | /** Internal use only: callback to read memory. */ | 41 | /* Internal use only: callback to read memory. */ |
55 | BacktraceMemoryReader read_memory_func; | 42 | BacktraceMemoryReader read_memory_func; |
56 | 43 | ||
57 | /** Internal use only: arbitrary argument to read_memory_func. */ | 44 | /* Internal use only: arbitrary argument to read_memory_func. */ |
58 | void *read_memory_func_extra; | 45 | void *read_memory_func_extra; |
59 | 46 | ||
60 | } BacktraceIterator; | 47 | } BacktraceIterator; |
61 | 48 | ||
62 | 49 | ||
63 | /** Initializes a backtracer to start from the given location. | ||
64 | * | ||
65 | * If the frame pointer cannot be determined it is set to -1. | ||
66 | * | ||
67 | * @param state The state to be filled in. | ||
68 | * @param read_memory_func A callback that reads memory. If NULL, a default | ||
69 | * value is provided. | ||
70 | * @param read_memory_func_extra An arbitrary argument to read_memory_func. | ||
71 | * @param pc The current PC. | ||
72 | * @param lr The current value of the 'lr' register. | ||
73 | * @param sp The current value of the 'sp' register. | ||
74 | * @param r52 The current value of the 'r52' register. | ||
75 | */ | ||
76 | extern void backtrace_init(BacktraceIterator *state, | ||
77 | BacktraceMemoryReader read_memory_func, | ||
78 | void *read_memory_func_extra, | ||
79 | VirtualAddress pc, VirtualAddress lr, | ||
80 | VirtualAddress sp, VirtualAddress r52); | ||
81 | |||
82 | |||
83 | /** Advances the backtracing state to the calling frame, returning | ||
84 | * true iff successful. | ||
85 | */ | ||
86 | extern bool backtrace_next(BacktraceIterator *state); | ||
87 | |||
88 | |||
89 | typedef enum { | 50 | typedef enum { |
90 | 51 | ||
91 | /* We have no idea what the caller's pc is. */ | 52 | /* We have no idea what the caller's pc is. */ |
@@ -138,7 +99,7 @@ enum { | |||
138 | }; | 99 | }; |
139 | 100 | ||
140 | 101 | ||
141 | /** Internal constants used to define 'info' operands. */ | 102 | /* Internal constants used to define 'info' operands. */ |
142 | enum { | 103 | enum { |
143 | /* 0 and 1 are reserved, as are all negative numbers. */ | 104 | /* 0 and 1 are reserved, as are all negative numbers. */ |
144 | 105 | ||
@@ -147,13 +108,10 @@ enum { | |||
147 | CALLER_SP_IN_R52_BASE = 4, | 108 | CALLER_SP_IN_R52_BASE = 4, |
148 | 109 | ||
149 | CALLER_SP_OFFSET_BASE = 8, | 110 | CALLER_SP_OFFSET_BASE = 8, |
150 | |||
151 | /* Marks the entry point of certain functions. */ | ||
152 | ENTRY_POINT_INFO_OP = 16 | ||
153 | }; | 111 | }; |
154 | 112 | ||
155 | 113 | ||
156 | /** Current backtracer state describing where it thinks the caller is. */ | 114 | /* Current backtracer state describing where it thinks the caller is. */ |
157 | typedef struct { | 115 | typedef struct { |
158 | /* | 116 | /* |
159 | * Public fields | 117 | * Public fields |
@@ -192,7 +150,13 @@ typedef struct { | |||
192 | 150 | ||
193 | } CallerLocation; | 151 | } CallerLocation; |
194 | 152 | ||
153 | extern void backtrace_init(BacktraceIterator *state, | ||
154 | BacktraceMemoryReader read_memory_func, | ||
155 | void *read_memory_func_extra, | ||
156 | unsigned long pc, unsigned long lr, | ||
157 | unsigned long sp, unsigned long r52); | ||
195 | 158 | ||
196 | 159 | ||
160 | extern bool backtrace_next(BacktraceIterator *state); | ||
197 | 161 | ||
198 | #endif /* _TILE_BACKTRACE_H */ | 162 | #endif /* _ASM_TILE_BACKTRACE_H */ |
diff --git a/arch/tile/include/asm/opcode-tile_32.h b/arch/tile/include/asm/opcode-tile_32.h index eda60ecbae3d..03df7b1e77bf 100644 --- a/arch/tile/include/asm/opcode-tile_32.h +++ b/arch/tile/include/asm/opcode-tile_32.h | |||
@@ -1502,5 +1502,12 @@ extern int parse_insn_tile(tile_bundle_bits bits, | |||
1502 | decoded[TILE_MAX_INSTRUCTIONS_PER_BUNDLE]); | 1502 | decoded[TILE_MAX_INSTRUCTIONS_PER_BUNDLE]); |
1503 | 1503 | ||
1504 | 1504 | ||
1505 | /* Given a set of bundle bits and a specific pipe, returns which | ||
1506 | * instruction the bundle contains in that pipe. | ||
1507 | */ | ||
1508 | extern const struct tile_opcode * | ||
1509 | find_opcode(tile_bundle_bits bits, tile_pipeline pipe); | ||
1510 | |||
1511 | |||
1505 | 1512 | ||
1506 | #endif /* opcode_tile_h */ | 1513 | #endif /* opcode_tile_h */ |
diff --git a/arch/tile/include/asm/opcode-tile_64.h b/arch/tile/include/asm/opcode-tile_64.h index eda60ecbae3d..03df7b1e77bf 100644 --- a/arch/tile/include/asm/opcode-tile_64.h +++ b/arch/tile/include/asm/opcode-tile_64.h | |||
@@ -1502,5 +1502,12 @@ extern int parse_insn_tile(tile_bundle_bits bits, | |||
1502 | decoded[TILE_MAX_INSTRUCTIONS_PER_BUNDLE]); | 1502 | decoded[TILE_MAX_INSTRUCTIONS_PER_BUNDLE]); |
1503 | 1503 | ||
1504 | 1504 | ||
1505 | /* Given a set of bundle bits and a specific pipe, returns which | ||
1506 | * instruction the bundle contains in that pipe. | ||
1507 | */ | ||
1508 | extern const struct tile_opcode * | ||
1509 | find_opcode(tile_bundle_bits bits, tile_pipeline pipe); | ||
1510 | |||
1511 | |||
1505 | 1512 | ||
1506 | #endif /* opcode_tile_h */ | 1513 | #endif /* opcode_tile_h */ |
diff --git a/arch/tile/kernel/backtrace.c b/arch/tile/kernel/backtrace.c index 55a6a74974b4..1dc71eabfc5a 100644 --- a/arch/tile/kernel/backtrace.c +++ b/arch/tile/kernel/backtrace.c | |||
@@ -14,19 +14,11 @@ | |||
14 | 14 | ||
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/string.h> | 16 | #include <linux/string.h> |
17 | |||
18 | #include <asm/backtrace.h> | 17 | #include <asm/backtrace.h> |
19 | |||
20 | #include <arch/chip.h> | ||
21 | |||
22 | #include <asm/opcode-tile.h> | 18 | #include <asm/opcode-tile.h> |
19 | #include <arch/abi.h> | ||
23 | 20 | ||
24 | 21 | #ifdef __tilegx__ | |
25 | #define TREG_SP 54 | ||
26 | #define TREG_LR 55 | ||
27 | |||
28 | |||
29 | #if TILE_CHIP >= 10 | ||
30 | #define tile_bundle_bits tilegx_bundle_bits | 22 | #define tile_bundle_bits tilegx_bundle_bits |
31 | #define TILE_MAX_INSTRUCTIONS_PER_BUNDLE TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE | 23 | #define TILE_MAX_INSTRUCTIONS_PER_BUNDLE TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE |
32 | #define TILE_BUNDLE_ALIGNMENT_IN_BYTES TILEGX_BUNDLE_ALIGNMENT_IN_BYTES | 24 | #define TILE_BUNDLE_ALIGNMENT_IN_BYTES TILEGX_BUNDLE_ALIGNMENT_IN_BYTES |
@@ -47,7 +39,7 @@ typedef long long bt_int_reg_t; | |||
47 | typedef int bt_int_reg_t; | 39 | typedef int bt_int_reg_t; |
48 | #endif | 40 | #endif |
49 | 41 | ||
50 | /** A decoded bundle used for backtracer analysis. */ | 42 | /* A decoded bundle used for backtracer analysis. */ |
51 | struct BacktraceBundle { | 43 | struct BacktraceBundle { |
52 | tile_bundle_bits bits; | 44 | tile_bundle_bits bits; |
53 | int num_insns; | 45 | int num_insns; |
@@ -56,23 +48,7 @@ struct BacktraceBundle { | |||
56 | }; | 48 | }; |
57 | 49 | ||
58 | 50 | ||
59 | /* This implementation only makes sense for native tools. */ | 51 | /* Locates an instruction inside the given bundle that |
60 | /** Default function to read memory. */ | ||
61 | static bool bt_read_memory(void *result, VirtualAddress addr, | ||
62 | unsigned int size, void *extra) | ||
63 | { | ||
64 | /* FIXME: this should do some horrible signal stuff to catch | ||
65 | * SEGV cleanly and fail. | ||
66 | * | ||
67 | * Or else the caller should do the setjmp for efficiency. | ||
68 | */ | ||
69 | |||
70 | memcpy(result, (const void *)addr, size); | ||
71 | return true; | ||
72 | } | ||
73 | |||
74 | |||
75 | /** Locates an instruction inside the given bundle that | ||
76 | * has the specified mnemonic, and whose first 'num_operands_to_match' | 52 | * has the specified mnemonic, and whose first 'num_operands_to_match' |
77 | * operands exactly match those in 'operand_values'. | 53 | * operands exactly match those in 'operand_values'. |
78 | */ | 54 | */ |
@@ -107,13 +83,13 @@ static const struct tile_decoded_instruction *find_matching_insn( | |||
107 | return NULL; | 83 | return NULL; |
108 | } | 84 | } |
109 | 85 | ||
110 | /** Does this bundle contain an 'iret' instruction? */ | 86 | /* Does this bundle contain an 'iret' instruction? */ |
111 | static inline bool bt_has_iret(const struct BacktraceBundle *bundle) | 87 | static inline bool bt_has_iret(const struct BacktraceBundle *bundle) |
112 | { | 88 | { |
113 | return find_matching_insn(bundle, TILE_OPC_IRET, NULL, 0) != NULL; | 89 | return find_matching_insn(bundle, TILE_OPC_IRET, NULL, 0) != NULL; |
114 | } | 90 | } |
115 | 91 | ||
116 | /** Does this bundle contain an 'addi sp, sp, OFFSET' or | 92 | /* Does this bundle contain an 'addi sp, sp, OFFSET' or |
117 | * 'addli sp, sp, OFFSET' instruction, and if so, what is OFFSET? | 93 | * 'addli sp, sp, OFFSET' instruction, and if so, what is OFFSET? |
118 | */ | 94 | */ |
119 | static bool bt_has_addi_sp(const struct BacktraceBundle *bundle, int *adjust) | 95 | static bool bt_has_addi_sp(const struct BacktraceBundle *bundle, int *adjust) |
@@ -124,7 +100,7 @@ static bool bt_has_addi_sp(const struct BacktraceBundle *bundle, int *adjust) | |||
124 | find_matching_insn(bundle, TILE_OPC_ADDI, vals, 2); | 100 | find_matching_insn(bundle, TILE_OPC_ADDI, vals, 2); |
125 | if (insn == NULL) | 101 | if (insn == NULL) |
126 | insn = find_matching_insn(bundle, TILE_OPC_ADDLI, vals, 2); | 102 | insn = find_matching_insn(bundle, TILE_OPC_ADDLI, vals, 2); |
127 | #if TILE_CHIP >= 10 | 103 | #ifdef __tilegx__ |
128 | if (insn == NULL) | 104 | if (insn == NULL) |
129 | insn = find_matching_insn(bundle, TILEGX_OPC_ADDXLI, vals, 2); | 105 | insn = find_matching_insn(bundle, TILEGX_OPC_ADDXLI, vals, 2); |
130 | if (insn == NULL) | 106 | if (insn == NULL) |
@@ -137,7 +113,7 @@ static bool bt_has_addi_sp(const struct BacktraceBundle *bundle, int *adjust) | |||
137 | return true; | 113 | return true; |
138 | } | 114 | } |
139 | 115 | ||
140 | /** Does this bundle contain any 'info OP' or 'infol OP' | 116 | /* Does this bundle contain any 'info OP' or 'infol OP' |
141 | * instruction, and if so, what are their OP? Note that OP is interpreted | 117 | * instruction, and if so, what are their OP? Note that OP is interpreted |
142 | * as an unsigned value by this code since that's what the caller wants. | 118 | * as an unsigned value by this code since that's what the caller wants. |
143 | * Returns the number of info ops found. | 119 | * Returns the number of info ops found. |
@@ -161,7 +137,7 @@ static int bt_get_info_ops(const struct BacktraceBundle *bundle, | |||
161 | return num_ops; | 137 | return num_ops; |
162 | } | 138 | } |
163 | 139 | ||
164 | /** Does this bundle contain a jrp instruction, and if so, to which | 140 | /* Does this bundle contain a jrp instruction, and if so, to which |
165 | * register is it jumping? | 141 | * register is it jumping? |
166 | */ | 142 | */ |
167 | static bool bt_has_jrp(const struct BacktraceBundle *bundle, int *target_reg) | 143 | static bool bt_has_jrp(const struct BacktraceBundle *bundle, int *target_reg) |
@@ -175,7 +151,7 @@ static bool bt_has_jrp(const struct BacktraceBundle *bundle, int *target_reg) | |||
175 | return true; | 151 | return true; |
176 | } | 152 | } |
177 | 153 | ||
178 | /** Does this bundle modify the specified register in any way? */ | 154 | /* Does this bundle modify the specified register in any way? */ |
179 | static bool bt_modifies_reg(const struct BacktraceBundle *bundle, int reg) | 155 | static bool bt_modifies_reg(const struct BacktraceBundle *bundle, int reg) |
180 | { | 156 | { |
181 | int i, j; | 157 | int i, j; |
@@ -195,34 +171,34 @@ static bool bt_modifies_reg(const struct BacktraceBundle *bundle, int reg) | |||
195 | return false; | 171 | return false; |
196 | } | 172 | } |
197 | 173 | ||
198 | /** Does this bundle modify sp? */ | 174 | /* Does this bundle modify sp? */ |
199 | static inline bool bt_modifies_sp(const struct BacktraceBundle *bundle) | 175 | static inline bool bt_modifies_sp(const struct BacktraceBundle *bundle) |
200 | { | 176 | { |
201 | return bt_modifies_reg(bundle, TREG_SP); | 177 | return bt_modifies_reg(bundle, TREG_SP); |
202 | } | 178 | } |
203 | 179 | ||
204 | /** Does this bundle modify lr? */ | 180 | /* Does this bundle modify lr? */ |
205 | static inline bool bt_modifies_lr(const struct BacktraceBundle *bundle) | 181 | static inline bool bt_modifies_lr(const struct BacktraceBundle *bundle) |
206 | { | 182 | { |
207 | return bt_modifies_reg(bundle, TREG_LR); | 183 | return bt_modifies_reg(bundle, TREG_LR); |
208 | } | 184 | } |
209 | 185 | ||
210 | /** Does this bundle contain the instruction 'move fp, sp'? */ | 186 | /* Does this bundle contain the instruction 'move fp, sp'? */ |
211 | static inline bool bt_has_move_r52_sp(const struct BacktraceBundle *bundle) | 187 | static inline bool bt_has_move_r52_sp(const struct BacktraceBundle *bundle) |
212 | { | 188 | { |
213 | static const int vals[2] = { 52, TREG_SP }; | 189 | static const int vals[2] = { 52, TREG_SP }; |
214 | return find_matching_insn(bundle, TILE_OPC_MOVE, vals, 2) != NULL; | 190 | return find_matching_insn(bundle, TILE_OPC_MOVE, vals, 2) != NULL; |
215 | } | 191 | } |
216 | 192 | ||
217 | /** Does this bundle contain a store of lr to sp? */ | 193 | /* Does this bundle contain a store of lr to sp? */ |
218 | static inline bool bt_has_sw_sp_lr(const struct BacktraceBundle *bundle) | 194 | static inline bool bt_has_sw_sp_lr(const struct BacktraceBundle *bundle) |
219 | { | 195 | { |
220 | static const int vals[2] = { TREG_SP, TREG_LR }; | 196 | static const int vals[2] = { TREG_SP, TREG_LR }; |
221 | return find_matching_insn(bundle, OPCODE_STORE, vals, 2) != NULL; | 197 | return find_matching_insn(bundle, OPCODE_STORE, vals, 2) != NULL; |
222 | } | 198 | } |
223 | 199 | ||
224 | #if TILE_CHIP >= 10 | 200 | #ifdef __tilegx__ |
225 | /** Track moveli values placed into registers. */ | 201 | /* Track moveli values placed into registers. */ |
226 | static inline void bt_update_moveli(const struct BacktraceBundle *bundle, | 202 | static inline void bt_update_moveli(const struct BacktraceBundle *bundle, |
227 | int moveli_args[]) | 203 | int moveli_args[]) |
228 | { | 204 | { |
@@ -238,7 +214,7 @@ static inline void bt_update_moveli(const struct BacktraceBundle *bundle, | |||
238 | } | 214 | } |
239 | } | 215 | } |
240 | 216 | ||
241 | /** Does this bundle contain an 'add sp, sp, reg' instruction | 217 | /* Does this bundle contain an 'add sp, sp, reg' instruction |
242 | * from a register that we saw a moveli into, and if so, what | 218 | * from a register that we saw a moveli into, and if so, what |
243 | * is the value in the register? | 219 | * is the value in the register? |
244 | */ | 220 | */ |
@@ -260,11 +236,11 @@ static bool bt_has_add_sp(const struct BacktraceBundle *bundle, int *adjust, | |||
260 | } | 236 | } |
261 | #endif | 237 | #endif |
262 | 238 | ||
263 | /** Locates the caller's PC and SP for a program starting at the | 239 | /* Locates the caller's PC and SP for a program starting at the |
264 | * given address. | 240 | * given address. |
265 | */ | 241 | */ |
266 | static void find_caller_pc_and_caller_sp(CallerLocation *location, | 242 | static void find_caller_pc_and_caller_sp(CallerLocation *location, |
267 | const VirtualAddress start_pc, | 243 | const unsigned long start_pc, |
268 | BacktraceMemoryReader read_memory_func, | 244 | BacktraceMemoryReader read_memory_func, |
269 | void *read_memory_func_extra) | 245 | void *read_memory_func_extra) |
270 | { | 246 | { |
@@ -288,9 +264,9 @@ static void find_caller_pc_and_caller_sp(CallerLocation *location, | |||
288 | tile_bundle_bits prefetched_bundles[32]; | 264 | tile_bundle_bits prefetched_bundles[32]; |
289 | int num_bundles_prefetched = 0; | 265 | int num_bundles_prefetched = 0; |
290 | int next_bundle = 0; | 266 | int next_bundle = 0; |
291 | VirtualAddress pc; | 267 | unsigned long pc; |
292 | 268 | ||
293 | #if TILE_CHIP >= 10 | 269 | #ifdef __tilegx__ |
294 | /* Naively try to track moveli values to support addx for -m32. */ | 270 | /* Naively try to track moveli values to support addx for -m32. */ |
295 | int moveli_args[TILEGX_NUM_REGISTERS] = { 0 }; | 271 | int moveli_args[TILEGX_NUM_REGISTERS] = { 0 }; |
296 | #endif | 272 | #endif |
@@ -369,10 +345,6 @@ static void find_caller_pc_and_caller_sp(CallerLocation *location, | |||
369 | /* Weird; reserved value, ignore it. */ | 345 | /* Weird; reserved value, ignore it. */ |
370 | continue; | 346 | continue; |
371 | } | 347 | } |
372 | if (info_operand & ENTRY_POINT_INFO_OP) { | ||
373 | /* This info op is ignored by the backtracer. */ | ||
374 | continue; | ||
375 | } | ||
376 | 348 | ||
377 | /* Skip info ops which are not in the | 349 | /* Skip info ops which are not in the |
378 | * "one_ago" mode we want right now. | 350 | * "one_ago" mode we want right now. |
@@ -453,7 +425,7 @@ static void find_caller_pc_and_caller_sp(CallerLocation *location, | |||
453 | if (!sp_determined) { | 425 | if (!sp_determined) { |
454 | int adjust; | 426 | int adjust; |
455 | if (bt_has_addi_sp(&bundle, &adjust) | 427 | if (bt_has_addi_sp(&bundle, &adjust) |
456 | #if TILE_CHIP >= 10 | 428 | #ifdef __tilegx__ |
457 | || bt_has_add_sp(&bundle, &adjust, moveli_args) | 429 | || bt_has_add_sp(&bundle, &adjust, moveli_args) |
458 | #endif | 430 | #endif |
459 | ) { | 431 | ) { |
@@ -504,7 +476,7 @@ static void find_caller_pc_and_caller_sp(CallerLocation *location, | |||
504 | } | 476 | } |
505 | } | 477 | } |
506 | 478 | ||
507 | #if TILE_CHIP >= 10 | 479 | #ifdef __tilegx__ |
508 | /* Track moveli arguments for -m32 mode. */ | 480 | /* Track moveli arguments for -m32 mode. */ |
509 | bt_update_moveli(&bundle, moveli_args); | 481 | bt_update_moveli(&bundle, moveli_args); |
510 | #endif | 482 | #endif |
@@ -546,18 +518,26 @@ static void find_caller_pc_and_caller_sp(CallerLocation *location, | |||
546 | } | 518 | } |
547 | } | 519 | } |
548 | 520 | ||
521 | /* Initializes a backtracer to start from the given location. | ||
522 | * | ||
523 | * If the frame pointer cannot be determined it is set to -1. | ||
524 | * | ||
525 | * state: The state to be filled in. | ||
526 | * read_memory_func: A callback that reads memory. | ||
527 | * read_memory_func_extra: An arbitrary argument to read_memory_func. | ||
528 | * pc: The current PC. | ||
529 | * lr: The current value of the 'lr' register. | ||
530 | * sp: The current value of the 'sp' register. | ||
531 | * r52: The current value of the 'r52' register. | ||
532 | */ | ||
549 | void backtrace_init(BacktraceIterator *state, | 533 | void backtrace_init(BacktraceIterator *state, |
550 | BacktraceMemoryReader read_memory_func, | 534 | BacktraceMemoryReader read_memory_func, |
551 | void *read_memory_func_extra, | 535 | void *read_memory_func_extra, |
552 | VirtualAddress pc, VirtualAddress lr, | 536 | unsigned long pc, unsigned long lr, |
553 | VirtualAddress sp, VirtualAddress r52) | 537 | unsigned long sp, unsigned long r52) |
554 | { | 538 | { |
555 | CallerLocation location; | 539 | CallerLocation location; |
556 | VirtualAddress fp, initial_frame_caller_pc; | 540 | unsigned long fp, initial_frame_caller_pc; |
557 | |||
558 | if (read_memory_func == NULL) { | ||
559 | read_memory_func = bt_read_memory; | ||
560 | } | ||
561 | 541 | ||
562 | /* Find out where we are in the initial frame. */ | 542 | /* Find out where we are in the initial frame. */ |
563 | find_caller_pc_and_caller_sp(&location, pc, | 543 | find_caller_pc_and_caller_sp(&location, pc, |
@@ -630,12 +610,15 @@ void backtrace_init(BacktraceIterator *state, | |||
630 | /* Handle the case where the register holds more bits than the VA. */ | 610 | /* Handle the case where the register holds more bits than the VA. */ |
631 | static bool valid_addr_reg(bt_int_reg_t reg) | 611 | static bool valid_addr_reg(bt_int_reg_t reg) |
632 | { | 612 | { |
633 | return ((VirtualAddress)reg == reg); | 613 | return ((unsigned long)reg == reg); |
634 | } | 614 | } |
635 | 615 | ||
616 | /* Advances the backtracing state to the calling frame, returning | ||
617 | * true iff successful. | ||
618 | */ | ||
636 | bool backtrace_next(BacktraceIterator *state) | 619 | bool backtrace_next(BacktraceIterator *state) |
637 | { | 620 | { |
638 | VirtualAddress next_fp, next_pc; | 621 | unsigned long next_fp, next_pc; |
639 | bt_int_reg_t next_frame[2]; | 622 | bt_int_reg_t next_frame[2]; |
640 | 623 | ||
641 | if (state->fp == -1) { | 624 | if (state->fp == -1) { |
diff --git a/arch/tile/kernel/stack.c b/arch/tile/kernel/stack.c index dd81713a90dc..37ee4d037e0b 100644 --- a/arch/tile/kernel/stack.c +++ b/arch/tile/kernel/stack.c | |||
@@ -36,7 +36,7 @@ | |||
36 | #define KBT_LOOP 3 /* Backtrace entered a loop */ | 36 | #define KBT_LOOP 3 /* Backtrace entered a loop */ |
37 | 37 | ||
38 | /* Is address on the specified kernel stack? */ | 38 | /* Is address on the specified kernel stack? */ |
39 | static int in_kernel_stack(struct KBacktraceIterator *kbt, VirtualAddress sp) | 39 | static int in_kernel_stack(struct KBacktraceIterator *kbt, unsigned long sp) |
40 | { | 40 | { |
41 | ulong kstack_base = (ulong) kbt->task->stack; | 41 | ulong kstack_base = (ulong) kbt->task->stack; |
42 | if (kstack_base == 0) /* corrupt task pointer; just follow stack... */ | 42 | if (kstack_base == 0) /* corrupt task pointer; just follow stack... */ |
@@ -45,7 +45,7 @@ static int in_kernel_stack(struct KBacktraceIterator *kbt, VirtualAddress sp) | |||
45 | } | 45 | } |
46 | 46 | ||
47 | /* Is address valid for reading? */ | 47 | /* Is address valid for reading? */ |
48 | static int valid_address(struct KBacktraceIterator *kbt, VirtualAddress address) | 48 | static int valid_address(struct KBacktraceIterator *kbt, unsigned long address) |
49 | { | 49 | { |
50 | HV_PTE *l1_pgtable = kbt->pgtable; | 50 | HV_PTE *l1_pgtable = kbt->pgtable; |
51 | HV_PTE *l2_pgtable; | 51 | HV_PTE *l2_pgtable; |
@@ -97,7 +97,7 @@ static int valid_address(struct KBacktraceIterator *kbt, VirtualAddress address) | |||
97 | } | 97 | } |
98 | 98 | ||
99 | /* Callback for backtracer; basically a glorified memcpy */ | 99 | /* Callback for backtracer; basically a glorified memcpy */ |
100 | static bool read_memory_func(void *result, VirtualAddress address, | 100 | static bool read_memory_func(void *result, unsigned long address, |
101 | unsigned int size, void *vkbt) | 101 | unsigned int size, void *vkbt) |
102 | { | 102 | { |
103 | int retval; | 103 | int retval; |
@@ -124,7 +124,7 @@ static struct pt_regs *valid_fault_handler(struct KBacktraceIterator* kbt) | |||
124 | { | 124 | { |
125 | const char *fault = NULL; /* happy compiler */ | 125 | const char *fault = NULL; /* happy compiler */ |
126 | char fault_buf[64]; | 126 | char fault_buf[64]; |
127 | VirtualAddress sp = kbt->it.sp; | 127 | unsigned long sp = kbt->it.sp; |
128 | struct pt_regs *p; | 128 | struct pt_regs *p; |
129 | 129 | ||
130 | if (!in_kernel_stack(kbt, sp)) | 130 | if (!in_kernel_stack(kbt, sp)) |
@@ -163,7 +163,7 @@ static struct pt_regs *valid_fault_handler(struct KBacktraceIterator* kbt) | |||
163 | } | 163 | } |
164 | 164 | ||
165 | /* Is the pc pointing to a sigreturn trampoline? */ | 165 | /* Is the pc pointing to a sigreturn trampoline? */ |
166 | static int is_sigreturn(VirtualAddress pc) | 166 | static int is_sigreturn(unsigned long pc) |
167 | { | 167 | { |
168 | return (pc == VDSO_BASE); | 168 | return (pc == VDSO_BASE); |
169 | } | 169 | } |
@@ -260,7 +260,7 @@ static void validate_stack(struct pt_regs *regs) | |||
260 | void KBacktraceIterator_init(struct KBacktraceIterator *kbt, | 260 | void KBacktraceIterator_init(struct KBacktraceIterator *kbt, |
261 | struct task_struct *t, struct pt_regs *regs) | 261 | struct task_struct *t, struct pt_regs *regs) |
262 | { | 262 | { |
263 | VirtualAddress pc, lr, sp, r52; | 263 | unsigned long pc, lr, sp, r52; |
264 | int is_current; | 264 | int is_current; |
265 | 265 | ||
266 | /* | 266 | /* |
@@ -331,7 +331,7 @@ EXPORT_SYMBOL(KBacktraceIterator_end); | |||
331 | 331 | ||
332 | void KBacktraceIterator_next(struct KBacktraceIterator *kbt) | 332 | void KBacktraceIterator_next(struct KBacktraceIterator *kbt) |
333 | { | 333 | { |
334 | VirtualAddress old_pc = kbt->it.pc, old_sp = kbt->it.sp; | 334 | unsigned long old_pc = kbt->it.pc, old_sp = kbt->it.sp; |
335 | kbt->new_context = 0; | 335 | kbt->new_context = 0; |
336 | if (!backtrace_next(&kbt->it) && !KBacktraceIterator_restart(kbt)) { | 336 | if (!backtrace_next(&kbt->it) && !KBacktraceIterator_restart(kbt)) { |
337 | kbt->end = KBT_DONE; | 337 | kbt->end = KBT_DONE; |
diff --git a/arch/tile/kernel/tile-desc_32.c b/arch/tile/kernel/tile-desc_32.c index 69af0e150f78..7e31a1285788 100644 --- a/arch/tile/kernel/tile-desc_32.c +++ b/arch/tile/kernel/tile-desc_32.c | |||
@@ -2413,12 +2413,13 @@ const struct tile_operand tile_operands[43] = | |||
2413 | 2413 | ||
2414 | 2414 | ||
2415 | 2415 | ||
2416 | /* Given a set of bundle bits and the lookup FSM for a specific pipe, | 2416 | /* Given a set of bundle bits and a specific pipe, returns which |
2417 | * returns which instruction the bundle contains in that pipe. | 2417 | * instruction the bundle contains in that pipe. |
2418 | */ | 2418 | */ |
2419 | static const struct tile_opcode * | 2419 | const struct tile_opcode * |
2420 | find_opcode(tile_bundle_bits bits, const unsigned short *table) | 2420 | find_opcode(tile_bundle_bits bits, tile_pipeline pipe) |
2421 | { | 2421 | { |
2422 | const unsigned short *table = tile_bundle_decoder_fsms[pipe]; | ||
2422 | int index = 0; | 2423 | int index = 0; |
2423 | 2424 | ||
2424 | while (1) | 2425 | while (1) |
@@ -2465,7 +2466,7 @@ parse_insn_tile(tile_bundle_bits bits, | |||
2465 | int i; | 2466 | int i; |
2466 | 2467 | ||
2467 | d = &decoded[num_instructions++]; | 2468 | d = &decoded[num_instructions++]; |
2468 | opc = find_opcode (bits, tile_bundle_decoder_fsms[pipe]); | 2469 | opc = find_opcode (bits, (tile_pipeline)pipe); |
2469 | d->opcode = opc; | 2470 | d->opcode = opc; |
2470 | 2471 | ||
2471 | /* Decode each operand, sign extending, etc. as appropriate. */ | 2472 | /* Decode each operand, sign extending, etc. as appropriate. */ |