connectTheSignalSlot.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * arch/arm/kernel/kprobes-test.h
  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. #define VERBOSE 0 /* Set to '1' for more logging of test cases */
  11. #ifdef CONFIG_THUMB2_KERNEL
  12. #define NORMAL_ISA "16"
  13. #else
  14. #define NORMAL_ISA "32"
  15. #endif
  16. /* Flags used in kprobe_test_flags */
  17. #define TEST_FLAG_NO_ITBLOCK (1<<0)
  18. #define TEST_FLAG_FULL_ITBLOCK (1<<1)
  19. #define TEST_FLAG_NARROW_INSTR (1<<2)
  20. extern int kprobe_test_flags;
  21. extern int kprobe_test_cc_position;
  22. #define TEST_MEMORY_SIZE 256
  23. /*
  24. * Test case structures.
  25. *
  26. * The arguments given to test cases can be one of three types.
  27. *
  28. * ARG_TYPE_REG
  29. * Load a register with the given value.
  30. *
  31. * ARG_TYPE_PTR
  32. * Load a register with a pointer into the stack buffer (SP + given value).
  33. *
  34. * ARG_TYPE_MEM
  35. * Store the given value into the stack buffer at [SP+index].
  36. *
  37. */
  38. #define ARG_TYPE_END 0
  39. #define ARG_TYPE_REG 1
  40. #define ARG_TYPE_PTR 2
  41. #define ARG_TYPE_MEM 3
  42. #define ARG_FLAG_UNSUPPORTED 0x01
  43. #define ARG_FLAG_SUPPORTED 0x02
  44. #define ARG_FLAG_THUMB 0x10 /* Must be 16 so TEST_ISA can be used */
  45. #define ARG_FLAG_ARM 0x20 /* Must be 32 so TEST_ISA can be used */
  46. struct test_arg {
  47. u8 type; /* ARG_TYPE_x */
  48. u8 _padding[7];
  49. };
  50. struct test_arg_regptr {
  51. u8 type; /* ARG_TYPE_REG or ARG_TYPE_PTR */
  52. u8 reg;
  53. u8 _padding[2];
  54. u32 val;
  55. };
  56. struct test_arg_mem {
  57. u8 type; /* ARG_TYPE_MEM */
  58. u8 index;
  59. u8 _padding[2];
  60. u32 val;
  61. };
  62. struct test_arg_end {
  63. u8 type; /* ARG_TYPE_END */
  64. u8 flags; /* ARG_FLAG_x */
  65. u16 code_offset;
  66. u16 branch_offset;
  67. u16 end_offset;
  68. };
  69. /*
  70. * Building blocks for test cases.
  71. *
  72. * Each test case is wrapped between TESTCASE_START and TESTCASE_END.
  73. *
  74. * To specify arguments for a test case the TEST_ARG_{REG,PTR,MEM} macros are
  75. * used followed by a terminating TEST_ARG_END.
  76. *
  77. * After this, the instruction to be tested is defined with TEST_INSTRUCTION.
  78. * Or for branches, TEST_BRANCH_B and TEST_BRANCH_F (branch forwards/backwards).
  79. *
  80. * Some specific test cases may make use of other custom constructs.
  81. */
  82. #if VERBOSE
  83. #define verbose(fmt, ...) pr_info(fmt, ##__VA_ARGS__)
  84. #else
  85. #define verbose(fmt, ...)
  86. #endif
  87. #define TEST_GROUP(title) \
  88. verbose("\n"); \
  89. verbose(title"\n"); \
  90. verbose("---------------------------------------------------------\n");
  91. #define TESTCASE_START(title) \
  92. __asm__ __volatile__ ( \
  93. "bl __kprobes_test_case_start \n\t" \
  94. /* don't use .asciz here as 'title' may be */ \
  95. /* multiple strings to be concatenated. */ \
  96. ".ascii "#title" \n\t" \
  97. ".byte 0 \n\t" \
  98. ".align 2 \n\t"
  99. #define TEST_ARG_REG(reg, val) \
  100. ".byte "__stringify(ARG_TYPE_REG)" \n\t" \
  101. ".byte "#reg" \n\t" \
  102. ".short 0 \n\t" \
  103. ".word "#val" \n\t"
  104. #define TEST_ARG_PTR(reg, val) \
  105. ".byte "__stringify(ARG_TYPE_PTR)" \n\t" \
  106. ".byte "#reg" \n\t" \
  107. ".short 0 \n\t" \
  108. ".word "#val" \n\t"
  109. #define TEST_ARG_MEM(index, val) \
  110. ".byte "__stringify(ARG_TYPE_MEM)" \n\t" \
  111. ".byte "#index" \n\t" \
  112. ".short 0 \n\t" \
  113. ".word "#val" \n\t"
  114. #define TEST_ARG_END(flags) \
  115. ".byte "__stringify(ARG_TYPE_END)" \n\t" \
  116. ".byte "TEST_ISA flags" \n\t" \
  117. ".short 50f-0f \n\t" \
  118. ".short 2f-0f \n\t" \
  119. ".short 99f-0f \n\t" \
  120. ".code "TEST_ISA" \n\t" \
  121. "0: \n\t"
  122. #define TEST_INSTRUCTION(instruction) \
  123. "50: nop \n\t" \
  124. "1: "instruction" \n\t" \
  125. " nop \n\t"