| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2011 Red Hat, Inc., Frederic Weisbecker <fweisbec@redhat.com> |
|---|
| 3 | | - * |
|---|
| 4 | | - * Licensed under the terms of the GNU GPL License version 2 |
|---|
| 5 | 4 | * |
|---|
| 6 | 5 | * Selftests for breakpoints (and more generally the do_debug() path) in x86. |
|---|
| 7 | 6 | */ |
|---|
| .. | .. |
|---|
| 21 | 20 | |
|---|
| 22 | 21 | #include "../kselftest.h" |
|---|
| 23 | 22 | |
|---|
| 23 | +#define COUNT_ISN_BPS 4 |
|---|
| 24 | +#define COUNT_WPS 4 |
|---|
| 24 | 25 | |
|---|
| 25 | 26 | /* Breakpoint access modes */ |
|---|
| 26 | 27 | enum { |
|---|
| .. | .. |
|---|
| 220 | 221 | if (!local && !global) |
|---|
| 221 | 222 | continue; |
|---|
| 222 | 223 | |
|---|
| 223 | | - for (i = 0; i < 4; i++) { |
|---|
| 224 | + for (i = 0; i < COUNT_ISN_BPS; i++) { |
|---|
| 224 | 225 | dummy_funcs[i](); |
|---|
| 225 | 226 | check_trapped(); |
|---|
| 226 | 227 | } |
|---|
| .. | .. |
|---|
| 292 | 293 | { |
|---|
| 293 | 294 | int i; |
|---|
| 294 | 295 | |
|---|
| 295 | | - for (i = 0; i < 4; i++) { |
|---|
| 296 | + for (i = 0; i < COUNT_ISN_BPS; i++) { |
|---|
| 296 | 297 | set_breakpoint_addr(dummy_funcs[i], i); |
|---|
| 297 | 298 | toggle_breakpoint(i, BP_X, 1, local, global, 1); |
|---|
| 298 | 299 | ptrace(PTRACE_CONT, child_pid, NULL, 0); |
|---|
| .. | .. |
|---|
| 314 | 315 | else |
|---|
| 315 | 316 | mode_str = "read"; |
|---|
| 316 | 317 | |
|---|
| 317 | | - for (i = 0; i < 4; i++) { |
|---|
| 318 | + for (i = 0; i < COUNT_WPS; i++) { |
|---|
| 318 | 319 | set_breakpoint_addr(&dummy_var[i], i); |
|---|
| 319 | 320 | toggle_breakpoint(i, mode, len, local, global, 1); |
|---|
| 320 | 321 | ptrace(PTRACE_CONT, child_pid, NULL, 0); |
|---|
| .. | .. |
|---|
| 330 | 331 | static void launch_tests(void) |
|---|
| 331 | 332 | { |
|---|
| 332 | 333 | char buf[1024]; |
|---|
| 334 | + unsigned int tests = 0; |
|---|
| 333 | 335 | int len, local, global, i; |
|---|
| 334 | 336 | |
|---|
| 337 | + tests += 3 * COUNT_ISN_BPS; |
|---|
| 338 | + tests += sizeof(long) / 2 * 3 * COUNT_WPS; |
|---|
| 339 | + tests += sizeof(long) / 2 * 3 * COUNT_WPS; |
|---|
| 340 | + tests += 2; |
|---|
| 341 | + ksft_set_plan(tests); |
|---|
| 342 | + |
|---|
| 335 | 343 | /* Instruction breakpoints */ |
|---|
| 336 | 344 | for (local = 0; local < 2; local++) { |
|---|
| 337 | 345 | for (global = 0; global < 2; global++) { |
|---|