11 #define __SANE_USERSPACE_TYPES__ 17 #include <sys/ioctl.h> 22 #include <linux/compiler.h> 23 #include <linux/hw_breakpoint.h> 38 siginfo_t *oh __maybe_unused,
39 void *uc __maybe_unused)
49 ret = read(fd, &count,
sizeof(
long long));
50 if (ret !=
sizeof(
long long)) {
51 pr_debug(
"failed to read: %d\n", ret);
58 #define EXECUTIONS 10000 63 struct perf_event_attr pe;
69 memset(&sa, 0,
sizeof(
struct sigaction));
71 sa.sa_flags = SA_SIGINFO;
73 if (sigaction(SIGIO, &sa, NULL) < 0) {
74 pr_debug(
"failed setting up signal handler\n");
78 memset(&pe, 0,
sizeof(
struct perf_event_attr));
79 pe.type = PERF_TYPE_BREAKPOINT;
80 pe.size =
sizeof(
struct perf_event_attr);
83 pe.bp_type = HW_BREAKPOINT_X;
85 pe.bp_len =
sizeof(long);
88 pe.sample_type = PERF_SAMPLE_IP;
92 pe.exclude_kernel = 1;
98 pr_debug(
"failed opening event %llx\n", pe.config);
102 fcntl(fd, F_SETFL, O_RDWR|O_NONBLOCK|O_ASYNC);
103 fcntl(fd, F_SETSIG, SIGIO);
104 fcntl(fd, F_SETOWN, getpid());
106 ioctl(fd, PERF_EVENT_IOC_RESET, 0);
107 ioctl(fd, PERF_EVENT_IOC_ENABLE, 0);
112 ioctl(fd, PERF_EVENT_IOC_DISABLE, 0);
118 pr_debug(
"count %lld, overflow %d\n",
121 if (count != EXECUTIONS) {
122 pr_debug(
"\tWrong number of executions %lld != %d\n",
128 pr_debug(
"\tWrong number of overflows %d != %d\n",
int test__bp_signal_overflow(struct test *test __maybe_unused, int subtest __maybe_unused)
static int sys_perf_event_open(struct perf_event_attr *attr, pid_t pid, int cpu, int group_fd, unsigned long flags)
x86 movsq based memset() in arch/x86/lib/memset_64.S") MEMSET_FN(memset_erms
static noinline int test_function(void)
#define pr_debug(fmt,...)
unsigned long perf_event_open_cloexec_flag(void)
static void sig_handler(int signum __maybe_unused, siginfo_t *oh __maybe_unused, void *uc __maybe_unused)
static long long bp_count(int fd)