kprobes-thumb.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * arch/arm/kernel/kprobes-thumb.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. #include <linux/kernel.h>
  11. #include <linux/kprobes.h>
  12. #include "kprobes.h"
  13. /*
  14. * True if current instruction is in an IT block.
  15. */
  16. #define in_it_block(cpsr) ((cpsr & 0x06000c00) != 0x00000000)
  17. /*
  18. * Return the condition code to check for the currently executing instruction.
  19. * This is in ITSTATE<7:4> which is in CPSR<15:12> but is only valid if
  20. * in_it_block returns true.
  21. */
  22. #define current_cond(cpsr) ((cpsr >> 12) & 0xf)
  23. static unsigned long __kprobes thumb_check_cc(unsigned long cpsr)
  24. {
  25. if (unlikely(in_it_block(cpsr)))
  26. return kprobe_condition_checks[current_cond(cpsr)](cpsr);
  27. return true;
  28. }
  29. enum kprobe_insn __kprobes
  30. thumb16_kprobe_decode_insn(kprobe_opcode_t insn, struct arch_specific_insn *asi)
  31. {
  32. asi->insn_check_cc = thumb_check_cc;
  33. return INSN_REJECTED;
  34. }
  35. enum kprobe_insn __kprobes
  36. thumb32_kprobe_decode_insn(kprobe_opcode_t insn, struct arch_specific_insn *asi)
  37. {
  38. asi->insn_check_cc = thumb_check_cc;
  39. return INSN_REJECTED;
  40. }