-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfilter-bytecode.h
185 lines (154 loc) · 4 KB
/
filter-bytecode.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#ifndef _FILTER_BYTECODE_H
#define _FILTER_BYTECODE_H
/*
* filter-bytecode.h
*
* LTTng filter bytecode
*
* Copyright 2012 - Mathieu Desnoyers <[email protected]>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License, version 2.1 only,
* as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* offsets are absolute from start of bytecode.
*/
struct field_ref {
/* Initially, symbol offset. After link, field offset. */
uint16_t offset;
} __attribute__((packed));
struct literal_numeric {
int64_t v;
} __attribute__((packed));
struct literal_double {
double v;
} __attribute__((packed));
struct literal_string {
char string[0];
} __attribute__((packed));
enum filter_op {
FILTER_OP_UNKNOWN = 0,
FILTER_OP_RETURN,
/* binary */
FILTER_OP_MUL,
FILTER_OP_DIV,
FILTER_OP_MOD,
FILTER_OP_PLUS,
FILTER_OP_MINUS,
FILTER_OP_RSHIFT,
FILTER_OP_LSHIFT,
FILTER_OP_BIN_AND,
FILTER_OP_BIN_OR,
FILTER_OP_BIN_XOR,
/* binary comparators */
FILTER_OP_EQ,
FILTER_OP_NE,
FILTER_OP_GT,
FILTER_OP_LT,
FILTER_OP_GE,
FILTER_OP_LE,
/* string binary comparator */
FILTER_OP_EQ_STRING,
FILTER_OP_NE_STRING,
FILTER_OP_GT_STRING,
FILTER_OP_LT_STRING,
FILTER_OP_GE_STRING,
FILTER_OP_LE_STRING,
/* s64 binary comparator */
FILTER_OP_EQ_S64,
FILTER_OP_NE_S64,
FILTER_OP_GT_S64,
FILTER_OP_LT_S64,
FILTER_OP_GE_S64,
FILTER_OP_LE_S64,
/* double binary comparator */
FILTER_OP_EQ_DOUBLE,
FILTER_OP_NE_DOUBLE,
FILTER_OP_GT_DOUBLE,
FILTER_OP_LT_DOUBLE,
FILTER_OP_GE_DOUBLE,
FILTER_OP_LE_DOUBLE,
/* Mixed S64-double binary comparators */
FILTER_OP_EQ_DOUBLE_S64,
FILTER_OP_NE_DOUBLE_S64,
FILTER_OP_GT_DOUBLE_S64,
FILTER_OP_LT_DOUBLE_S64,
FILTER_OP_GE_DOUBLE_S64,
FILTER_OP_LE_DOUBLE_S64,
FILTER_OP_EQ_S64_DOUBLE,
FILTER_OP_NE_S64_DOUBLE,
FILTER_OP_GT_S64_DOUBLE,
FILTER_OP_LT_S64_DOUBLE,
FILTER_OP_GE_S64_DOUBLE,
FILTER_OP_LE_S64_DOUBLE,
/* unary */
FILTER_OP_UNARY_PLUS,
FILTER_OP_UNARY_MINUS,
FILTER_OP_UNARY_NOT,
FILTER_OP_UNARY_PLUS_S64,
FILTER_OP_UNARY_MINUS_S64,
FILTER_OP_UNARY_NOT_S64,
FILTER_OP_UNARY_PLUS_DOUBLE,
FILTER_OP_UNARY_MINUS_DOUBLE,
FILTER_OP_UNARY_NOT_DOUBLE,
/* logical */
FILTER_OP_AND,
FILTER_OP_OR,
/* load field ref */
FILTER_OP_LOAD_FIELD_REF,
FILTER_OP_LOAD_FIELD_REF_STRING,
FILTER_OP_LOAD_FIELD_REF_SEQUENCE,
FILTER_OP_LOAD_FIELD_REF_S64,
FILTER_OP_LOAD_FIELD_REF_DOUBLE,
/* load immediate from operand */
FILTER_OP_LOAD_STRING,
FILTER_OP_LOAD_S64,
FILTER_OP_LOAD_DOUBLE,
/* cast */
FILTER_OP_CAST_TO_S64,
FILTER_OP_CAST_DOUBLE_TO_S64,
FILTER_OP_CAST_NOP,
/* get context ref */
FILTER_OP_GET_CONTEXT_REF,
FILTER_OP_GET_CONTEXT_REF_STRING,
FILTER_OP_GET_CONTEXT_REF_S64,
FILTER_OP_GET_CONTEXT_REF_DOUBLE,
/* load userspace field ref */
FILTER_OP_LOAD_FIELD_REF_USER_STRING,
FILTER_OP_LOAD_FIELD_REF_USER_SEQUENCE,
NR_FILTER_OPS,
};
typedef uint8_t filter_opcode_t;
struct load_op {
filter_opcode_t op;
char data[0];
/* data to load. Size known by enum filter_opcode and null-term char. */
} __attribute__((packed));
struct binary_op {
filter_opcode_t op;
} __attribute__((packed));
struct unary_op {
filter_opcode_t op;
} __attribute__((packed));
/* skip_offset is absolute from start of bytecode */
struct logical_op {
filter_opcode_t op;
uint16_t skip_offset; /* bytecode insn, if skip second test */
} __attribute__((packed));
struct cast_op {
filter_opcode_t op;
} __attribute__((packed));
struct return_op {
filter_opcode_t op;
} __attribute__((packed));
#endif /* _FILTER_BYTECODE_H */