^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #include <stdlib.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #include <string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <unistd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <sys/ioctl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/hw_breakpoint.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include "tests.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include "debug.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include "event.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include "cloexec.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "../perf-sys.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #define WP_TEST_ASSERT_VAL(fd, text, val) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) long long count; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) wp_read(fd, &count, sizeof(long long)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) TEST_ASSERT_VAL(text, count == val); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) volatile u64 data1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) volatile u8 data2[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) static int wp_read(int fd, long long *count, int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) int ret = read(fd, count, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) if (ret != size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) pr_debug("failed to read: %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) static void get__perf_event_attr(struct perf_event_attr *attr, int wp_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) void *wp_addr, unsigned long wp_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) memset(attr, 0, sizeof(struct perf_event_attr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) attr->type = PERF_TYPE_BREAKPOINT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) attr->size = sizeof(struct perf_event_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) attr->config = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) attr->bp_type = wp_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) attr->bp_addr = (unsigned long)wp_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) attr->bp_len = wp_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) attr->sample_period = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) attr->sample_type = PERF_SAMPLE_IP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) attr->exclude_kernel = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) attr->exclude_hv = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) static int __event(int wp_type, void *wp_addr, unsigned long wp_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) int fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) struct perf_event_attr attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) get__perf_event_attr(&attr, wp_type, wp_addr, wp_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) fd = sys_perf_event_open(&attr, 0, -1, -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) perf_event_open_cloexec_flag());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) if (fd < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) pr_debug("failed opening event %x\n", attr.bp_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) return fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) static int wp_ro_test(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) int fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) unsigned long tmp, tmp1 = rand();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) fd = __event(HW_BREAKPOINT_R, (void *)&data1, sizeof(data1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) if (fd < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) tmp = data1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) WP_TEST_ASSERT_VAL(fd, "RO watchpoint", 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) data1 = tmp1 + tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) WP_TEST_ASSERT_VAL(fd, "RO watchpoint", 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) close(fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) static int wp_wo_test(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) int fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) unsigned long tmp, tmp1 = rand();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) fd = __event(HW_BREAKPOINT_W, (void *)&data1, sizeof(data1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) if (fd < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) tmp = data1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) WP_TEST_ASSERT_VAL(fd, "WO watchpoint", 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) data1 = tmp1 + tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) WP_TEST_ASSERT_VAL(fd, "WO watchpoint", 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) close(fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) static int wp_rw_test(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) int fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) unsigned long tmp, tmp1 = rand();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) fd = __event(HW_BREAKPOINT_R | HW_BREAKPOINT_W, (void *)&data1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) sizeof(data1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) if (fd < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) tmp = data1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) WP_TEST_ASSERT_VAL(fd, "RW watchpoint", 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) data1 = tmp1 + tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) WP_TEST_ASSERT_VAL(fd, "RW watchpoint", 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) close(fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) static int wp_modify_test(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) int fd, ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) unsigned long tmp = rand();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) struct perf_event_attr new_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) fd = __event(HW_BREAKPOINT_W, (void *)&data1, sizeof(data1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) if (fd < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) data1 = tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) WP_TEST_ASSERT_VAL(fd, "Modify watchpoint", 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) /* Modify watchpoint with disabled = 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) get__perf_event_attr(&new_attr, HW_BREAKPOINT_W, (void *)&data2[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) sizeof(u8) * 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) new_attr.disabled = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) ret = ioctl(fd, PERF_EVENT_IOC_MODIFY_ATTRIBUTES, &new_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) pr_debug("ioctl(PERF_EVENT_IOC_MODIFY_ATTRIBUTES) failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) close(fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) data2[1] = tmp; /* Not Counted */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) WP_TEST_ASSERT_VAL(fd, "Modify watchpoint", 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) /* Enable the event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) ioctl(fd, PERF_EVENT_IOC_ENABLE, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) pr_debug("Failed to enable event\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) close(fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) data2[1] = tmp; /* Counted */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) WP_TEST_ASSERT_VAL(fd, "Modify watchpoint", 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) data2[2] = tmp; /* Not Counted */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) WP_TEST_ASSERT_VAL(fd, "Modify watchpoint", 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) close(fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) static bool wp_ro_supported(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) #if defined (__x86_64__) || defined (__i386__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) static void wp_ro_skip_msg(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) #if defined (__x86_64__) || defined (__i386__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) pr_debug("Hardware does not support read only watchpoints.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) static struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) const char *desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) int (*target_func)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) bool (*is_supported)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) void (*skip_msg)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) } wp_testcase_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) .desc = "Read Only Watchpoint",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) .target_func = &wp_ro_test,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) .is_supported = &wp_ro_supported,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) .skip_msg = &wp_ro_skip_msg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) .desc = "Write Only Watchpoint",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) .target_func = &wp_wo_test,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) .desc = "Read / Write Watchpoint",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) .target_func = &wp_rw_test,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) .desc = "Modify Watchpoint",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) .target_func = &wp_modify_test,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) int test__wp_subtest_get_nr(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) return (int)ARRAY_SIZE(wp_testcase_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) const char *test__wp_subtest_get_desc(int i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) if (i < 0 || i >= (int)ARRAY_SIZE(wp_testcase_table))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) return wp_testcase_table[i].desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) int test__wp(struct test *test __maybe_unused, int i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) if (i < 0 || i >= (int)ARRAY_SIZE(wp_testcase_table))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) return TEST_FAIL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) if (wp_testcase_table[i].is_supported &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) !wp_testcase_table[i].is_supported()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) wp_testcase_table[i].skip_msg();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) return TEST_SKIP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) return !wp_testcase_table[i].target_func() ? TEST_OK : TEST_FAIL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) /* The s390 so far does not have support for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) * instruction breakpoint using the perf_event_open() system call.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) bool test__wp_is_supported(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) #if defined(__s390x__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) }