|
15 | 15 | #include <linux/extable.h>
|
16 | 16 | #include <linux/kdebug.h>
|
17 | 17 | #include <linux/kallsyms.h>
|
| 18 | +#include <linux/kgdb.h> |
18 | 19 | #include <linux/ftrace.h>
|
19 | 20 | #include <linux/objtool.h>
|
20 | 21 | #include <linux/pgtable.h>
|
@@ -279,19 +280,6 @@ static int insn_is_indirect_jump(struct insn *insn)
|
279 | 280 | return ret;
|
280 | 281 | }
|
281 | 282 |
|
282 |
| -static bool is_padding_int3(unsigned long addr, unsigned long eaddr) |
283 |
| -{ |
284 |
| - unsigned char ops; |
285 |
| - |
286 |
| - for (; addr < eaddr; addr++) { |
287 |
| - if (get_kernel_nofault(ops, (void *)addr) < 0 || |
288 |
| - ops != INT3_INSN_OPCODE) |
289 |
| - return false; |
290 |
| - } |
291 |
| - |
292 |
| - return true; |
293 |
| -} |
294 |
| - |
295 | 283 | /* Decode whole function to ensure any instructions don't jump into target */
|
296 | 284 | static int can_optimize(unsigned long paddr)
|
297 | 285 | {
|
@@ -334,15 +322,15 @@ static int can_optimize(unsigned long paddr)
|
334 | 322 | ret = insn_decode_kernel(&insn, (void *)recovered_insn);
|
335 | 323 | if (ret < 0)
|
336 | 324 | return 0;
|
337 |
| - |
| 325 | +#ifdef CONFIG_KGDB |
338 | 326 | /*
|
339 |
| - * In the case of detecting unknown breakpoint, this could be |
340 |
| - * a padding INT3 between functions. Let's check that all the |
341 |
| - * rest of the bytes are also INT3. |
| 327 | + * If there is a dynamically installed kgdb sw breakpoint, |
| 328 | + * this function should not be probed. |
342 | 329 | */
|
343 |
| - if (insn.opcode.bytes[0] == INT3_INSN_OPCODE) |
344 |
| - return is_padding_int3(addr, paddr - offset + size) ? 1 : 0; |
345 |
| - |
| 330 | + if (insn.opcode.bytes[0] == INT3_INSN_OPCODE && |
| 331 | + kgdb_has_hit_break(addr)) |
| 332 | + return 0; |
| 333 | +#endif |
346 | 334 | /* Recover address */
|
347 | 335 | insn.kaddr = (void *)addr;
|
348 | 336 | insn.next_byte = (void *)(addr + insn.length);
|
|
0 commit comments