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 <wrapper/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(!lttng_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
.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
;
301 case atype_enum_nestable
:
303 const struct lttng_integer_type
*itype
=
304 &field
->type
.u
.enum_nestable
.container_type
->u
.integer
;
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
;
318 case atype_array_nestable
:
319 if (!lttng_is_bytewise_integer(field
->type
.u
.array_nestable
.elem_type
)) {
320 printk(KERN_WARNING
"Array nesting only supports integer types.\n");
323 if (field
->type
.u
.array_nestable
.elem_type
->u
.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
);
331 case atype_sequence_nestable
:
332 if (!lttng_is_bytewise_integer(field
->type
.u
.sequence_nestable
.elem_type
)) {
333 printk(KERN_WARNING
"Sequence nesting only supports integer types.\n");
336 if (field
->type
.u
.sequence_nestable
.elem_type
->u
.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
);
345 ptr
->object_type
= OBJECT_TYPE_STRING
;
346 ctx_field
->get_value(ctx_field
, lttng_probe_ctx
, &v
);
349 case atype_struct_nestable
:
350 printk(KERN_WARNING
"Structure type cannot be loaded.\n");
352 case atype_variant_nestable
:
353 printk(KERN_WARNING
"Variant type cannot be loaded.\n");
356 printk(KERN_WARNING
"Unknown type: %d", (int) field
->type
.atype
);
362 static int dynamic_get_index(struct lttng_probe_ctx
*lttng_probe_ctx
,
363 struct bytecode_runtime
*runtime
,
364 uint64_t index
, struct estack_entry
*stack_top
)
367 const struct filter_get_index_data
*gid
;
370 * Types nested within variants need to perform dynamic lookup
371 * based on the field descriptions. LTTng-UST does not implement
374 if (stack_top
->u
.ptr
.field
)
376 gid
= (const struct filter_get_index_data
*) &runtime
->data
[index
];
377 switch (stack_top
->u
.ptr
.type
) {
379 switch (stack_top
->u
.ptr
.object_type
) {
380 case OBJECT_TYPE_ARRAY
:
384 WARN_ON_ONCE(gid
->offset
>= gid
->array_len
);
385 /* Skip count (unsigned long) */
386 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
387 ptr
= ptr
+ gid
->offset
;
388 stack_top
->u
.ptr
.ptr
= ptr
;
389 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
390 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
391 /* field is only used for types nested within variants. */
392 stack_top
->u
.ptr
.field
= NULL
;
395 case OBJECT_TYPE_SEQUENCE
:
400 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
401 ptr_seq_len
= *(unsigned long *) stack_top
->u
.ptr
.ptr
;
402 if (gid
->offset
>= gid
->elem
.len
* ptr_seq_len
) {
406 ptr
= ptr
+ gid
->offset
;
407 stack_top
->u
.ptr
.ptr
= ptr
;
408 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
409 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
410 /* field is only used for types nested within variants. */
411 stack_top
->u
.ptr
.field
= NULL
;
414 case OBJECT_TYPE_STRUCT
:
415 printk(KERN_WARNING
"Nested structures are not supported yet.\n");
418 case OBJECT_TYPE_VARIANT
:
420 printk(KERN_WARNING
"Unexpected get index type %d",
421 (int) stack_top
->u
.ptr
.object_type
);
426 case LOAD_ROOT_CONTEXT
:
427 case LOAD_ROOT_APP_CONTEXT
: /* Fall-through */
429 ret
= context_get_index(lttng_probe_ctx
,
437 case LOAD_ROOT_PAYLOAD
:
438 stack_top
->u
.ptr
.ptr
+= gid
->offset
;
439 if (gid
->elem
.type
== OBJECT_TYPE_STRING
)
440 stack_top
->u
.ptr
.ptr
= *(const char * const *) stack_top
->u
.ptr
.ptr
;
441 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
442 stack_top
->u
.ptr
.type
= LOAD_OBJECT
;
443 /* field is only used for types nested within variants. */
444 stack_top
->u
.ptr
.field
= NULL
;
453 static int dynamic_load_field(struct estack_entry
*stack_top
)
457 switch (stack_top
->u
.ptr
.type
) {
460 case LOAD_ROOT_CONTEXT
:
461 case LOAD_ROOT_APP_CONTEXT
:
462 case LOAD_ROOT_PAYLOAD
:
464 dbg_printk("Filter warning: cannot load root, missing field name.\n");
468 switch (stack_top
->u
.ptr
.object_type
) {
470 dbg_printk("op load field s8\n");
471 stack_top
->u
.v
= *(int8_t *) stack_top
->u
.ptr
.ptr
;
473 case OBJECT_TYPE_S16
:
477 dbg_printk("op load field s16\n");
478 tmp
= *(int16_t *) stack_top
->u
.ptr
.ptr
;
479 if (stack_top
->u
.ptr
.rev_bo
)
481 stack_top
->u
.v
= tmp
;
484 case OBJECT_TYPE_S32
:
488 dbg_printk("op load field s32\n");
489 tmp
= *(int32_t *) stack_top
->u
.ptr
.ptr
;
490 if (stack_top
->u
.ptr
.rev_bo
)
492 stack_top
->u
.v
= tmp
;
495 case OBJECT_TYPE_S64
:
499 dbg_printk("op load field s64\n");
500 tmp
= *(int64_t *) stack_top
->u
.ptr
.ptr
;
501 if (stack_top
->u
.ptr
.rev_bo
)
503 stack_top
->u
.v
= tmp
;
507 dbg_printk("op load field u8\n");
508 stack_top
->u
.v
= *(uint8_t *) stack_top
->u
.ptr
.ptr
;
510 case OBJECT_TYPE_U16
:
514 dbg_printk("op load field s16\n");
515 tmp
= *(uint16_t *) stack_top
->u
.ptr
.ptr
;
516 if (stack_top
->u
.ptr
.rev_bo
)
518 stack_top
->u
.v
= tmp
;
521 case OBJECT_TYPE_U32
:
525 dbg_printk("op load field u32\n");
526 tmp
= *(uint32_t *) stack_top
->u
.ptr
.ptr
;
527 if (stack_top
->u
.ptr
.rev_bo
)
529 stack_top
->u
.v
= tmp
;
532 case OBJECT_TYPE_U64
:
536 dbg_printk("op load field u64\n");
537 tmp
= *(uint64_t *) stack_top
->u
.ptr
.ptr
;
538 if (stack_top
->u
.ptr
.rev_bo
)
540 stack_top
->u
.v
= tmp
;
543 case OBJECT_TYPE_STRING
:
547 dbg_printk("op load field string\n");
548 str
= (const char *) stack_top
->u
.ptr
.ptr
;
549 stack_top
->u
.s
.str
= str
;
550 if (unlikely(!stack_top
->u
.s
.str
)) {
551 dbg_printk("Filter warning: loading a NULL string.\n");
555 stack_top
->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
556 stack_top
->u
.s
.literal_type
=
557 ESTACK_STRING_LITERAL_TYPE_NONE
;
560 case OBJECT_TYPE_STRING_SEQUENCE
:
564 dbg_printk("op load field string sequence\n");
565 ptr
= stack_top
->u
.ptr
.ptr
;
566 stack_top
->u
.s
.seq_len
= *(unsigned long *) ptr
;
567 stack_top
->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
568 if (unlikely(!stack_top
->u
.s
.str
)) {
569 dbg_printk("Filter warning: loading a NULL sequence.\n");
573 stack_top
->u
.s
.literal_type
=
574 ESTACK_STRING_LITERAL_TYPE_NONE
;
577 case OBJECT_TYPE_DYNAMIC
:
579 * Dynamic types in context are looked up
580 * by context get index.
584 case OBJECT_TYPE_DOUBLE
:
587 case OBJECT_TYPE_SEQUENCE
:
588 case OBJECT_TYPE_ARRAY
:
589 case OBJECT_TYPE_STRUCT
:
590 case OBJECT_TYPE_VARIANT
:
591 printk(KERN_WARNING
"Sequences, arrays, struct and variant cannot be loaded (nested types).\n");
602 * Return 0 (discard), or raise the 0x1 flag (log event).
603 * Currently, other flags are kept for future extensions and have no
606 uint64_t lttng_filter_interpret_bytecode(void *filter_data
,
607 struct lttng_probe_ctx
*lttng_probe_ctx
,
608 const char *filter_stack_data
)
610 struct bytecode_runtime
*bytecode
= filter_data
;
611 void *pc
, *next_pc
, *start_pc
;
614 struct estack _stack
;
615 struct estack
*stack
= &_stack
;
616 register int64_t ax
= 0, bx
= 0;
617 register int top
= FILTER_STACK_EMPTY
;
618 #ifndef INTERPRETER_USE_SWITCH
619 static void *dispatch
[NR_FILTER_OPS
] = {
620 [ FILTER_OP_UNKNOWN
] = &&LABEL_FILTER_OP_UNKNOWN
,
622 [ FILTER_OP_RETURN
] = &&LABEL_FILTER_OP_RETURN
,
625 [ FILTER_OP_MUL
] = &&LABEL_FILTER_OP_MUL
,
626 [ FILTER_OP_DIV
] = &&LABEL_FILTER_OP_DIV
,
627 [ FILTER_OP_MOD
] = &&LABEL_FILTER_OP_MOD
,
628 [ FILTER_OP_PLUS
] = &&LABEL_FILTER_OP_PLUS
,
629 [ FILTER_OP_MINUS
] = &&LABEL_FILTER_OP_MINUS
,
630 [ FILTER_OP_BIT_RSHIFT
] = &&LABEL_FILTER_OP_BIT_RSHIFT
,
631 [ FILTER_OP_BIT_LSHIFT
] = &&LABEL_FILTER_OP_BIT_LSHIFT
,
632 [ FILTER_OP_BIT_AND
] = &&LABEL_FILTER_OP_BIT_AND
,
633 [ FILTER_OP_BIT_OR
] = &&LABEL_FILTER_OP_BIT_OR
,
634 [ FILTER_OP_BIT_XOR
] = &&LABEL_FILTER_OP_BIT_XOR
,
636 /* binary comparators */
637 [ FILTER_OP_EQ
] = &&LABEL_FILTER_OP_EQ
,
638 [ FILTER_OP_NE
] = &&LABEL_FILTER_OP_NE
,
639 [ FILTER_OP_GT
] = &&LABEL_FILTER_OP_GT
,
640 [ FILTER_OP_LT
] = &&LABEL_FILTER_OP_LT
,
641 [ FILTER_OP_GE
] = &&LABEL_FILTER_OP_GE
,
642 [ FILTER_OP_LE
] = &&LABEL_FILTER_OP_LE
,
644 /* string binary comparator */
645 [ FILTER_OP_EQ_STRING
] = &&LABEL_FILTER_OP_EQ_STRING
,
646 [ FILTER_OP_NE_STRING
] = &&LABEL_FILTER_OP_NE_STRING
,
647 [ FILTER_OP_GT_STRING
] = &&LABEL_FILTER_OP_GT_STRING
,
648 [ FILTER_OP_LT_STRING
] = &&LABEL_FILTER_OP_LT_STRING
,
649 [ FILTER_OP_GE_STRING
] = &&LABEL_FILTER_OP_GE_STRING
,
650 [ FILTER_OP_LE_STRING
] = &&LABEL_FILTER_OP_LE_STRING
,
652 /* globbing pattern binary comparator */
653 [ FILTER_OP_EQ_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_EQ_STAR_GLOB_STRING
,
654 [ FILTER_OP_NE_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_NE_STAR_GLOB_STRING
,
656 /* s64 binary comparator */
657 [ FILTER_OP_EQ_S64
] = &&LABEL_FILTER_OP_EQ_S64
,
658 [ FILTER_OP_NE_S64
] = &&LABEL_FILTER_OP_NE_S64
,
659 [ FILTER_OP_GT_S64
] = &&LABEL_FILTER_OP_GT_S64
,
660 [ FILTER_OP_LT_S64
] = &&LABEL_FILTER_OP_LT_S64
,
661 [ FILTER_OP_GE_S64
] = &&LABEL_FILTER_OP_GE_S64
,
662 [ FILTER_OP_LE_S64
] = &&LABEL_FILTER_OP_LE_S64
,
664 /* double binary comparator */
665 [ FILTER_OP_EQ_DOUBLE
] = &&LABEL_FILTER_OP_EQ_DOUBLE
,
666 [ FILTER_OP_NE_DOUBLE
] = &&LABEL_FILTER_OP_NE_DOUBLE
,
667 [ FILTER_OP_GT_DOUBLE
] = &&LABEL_FILTER_OP_GT_DOUBLE
,
668 [ FILTER_OP_LT_DOUBLE
] = &&LABEL_FILTER_OP_LT_DOUBLE
,
669 [ FILTER_OP_GE_DOUBLE
] = &&LABEL_FILTER_OP_GE_DOUBLE
,
670 [ FILTER_OP_LE_DOUBLE
] = &&LABEL_FILTER_OP_LE_DOUBLE
,
672 /* Mixed S64-double binary comparators */
673 [ FILTER_OP_EQ_DOUBLE_S64
] = &&LABEL_FILTER_OP_EQ_DOUBLE_S64
,
674 [ FILTER_OP_NE_DOUBLE_S64
] = &&LABEL_FILTER_OP_NE_DOUBLE_S64
,
675 [ FILTER_OP_GT_DOUBLE_S64
] = &&LABEL_FILTER_OP_GT_DOUBLE_S64
,
676 [ FILTER_OP_LT_DOUBLE_S64
] = &&LABEL_FILTER_OP_LT_DOUBLE_S64
,
677 [ FILTER_OP_GE_DOUBLE_S64
] = &&LABEL_FILTER_OP_GE_DOUBLE_S64
,
678 [ FILTER_OP_LE_DOUBLE_S64
] = &&LABEL_FILTER_OP_LE_DOUBLE_S64
,
680 [ FILTER_OP_EQ_S64_DOUBLE
] = &&LABEL_FILTER_OP_EQ_S64_DOUBLE
,
681 [ FILTER_OP_NE_S64_DOUBLE
] = &&LABEL_FILTER_OP_NE_S64_DOUBLE
,
682 [ FILTER_OP_GT_S64_DOUBLE
] = &&LABEL_FILTER_OP_GT_S64_DOUBLE
,
683 [ FILTER_OP_LT_S64_DOUBLE
] = &&LABEL_FILTER_OP_LT_S64_DOUBLE
,
684 [ FILTER_OP_GE_S64_DOUBLE
] = &&LABEL_FILTER_OP_GE_S64_DOUBLE
,
685 [ FILTER_OP_LE_S64_DOUBLE
] = &&LABEL_FILTER_OP_LE_S64_DOUBLE
,
688 [ FILTER_OP_UNARY_PLUS
] = &&LABEL_FILTER_OP_UNARY_PLUS
,
689 [ FILTER_OP_UNARY_MINUS
] = &&LABEL_FILTER_OP_UNARY_MINUS
,
690 [ FILTER_OP_UNARY_NOT
] = &&LABEL_FILTER_OP_UNARY_NOT
,
691 [ FILTER_OP_UNARY_PLUS_S64
] = &&LABEL_FILTER_OP_UNARY_PLUS_S64
,
692 [ FILTER_OP_UNARY_MINUS_S64
] = &&LABEL_FILTER_OP_UNARY_MINUS_S64
,
693 [ FILTER_OP_UNARY_NOT_S64
] = &&LABEL_FILTER_OP_UNARY_NOT_S64
,
694 [ FILTER_OP_UNARY_PLUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_PLUS_DOUBLE
,
695 [ FILTER_OP_UNARY_MINUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_MINUS_DOUBLE
,
696 [ FILTER_OP_UNARY_NOT_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_NOT_DOUBLE
,
699 [ FILTER_OP_AND
] = &&LABEL_FILTER_OP_AND
,
700 [ FILTER_OP_OR
] = &&LABEL_FILTER_OP_OR
,
703 [ FILTER_OP_LOAD_FIELD_REF
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF
,
704 [ FILTER_OP_LOAD_FIELD_REF_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_STRING
,
705 [ FILTER_OP_LOAD_FIELD_REF_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_SEQUENCE
,
706 [ FILTER_OP_LOAD_FIELD_REF_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_S64
,
707 [ FILTER_OP_LOAD_FIELD_REF_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_DOUBLE
,
709 /* load from immediate operand */
710 [ FILTER_OP_LOAD_STRING
] = &&LABEL_FILTER_OP_LOAD_STRING
,
711 [ FILTER_OP_LOAD_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_LOAD_STAR_GLOB_STRING
,
712 [ FILTER_OP_LOAD_S64
] = &&LABEL_FILTER_OP_LOAD_S64
,
713 [ FILTER_OP_LOAD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_DOUBLE
,
716 [ FILTER_OP_CAST_TO_S64
] = &&LABEL_FILTER_OP_CAST_TO_S64
,
717 [ FILTER_OP_CAST_DOUBLE_TO_S64
] = &&LABEL_FILTER_OP_CAST_DOUBLE_TO_S64
,
718 [ FILTER_OP_CAST_NOP
] = &&LABEL_FILTER_OP_CAST_NOP
,
720 /* get context ref */
721 [ FILTER_OP_GET_CONTEXT_REF
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF
,
722 [ FILTER_OP_GET_CONTEXT_REF_STRING
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_STRING
,
723 [ FILTER_OP_GET_CONTEXT_REF_S64
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_S64
,
724 [ FILTER_OP_GET_CONTEXT_REF_DOUBLE
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_DOUBLE
,
726 /* load userspace field ref */
727 [ FILTER_OP_LOAD_FIELD_REF_USER_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_USER_STRING
,
728 [ FILTER_OP_LOAD_FIELD_REF_USER_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_USER_SEQUENCE
,
730 /* Instructions for recursive traversal through composed types. */
731 [ FILTER_OP_GET_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_CONTEXT_ROOT
,
732 [ FILTER_OP_GET_APP_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_APP_CONTEXT_ROOT
,
733 [ FILTER_OP_GET_PAYLOAD_ROOT
] = &&LABEL_FILTER_OP_GET_PAYLOAD_ROOT
,
735 [ FILTER_OP_GET_SYMBOL
] = &&LABEL_FILTER_OP_GET_SYMBOL
,
736 [ FILTER_OP_GET_SYMBOL_FIELD
] = &&LABEL_FILTER_OP_GET_SYMBOL_FIELD
,
737 [ FILTER_OP_GET_INDEX_U16
] = &&LABEL_FILTER_OP_GET_INDEX_U16
,
738 [ FILTER_OP_GET_INDEX_U64
] = &&LABEL_FILTER_OP_GET_INDEX_U64
,
740 [ FILTER_OP_LOAD_FIELD
] = &&LABEL_FILTER_OP_LOAD_FIELD
,
741 [ FILTER_OP_LOAD_FIELD_S8
] = &&LABEL_FILTER_OP_LOAD_FIELD_S8
,
742 [ FILTER_OP_LOAD_FIELD_S16
] = &&LABEL_FILTER_OP_LOAD_FIELD_S16
,
743 [ FILTER_OP_LOAD_FIELD_S32
] = &&LABEL_FILTER_OP_LOAD_FIELD_S32
,
744 [ FILTER_OP_LOAD_FIELD_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_S64
,
745 [ FILTER_OP_LOAD_FIELD_U8
] = &&LABEL_FILTER_OP_LOAD_FIELD_U8
,
746 [ FILTER_OP_LOAD_FIELD_U16
] = &&LABEL_FILTER_OP_LOAD_FIELD_U16
,
747 [ FILTER_OP_LOAD_FIELD_U32
] = &&LABEL_FILTER_OP_LOAD_FIELD_U32
,
748 [ FILTER_OP_LOAD_FIELD_U64
] = &&LABEL_FILTER_OP_LOAD_FIELD_U64
,
749 [ FILTER_OP_LOAD_FIELD_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_STRING
,
750 [ FILTER_OP_LOAD_FIELD_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_SEQUENCE
,
751 [ FILTER_OP_LOAD_FIELD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_DOUBLE
,
753 [ FILTER_OP_UNARY_BIT_NOT
] = &&LABEL_FILTER_OP_UNARY_BIT_NOT
,
755 [ FILTER_OP_RETURN_S64
] = &&LABEL_FILTER_OP_RETURN_S64
,
757 #endif /* #ifndef INTERPRETER_USE_SWITCH */
761 OP(FILTER_OP_UNKNOWN
):
762 OP(FILTER_OP_LOAD_FIELD_REF
):
763 OP(FILTER_OP_GET_CONTEXT_REF
):
764 #ifdef INTERPRETER_USE_SWITCH
766 #endif /* INTERPRETER_USE_SWITCH */
767 printk(KERN_WARNING
"unknown bytecode op %u\n",
768 (unsigned int) *(filter_opcode_t
*) pc
);
772 OP(FILTER_OP_RETURN
):
773 OP(FILTER_OP_RETURN_S64
):
774 /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
775 retval
= !!estack_ax_v
;
785 printk(KERN_WARNING
"unsupported bytecode op %u\n",
786 (unsigned int) *(filter_opcode_t
*) pc
);
796 printk(KERN_WARNING
"unsupported non-specialized bytecode op %u\n",
797 (unsigned int) *(filter_opcode_t
*) pc
);
801 OP(FILTER_OP_EQ_STRING
):
805 res
= (stack_strcmp(stack
, top
, "==") == 0);
806 estack_pop(stack
, top
, ax
, bx
);
808 next_pc
+= sizeof(struct binary_op
);
811 OP(FILTER_OP_NE_STRING
):
815 res
= (stack_strcmp(stack
, top
, "!=") != 0);
816 estack_pop(stack
, top
, ax
, bx
);
818 next_pc
+= sizeof(struct binary_op
);
821 OP(FILTER_OP_GT_STRING
):
825 res
= (stack_strcmp(stack
, top
, ">") > 0);
826 estack_pop(stack
, top
, ax
, bx
);
828 next_pc
+= sizeof(struct binary_op
);
831 OP(FILTER_OP_LT_STRING
):
835 res
= (stack_strcmp(stack
, top
, "<") < 0);
836 estack_pop(stack
, top
, ax
, bx
);
838 next_pc
+= sizeof(struct binary_op
);
841 OP(FILTER_OP_GE_STRING
):
845 res
= (stack_strcmp(stack
, top
, ">=") >= 0);
846 estack_pop(stack
, top
, ax
, bx
);
848 next_pc
+= sizeof(struct binary_op
);
851 OP(FILTER_OP_LE_STRING
):
855 res
= (stack_strcmp(stack
, top
, "<=") <= 0);
856 estack_pop(stack
, top
, ax
, bx
);
858 next_pc
+= sizeof(struct binary_op
);
862 OP(FILTER_OP_EQ_STAR_GLOB_STRING
):
866 res
= (stack_star_glob_match(stack
, top
, "==") == 0);
867 estack_pop(stack
, top
, ax
, bx
);
869 next_pc
+= sizeof(struct binary_op
);
872 OP(FILTER_OP_NE_STAR_GLOB_STRING
):
876 res
= (stack_star_glob_match(stack
, top
, "!=") != 0);
877 estack_pop(stack
, top
, ax
, bx
);
879 next_pc
+= sizeof(struct binary_op
);
883 OP(FILTER_OP_EQ_S64
):
887 res
= (estack_bx_v
== estack_ax_v
);
888 estack_pop(stack
, top
, ax
, bx
);
890 next_pc
+= sizeof(struct binary_op
);
893 OP(FILTER_OP_NE_S64
):
897 res
= (estack_bx_v
!= estack_ax_v
);
898 estack_pop(stack
, top
, ax
, bx
);
900 next_pc
+= sizeof(struct binary_op
);
903 OP(FILTER_OP_GT_S64
):
907 res
= (estack_bx_v
> estack_ax_v
);
908 estack_pop(stack
, top
, ax
, bx
);
910 next_pc
+= sizeof(struct binary_op
);
913 OP(FILTER_OP_LT_S64
):
917 res
= (estack_bx_v
< estack_ax_v
);
918 estack_pop(stack
, top
, ax
, bx
);
920 next_pc
+= sizeof(struct binary_op
);
923 OP(FILTER_OP_GE_S64
):
927 res
= (estack_bx_v
>= estack_ax_v
);
928 estack_pop(stack
, top
, ax
, bx
);
930 next_pc
+= sizeof(struct binary_op
);
933 OP(FILTER_OP_LE_S64
):
937 res
= (estack_bx_v
<= estack_ax_v
);
938 estack_pop(stack
, top
, ax
, bx
);
940 next_pc
+= sizeof(struct binary_op
);
944 OP(FILTER_OP_EQ_DOUBLE
):
945 OP(FILTER_OP_NE_DOUBLE
):
946 OP(FILTER_OP_GT_DOUBLE
):
947 OP(FILTER_OP_LT_DOUBLE
):
948 OP(FILTER_OP_GE_DOUBLE
):
949 OP(FILTER_OP_LE_DOUBLE
):
955 /* Mixed S64-double binary comparators */
956 OP(FILTER_OP_EQ_DOUBLE_S64
):
957 OP(FILTER_OP_NE_DOUBLE_S64
):
958 OP(FILTER_OP_GT_DOUBLE_S64
):
959 OP(FILTER_OP_LT_DOUBLE_S64
):
960 OP(FILTER_OP_GE_DOUBLE_S64
):
961 OP(FILTER_OP_LE_DOUBLE_S64
):
962 OP(FILTER_OP_EQ_S64_DOUBLE
):
963 OP(FILTER_OP_NE_S64_DOUBLE
):
964 OP(FILTER_OP_GT_S64_DOUBLE
):
965 OP(FILTER_OP_LT_S64_DOUBLE
):
966 OP(FILTER_OP_GE_S64_DOUBLE
):
967 OP(FILTER_OP_LE_S64_DOUBLE
):
972 OP(FILTER_OP_BIT_RSHIFT
):
976 /* Catch undefined behavior. */
977 if (unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
981 res
= ((uint64_t) estack_bx_v
>> (uint32_t) estack_ax_v
);
982 estack_pop(stack
, top
, ax
, bx
);
984 next_pc
+= sizeof(struct binary_op
);
987 OP(FILTER_OP_BIT_LSHIFT
):
991 /* Catch undefined behavior. */
992 if (unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
996 res
= ((uint64_t) estack_bx_v
<< (uint32_t) estack_ax_v
);
997 estack_pop(stack
, top
, ax
, bx
);
999 next_pc
+= sizeof(struct binary_op
);
1002 OP(FILTER_OP_BIT_AND
):
1006 res
= ((uint64_t) estack_bx_v
& (uint64_t) estack_ax_v
);
1007 estack_pop(stack
, top
, ax
, bx
);
1009 next_pc
+= sizeof(struct binary_op
);
1012 OP(FILTER_OP_BIT_OR
):
1016 res
= ((uint64_t) estack_bx_v
| (uint64_t) estack_ax_v
);
1017 estack_pop(stack
, top
, ax
, bx
);
1019 next_pc
+= sizeof(struct binary_op
);
1022 OP(FILTER_OP_BIT_XOR
):
1026 res
= ((uint64_t) estack_bx_v
^ (uint64_t) estack_ax_v
);
1027 estack_pop(stack
, top
, ax
, bx
);
1029 next_pc
+= sizeof(struct binary_op
);
1034 OP(FILTER_OP_UNARY_PLUS
):
1035 OP(FILTER_OP_UNARY_MINUS
):
1036 OP(FILTER_OP_UNARY_NOT
):
1037 printk(KERN_WARNING
"unsupported non-specialized bytecode op %u\n",
1038 (unsigned int) *(filter_opcode_t
*) pc
);
1043 OP(FILTER_OP_UNARY_BIT_NOT
):
1045 estack_ax_v
= ~(uint64_t) estack_ax_v
;
1046 next_pc
+= sizeof(struct unary_op
);
1050 OP(FILTER_OP_UNARY_PLUS_S64
):
1052 next_pc
+= sizeof(struct unary_op
);
1055 OP(FILTER_OP_UNARY_MINUS_S64
):
1057 estack_ax_v
= -estack_ax_v
;
1058 next_pc
+= sizeof(struct unary_op
);
1061 OP(FILTER_OP_UNARY_PLUS_DOUBLE
):
1062 OP(FILTER_OP_UNARY_MINUS_DOUBLE
):
1067 OP(FILTER_OP_UNARY_NOT_S64
):
1069 estack_ax_v
= !estack_ax_v
;
1070 next_pc
+= sizeof(struct unary_op
);
1073 OP(FILTER_OP_UNARY_NOT_DOUBLE
):
1082 struct logical_op
*insn
= (struct logical_op
*) pc
;
1084 /* If AX is 0, skip and evaluate to 0 */
1085 if (unlikely(estack_ax_v
== 0)) {
1086 dbg_printk("Jumping to bytecode offset %u\n",
1087 (unsigned int) insn
->skip_offset
);
1088 next_pc
= start_pc
+ insn
->skip_offset
;
1090 /* Pop 1 when jump not taken */
1091 estack_pop(stack
, top
, ax
, bx
);
1092 next_pc
+= sizeof(struct logical_op
);
1098 struct logical_op
*insn
= (struct logical_op
*) pc
;
1100 /* If AX is nonzero, skip and evaluate to 1 */
1102 if (unlikely(estack_ax_v
!= 0)) {
1104 dbg_printk("Jumping to bytecode offset %u\n",
1105 (unsigned int) insn
->skip_offset
);
1106 next_pc
= start_pc
+ insn
->skip_offset
;
1108 /* Pop 1 when jump not taken */
1109 estack_pop(stack
, top
, ax
, bx
);
1110 next_pc
+= sizeof(struct logical_op
);
1116 /* load field ref */
1117 OP(FILTER_OP_LOAD_FIELD_REF_STRING
):
1119 struct load_op
*insn
= (struct load_op
*) pc
;
1120 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1122 dbg_printk("load field ref offset %u type string\n",
1124 estack_push(stack
, top
, ax
, bx
);
1125 estack_ax(stack
, top
)->u
.s
.str
=
1126 *(const char * const *) &filter_stack_data
[ref
->offset
];
1127 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1128 dbg_printk("Filter warning: loading a NULL string.\n");
1132 estack_ax(stack
, top
)->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
1133 estack_ax(stack
, top
)->u
.s
.literal_type
=
1134 ESTACK_STRING_LITERAL_TYPE_NONE
;
1135 estack_ax(stack
, top
)->u
.s
.user
= 0;
1136 dbg_printk("ref load string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
1137 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1141 OP(FILTER_OP_LOAD_FIELD_REF_SEQUENCE
):
1143 struct load_op
*insn
= (struct load_op
*) pc
;
1144 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1146 dbg_printk("load field ref offset %u type sequence\n",
1148 estack_push(stack
, top
, ax
, bx
);
1149 estack_ax(stack
, top
)->u
.s
.seq_len
=
1150 *(unsigned long *) &filter_stack_data
[ref
->offset
];
1151 estack_ax(stack
, top
)->u
.s
.str
=
1152 *(const char **) (&filter_stack_data
[ref
->offset
1153 + sizeof(unsigned long)]);
1154 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1155 dbg_printk("Filter warning: loading a NULL sequence.\n");
1159 estack_ax(stack
, top
)->u
.s
.literal_type
=
1160 ESTACK_STRING_LITERAL_TYPE_NONE
;
1161 estack_ax(stack
, top
)->u
.s
.user
= 0;
1162 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1166 OP(FILTER_OP_LOAD_FIELD_REF_S64
):
1168 struct load_op
*insn
= (struct load_op
*) pc
;
1169 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1171 dbg_printk("load field ref offset %u type s64\n",
1173 estack_push(stack
, top
, ax
, bx
);
1175 ((struct literal_numeric
*) &filter_stack_data
[ref
->offset
])->v
;
1176 dbg_printk("ref load s64 %lld\n",
1177 (long long) estack_ax_v
);
1178 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1182 OP(FILTER_OP_LOAD_FIELD_REF_DOUBLE
):
1188 /* load from immediate operand */
1189 OP(FILTER_OP_LOAD_STRING
):
1191 struct load_op
*insn
= (struct load_op
*) pc
;
1193 dbg_printk("load string %s\n", insn
->data
);
1194 estack_push(stack
, top
, ax
, bx
);
1195 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1196 estack_ax(stack
, top
)->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
1197 estack_ax(stack
, top
)->u
.s
.literal_type
=
1198 ESTACK_STRING_LITERAL_TYPE_PLAIN
;
1199 estack_ax(stack
, top
)->u
.s
.user
= 0;
1200 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1204 OP(FILTER_OP_LOAD_STAR_GLOB_STRING
):
1206 struct load_op
*insn
= (struct load_op
*) pc
;
1208 dbg_printk("load globbing pattern %s\n", insn
->data
);
1209 estack_push(stack
, top
, ax
, bx
);
1210 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1211 estack_ax(stack
, top
)->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
1212 estack_ax(stack
, top
)->u
.s
.literal_type
=
1213 ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
;
1214 estack_ax(stack
, top
)->u
.s
.user
= 0;
1215 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1219 OP(FILTER_OP_LOAD_S64
):
1221 struct load_op
*insn
= (struct load_op
*) pc
;
1223 estack_push(stack
, top
, ax
, bx
);
1224 estack_ax_v
= ((struct literal_numeric
*) insn
->data
)->v
;
1225 dbg_printk("load s64 %lld\n",
1226 (long long) estack_ax_v
);
1227 next_pc
+= sizeof(struct load_op
)
1228 + sizeof(struct literal_numeric
);
1232 OP(FILTER_OP_LOAD_DOUBLE
):
1239 OP(FILTER_OP_CAST_TO_S64
):
1240 printk(KERN_WARNING
"unsupported non-specialized bytecode op %u\n",
1241 (unsigned int) *(filter_opcode_t
*) pc
);
1245 OP(FILTER_OP_CAST_DOUBLE_TO_S64
):
1251 OP(FILTER_OP_CAST_NOP
):
1253 next_pc
+= sizeof(struct cast_op
);
1257 /* get context ref */
1258 OP(FILTER_OP_GET_CONTEXT_REF_STRING
):
1260 struct load_op
*insn
= (struct load_op
*) pc
;
1261 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1262 struct lttng_ctx_field
*ctx_field
;
1263 union lttng_ctx_value v
;
1265 dbg_printk("get context ref offset %u type string\n",
1267 ctx_field
= <tng_static_ctx
->fields
[ref
->offset
];
1268 ctx_field
->get_value(ctx_field
, lttng_probe_ctx
, &v
);
1269 estack_push(stack
, top
, ax
, bx
);
1270 estack_ax(stack
, top
)->u
.s
.str
= v
.str
;
1271 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1272 dbg_printk("Filter warning: loading a NULL string.\n");
1276 estack_ax(stack
, top
)->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
1277 estack_ax(stack
, top
)->u
.s
.literal_type
=
1278 ESTACK_STRING_LITERAL_TYPE_NONE
;
1279 estack_ax(stack
, top
)->u
.s
.user
= 0;
1280 dbg_printk("ref get context string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
1281 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1285 OP(FILTER_OP_GET_CONTEXT_REF_S64
):
1287 struct load_op
*insn
= (struct load_op
*) pc
;
1288 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1289 struct lttng_ctx_field
*ctx_field
;
1290 union lttng_ctx_value v
;
1292 dbg_printk("get context ref offset %u type s64\n",
1294 ctx_field
= <tng_static_ctx
->fields
[ref
->offset
];
1295 ctx_field
->get_value(ctx_field
, lttng_probe_ctx
, &v
);
1296 estack_push(stack
, top
, ax
, bx
);
1297 estack_ax_v
= v
.s64
;
1298 dbg_printk("ref get context s64 %lld\n",
1299 (long long) estack_ax_v
);
1300 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1304 OP(FILTER_OP_GET_CONTEXT_REF_DOUBLE
):
1310 /* load userspace field ref */
1311 OP(FILTER_OP_LOAD_FIELD_REF_USER_STRING
):
1313 struct load_op
*insn
= (struct load_op
*) pc
;
1314 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1316 dbg_printk("load field ref offset %u type user string\n",
1318 estack_push(stack
, top
, ax
, bx
);
1319 estack_ax(stack
, top
)->u
.s
.user_str
=
1320 *(const char * const *) &filter_stack_data
[ref
->offset
];
1321 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1322 dbg_printk("Filter warning: loading a NULL string.\n");
1326 estack_ax(stack
, top
)->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
1327 estack_ax(stack
, top
)->u
.s
.literal_type
=
1328 ESTACK_STRING_LITERAL_TYPE_NONE
;
1329 estack_ax(stack
, top
)->u
.s
.user
= 1;
1330 dbg_printk("ref load string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
1331 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1335 OP(FILTER_OP_LOAD_FIELD_REF_USER_SEQUENCE
):
1337 struct load_op
*insn
= (struct load_op
*) pc
;
1338 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1340 dbg_printk("load field ref offset %u type user sequence\n",
1342 estack_push(stack
, top
, ax
, bx
);
1343 estack_ax(stack
, top
)->u
.s
.seq_len
=
1344 *(unsigned long *) &filter_stack_data
[ref
->offset
];
1345 estack_ax(stack
, top
)->u
.s
.user_str
=
1346 *(const char **) (&filter_stack_data
[ref
->offset
1347 + sizeof(unsigned long)]);
1348 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1349 dbg_printk("Filter warning: loading a NULL sequence.\n");
1353 estack_ax(stack
, top
)->u
.s
.literal_type
=
1354 ESTACK_STRING_LITERAL_TYPE_NONE
;
1355 estack_ax(stack
, top
)->u
.s
.user
= 1;
1356 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1360 OP(FILTER_OP_GET_CONTEXT_ROOT
):
1362 dbg_printk("op get context root\n");
1363 estack_push(stack
, top
, ax
, bx
);
1364 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_CONTEXT
;
1365 /* "field" only needed for variants. */
1366 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
1367 next_pc
+= sizeof(struct load_op
);
1371 OP(FILTER_OP_GET_APP_CONTEXT_ROOT
):
1377 OP(FILTER_OP_GET_PAYLOAD_ROOT
):
1379 dbg_printk("op get app payload root\n");
1380 estack_push(stack
, top
, ax
, bx
);
1381 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_PAYLOAD
;
1382 estack_ax(stack
, top
)->u
.ptr
.ptr
= filter_stack_data
;
1383 /* "field" only needed for variants. */
1384 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
1385 next_pc
+= sizeof(struct load_op
);
1389 OP(FILTER_OP_GET_SYMBOL
):
1391 dbg_printk("op get symbol\n");
1392 switch (estack_ax(stack
, top
)->u
.ptr
.type
) {
1394 printk(KERN_WARNING
"Nested fields not implemented yet.\n");
1397 case LOAD_ROOT_CONTEXT
:
1398 case LOAD_ROOT_APP_CONTEXT
:
1399 case LOAD_ROOT_PAYLOAD
:
1401 * symbol lookup is performed by
1407 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_symbol
);
1411 OP(FILTER_OP_GET_SYMBOL_FIELD
):
1414 * Used for first variant encountered in a
1415 * traversal. Variants are not implemented yet.
1421 OP(FILTER_OP_GET_INDEX_U16
):
1423 struct load_op
*insn
= (struct load_op
*) pc
;
1424 struct get_index_u16
*index
= (struct get_index_u16
*) insn
->data
;
1426 dbg_printk("op get index u16\n");
1427 ret
= dynamic_get_index(lttng_probe_ctx
, bytecode
, index
->index
, estack_ax(stack
, top
));
1430 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
1431 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u16
);
1435 OP(FILTER_OP_GET_INDEX_U64
):
1437 struct load_op
*insn
= (struct load_op
*) pc
;
1438 struct get_index_u64
*index
= (struct get_index_u64
*) insn
->data
;
1440 dbg_printk("op get index u64\n");
1441 ret
= dynamic_get_index(lttng_probe_ctx
, bytecode
, index
->index
, estack_ax(stack
, top
));
1444 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
1445 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u64
);
1449 OP(FILTER_OP_LOAD_FIELD
):
1451 dbg_printk("op load field\n");
1452 ret
= dynamic_load_field(estack_ax(stack
, top
));
1455 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
1456 next_pc
+= sizeof(struct load_op
);
1460 OP(FILTER_OP_LOAD_FIELD_S8
):
1462 dbg_printk("op load field s8\n");
1464 estack_ax_v
= *(int8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1465 next_pc
+= sizeof(struct load_op
);
1468 OP(FILTER_OP_LOAD_FIELD_S16
):
1470 dbg_printk("op load field s16\n");
1472 estack_ax_v
= *(int16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1473 next_pc
+= sizeof(struct load_op
);
1476 OP(FILTER_OP_LOAD_FIELD_S32
):
1478 dbg_printk("op load field s32\n");
1480 estack_ax_v
= *(int32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1481 next_pc
+= sizeof(struct load_op
);
1484 OP(FILTER_OP_LOAD_FIELD_S64
):
1486 dbg_printk("op load field s64\n");
1488 estack_ax_v
= *(int64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1489 next_pc
+= sizeof(struct load_op
);
1492 OP(FILTER_OP_LOAD_FIELD_U8
):
1494 dbg_printk("op load field u8\n");
1496 estack_ax_v
= *(uint8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1497 next_pc
+= sizeof(struct load_op
);
1500 OP(FILTER_OP_LOAD_FIELD_U16
):
1502 dbg_printk("op load field u16\n");
1504 estack_ax_v
= *(uint16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1505 next_pc
+= sizeof(struct load_op
);
1508 OP(FILTER_OP_LOAD_FIELD_U32
):
1510 dbg_printk("op load field u32\n");
1512 estack_ax_v
= *(uint32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1513 next_pc
+= sizeof(struct load_op
);
1516 OP(FILTER_OP_LOAD_FIELD_U64
):
1518 dbg_printk("op load field u64\n");
1520 estack_ax_v
= *(uint64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1521 next_pc
+= sizeof(struct load_op
);
1524 OP(FILTER_OP_LOAD_FIELD_DOUBLE
):
1530 OP(FILTER_OP_LOAD_FIELD_STRING
):
1534 dbg_printk("op load field string\n");
1535 str
= (const char *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1536 estack_ax(stack
, top
)->u
.s
.str
= str
;
1537 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1538 dbg_printk("Filter warning: loading a NULL string.\n");
1542 estack_ax(stack
, top
)->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
1543 estack_ax(stack
, top
)->u
.s
.literal_type
=
1544 ESTACK_STRING_LITERAL_TYPE_NONE
;
1545 next_pc
+= sizeof(struct load_op
);
1549 OP(FILTER_OP_LOAD_FIELD_SEQUENCE
):
1553 dbg_printk("op load field string sequence\n");
1554 ptr
= estack_ax(stack
, top
)->u
.ptr
.ptr
;
1555 estack_ax(stack
, top
)->u
.s
.seq_len
= *(unsigned long *) ptr
;
1556 estack_ax(stack
, top
)->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
1557 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1558 dbg_printk("Filter warning: loading a NULL sequence.\n");
1562 estack_ax(stack
, top
)->u
.s
.literal_type
=
1563 ESTACK_STRING_LITERAL_TYPE_NONE
;
1564 next_pc
+= sizeof(struct load_op
);
1570 /* return 0 (discard) on error */