|
20 | 20 |
|
21 | 21 | #include "../../kselftest.h"
|
22 | 22 |
|
23 |
| -#define EXPECTED_TESTS 7 |
| 23 | +#define EXPECTED_TESTS 11 |
24 | 24 |
|
25 | 25 | #define MAX_TPIDRS 2
|
26 | 26 |
|
@@ -132,6 +132,34 @@ static void test_tpidr(pid_t child)
|
132 | 132 | }
|
133 | 133 | }
|
134 | 134 |
|
| 135 | +static void test_hw_debug(pid_t child, int type, const char *type_name) |
| 136 | +{ |
| 137 | + struct user_hwdebug_state state; |
| 138 | + struct iovec iov; |
| 139 | + int slots, arch, ret; |
| 140 | + |
| 141 | + iov.iov_len = sizeof(state); |
| 142 | + iov.iov_base = &state; |
| 143 | + |
| 144 | + /* Should be able to read the values */ |
| 145 | + ret = ptrace(PTRACE_GETREGSET, child, type, &iov); |
| 146 | + ksft_test_result(ret == 0, "read_%s\n", type_name); |
| 147 | + |
| 148 | + if (ret == 0) { |
| 149 | + /* Low 8 bits is the number of slots, next 4 bits the arch */ |
| 150 | + slots = state.dbg_info & 0xff; |
| 151 | + arch = (state.dbg_info >> 8) & 0xf; |
| 152 | + |
| 153 | + ksft_print_msg("%s version %d with %d slots\n", type_name, |
| 154 | + arch, slots); |
| 155 | + |
| 156 | + /* Zero is not currently architecturally valid */ |
| 157 | + ksft_test_result(arch, "%s_arch_set\n", type_name); |
| 158 | + } else { |
| 159 | + ksft_test_result_skip("%s_arch_set\n"); |
| 160 | + } |
| 161 | +} |
| 162 | + |
135 | 163 | static int do_child(void)
|
136 | 164 | {
|
137 | 165 | if (ptrace(PTRACE_TRACEME, -1, NULL, NULL))
|
@@ -207,6 +235,8 @@ static int do_parent(pid_t child)
|
207 | 235 | ksft_print_msg("Parent is %d, child is %d\n", getpid(), child);
|
208 | 236 |
|
209 | 237 | test_tpidr(child);
|
| 238 | + test_hw_debug(child, NT_ARM_HW_WATCH, "NT_ARM_HW_WATCH"); |
| 239 | + test_hw_debug(child, NT_ARM_HW_BREAK, "NT_ARM_HW_BREAK"); |
210 | 240 |
|
211 | 241 | ret = EXIT_SUCCESS;
|
212 | 242 |
|
|
0 commit comments