1 /* SPDX-License-Identifier: MIT
3 * lttng-filter-interpreter.c
5 * LTTng modules filter interpreter.
7 * Copyright (C) 2010-2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 #include <linux/uaccess.h>
11 #include <wrapper/frame.h>
12 #include <wrapper/types.h>
13 #include <linux/swab.h>
15 #include <lttng-filter.h>
16 #include <lttng-string-utils.h>
18 LTTNG_STACK_FRAME_NON_STANDARD(lttng_filter_interpret_bytecode
);
21 * get_char should be called with page fault handler disabled if it is expected
22 * to handle user-space read.
25 char get_char(struct estack_entry
*reg
, size_t offset
)
27 if (unlikely(offset
>= reg
->u
.s
.seq_len
))
32 /* Handle invalid access as end of string. */
33 if (unlikely(!access_ok(VERIFY_READ
,
34 reg
->u
.s
.user_str
+ offset
,
37 /* Handle fault (nonzero return value) as end of string. */
38 if (unlikely(__copy_from_user_inatomic(&c
,
39 reg
->u
.s
.user_str
+ offset
,
44 return reg
->u
.s
.str
[offset
];
50 * -2: unknown escape char.
54 int parse_char(struct estack_entry
*reg
, char *c
, size_t *offset
)
59 *c
= get_char(reg
, *offset
);
75 char get_char_at_cb(size_t at
, void *data
)
77 return get_char(data
, at
);
81 int stack_star_glob_match(struct estack
*stack
, int top
, const char *cmp_type
)
83 bool has_user
= false;
86 struct estack_entry
*pattern_reg
;
87 struct estack_entry
*candidate_reg
;
89 if (estack_bx(stack
, top
)->u
.s
.user
90 || estack_ax(stack
, top
)->u
.s
.user
) {
97 /* Find out which side is the pattern vs. the candidate. */
98 if (estack_ax(stack
, top
)->u
.s
.literal_type
== ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
) {
99 pattern_reg
= estack_ax(stack
, top
);
100 candidate_reg
= estack_bx(stack
, top
);
102 pattern_reg
= estack_bx(stack
, top
);
103 candidate_reg
= estack_ax(stack
, top
);
106 /* Perform the match operation. */
107 result
= !strutils_star_glob_match_char_cb(get_char_at_cb
,
108 pattern_reg
, get_char_at_cb
, candidate_reg
);
118 int stack_strcmp(struct estack
*stack
, int top
, const char *cmp_type
)
120 size_t offset_bx
= 0, offset_ax
= 0;
121 int diff
, has_user
= 0;
124 if (estack_bx(stack
, top
)->u
.s
.user
125 || estack_ax(stack
, top
)->u
.s
.user
) {
135 char char_bx
, char_ax
;
137 char_bx
= get_char(estack_bx(stack
, top
), offset_bx
);
138 char_ax
= get_char(estack_ax(stack
, top
), offset_ax
);
140 if (unlikely(char_bx
== '\0')) {
141 if (char_ax
== '\0') {
145 if (estack_ax(stack
, top
)->u
.s
.literal_type
==
146 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
147 ret
= parse_char(estack_ax(stack
, top
),
148 &char_ax
, &offset_ax
);
158 if (unlikely(char_ax
== '\0')) {
159 if (estack_bx(stack
, top
)->u
.s
.literal_type
==
160 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
161 ret
= parse_char(estack_bx(stack
, top
),
162 &char_bx
, &offset_bx
);
171 if (estack_bx(stack
, top
)->u
.s
.literal_type
==
172 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
173 ret
= parse_char(estack_bx(stack
, top
),
174 &char_bx
, &offset_bx
);
178 } else if (ret
== -2) {
181 /* else compare both char */
183 if (estack_ax(stack
, top
)->u
.s
.literal_type
==
184 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
185 ret
= parse_char(estack_ax(stack
, top
),
186 &char_ax
, &offset_ax
);
190 } else if (ret
== -2) {
207 diff
= char_bx
- char_ax
;
220 uint64_t lttng_filter_false(void *filter_data
,
221 struct lttng_probe_ctx
*lttng_probe_ctx
,
222 const char *filter_stack_data
)
227 #ifdef INTERPRETER_USE_SWITCH
230 * Fallback for compilers that do not support taking address of labels.
234 start_pc = &bytecode->data[0]; \
235 for (pc = next_pc = start_pc; pc - start_pc < bytecode->len; \
237 dbg_printk("Executing op %s (%u)\n", \
238 lttng_filter_print_op((unsigned int) *(filter_opcode_t *) pc), \
239 (unsigned int) *(filter_opcode_t *) pc); \
240 switch (*(filter_opcode_t *) pc) {
242 #define OP(name) case name
252 * Dispatch-table based interpreter.
256 start_pc = &bytecode->code[0]; \
257 pc = next_pc = start_pc; \
258 if (unlikely(pc - start_pc >= bytecode->len)) \
260 goto *dispatch[*(filter_opcode_t *) pc];
267 goto *dispatch[*(filter_opcode_t *) pc];
273 static int context_get_index(struct lttng_probe_ctx
*lttng_probe_ctx
,
274 struct load_ptr
*ptr
,
278 struct lttng_ctx_field
*ctx_field
;
279 struct lttng_event_field
*field
;
280 union lttng_ctx_value v
;
282 ctx_field
= <tng_static_ctx
->fields
[idx
];
283 field
= &ctx_field
->event_field
;
284 ptr
->type
= LOAD_OBJECT
;
285 /* field is only used for types nested within variants. */
288 switch (field
->type
.atype
) {
290 ctx_field
->get_value(ctx_field
, lttng_probe_ctx
, &v
);
291 if (field
->type
.u
.basic
.integer
.signedness
) {
292 ptr
->object_type
= OBJECT_TYPE_S64
;
294 ptr
->ptr
= &ptr
->u
.s64
;
296 ptr
->object_type
= OBJECT_TYPE_U64
;
297 ptr
->u
.u64
= v
.s64
; /* Cast. */
298 ptr
->ptr
= &ptr
->u
.u64
;
303 const struct lttng_integer_type
*itype
=
304 &field
->type
.u
.basic
.enumeration
.container_type
;
306 ctx_field
->get_value(ctx_field
, lttng_probe_ctx
, &v
);
307 if (itype
->signedness
) {
308 ptr
->object_type
= OBJECT_TYPE_S64
;
310 ptr
->ptr
= &ptr
->u
.s64
;
312 ptr
->object_type
= OBJECT_TYPE_U64
;
313 ptr
->u
.u64
= v
.s64
; /* Cast. */
314 ptr
->ptr
= &ptr
->u
.u64
;
319 if (field
->type
.u
.array
.elem_type
.atype
!= atype_integer
) {
320 printk(KERN_WARNING
"Array nesting only supports integer types.\n");
323 if (field
->type
.u
.array
.elem_type
.u
.basic
.integer
.encoding
== lttng_encode_none
) {
324 printk(KERN_WARNING
"Only string arrays are supported for contexts.\n");
327 ptr
->object_type
= OBJECT_TYPE_STRING
;
328 ctx_field
->get_value(ctx_field
, lttng_probe_ctx
, &v
);
332 if (field
->type
.u
.sequence
.elem_type
.atype
!= atype_integer
) {
333 printk(KERN_WARNING
"Sequence nesting only supports integer types.\n");
336 if (field
->type
.u
.sequence
.elem_type
.u
.basic
.integer
.encoding
== lttng_encode_none
) {
337 printk(KERN_WARNING
"Only string sequences are supported for contexts.\n");
340 ptr
->object_type
= OBJECT_TYPE_STRING
;
341 ctx_field
->get_value(ctx_field
, lttng_probe_ctx
, &v
);
344 case atype_array_bitfield
:
345 printk(KERN_WARNING
"Bitfield array type is not supported.\n");
347 case atype_sequence_bitfield
:
348 printk(KERN_WARNING
"Bitfield sequence type is not supported.\n");
351 ptr
->object_type
= OBJECT_TYPE_STRING
;
352 ctx_field
->get_value(ctx_field
, lttng_probe_ctx
, &v
);
356 printk(KERN_WARNING
"Structure type cannot be loaded.\n");
359 printk(KERN_WARNING
"Unknown type: %d", (int) field
->type
.atype
);
365 static int dynamic_get_index(struct lttng_probe_ctx
*lttng_probe_ctx
,
366 struct bytecode_runtime
*runtime
,
367 uint64_t index
, struct estack_entry
*stack_top
)
370 const struct filter_get_index_data
*gid
;
373 * Types nested within variants need to perform dynamic lookup
374 * based on the field descriptions. LTTng-UST does not implement
377 if (stack_top
->u
.ptr
.field
)
379 gid
= (const struct filter_get_index_data
*) &runtime
->data
[index
];
380 switch (stack_top
->u
.ptr
.type
) {
382 switch (stack_top
->u
.ptr
.object_type
) {
383 case OBJECT_TYPE_ARRAY
:
387 WARN_ON_ONCE(gid
->offset
>= gid
->array_len
);
388 /* Skip count (unsigned long) */
389 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
390 ptr
= ptr
+ gid
->offset
;
391 stack_top
->u
.ptr
.ptr
= ptr
;
392 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
393 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
394 /* field is only used for types nested within variants. */
395 stack_top
->u
.ptr
.field
= NULL
;
398 case OBJECT_TYPE_SEQUENCE
:
403 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
404 ptr_seq_len
= *(unsigned long *) stack_top
->u
.ptr
.ptr
;
405 if (gid
->offset
>= gid
->elem
.len
* ptr_seq_len
) {
409 ptr
= ptr
+ gid
->offset
;
410 stack_top
->u
.ptr
.ptr
= ptr
;
411 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
412 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
413 /* field is only used for types nested within variants. */
414 stack_top
->u
.ptr
.field
= NULL
;
417 case OBJECT_TYPE_STRUCT
:
418 printk(KERN_WARNING
"Nested structures are not supported yet.\n");
421 case OBJECT_TYPE_VARIANT
:
423 printk(KERN_WARNING
"Unexpected get index type %d",
424 (int) stack_top
->u
.ptr
.object_type
);
429 case LOAD_ROOT_CONTEXT
:
430 case LOAD_ROOT_APP_CONTEXT
: /* Fall-through */
432 ret
= context_get_index(lttng_probe_ctx
,
440 case LOAD_ROOT_PAYLOAD
:
441 stack_top
->u
.ptr
.ptr
+= gid
->offset
;
442 if (gid
->elem
.type
== OBJECT_TYPE_STRING
)
443 stack_top
->u
.ptr
.ptr
= *(const char * const *) stack_top
->u
.ptr
.ptr
;
444 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
445 stack_top
->u
.ptr
.type
= LOAD_OBJECT
;
446 /* field is only used for types nested within variants. */
447 stack_top
->u
.ptr
.field
= NULL
;
456 static int dynamic_load_field(struct estack_entry
*stack_top
)
460 switch (stack_top
->u
.ptr
.type
) {
463 case LOAD_ROOT_CONTEXT
:
464 case LOAD_ROOT_APP_CONTEXT
:
465 case LOAD_ROOT_PAYLOAD
:
467 dbg_printk("Filter warning: cannot load root, missing field name.\n");
471 switch (stack_top
->u
.ptr
.object_type
) {
473 dbg_printk("op load field s8\n");
474 stack_top
->u
.v
= *(int8_t *) stack_top
->u
.ptr
.ptr
;
476 case OBJECT_TYPE_S16
:
480 dbg_printk("op load field s16\n");
481 tmp
= *(int16_t *) stack_top
->u
.ptr
.ptr
;
482 if (stack_top
->u
.ptr
.rev_bo
)
484 stack_top
->u
.v
= tmp
;
487 case OBJECT_TYPE_S32
:
491 dbg_printk("op load field s32\n");
492 tmp
= *(int32_t *) stack_top
->u
.ptr
.ptr
;
493 if (stack_top
->u
.ptr
.rev_bo
)
495 stack_top
->u
.v
= tmp
;
498 case OBJECT_TYPE_S64
:
502 dbg_printk("op load field s64\n");
503 tmp
= *(int64_t *) stack_top
->u
.ptr
.ptr
;
504 if (stack_top
->u
.ptr
.rev_bo
)
506 stack_top
->u
.v
= tmp
;
510 dbg_printk("op load field u8\n");
511 stack_top
->u
.v
= *(uint8_t *) stack_top
->u
.ptr
.ptr
;
513 case OBJECT_TYPE_U16
:
517 dbg_printk("op load field s16\n");
518 tmp
= *(uint16_t *) stack_top
->u
.ptr
.ptr
;
519 if (stack_top
->u
.ptr
.rev_bo
)
521 stack_top
->u
.v
= tmp
;
524 case OBJECT_TYPE_U32
:
528 dbg_printk("op load field u32\n");
529 tmp
= *(uint32_t *) stack_top
->u
.ptr
.ptr
;
530 if (stack_top
->u
.ptr
.rev_bo
)
532 stack_top
->u
.v
= tmp
;
535 case OBJECT_TYPE_U64
:
539 dbg_printk("op load field u64\n");
540 tmp
= *(uint64_t *) stack_top
->u
.ptr
.ptr
;
541 if (stack_top
->u
.ptr
.rev_bo
)
543 stack_top
->u
.v
= tmp
;
546 case OBJECT_TYPE_STRING
:
550 dbg_printk("op load field string\n");
551 str
= (const char *) stack_top
->u
.ptr
.ptr
;
552 stack_top
->u
.s
.str
= str
;
553 if (unlikely(!stack_top
->u
.s
.str
)) {
554 dbg_printk("Filter warning: loading a NULL string.\n");
558 stack_top
->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
559 stack_top
->u
.s
.literal_type
=
560 ESTACK_STRING_LITERAL_TYPE_NONE
;
563 case OBJECT_TYPE_STRING_SEQUENCE
:
567 dbg_printk("op load field string sequence\n");
568 ptr
= stack_top
->u
.ptr
.ptr
;
569 stack_top
->u
.s
.seq_len
= *(unsigned long *) ptr
;
570 stack_top
->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
571 if (unlikely(!stack_top
->u
.s
.str
)) {
572 dbg_printk("Filter warning: loading a NULL sequence.\n");
576 stack_top
->u
.s
.literal_type
=
577 ESTACK_STRING_LITERAL_TYPE_NONE
;
580 case OBJECT_TYPE_DYNAMIC
:
582 * Dynamic types in context are looked up
583 * by context get index.
587 case OBJECT_TYPE_DOUBLE
:
590 case OBJECT_TYPE_SEQUENCE
:
591 case OBJECT_TYPE_ARRAY
:
592 case OBJECT_TYPE_STRUCT
:
593 case OBJECT_TYPE_VARIANT
:
594 printk(KERN_WARNING
"Sequences, arrays, struct and variant cannot be loaded (nested types).\n");
605 * Return 0 (discard), or raise the 0x1 flag (log event).
606 * Currently, other flags are kept for future extensions and have no
609 uint64_t lttng_filter_interpret_bytecode(void *filter_data
,
610 struct lttng_probe_ctx
*lttng_probe_ctx
,
611 const char *filter_stack_data
)
613 struct bytecode_runtime
*bytecode
= filter_data
;
614 void *pc
, *next_pc
, *start_pc
;
617 struct estack _stack
;
618 struct estack
*stack
= &_stack
;
619 register int64_t ax
= 0, bx
= 0;
620 register int top
= FILTER_STACK_EMPTY
;
621 #ifndef INTERPRETER_USE_SWITCH
622 static void *dispatch
[NR_FILTER_OPS
] = {
623 [ FILTER_OP_UNKNOWN
] = &&LABEL_FILTER_OP_UNKNOWN
,
625 [ FILTER_OP_RETURN
] = &&LABEL_FILTER_OP_RETURN
,
628 [ FILTER_OP_MUL
] = &&LABEL_FILTER_OP_MUL
,
629 [ FILTER_OP_DIV
] = &&LABEL_FILTER_OP_DIV
,
630 [ FILTER_OP_MOD
] = &&LABEL_FILTER_OP_MOD
,
631 [ FILTER_OP_PLUS
] = &&LABEL_FILTER_OP_PLUS
,
632 [ FILTER_OP_MINUS
] = &&LABEL_FILTER_OP_MINUS
,
633 [ FILTER_OP_BIT_RSHIFT
] = &&LABEL_FILTER_OP_BIT_RSHIFT
,
634 [ FILTER_OP_BIT_LSHIFT
] = &&LABEL_FILTER_OP_BIT_LSHIFT
,
635 [ FILTER_OP_BIT_AND
] = &&LABEL_FILTER_OP_BIT_AND
,
636 [ FILTER_OP_BIT_OR
] = &&LABEL_FILTER_OP_BIT_OR
,
637 [ FILTER_OP_BIT_XOR
] = &&LABEL_FILTER_OP_BIT_XOR
,
639 /* binary comparators */
640 [ FILTER_OP_EQ
] = &&LABEL_FILTER_OP_EQ
,
641 [ FILTER_OP_NE
] = &&LABEL_FILTER_OP_NE
,
642 [ FILTER_OP_GT
] = &&LABEL_FILTER_OP_GT
,
643 [ FILTER_OP_LT
] = &&LABEL_FILTER_OP_LT
,
644 [ FILTER_OP_GE
] = &&LABEL_FILTER_OP_GE
,
645 [ FILTER_OP_LE
] = &&LABEL_FILTER_OP_LE
,
647 /* string binary comparator */
648 [ FILTER_OP_EQ_STRING
] = &&LABEL_FILTER_OP_EQ_STRING
,
649 [ FILTER_OP_NE_STRING
] = &&LABEL_FILTER_OP_NE_STRING
,
650 [ FILTER_OP_GT_STRING
] = &&LABEL_FILTER_OP_GT_STRING
,
651 [ FILTER_OP_LT_STRING
] = &&LABEL_FILTER_OP_LT_STRING
,
652 [ FILTER_OP_GE_STRING
] = &&LABEL_FILTER_OP_GE_STRING
,
653 [ FILTER_OP_LE_STRING
] = &&LABEL_FILTER_OP_LE_STRING
,
655 /* globbing pattern binary comparator */
656 [ FILTER_OP_EQ_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_EQ_STAR_GLOB_STRING
,
657 [ FILTER_OP_NE_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_NE_STAR_GLOB_STRING
,
659 /* s64 binary comparator */
660 [ FILTER_OP_EQ_S64
] = &&LABEL_FILTER_OP_EQ_S64
,
661 [ FILTER_OP_NE_S64
] = &&LABEL_FILTER_OP_NE_S64
,
662 [ FILTER_OP_GT_S64
] = &&LABEL_FILTER_OP_GT_S64
,
663 [ FILTER_OP_LT_S64
] = &&LABEL_FILTER_OP_LT_S64
,
664 [ FILTER_OP_GE_S64
] = &&LABEL_FILTER_OP_GE_S64
,
665 [ FILTER_OP_LE_S64
] = &&LABEL_FILTER_OP_LE_S64
,
667 /* double binary comparator */
668 [ FILTER_OP_EQ_DOUBLE
] = &&LABEL_FILTER_OP_EQ_DOUBLE
,
669 [ FILTER_OP_NE_DOUBLE
] = &&LABEL_FILTER_OP_NE_DOUBLE
,
670 [ FILTER_OP_GT_DOUBLE
] = &&LABEL_FILTER_OP_GT_DOUBLE
,
671 [ FILTER_OP_LT_DOUBLE
] = &&LABEL_FILTER_OP_LT_DOUBLE
,
672 [ FILTER_OP_GE_DOUBLE
] = &&LABEL_FILTER_OP_GE_DOUBLE
,
673 [ FILTER_OP_LE_DOUBLE
] = &&LABEL_FILTER_OP_LE_DOUBLE
,
675 /* Mixed S64-double binary comparators */
676 [ FILTER_OP_EQ_DOUBLE_S64
] = &&LABEL_FILTER_OP_EQ_DOUBLE_S64
,
677 [ FILTER_OP_NE_DOUBLE_S64
] = &&LABEL_FILTER_OP_NE_DOUBLE_S64
,
678 [ FILTER_OP_GT_DOUBLE_S64
] = &&LABEL_FILTER_OP_GT_DOUBLE_S64
,
679 [ FILTER_OP_LT_DOUBLE_S64
] = &&LABEL_FILTER_OP_LT_DOUBLE_S64
,
680 [ FILTER_OP_GE_DOUBLE_S64
] = &&LABEL_FILTER_OP_GE_DOUBLE_S64
,
681 [ FILTER_OP_LE_DOUBLE_S64
] = &&LABEL_FILTER_OP_LE_DOUBLE_S64
,
683 [ FILTER_OP_EQ_S64_DOUBLE
] = &&LABEL_FILTER_OP_EQ_S64_DOUBLE
,
684 [ FILTER_OP_NE_S64_DOUBLE
] = &&LABEL_FILTER_OP_NE_S64_DOUBLE
,
685 [ FILTER_OP_GT_S64_DOUBLE
] = &&LABEL_FILTER_OP_GT_S64_DOUBLE
,
686 [ FILTER_OP_LT_S64_DOUBLE
] = &&LABEL_FILTER_OP_LT_S64_DOUBLE
,
687 [ FILTER_OP_GE_S64_DOUBLE
] = &&LABEL_FILTER_OP_GE_S64_DOUBLE
,
688 [ FILTER_OP_LE_S64_DOUBLE
] = &&LABEL_FILTER_OP_LE_S64_DOUBLE
,
691 [ FILTER_OP_UNARY_PLUS
] = &&LABEL_FILTER_OP_UNARY_PLUS
,
692 [ FILTER_OP_UNARY_MINUS
] = &&LABEL_FILTER_OP_UNARY_MINUS
,
693 [ FILTER_OP_UNARY_NOT
] = &&LABEL_FILTER_OP_UNARY_NOT
,
694 [ FILTER_OP_UNARY_PLUS_S64
] = &&LABEL_FILTER_OP_UNARY_PLUS_S64
,
695 [ FILTER_OP_UNARY_MINUS_S64
] = &&LABEL_FILTER_OP_UNARY_MINUS_S64
,
696 [ FILTER_OP_UNARY_NOT_S64
] = &&LABEL_FILTER_OP_UNARY_NOT_S64
,
697 [ FILTER_OP_UNARY_PLUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_PLUS_DOUBLE
,
698 [ FILTER_OP_UNARY_MINUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_MINUS_DOUBLE
,
699 [ FILTER_OP_UNARY_NOT_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_NOT_DOUBLE
,
702 [ FILTER_OP_AND
] = &&LABEL_FILTER_OP_AND
,
703 [ FILTER_OP_OR
] = &&LABEL_FILTER_OP_OR
,
706 [ FILTER_OP_LOAD_FIELD_REF
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF
,
707 [ FILTER_OP_LOAD_FIELD_REF_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_STRING
,
708 [ FILTER_OP_LOAD_FIELD_REF_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_SEQUENCE
,
709 [ FILTER_OP_LOAD_FIELD_REF_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_S64
,
710 [ FILTER_OP_LOAD_FIELD_REF_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_DOUBLE
,
712 /* load from immediate operand */
713 [ FILTER_OP_LOAD_STRING
] = &&LABEL_FILTER_OP_LOAD_STRING
,
714 [ FILTER_OP_LOAD_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_LOAD_STAR_GLOB_STRING
,
715 [ FILTER_OP_LOAD_S64
] = &&LABEL_FILTER_OP_LOAD_S64
,
716 [ FILTER_OP_LOAD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_DOUBLE
,
719 [ FILTER_OP_CAST_TO_S64
] = &&LABEL_FILTER_OP_CAST_TO_S64
,
720 [ FILTER_OP_CAST_DOUBLE_TO_S64
] = &&LABEL_FILTER_OP_CAST_DOUBLE_TO_S64
,
721 [ FILTER_OP_CAST_NOP
] = &&LABEL_FILTER_OP_CAST_NOP
,
723 /* get context ref */
724 [ FILTER_OP_GET_CONTEXT_REF
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF
,
725 [ FILTER_OP_GET_CONTEXT_REF_STRING
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_STRING
,
726 [ FILTER_OP_GET_CONTEXT_REF_S64
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_S64
,
727 [ FILTER_OP_GET_CONTEXT_REF_DOUBLE
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_DOUBLE
,
729 /* load userspace field ref */
730 [ FILTER_OP_LOAD_FIELD_REF_USER_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_USER_STRING
,
731 [ FILTER_OP_LOAD_FIELD_REF_USER_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_USER_SEQUENCE
,
733 /* Instructions for recursive traversal through composed types. */
734 [ FILTER_OP_GET_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_CONTEXT_ROOT
,
735 [ FILTER_OP_GET_APP_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_APP_CONTEXT_ROOT
,
736 [ FILTER_OP_GET_PAYLOAD_ROOT
] = &&LABEL_FILTER_OP_GET_PAYLOAD_ROOT
,
738 [ FILTER_OP_GET_SYMBOL
] = &&LABEL_FILTER_OP_GET_SYMBOL
,
739 [ FILTER_OP_GET_SYMBOL_FIELD
] = &&LABEL_FILTER_OP_GET_SYMBOL_FIELD
,
740 [ FILTER_OP_GET_INDEX_U16
] = &&LABEL_FILTER_OP_GET_INDEX_U16
,
741 [ FILTER_OP_GET_INDEX_U64
] = &&LABEL_FILTER_OP_GET_INDEX_U64
,
743 [ FILTER_OP_LOAD_FIELD
] = &&LABEL_FILTER_OP_LOAD_FIELD
,
744 [ FILTER_OP_LOAD_FIELD_S8
] = &&LABEL_FILTER_OP_LOAD_FIELD_S8
,
745 [ FILTER_OP_LOAD_FIELD_S16
] = &&LABEL_FILTER_OP_LOAD_FIELD_S16
,
746 [ FILTER_OP_LOAD_FIELD_S32
] = &&LABEL_FILTER_OP_LOAD_FIELD_S32
,
747 [ FILTER_OP_LOAD_FIELD_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_S64
,
748 [ FILTER_OP_LOAD_FIELD_U8
] = &&LABEL_FILTER_OP_LOAD_FIELD_U8
,
749 [ FILTER_OP_LOAD_FIELD_U16
] = &&LABEL_FILTER_OP_LOAD_FIELD_U16
,
750 [ FILTER_OP_LOAD_FIELD_U32
] = &&LABEL_FILTER_OP_LOAD_FIELD_U32
,
751 [ FILTER_OP_LOAD_FIELD_U64
] = &&LABEL_FILTER_OP_LOAD_FIELD_U64
,
752 [ FILTER_OP_LOAD_FIELD_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_STRING
,
753 [ FILTER_OP_LOAD_FIELD_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_SEQUENCE
,
754 [ FILTER_OP_LOAD_FIELD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_DOUBLE
,
756 [ FILTER_OP_UNARY_BIT_NOT
] = &&LABEL_FILTER_OP_UNARY_BIT_NOT
,
758 [ FILTER_OP_RETURN_S64
] = &&LABEL_FILTER_OP_RETURN_S64
,
760 #endif /* #ifndef INTERPRETER_USE_SWITCH */
764 OP(FILTER_OP_UNKNOWN
):
765 OP(FILTER_OP_LOAD_FIELD_REF
):
766 OP(FILTER_OP_GET_CONTEXT_REF
):
767 #ifdef INTERPRETER_USE_SWITCH
769 #endif /* INTERPRETER_USE_SWITCH */
770 printk(KERN_WARNING
"unknown bytecode op %u\n",
771 (unsigned int) *(filter_opcode_t
*) pc
);
775 OP(FILTER_OP_RETURN
):
776 OP(FILTER_OP_RETURN_S64
):
777 /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
778 retval
= !!estack_ax_v
;
788 printk(KERN_WARNING
"unsupported bytecode op %u\n",
789 (unsigned int) *(filter_opcode_t
*) pc
);
799 printk(KERN_WARNING
"unsupported non-specialized bytecode op %u\n",
800 (unsigned int) *(filter_opcode_t
*) pc
);
804 OP(FILTER_OP_EQ_STRING
):
808 res
= (stack_strcmp(stack
, top
, "==") == 0);
809 estack_pop(stack
, top
, ax
, bx
);
811 next_pc
+= sizeof(struct binary_op
);
814 OP(FILTER_OP_NE_STRING
):
818 res
= (stack_strcmp(stack
, top
, "!=") != 0);
819 estack_pop(stack
, top
, ax
, bx
);
821 next_pc
+= sizeof(struct binary_op
);
824 OP(FILTER_OP_GT_STRING
):
828 res
= (stack_strcmp(stack
, top
, ">") > 0);
829 estack_pop(stack
, top
, ax
, bx
);
831 next_pc
+= sizeof(struct binary_op
);
834 OP(FILTER_OP_LT_STRING
):
838 res
= (stack_strcmp(stack
, top
, "<") < 0);
839 estack_pop(stack
, top
, ax
, bx
);
841 next_pc
+= sizeof(struct binary_op
);
844 OP(FILTER_OP_GE_STRING
):
848 res
= (stack_strcmp(stack
, top
, ">=") >= 0);
849 estack_pop(stack
, top
, ax
, bx
);
851 next_pc
+= sizeof(struct binary_op
);
854 OP(FILTER_OP_LE_STRING
):
858 res
= (stack_strcmp(stack
, top
, "<=") <= 0);
859 estack_pop(stack
, top
, ax
, bx
);
861 next_pc
+= sizeof(struct binary_op
);
865 OP(FILTER_OP_EQ_STAR_GLOB_STRING
):
869 res
= (stack_star_glob_match(stack
, top
, "==") == 0);
870 estack_pop(stack
, top
, ax
, bx
);
872 next_pc
+= sizeof(struct binary_op
);
875 OP(FILTER_OP_NE_STAR_GLOB_STRING
):
879 res
= (stack_star_glob_match(stack
, top
, "!=") != 0);
880 estack_pop(stack
, top
, ax
, bx
);
882 next_pc
+= sizeof(struct binary_op
);
886 OP(FILTER_OP_EQ_S64
):
890 res
= (estack_bx_v
== estack_ax_v
);
891 estack_pop(stack
, top
, ax
, bx
);
893 next_pc
+= sizeof(struct binary_op
);
896 OP(FILTER_OP_NE_S64
):
900 res
= (estack_bx_v
!= estack_ax_v
);
901 estack_pop(stack
, top
, ax
, bx
);
903 next_pc
+= sizeof(struct binary_op
);
906 OP(FILTER_OP_GT_S64
):
910 res
= (estack_bx_v
> estack_ax_v
);
911 estack_pop(stack
, top
, ax
, bx
);
913 next_pc
+= sizeof(struct binary_op
);
916 OP(FILTER_OP_LT_S64
):
920 res
= (estack_bx_v
< estack_ax_v
);
921 estack_pop(stack
, top
, ax
, bx
);
923 next_pc
+= sizeof(struct binary_op
);
926 OP(FILTER_OP_GE_S64
):
930 res
= (estack_bx_v
>= estack_ax_v
);
931 estack_pop(stack
, top
, ax
, bx
);
933 next_pc
+= sizeof(struct binary_op
);
936 OP(FILTER_OP_LE_S64
):
940 res
= (estack_bx_v
<= estack_ax_v
);
941 estack_pop(stack
, top
, ax
, bx
);
943 next_pc
+= sizeof(struct binary_op
);
947 OP(FILTER_OP_EQ_DOUBLE
):
948 OP(FILTER_OP_NE_DOUBLE
):
949 OP(FILTER_OP_GT_DOUBLE
):
950 OP(FILTER_OP_LT_DOUBLE
):
951 OP(FILTER_OP_GE_DOUBLE
):
952 OP(FILTER_OP_LE_DOUBLE
):
958 /* Mixed S64-double binary comparators */
959 OP(FILTER_OP_EQ_DOUBLE_S64
):
960 OP(FILTER_OP_NE_DOUBLE_S64
):
961 OP(FILTER_OP_GT_DOUBLE_S64
):
962 OP(FILTER_OP_LT_DOUBLE_S64
):
963 OP(FILTER_OP_GE_DOUBLE_S64
):
964 OP(FILTER_OP_LE_DOUBLE_S64
):
965 OP(FILTER_OP_EQ_S64_DOUBLE
):
966 OP(FILTER_OP_NE_S64_DOUBLE
):
967 OP(FILTER_OP_GT_S64_DOUBLE
):
968 OP(FILTER_OP_LT_S64_DOUBLE
):
969 OP(FILTER_OP_GE_S64_DOUBLE
):
970 OP(FILTER_OP_LE_S64_DOUBLE
):
975 OP(FILTER_OP_BIT_RSHIFT
):
979 /* Catch undefined behavior. */
980 if (unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
984 res
= ((uint64_t) estack_bx_v
>> (uint32_t) estack_ax_v
);
985 estack_pop(stack
, top
, ax
, bx
);
987 next_pc
+= sizeof(struct binary_op
);
990 OP(FILTER_OP_BIT_LSHIFT
):
994 /* Catch undefined behavior. */
995 if (unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
999 res
= ((uint64_t) estack_bx_v
<< (uint32_t) estack_ax_v
);
1000 estack_pop(stack
, top
, ax
, bx
);
1002 next_pc
+= sizeof(struct binary_op
);
1005 OP(FILTER_OP_BIT_AND
):
1009 res
= ((uint64_t) estack_bx_v
& (uint64_t) estack_ax_v
);
1010 estack_pop(stack
, top
, ax
, bx
);
1012 next_pc
+= sizeof(struct binary_op
);
1015 OP(FILTER_OP_BIT_OR
):
1019 res
= ((uint64_t) estack_bx_v
| (uint64_t) estack_ax_v
);
1020 estack_pop(stack
, top
, ax
, bx
);
1022 next_pc
+= sizeof(struct binary_op
);
1025 OP(FILTER_OP_BIT_XOR
):
1029 res
= ((uint64_t) estack_bx_v
^ (uint64_t) estack_ax_v
);
1030 estack_pop(stack
, top
, ax
, bx
);
1032 next_pc
+= sizeof(struct binary_op
);
1037 OP(FILTER_OP_UNARY_PLUS
):
1038 OP(FILTER_OP_UNARY_MINUS
):
1039 OP(FILTER_OP_UNARY_NOT
):
1040 printk(KERN_WARNING
"unsupported non-specialized bytecode op %u\n",
1041 (unsigned int) *(filter_opcode_t
*) pc
);
1046 OP(FILTER_OP_UNARY_BIT_NOT
):
1048 estack_ax_v
= ~(uint64_t) estack_ax_v
;
1049 next_pc
+= sizeof(struct unary_op
);
1053 OP(FILTER_OP_UNARY_PLUS_S64
):
1055 next_pc
+= sizeof(struct unary_op
);
1058 OP(FILTER_OP_UNARY_MINUS_S64
):
1060 estack_ax_v
= -estack_ax_v
;
1061 next_pc
+= sizeof(struct unary_op
);
1064 OP(FILTER_OP_UNARY_PLUS_DOUBLE
):
1065 OP(FILTER_OP_UNARY_MINUS_DOUBLE
):
1070 OP(FILTER_OP_UNARY_NOT_S64
):
1072 estack_ax_v
= !estack_ax_v
;
1073 next_pc
+= sizeof(struct unary_op
);
1076 OP(FILTER_OP_UNARY_NOT_DOUBLE
):
1085 struct logical_op
*insn
= (struct logical_op
*) pc
;
1087 /* If AX is 0, skip and evaluate to 0 */
1088 if (unlikely(estack_ax_v
== 0)) {
1089 dbg_printk("Jumping to bytecode offset %u\n",
1090 (unsigned int) insn
->skip_offset
);
1091 next_pc
= start_pc
+ insn
->skip_offset
;
1093 /* Pop 1 when jump not taken */
1094 estack_pop(stack
, top
, ax
, bx
);
1095 next_pc
+= sizeof(struct logical_op
);
1101 struct logical_op
*insn
= (struct logical_op
*) pc
;
1103 /* If AX is nonzero, skip and evaluate to 1 */
1105 if (unlikely(estack_ax_v
!= 0)) {
1107 dbg_printk("Jumping to bytecode offset %u\n",
1108 (unsigned int) insn
->skip_offset
);
1109 next_pc
= start_pc
+ insn
->skip_offset
;
1111 /* Pop 1 when jump not taken */
1112 estack_pop(stack
, top
, ax
, bx
);
1113 next_pc
+= sizeof(struct logical_op
);
1119 /* load field ref */
1120 OP(FILTER_OP_LOAD_FIELD_REF_STRING
):
1122 struct load_op
*insn
= (struct load_op
*) pc
;
1123 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1125 dbg_printk("load field ref offset %u type string\n",
1127 estack_push(stack
, top
, ax
, bx
);
1128 estack_ax(stack
, top
)->u
.s
.str
=
1129 *(const char * const *) &filter_stack_data
[ref
->offset
];
1130 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1131 dbg_printk("Filter warning: loading a NULL string.\n");
1135 estack_ax(stack
, top
)->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
1136 estack_ax(stack
, top
)->u
.s
.literal_type
=
1137 ESTACK_STRING_LITERAL_TYPE_NONE
;
1138 estack_ax(stack
, top
)->u
.s
.user
= 0;
1139 dbg_printk("ref load string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
1140 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1144 OP(FILTER_OP_LOAD_FIELD_REF_SEQUENCE
):
1146 struct load_op
*insn
= (struct load_op
*) pc
;
1147 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1149 dbg_printk("load field ref offset %u type sequence\n",
1151 estack_push(stack
, top
, ax
, bx
);
1152 estack_ax(stack
, top
)->u
.s
.seq_len
=
1153 *(unsigned long *) &filter_stack_data
[ref
->offset
];
1154 estack_ax(stack
, top
)->u
.s
.str
=
1155 *(const char **) (&filter_stack_data
[ref
->offset
1156 + sizeof(unsigned long)]);
1157 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1158 dbg_printk("Filter warning: loading a NULL sequence.\n");
1162 estack_ax(stack
, top
)->u
.s
.literal_type
=
1163 ESTACK_STRING_LITERAL_TYPE_NONE
;
1164 estack_ax(stack
, top
)->u
.s
.user
= 0;
1165 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1169 OP(FILTER_OP_LOAD_FIELD_REF_S64
):
1171 struct load_op
*insn
= (struct load_op
*) pc
;
1172 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1174 dbg_printk("load field ref offset %u type s64\n",
1176 estack_push(stack
, top
, ax
, bx
);
1178 ((struct literal_numeric
*) &filter_stack_data
[ref
->offset
])->v
;
1179 dbg_printk("ref load s64 %lld\n",
1180 (long long) estack_ax_v
);
1181 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1185 OP(FILTER_OP_LOAD_FIELD_REF_DOUBLE
):
1191 /* load from immediate operand */
1192 OP(FILTER_OP_LOAD_STRING
):
1194 struct load_op
*insn
= (struct load_op
*) pc
;
1196 dbg_printk("load string %s\n", insn
->data
);
1197 estack_push(stack
, top
, ax
, bx
);
1198 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1199 estack_ax(stack
, top
)->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
1200 estack_ax(stack
, top
)->u
.s
.literal_type
=
1201 ESTACK_STRING_LITERAL_TYPE_PLAIN
;
1202 estack_ax(stack
, top
)->u
.s
.user
= 0;
1203 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1207 OP(FILTER_OP_LOAD_STAR_GLOB_STRING
):
1209 struct load_op
*insn
= (struct load_op
*) pc
;
1211 dbg_printk("load globbing pattern %s\n", insn
->data
);
1212 estack_push(stack
, top
, ax
, bx
);
1213 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1214 estack_ax(stack
, top
)->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
1215 estack_ax(stack
, top
)->u
.s
.literal_type
=
1216 ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
;
1217 estack_ax(stack
, top
)->u
.s
.user
= 0;
1218 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1222 OP(FILTER_OP_LOAD_S64
):
1224 struct load_op
*insn
= (struct load_op
*) pc
;
1226 estack_push(stack
, top
, ax
, bx
);
1227 estack_ax_v
= ((struct literal_numeric
*) insn
->data
)->v
;
1228 dbg_printk("load s64 %lld\n",
1229 (long long) estack_ax_v
);
1230 next_pc
+= sizeof(struct load_op
)
1231 + sizeof(struct literal_numeric
);
1235 OP(FILTER_OP_LOAD_DOUBLE
):
1242 OP(FILTER_OP_CAST_TO_S64
):
1243 printk(KERN_WARNING
"unsupported non-specialized bytecode op %u\n",
1244 (unsigned int) *(filter_opcode_t
*) pc
);
1248 OP(FILTER_OP_CAST_DOUBLE_TO_S64
):
1254 OP(FILTER_OP_CAST_NOP
):
1256 next_pc
+= sizeof(struct cast_op
);
1260 /* get context ref */
1261 OP(FILTER_OP_GET_CONTEXT_REF_STRING
):
1263 struct load_op
*insn
= (struct load_op
*) pc
;
1264 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1265 struct lttng_ctx_field
*ctx_field
;
1266 union lttng_ctx_value v
;
1268 dbg_printk("get context ref offset %u type string\n",
1270 ctx_field
= <tng_static_ctx
->fields
[ref
->offset
];
1271 ctx_field
->get_value(ctx_field
, lttng_probe_ctx
, &v
);
1272 estack_push(stack
, top
, ax
, bx
);
1273 estack_ax(stack
, top
)->u
.s
.str
= v
.str
;
1274 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1275 dbg_printk("Filter warning: loading a NULL string.\n");
1279 estack_ax(stack
, top
)->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
1280 estack_ax(stack
, top
)->u
.s
.literal_type
=
1281 ESTACK_STRING_LITERAL_TYPE_NONE
;
1282 estack_ax(stack
, top
)->u
.s
.user
= 0;
1283 dbg_printk("ref get context string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
1284 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1288 OP(FILTER_OP_GET_CONTEXT_REF_S64
):
1290 struct load_op
*insn
= (struct load_op
*) pc
;
1291 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1292 struct lttng_ctx_field
*ctx_field
;
1293 union lttng_ctx_value v
;
1295 dbg_printk("get context ref offset %u type s64\n",
1297 ctx_field
= <tng_static_ctx
->fields
[ref
->offset
];
1298 ctx_field
->get_value(ctx_field
, lttng_probe_ctx
, &v
);
1299 estack_push(stack
, top
, ax
, bx
);
1300 estack_ax_v
= v
.s64
;
1301 dbg_printk("ref get context s64 %lld\n",
1302 (long long) estack_ax_v
);
1303 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1307 OP(FILTER_OP_GET_CONTEXT_REF_DOUBLE
):
1313 /* load userspace field ref */
1314 OP(FILTER_OP_LOAD_FIELD_REF_USER_STRING
):
1316 struct load_op
*insn
= (struct load_op
*) pc
;
1317 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1319 dbg_printk("load field ref offset %u type user string\n",
1321 estack_push(stack
, top
, ax
, bx
);
1322 estack_ax(stack
, top
)->u
.s
.user_str
=
1323 *(const char * const *) &filter_stack_data
[ref
->offset
];
1324 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1325 dbg_printk("Filter warning: loading a NULL string.\n");
1329 estack_ax(stack
, top
)->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
1330 estack_ax(stack
, top
)->u
.s
.literal_type
=
1331 ESTACK_STRING_LITERAL_TYPE_NONE
;
1332 estack_ax(stack
, top
)->u
.s
.user
= 1;
1333 dbg_printk("ref load string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
1334 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1338 OP(FILTER_OP_LOAD_FIELD_REF_USER_SEQUENCE
):
1340 struct load_op
*insn
= (struct load_op
*) pc
;
1341 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1343 dbg_printk("load field ref offset %u type user sequence\n",
1345 estack_push(stack
, top
, ax
, bx
);
1346 estack_ax(stack
, top
)->u
.s
.seq_len
=
1347 *(unsigned long *) &filter_stack_data
[ref
->offset
];
1348 estack_ax(stack
, top
)->u
.s
.user_str
=
1349 *(const char **) (&filter_stack_data
[ref
->offset
1350 + sizeof(unsigned long)]);
1351 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1352 dbg_printk("Filter warning: loading a NULL sequence.\n");
1356 estack_ax(stack
, top
)->u
.s
.literal_type
=
1357 ESTACK_STRING_LITERAL_TYPE_NONE
;
1358 estack_ax(stack
, top
)->u
.s
.user
= 1;
1359 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1363 OP(FILTER_OP_GET_CONTEXT_ROOT
):
1365 dbg_printk("op get context root\n");
1366 estack_push(stack
, top
, ax
, bx
);
1367 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_CONTEXT
;
1368 /* "field" only needed for variants. */
1369 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
1370 next_pc
+= sizeof(struct load_op
);
1374 OP(FILTER_OP_GET_APP_CONTEXT_ROOT
):
1380 OP(FILTER_OP_GET_PAYLOAD_ROOT
):
1382 dbg_printk("op get app payload root\n");
1383 estack_push(stack
, top
, ax
, bx
);
1384 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_PAYLOAD
;
1385 estack_ax(stack
, top
)->u
.ptr
.ptr
= filter_stack_data
;
1386 /* "field" only needed for variants. */
1387 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
1388 next_pc
+= sizeof(struct load_op
);
1392 OP(FILTER_OP_GET_SYMBOL
):
1394 dbg_printk("op get symbol\n");
1395 switch (estack_ax(stack
, top
)->u
.ptr
.type
) {
1397 printk(KERN_WARNING
"Nested fields not implemented yet.\n");
1400 case LOAD_ROOT_CONTEXT
:
1401 case LOAD_ROOT_APP_CONTEXT
:
1402 case LOAD_ROOT_PAYLOAD
:
1404 * symbol lookup is performed by
1410 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_symbol
);
1414 OP(FILTER_OP_GET_SYMBOL_FIELD
):
1417 * Used for first variant encountered in a
1418 * traversal. Variants are not implemented yet.
1424 OP(FILTER_OP_GET_INDEX_U16
):
1426 struct load_op
*insn
= (struct load_op
*) pc
;
1427 struct get_index_u16
*index
= (struct get_index_u16
*) insn
->data
;
1429 dbg_printk("op get index u16\n");
1430 ret
= dynamic_get_index(lttng_probe_ctx
, bytecode
, index
->index
, estack_ax(stack
, top
));
1433 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
1434 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u16
);
1438 OP(FILTER_OP_GET_INDEX_U64
):
1440 struct load_op
*insn
= (struct load_op
*) pc
;
1441 struct get_index_u64
*index
= (struct get_index_u64
*) insn
->data
;
1443 dbg_printk("op get index u64\n");
1444 ret
= dynamic_get_index(lttng_probe_ctx
, bytecode
, index
->index
, estack_ax(stack
, top
));
1447 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
1448 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u64
);
1452 OP(FILTER_OP_LOAD_FIELD
):
1454 dbg_printk("op load field\n");
1455 ret
= dynamic_load_field(estack_ax(stack
, top
));
1458 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
1459 next_pc
+= sizeof(struct load_op
);
1463 OP(FILTER_OP_LOAD_FIELD_S8
):
1465 dbg_printk("op load field s8\n");
1467 estack_ax_v
= *(int8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1468 next_pc
+= sizeof(struct load_op
);
1471 OP(FILTER_OP_LOAD_FIELD_S16
):
1473 dbg_printk("op load field s16\n");
1475 estack_ax_v
= *(int16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1476 next_pc
+= sizeof(struct load_op
);
1479 OP(FILTER_OP_LOAD_FIELD_S32
):
1481 dbg_printk("op load field s32\n");
1483 estack_ax_v
= *(int32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1484 next_pc
+= sizeof(struct load_op
);
1487 OP(FILTER_OP_LOAD_FIELD_S64
):
1489 dbg_printk("op load field s64\n");
1491 estack_ax_v
= *(int64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1492 next_pc
+= sizeof(struct load_op
);
1495 OP(FILTER_OP_LOAD_FIELD_U8
):
1497 dbg_printk("op load field u8\n");
1499 estack_ax_v
= *(uint8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1500 next_pc
+= sizeof(struct load_op
);
1503 OP(FILTER_OP_LOAD_FIELD_U16
):
1505 dbg_printk("op load field u16\n");
1507 estack_ax_v
= *(uint16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1508 next_pc
+= sizeof(struct load_op
);
1511 OP(FILTER_OP_LOAD_FIELD_U32
):
1513 dbg_printk("op load field u32\n");
1515 estack_ax_v
= *(uint32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1516 next_pc
+= sizeof(struct load_op
);
1519 OP(FILTER_OP_LOAD_FIELD_U64
):
1521 dbg_printk("op load field u64\n");
1523 estack_ax_v
= *(uint64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1524 next_pc
+= sizeof(struct load_op
);
1527 OP(FILTER_OP_LOAD_FIELD_DOUBLE
):
1533 OP(FILTER_OP_LOAD_FIELD_STRING
):
1537 dbg_printk("op load field string\n");
1538 str
= (const char *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1539 estack_ax(stack
, top
)->u
.s
.str
= str
;
1540 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1541 dbg_printk("Filter warning: loading a NULL string.\n");
1545 estack_ax(stack
, top
)->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
1546 estack_ax(stack
, top
)->u
.s
.literal_type
=
1547 ESTACK_STRING_LITERAL_TYPE_NONE
;
1548 next_pc
+= sizeof(struct load_op
);
1552 OP(FILTER_OP_LOAD_FIELD_SEQUENCE
):
1556 dbg_printk("op load field string sequence\n");
1557 ptr
= estack_ax(stack
, top
)->u
.ptr
.ptr
;
1558 estack_ax(stack
, top
)->u
.s
.seq_len
= *(unsigned long *) ptr
;
1559 estack_ax(stack
, top
)->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
1560 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1561 dbg_printk("Filter warning: loading a NULL sequence.\n");
1565 estack_ax(stack
, top
)->u
.s
.literal_type
=
1566 ESTACK_STRING_LITERAL_TYPE_NONE
;
1567 next_pc
+= sizeof(struct load_op
);
1573 /* return 0 (discard) on error */