forked from jlgreathouse/AMD_IBS_Toolkit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ibs-structs.h
112 lines (99 loc) · 2.79 KB
/
ibs-structs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
* Linux kernel driver for the AMD Research IBS Toolkit
*
* Copyright (C) 2015-2018 Advanced Micro Devices, Inc.
*
* This driver is available under the Linux kernel's version of the GPLv2.
* See driver/LICENSE for more licensing details.
*
*
* This file contains the structs used to communicate IBS samples from the
* driver into user-space.
*/
#ifndef IBS_STRUCTS_H
#define IBS_STRUCTS_H
#include <linux/types.h>
#include <linux/version.h>
#include <linux/wait.h>
#include <linux/interrupt.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)
#include <linux/irq_work.h>
#endif
struct ibs_op {
__u64 op_ctl;
__u64 op_rip;
__u64 op_data;
__u64 op_data2;
__u64 op_data3;
__u64 op_data4;
__u64 dc_lin_ad;
__u64 dc_phys_ad;
__u64 br_target;
__u64 tsc;
__u64 cr3;
pid_t tid;
pid_t pid;
int cpu;
int kern_mode;
int micro_op_sample;
int mem_access_sample;
int valid_mem_access_sample;
};
struct ibs_fetch {
__u64 fetch_ctl;
__u64 fetch_ctl_extd;
__u64 fetch_lin_ad;
__u64 fetch_phys_ad;
__u64 tsc;
__u64 cr3;
pid_t tid;
pid_t pid;
int cpu;
int kern_mode;
};
struct ibs_dev {
char *buf; /* buffer memory region */
u64 size; /* size of buffer memory region in bytes */
u64 entry_size; /* size of each entry in bytes */
u64 capacity; /* buffer capacity in entries */
atomic_long_t wr; /* write index (0 <= wr < capacity) */
atomic_long_t rd; /* read index */
atomic_long_t entries; /* buffer occupancy in entries */
atomic_long_t lost; /* dropped samples counter */
atomic_t being_read_status; /* whether the sample buffer is being read */
struct mutex read_lock; /* read lock */
wait_queue_head_t readq; /* wait queue for blocking read */
wait_queue_head_t pollq; /* dedicated wait queue for polling */
atomic_long_t poll_threshold; /* min size for poll to return */
u64 ctl; /* copy of op/fetch ctl MSR to store control options */
u64 ctl_temp;
struct mutex ctl_lock; /* lock for device control options */
int cpu; /* this device's cpu id */
int flavor; /* IBS_FETCH or IBS_OP */
atomic_t in_use; /* nonzero when device is open */
/* Information about what IBS stuff is supported on this CPU */
int ibs_fetch_supported;
int ibs_op_supported;
int ibs_brn_trgt_supported;
int ibs_op_cnt_ext_supported;
int ibs_rip_invalid_chk_supported;
int ibs_op_brn_fuse_supported;
int ibs_fetch_ctl_extd_supported;
int ibs_op_data4_supported;
int workaround_fam10h_err_420;
int workaround_fam15h_err_718;
int workaround_fam17h_zn;
int micro_op_sample;
//atomic_long_t micro_op_sample;
int mem_access_sample;
int valid_mem_access_sample;
int valid_store_sample;
int fd;
//struct task_struct *target_process;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)
struct irq_work bottom_half;
//struct tasklet_struct bottom_half;
#endif
};
#define TABLE_SIZE 257
#endif /* IBS_STRUCTS_H */