bp_account.c (8dd06ef34b6e2f41b29fbf5fc1663780f2524285) bp_account.c (d68f0365087395fe232e39ac9c8ee53627522c3c)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Powerpc needs __SANE_USERSPACE_TYPES__ before <linux/types.h> to select
4 * 'int-ll64.h' and avoid compile warnings when printing __u64 with %llu.
5 */
6#define __SANE_USERSPACE_TYPES__
7
8#include <stdlib.h>

--- 159 unchanged lines hidden (view full) ---

168 * - detects if watchpoints and breakpoints share
169 * same slots
170 * - create all possible watchpoints on cpu 0
171 * - change one of it to breakpoint
172 * - in case wp and bp do not share slots,
173 * we create another watchpoint to ensure
174 * the slot accounting is correct
175 */
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Powerpc needs __SANE_USERSPACE_TYPES__ before <linux/types.h> to select
4 * 'int-ll64.h' and avoid compile warnings when printing __u64 with %llu.
5 */
6#define __SANE_USERSPACE_TYPES__
7
8#include <stdlib.h>

--- 159 unchanged lines hidden (view full) ---

168 * - detects if watchpoints and breakpoints share
169 * same slots
170 * - create all possible watchpoints on cpu 0
171 * - change one of it to breakpoint
172 * - in case wp and bp do not share slots,
173 * we create another watchpoint to ensure
174 * the slot accounting is correct
175 */
176int test__bp_accounting(struct test *test __maybe_unused, int subtest __maybe_unused)
176static int test__bp_accounting(struct test *test __maybe_unused, int subtest __maybe_unused)
177{
178 int has_ioctl = detect_ioctl();
179 int wp_cnt = detect_cnt(false);
180 int bp_cnt = detect_cnt(true);
181 int share = detect_share(wp_cnt, bp_cnt);
182
183 pr_debug("watchpoints count %d, breakpoints count %d, has_ioctl %d, share %d\n",
184 wp_cnt, bp_cnt, has_ioctl, share);
185
186 if (!wp_cnt || !bp_cnt || !has_ioctl)
187 return TEST_SKIP;
188
189 return bp_accounting(wp_cnt, share);
190}
191
177{
178 int has_ioctl = detect_ioctl();
179 int wp_cnt = detect_cnt(false);
180 int bp_cnt = detect_cnt(true);
181 int share = detect_share(wp_cnt, bp_cnt);
182
183 pr_debug("watchpoints count %d, breakpoints count %d, has_ioctl %d, share %d\n",
184 wp_cnt, bp_cnt, has_ioctl, share);
185
186 if (!wp_cnt || !bp_cnt || !has_ioctl)
187 return TEST_SKIP;
188
189 return bp_accounting(wp_cnt, share);
190}
191
192bool test__bp_account_is_supported(void)
192static bool test__bp_account_is_supported(void)
193{
194 /*
195 * PowerPC and S390 do not support creation of instruction
196 * breakpoints using the perf_event interface.
197 *
198 * Just disable the test for these architectures until these
199 * issues are resolved.
200 */
201#if defined(__powerpc__) || defined(__s390x__)
202 return false;
203#else
204 return true;
205#endif
206}
193{
194 /*
195 * PowerPC and S390 do not support creation of instruction
196 * breakpoints using the perf_event interface.
197 *
198 * Just disable the test for these architectures until these
199 * issues are resolved.
200 */
201#if defined(__powerpc__) || defined(__s390x__)
202 return false;
203#else
204 return true;
205#endif
206}
207
208struct test suite__bp_accounting = {
209 .desc = "Breakpoint accounting",
210 .func = test__bp_accounting,
211 .is_supported = test__bp_account_is_supported,
212};