wp.c (03ab8e6297acd1bc0eedaa050e2a1635c576fd11) wp.c (e1dda48e4370043443e7d121d4b67a96fb70c75b)
1// SPDX-License-Identifier: GPL-2.0
2#include <stdlib.h>
3#include <string.h>
4#include <unistd.h>
1// SPDX-License-Identifier: GPL-2.0
2#include <stdlib.h>
3#include <string.h>
4#include <unistd.h>
5#include <errno.h>
5#include <sys/ioctl.h>
6#include <sys/ioctl.h>
7#include <linux/compiler.h>
6#include <linux/hw_breakpoint.h>
7#include <linux/kernel.h>
8#include "tests.h"
9#include "debug.h"
10#include "event.h"
11#include "cloexec.h"
12#include "../perf-sys.h"
13

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

132 data1 = tmp1 + tmp;
133 WP_TEST_ASSERT_VAL(fd, "RW watchpoint", 2);
134
135 close(fd);
136 return 0;
137#endif
138}
139
8#include <linux/hw_breakpoint.h>
9#include <linux/kernel.h>
10#include "tests.h"
11#include "debug.h"
12#include "event.h"
13#include "cloexec.h"
14#include "../perf-sys.h"
15

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

134 data1 = tmp1 + tmp;
135 WP_TEST_ASSERT_VAL(fd, "RW watchpoint", 2);
136
137 close(fd);
138 return 0;
139#endif
140}
141
140static int test__wp_modify(struct test_suite *test __maybe_unused,
141 int subtest __maybe_unused)
142static int test__wp_modify(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
142{
143#if defined(__s390x__)
144 return TEST_SKIP;
145#else
146 int fd, ret;
147 unsigned long tmp = rand();
148 struct perf_event_attr new_attr;
149

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

155 WP_TEST_ASSERT_VAL(fd, "Modify watchpoint", 1);
156
157 /* Modify watchpoint with disabled = 1 */
158 get__perf_event_attr(&new_attr, HW_BREAKPOINT_W, (void *)&data2[0],
159 sizeof(u8) * 2);
160 new_attr.disabled = 1;
161 ret = ioctl(fd, PERF_EVENT_IOC_MODIFY_ATTRIBUTES, &new_attr);
162 if (ret < 0) {
143{
144#if defined(__s390x__)
145 return TEST_SKIP;
146#else
147 int fd, ret;
148 unsigned long tmp = rand();
149 struct perf_event_attr new_attr;
150

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

156 WP_TEST_ASSERT_VAL(fd, "Modify watchpoint", 1);
157
158 /* Modify watchpoint with disabled = 1 */
159 get__perf_event_attr(&new_attr, HW_BREAKPOINT_W, (void *)&data2[0],
160 sizeof(u8) * 2);
161 new_attr.disabled = 1;
162 ret = ioctl(fd, PERF_EVENT_IOC_MODIFY_ATTRIBUTES, &new_attr);
163 if (ret < 0) {
164 if (errno == ENOTTY) {
165 test->test_cases[subtest].skip_reason = "missing kernel support";
166 ret = TEST_SKIP;
167 }
168
163 pr_debug("ioctl(PERF_EVENT_IOC_MODIFY_ATTRIBUTES) failed\n");
164 close(fd);
165 return ret;
166 }
167
168 data2[1] = tmp; /* Not Counted */
169 WP_TEST_ASSERT_VAL(fd, "Modify watchpoint", 1);
170

--- 31 unchanged lines hidden ---
169 pr_debug("ioctl(PERF_EVENT_IOC_MODIFY_ATTRIBUTES) failed\n");
170 close(fd);
171 return ret;
172 }
173
174 data2[1] = tmp; /* Not Counted */
175 WP_TEST_ASSERT_VAL(fd, "Modify watchpoint", 1);
176

--- 31 unchanged lines hidden ---