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;
85 struct estack_entry
*pattern_reg
;
86 struct estack_entry
*candidate_reg
;
88 /* Disable the page fault handler when reading from userspace. */
89 if (estack_bx(stack
, top
)->u
.s
.user
90 || estack_ax(stack
, top
)->u
.s
.user
) {
95 /* Find out which side is the pattern vs. the candidate. */
96 if (estack_ax(stack
, top
)->u
.s
.literal_type
== ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
) {
97 pattern_reg
= estack_ax(stack
, top
);
98 candidate_reg
= estack_bx(stack
, top
);
100 pattern_reg
= estack_bx(stack
, top
);
101 candidate_reg
= estack_ax(stack
, top
);
104 /* Perform the match operation. */
105 result
= !strutils_star_glob_match_char_cb(get_char_at_cb
,
106 pattern_reg
, get_char_at_cb
, candidate_reg
);
114 int stack_strcmp(struct estack
*stack
, int top
, const char *cmp_type
)
116 size_t offset_bx
= 0, offset_ax
= 0;
117 int diff
, has_user
= 0;
119 if (estack_bx(stack
, top
)->u
.s
.user
120 || estack_ax(stack
, top
)->u
.s
.user
) {
128 char char_bx
, char_ax
;
130 char_bx
= get_char(estack_bx(stack
, top
), offset_bx
);
131 char_ax
= get_char(estack_ax(stack
, top
), offset_ax
);
133 if (unlikely(char_bx
== '\0')) {
134 if (char_ax
== '\0') {
138 if (estack_ax(stack
, top
)->u
.s
.literal_type
==
139 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
140 ret
= parse_char(estack_ax(stack
, top
),
141 &char_ax
, &offset_ax
);
151 if (unlikely(char_ax
== '\0')) {
152 if (estack_bx(stack
, top
)->u
.s
.literal_type
==
153 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
154 ret
= parse_char(estack_bx(stack
, top
),
155 &char_bx
, &offset_bx
);
164 if (estack_bx(stack
, top
)->u
.s
.literal_type
==
165 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
166 ret
= parse_char(estack_bx(stack
, top
),
167 &char_bx
, &offset_bx
);
171 } else if (ret
== -2) {
174 /* else compare both char */
176 if (estack_ax(stack
, top
)->u
.s
.literal_type
==
177 ESTACK_STRING_LITERAL_TYPE_PLAIN
) {
178 ret
= parse_char(estack_ax(stack
, top
),
179 &char_ax
, &offset_ax
);
183 } else if (ret
== -2) {
200 diff
= char_bx
- char_ax
;
212 uint64_t lttng_filter_false(void *filter_data
,
213 struct lttng_probe_ctx
*lttng_probe_ctx
,
214 const char *filter_stack_data
)
219 #ifdef INTERPRETER_USE_SWITCH
222 * Fallback for compilers that do not support taking address of labels.
226 start_pc = &bytecode->data[0]; \
227 for (pc = next_pc = start_pc; pc - start_pc < bytecode->len; \
229 dbg_printk("Executing op %s (%u)\n", \
230 lttng_filter_print_op((unsigned int) *(filter_opcode_t *) pc), \
231 (unsigned int) *(filter_opcode_t *) pc); \
232 switch (*(filter_opcode_t *) pc) {
234 #define OP(name) case name
244 * Dispatch-table based interpreter.
248 start_pc = &bytecode->code[0]; \
249 pc = next_pc = start_pc; \
250 if (unlikely(pc - start_pc >= bytecode->len)) \
252 goto *dispatch[*(filter_opcode_t *) pc];
259 goto *dispatch[*(filter_opcode_t *) pc];
265 static int context_get_index(struct lttng_probe_ctx
*lttng_probe_ctx
,
266 struct load_ptr
*ptr
,
270 struct lttng_ctx_field
*ctx_field
;
271 struct lttng_event_field
*field
;
272 union lttng_ctx_value v
;
274 ctx_field
= <tng_static_ctx
->fields
[idx
];
275 field
= &ctx_field
->event_field
;
276 ptr
->type
= LOAD_OBJECT
;
277 /* field is only used for types nested within variants. */
280 switch (field
->type
.atype
) {
282 ctx_field
->get_value(ctx_field
, lttng_probe_ctx
, &v
);
283 if (field
->type
.u
.basic
.integer
.signedness
) {
284 ptr
->object_type
= OBJECT_TYPE_S64
;
286 ptr
->ptr
= &ptr
->u
.s64
;
288 ptr
->object_type
= OBJECT_TYPE_U64
;
289 ptr
->u
.u64
= v
.s64
; /* Cast. */
290 ptr
->ptr
= &ptr
->u
.u64
;
295 const struct lttng_integer_type
*itype
=
296 &field
->type
.u
.basic
.enumeration
.container_type
;
298 ctx_field
->get_value(ctx_field
, lttng_probe_ctx
, &v
);
299 if (itype
->signedness
) {
300 ptr
->object_type
= OBJECT_TYPE_S64
;
302 ptr
->ptr
= &ptr
->u
.s64
;
304 ptr
->object_type
= OBJECT_TYPE_U64
;
305 ptr
->u
.u64
= v
.s64
; /* Cast. */
306 ptr
->ptr
= &ptr
->u
.u64
;
311 if (field
->type
.u
.array
.elem_type
.atype
!= atype_integer
) {
312 printk(KERN_WARNING
"Array nesting only supports integer types.\n");
315 if (field
->type
.u
.array
.elem_type
.u
.basic
.integer
.encoding
== lttng_encode_none
) {
316 printk(KERN_WARNING
"Only string arrays are supported for contexts.\n");
319 ptr
->object_type
= OBJECT_TYPE_STRING
;
320 ctx_field
->get_value(ctx_field
, lttng_probe_ctx
, &v
);
324 if (field
->type
.u
.sequence
.elem_type
.atype
!= atype_integer
) {
325 printk(KERN_WARNING
"Sequence nesting only supports integer types.\n");
328 if (field
->type
.u
.sequence
.elem_type
.u
.basic
.integer
.encoding
== lttng_encode_none
) {
329 printk(KERN_WARNING
"Only string sequences are supported for contexts.\n");
332 ptr
->object_type
= OBJECT_TYPE_STRING
;
333 ctx_field
->get_value(ctx_field
, lttng_probe_ctx
, &v
);
336 case atype_array_bitfield
:
337 printk(KERN_WARNING
"Bitfield array type is not supported.\n");
339 case atype_sequence_bitfield
:
340 printk(KERN_WARNING
"Bitfield sequence type is not supported.\n");
343 ptr
->object_type
= OBJECT_TYPE_STRING
;
344 ctx_field
->get_value(ctx_field
, lttng_probe_ctx
, &v
);
348 printk(KERN_WARNING
"Structure type cannot be loaded.\n");
351 printk(KERN_WARNING
"Unknown type: %d", (int) field
->type
.atype
);
357 static int dynamic_get_index(struct lttng_probe_ctx
*lttng_probe_ctx
,
358 struct bytecode_runtime
*runtime
,
359 uint64_t index
, struct estack_entry
*stack_top
)
362 const struct filter_get_index_data
*gid
;
365 * Types nested within variants need to perform dynamic lookup
366 * based on the field descriptions. LTTng-UST does not implement
369 if (stack_top
->u
.ptr
.field
)
371 gid
= (const struct filter_get_index_data
*) &runtime
->data
[index
];
372 switch (stack_top
->u
.ptr
.type
) {
374 switch (stack_top
->u
.ptr
.object_type
) {
375 case OBJECT_TYPE_ARRAY
:
379 WARN_ON_ONCE(gid
->offset
>= gid
->array_len
);
380 /* Skip count (unsigned long) */
381 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
382 ptr
= ptr
+ gid
->offset
;
383 stack_top
->u
.ptr
.ptr
= ptr
;
384 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
385 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
386 /* field is only used for types nested within variants. */
387 stack_top
->u
.ptr
.field
= NULL
;
390 case OBJECT_TYPE_SEQUENCE
:
395 ptr
= *(const char **) (stack_top
->u
.ptr
.ptr
+ sizeof(unsigned long));
396 ptr_seq_len
= *(unsigned long *) stack_top
->u
.ptr
.ptr
;
397 if (gid
->offset
>= gid
->elem
.len
* ptr_seq_len
) {
401 ptr
= ptr
+ gid
->offset
;
402 stack_top
->u
.ptr
.ptr
= ptr
;
403 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
404 stack_top
->u
.ptr
.rev_bo
= gid
->elem
.rev_bo
;
405 /* field is only used for types nested within variants. */
406 stack_top
->u
.ptr
.field
= NULL
;
409 case OBJECT_TYPE_STRUCT
:
410 printk(KERN_WARNING
"Nested structures are not supported yet.\n");
413 case OBJECT_TYPE_VARIANT
:
415 printk(KERN_WARNING
"Unexpected get index type %d",
416 (int) stack_top
->u
.ptr
.object_type
);
421 case LOAD_ROOT_CONTEXT
:
422 case LOAD_ROOT_APP_CONTEXT
: /* Fall-through */
424 ret
= context_get_index(lttng_probe_ctx
,
432 case LOAD_ROOT_PAYLOAD
:
433 stack_top
->u
.ptr
.ptr
+= gid
->offset
;
434 if (gid
->elem
.type
== OBJECT_TYPE_STRING
)
435 stack_top
->u
.ptr
.ptr
= *(const char * const *) stack_top
->u
.ptr
.ptr
;
436 stack_top
->u
.ptr
.object_type
= gid
->elem
.type
;
437 stack_top
->u
.ptr
.type
= LOAD_OBJECT
;
438 /* field is only used for types nested within variants. */
439 stack_top
->u
.ptr
.field
= NULL
;
448 static int dynamic_load_field(struct estack_entry
*stack_top
)
452 switch (stack_top
->u
.ptr
.type
) {
455 case LOAD_ROOT_CONTEXT
:
456 case LOAD_ROOT_APP_CONTEXT
:
457 case LOAD_ROOT_PAYLOAD
:
459 dbg_printk("Filter warning: cannot load root, missing field name.\n");
463 switch (stack_top
->u
.ptr
.object_type
) {
465 dbg_printk("op load field s8\n");
466 stack_top
->u
.v
= *(int8_t *) stack_top
->u
.ptr
.ptr
;
468 case OBJECT_TYPE_S16
:
472 dbg_printk("op load field s16\n");
473 tmp
= *(int16_t *) stack_top
->u
.ptr
.ptr
;
474 if (stack_top
->u
.ptr
.rev_bo
)
476 stack_top
->u
.v
= tmp
;
479 case OBJECT_TYPE_S32
:
483 dbg_printk("op load field s32\n");
484 tmp
= *(int32_t *) stack_top
->u
.ptr
.ptr
;
485 if (stack_top
->u
.ptr
.rev_bo
)
487 stack_top
->u
.v
= tmp
;
490 case OBJECT_TYPE_S64
:
494 dbg_printk("op load field s64\n");
495 tmp
= *(int64_t *) stack_top
->u
.ptr
.ptr
;
496 if (stack_top
->u
.ptr
.rev_bo
)
498 stack_top
->u
.v
= tmp
;
502 dbg_printk("op load field u8\n");
503 stack_top
->u
.v
= *(uint8_t *) stack_top
->u
.ptr
.ptr
;
505 case OBJECT_TYPE_U16
:
509 dbg_printk("op load field s16\n");
510 tmp
= *(uint16_t *) stack_top
->u
.ptr
.ptr
;
511 if (stack_top
->u
.ptr
.rev_bo
)
513 stack_top
->u
.v
= tmp
;
516 case OBJECT_TYPE_U32
:
520 dbg_printk("op load field u32\n");
521 tmp
= *(uint32_t *) stack_top
->u
.ptr
.ptr
;
522 if (stack_top
->u
.ptr
.rev_bo
)
524 stack_top
->u
.v
= tmp
;
527 case OBJECT_TYPE_U64
:
531 dbg_printk("op load field u64\n");
532 tmp
= *(uint64_t *) stack_top
->u
.ptr
.ptr
;
533 if (stack_top
->u
.ptr
.rev_bo
)
535 stack_top
->u
.v
= tmp
;
538 case OBJECT_TYPE_STRING
:
542 dbg_printk("op load field string\n");
543 str
= (const char *) stack_top
->u
.ptr
.ptr
;
544 stack_top
->u
.s
.str
= str
;
545 if (unlikely(!stack_top
->u
.s
.str
)) {
546 dbg_printk("Filter warning: loading a NULL string.\n");
550 stack_top
->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
551 stack_top
->u
.s
.literal_type
=
552 ESTACK_STRING_LITERAL_TYPE_NONE
;
555 case OBJECT_TYPE_STRING_SEQUENCE
:
559 dbg_printk("op load field string sequence\n");
560 ptr
= stack_top
->u
.ptr
.ptr
;
561 stack_top
->u
.s
.seq_len
= *(unsigned long *) ptr
;
562 stack_top
->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
563 if (unlikely(!stack_top
->u
.s
.str
)) {
564 dbg_printk("Filter warning: loading a NULL sequence.\n");
568 stack_top
->u
.s
.literal_type
=
569 ESTACK_STRING_LITERAL_TYPE_NONE
;
572 case OBJECT_TYPE_DYNAMIC
:
574 * Dynamic types in context are looked up
575 * by context get index.
579 case OBJECT_TYPE_DOUBLE
:
582 case OBJECT_TYPE_SEQUENCE
:
583 case OBJECT_TYPE_ARRAY
:
584 case OBJECT_TYPE_STRUCT
:
585 case OBJECT_TYPE_VARIANT
:
586 printk(KERN_WARNING
"Sequences, arrays, struct and variant cannot be loaded (nested types).\n");
597 * Return 0 (discard), or raise the 0x1 flag (log event).
598 * Currently, other flags are kept for future extensions and have no
601 uint64_t lttng_filter_interpret_bytecode(void *filter_data
,
602 struct lttng_probe_ctx
*lttng_probe_ctx
,
603 const char *filter_stack_data
)
605 struct bytecode_runtime
*bytecode
= filter_data
;
606 void *pc
, *next_pc
, *start_pc
;
609 struct estack _stack
;
610 struct estack
*stack
= &_stack
;
611 register int64_t ax
= 0, bx
= 0;
612 register int top
= FILTER_STACK_EMPTY
;
613 #ifndef INTERPRETER_USE_SWITCH
614 static void *dispatch
[NR_FILTER_OPS
] = {
615 [ FILTER_OP_UNKNOWN
] = &&LABEL_FILTER_OP_UNKNOWN
,
617 [ FILTER_OP_RETURN
] = &&LABEL_FILTER_OP_RETURN
,
620 [ FILTER_OP_MUL
] = &&LABEL_FILTER_OP_MUL
,
621 [ FILTER_OP_DIV
] = &&LABEL_FILTER_OP_DIV
,
622 [ FILTER_OP_MOD
] = &&LABEL_FILTER_OP_MOD
,
623 [ FILTER_OP_PLUS
] = &&LABEL_FILTER_OP_PLUS
,
624 [ FILTER_OP_MINUS
] = &&LABEL_FILTER_OP_MINUS
,
625 [ FILTER_OP_BIT_RSHIFT
] = &&LABEL_FILTER_OP_BIT_RSHIFT
,
626 [ FILTER_OP_BIT_LSHIFT
] = &&LABEL_FILTER_OP_BIT_LSHIFT
,
627 [ FILTER_OP_BIT_AND
] = &&LABEL_FILTER_OP_BIT_AND
,
628 [ FILTER_OP_BIT_OR
] = &&LABEL_FILTER_OP_BIT_OR
,
629 [ FILTER_OP_BIT_XOR
] = &&LABEL_FILTER_OP_BIT_XOR
,
631 /* binary comparators */
632 [ FILTER_OP_EQ
] = &&LABEL_FILTER_OP_EQ
,
633 [ FILTER_OP_NE
] = &&LABEL_FILTER_OP_NE
,
634 [ FILTER_OP_GT
] = &&LABEL_FILTER_OP_GT
,
635 [ FILTER_OP_LT
] = &&LABEL_FILTER_OP_LT
,
636 [ FILTER_OP_GE
] = &&LABEL_FILTER_OP_GE
,
637 [ FILTER_OP_LE
] = &&LABEL_FILTER_OP_LE
,
639 /* string binary comparator */
640 [ FILTER_OP_EQ_STRING
] = &&LABEL_FILTER_OP_EQ_STRING
,
641 [ FILTER_OP_NE_STRING
] = &&LABEL_FILTER_OP_NE_STRING
,
642 [ FILTER_OP_GT_STRING
] = &&LABEL_FILTER_OP_GT_STRING
,
643 [ FILTER_OP_LT_STRING
] = &&LABEL_FILTER_OP_LT_STRING
,
644 [ FILTER_OP_GE_STRING
] = &&LABEL_FILTER_OP_GE_STRING
,
645 [ FILTER_OP_LE_STRING
] = &&LABEL_FILTER_OP_LE_STRING
,
647 /* globbing pattern binary comparator */
648 [ FILTER_OP_EQ_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_EQ_STAR_GLOB_STRING
,
649 [ FILTER_OP_NE_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_NE_STAR_GLOB_STRING
,
651 /* s64 binary comparator */
652 [ FILTER_OP_EQ_S64
] = &&LABEL_FILTER_OP_EQ_S64
,
653 [ FILTER_OP_NE_S64
] = &&LABEL_FILTER_OP_NE_S64
,
654 [ FILTER_OP_GT_S64
] = &&LABEL_FILTER_OP_GT_S64
,
655 [ FILTER_OP_LT_S64
] = &&LABEL_FILTER_OP_LT_S64
,
656 [ FILTER_OP_GE_S64
] = &&LABEL_FILTER_OP_GE_S64
,
657 [ FILTER_OP_LE_S64
] = &&LABEL_FILTER_OP_LE_S64
,
659 /* double binary comparator */
660 [ FILTER_OP_EQ_DOUBLE
] = &&LABEL_FILTER_OP_EQ_DOUBLE
,
661 [ FILTER_OP_NE_DOUBLE
] = &&LABEL_FILTER_OP_NE_DOUBLE
,
662 [ FILTER_OP_GT_DOUBLE
] = &&LABEL_FILTER_OP_GT_DOUBLE
,
663 [ FILTER_OP_LT_DOUBLE
] = &&LABEL_FILTER_OP_LT_DOUBLE
,
664 [ FILTER_OP_GE_DOUBLE
] = &&LABEL_FILTER_OP_GE_DOUBLE
,
665 [ FILTER_OP_LE_DOUBLE
] = &&LABEL_FILTER_OP_LE_DOUBLE
,
667 /* Mixed S64-double binary comparators */
668 [ FILTER_OP_EQ_DOUBLE_S64
] = &&LABEL_FILTER_OP_EQ_DOUBLE_S64
,
669 [ FILTER_OP_NE_DOUBLE_S64
] = &&LABEL_FILTER_OP_NE_DOUBLE_S64
,
670 [ FILTER_OP_GT_DOUBLE_S64
] = &&LABEL_FILTER_OP_GT_DOUBLE_S64
,
671 [ FILTER_OP_LT_DOUBLE_S64
] = &&LABEL_FILTER_OP_LT_DOUBLE_S64
,
672 [ FILTER_OP_GE_DOUBLE_S64
] = &&LABEL_FILTER_OP_GE_DOUBLE_S64
,
673 [ FILTER_OP_LE_DOUBLE_S64
] = &&LABEL_FILTER_OP_LE_DOUBLE_S64
,
675 [ FILTER_OP_EQ_S64_DOUBLE
] = &&LABEL_FILTER_OP_EQ_S64_DOUBLE
,
676 [ FILTER_OP_NE_S64_DOUBLE
] = &&LABEL_FILTER_OP_NE_S64_DOUBLE
,
677 [ FILTER_OP_GT_S64_DOUBLE
] = &&LABEL_FILTER_OP_GT_S64_DOUBLE
,
678 [ FILTER_OP_LT_S64_DOUBLE
] = &&LABEL_FILTER_OP_LT_S64_DOUBLE
,
679 [ FILTER_OP_GE_S64_DOUBLE
] = &&LABEL_FILTER_OP_GE_S64_DOUBLE
,
680 [ FILTER_OP_LE_S64_DOUBLE
] = &&LABEL_FILTER_OP_LE_S64_DOUBLE
,
683 [ FILTER_OP_UNARY_PLUS
] = &&LABEL_FILTER_OP_UNARY_PLUS
,
684 [ FILTER_OP_UNARY_MINUS
] = &&LABEL_FILTER_OP_UNARY_MINUS
,
685 [ FILTER_OP_UNARY_NOT
] = &&LABEL_FILTER_OP_UNARY_NOT
,
686 [ FILTER_OP_UNARY_PLUS_S64
] = &&LABEL_FILTER_OP_UNARY_PLUS_S64
,
687 [ FILTER_OP_UNARY_MINUS_S64
] = &&LABEL_FILTER_OP_UNARY_MINUS_S64
,
688 [ FILTER_OP_UNARY_NOT_S64
] = &&LABEL_FILTER_OP_UNARY_NOT_S64
,
689 [ FILTER_OP_UNARY_PLUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_PLUS_DOUBLE
,
690 [ FILTER_OP_UNARY_MINUS_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_MINUS_DOUBLE
,
691 [ FILTER_OP_UNARY_NOT_DOUBLE
] = &&LABEL_FILTER_OP_UNARY_NOT_DOUBLE
,
694 [ FILTER_OP_AND
] = &&LABEL_FILTER_OP_AND
,
695 [ FILTER_OP_OR
] = &&LABEL_FILTER_OP_OR
,
698 [ FILTER_OP_LOAD_FIELD_REF
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF
,
699 [ FILTER_OP_LOAD_FIELD_REF_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_STRING
,
700 [ FILTER_OP_LOAD_FIELD_REF_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_SEQUENCE
,
701 [ FILTER_OP_LOAD_FIELD_REF_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_S64
,
702 [ FILTER_OP_LOAD_FIELD_REF_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_DOUBLE
,
704 /* load from immediate operand */
705 [ FILTER_OP_LOAD_STRING
] = &&LABEL_FILTER_OP_LOAD_STRING
,
706 [ FILTER_OP_LOAD_STAR_GLOB_STRING
] = &&LABEL_FILTER_OP_LOAD_STAR_GLOB_STRING
,
707 [ FILTER_OP_LOAD_S64
] = &&LABEL_FILTER_OP_LOAD_S64
,
708 [ FILTER_OP_LOAD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_DOUBLE
,
711 [ FILTER_OP_CAST_TO_S64
] = &&LABEL_FILTER_OP_CAST_TO_S64
,
712 [ FILTER_OP_CAST_DOUBLE_TO_S64
] = &&LABEL_FILTER_OP_CAST_DOUBLE_TO_S64
,
713 [ FILTER_OP_CAST_NOP
] = &&LABEL_FILTER_OP_CAST_NOP
,
715 /* get context ref */
716 [ FILTER_OP_GET_CONTEXT_REF
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF
,
717 [ FILTER_OP_GET_CONTEXT_REF_STRING
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_STRING
,
718 [ FILTER_OP_GET_CONTEXT_REF_S64
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_S64
,
719 [ FILTER_OP_GET_CONTEXT_REF_DOUBLE
] = &&LABEL_FILTER_OP_GET_CONTEXT_REF_DOUBLE
,
721 /* load userspace field ref */
722 [ FILTER_OP_LOAD_FIELD_REF_USER_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_USER_STRING
,
723 [ FILTER_OP_LOAD_FIELD_REF_USER_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_REF_USER_SEQUENCE
,
725 /* Instructions for recursive traversal through composed types. */
726 [ FILTER_OP_GET_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_CONTEXT_ROOT
,
727 [ FILTER_OP_GET_APP_CONTEXT_ROOT
] = &&LABEL_FILTER_OP_GET_APP_CONTEXT_ROOT
,
728 [ FILTER_OP_GET_PAYLOAD_ROOT
] = &&LABEL_FILTER_OP_GET_PAYLOAD_ROOT
,
730 [ FILTER_OP_GET_SYMBOL
] = &&LABEL_FILTER_OP_GET_SYMBOL
,
731 [ FILTER_OP_GET_SYMBOL_FIELD
] = &&LABEL_FILTER_OP_GET_SYMBOL_FIELD
,
732 [ FILTER_OP_GET_INDEX_U16
] = &&LABEL_FILTER_OP_GET_INDEX_U16
,
733 [ FILTER_OP_GET_INDEX_U64
] = &&LABEL_FILTER_OP_GET_INDEX_U64
,
735 [ FILTER_OP_LOAD_FIELD
] = &&LABEL_FILTER_OP_LOAD_FIELD
,
736 [ FILTER_OP_LOAD_FIELD_S8
] = &&LABEL_FILTER_OP_LOAD_FIELD_S8
,
737 [ FILTER_OP_LOAD_FIELD_S16
] = &&LABEL_FILTER_OP_LOAD_FIELD_S16
,
738 [ FILTER_OP_LOAD_FIELD_S32
] = &&LABEL_FILTER_OP_LOAD_FIELD_S32
,
739 [ FILTER_OP_LOAD_FIELD_S64
] = &&LABEL_FILTER_OP_LOAD_FIELD_S64
,
740 [ FILTER_OP_LOAD_FIELD_U8
] = &&LABEL_FILTER_OP_LOAD_FIELD_U8
,
741 [ FILTER_OP_LOAD_FIELD_U16
] = &&LABEL_FILTER_OP_LOAD_FIELD_U16
,
742 [ FILTER_OP_LOAD_FIELD_U32
] = &&LABEL_FILTER_OP_LOAD_FIELD_U32
,
743 [ FILTER_OP_LOAD_FIELD_U64
] = &&LABEL_FILTER_OP_LOAD_FIELD_U64
,
744 [ FILTER_OP_LOAD_FIELD_STRING
] = &&LABEL_FILTER_OP_LOAD_FIELD_STRING
,
745 [ FILTER_OP_LOAD_FIELD_SEQUENCE
] = &&LABEL_FILTER_OP_LOAD_FIELD_SEQUENCE
,
746 [ FILTER_OP_LOAD_FIELD_DOUBLE
] = &&LABEL_FILTER_OP_LOAD_FIELD_DOUBLE
,
748 [ FILTER_OP_UNARY_BIT_NOT
] = &&LABEL_FILTER_OP_UNARY_BIT_NOT
,
750 [ FILTER_OP_RETURN_S64
] = &&LABEL_FILTER_OP_RETURN_S64
,
752 #endif /* #ifndef INTERPRETER_USE_SWITCH */
756 OP(FILTER_OP_UNKNOWN
):
757 OP(FILTER_OP_LOAD_FIELD_REF
):
758 OP(FILTER_OP_GET_CONTEXT_REF
):
759 #ifdef INTERPRETER_USE_SWITCH
761 #endif /* INTERPRETER_USE_SWITCH */
762 printk(KERN_WARNING
"unknown bytecode op %u\n",
763 (unsigned int) *(filter_opcode_t
*) pc
);
767 OP(FILTER_OP_RETURN
):
768 OP(FILTER_OP_RETURN_S64
):
769 /* LTTNG_FILTER_DISCARD or LTTNG_FILTER_RECORD_FLAG */
770 retval
= !!estack_ax_v
;
780 printk(KERN_WARNING
"unsupported bytecode op %u\n",
781 (unsigned int) *(filter_opcode_t
*) pc
);
791 printk(KERN_WARNING
"unsupported non-specialized bytecode op %u\n",
792 (unsigned int) *(filter_opcode_t
*) pc
);
796 OP(FILTER_OP_EQ_STRING
):
800 res
= (stack_strcmp(stack
, top
, "==") == 0);
801 estack_pop(stack
, top
, ax
, bx
);
803 next_pc
+= sizeof(struct binary_op
);
806 OP(FILTER_OP_NE_STRING
):
810 res
= (stack_strcmp(stack
, top
, "!=") != 0);
811 estack_pop(stack
, top
, ax
, bx
);
813 next_pc
+= sizeof(struct binary_op
);
816 OP(FILTER_OP_GT_STRING
):
820 res
= (stack_strcmp(stack
, top
, ">") > 0);
821 estack_pop(stack
, top
, ax
, bx
);
823 next_pc
+= sizeof(struct binary_op
);
826 OP(FILTER_OP_LT_STRING
):
830 res
= (stack_strcmp(stack
, top
, "<") < 0);
831 estack_pop(stack
, top
, ax
, bx
);
833 next_pc
+= sizeof(struct binary_op
);
836 OP(FILTER_OP_GE_STRING
):
840 res
= (stack_strcmp(stack
, top
, ">=") >= 0);
841 estack_pop(stack
, top
, ax
, bx
);
843 next_pc
+= sizeof(struct binary_op
);
846 OP(FILTER_OP_LE_STRING
):
850 res
= (stack_strcmp(stack
, top
, "<=") <= 0);
851 estack_pop(stack
, top
, ax
, bx
);
853 next_pc
+= sizeof(struct binary_op
);
857 OP(FILTER_OP_EQ_STAR_GLOB_STRING
):
861 res
= (stack_star_glob_match(stack
, top
, "==") == 0);
862 estack_pop(stack
, top
, ax
, bx
);
864 next_pc
+= sizeof(struct binary_op
);
867 OP(FILTER_OP_NE_STAR_GLOB_STRING
):
871 res
= (stack_star_glob_match(stack
, top
, "!=") != 0);
872 estack_pop(stack
, top
, ax
, bx
);
874 next_pc
+= sizeof(struct binary_op
);
878 OP(FILTER_OP_EQ_S64
):
882 res
= (estack_bx_v
== estack_ax_v
);
883 estack_pop(stack
, top
, ax
, bx
);
885 next_pc
+= sizeof(struct binary_op
);
888 OP(FILTER_OP_NE_S64
):
892 res
= (estack_bx_v
!= estack_ax_v
);
893 estack_pop(stack
, top
, ax
, bx
);
895 next_pc
+= sizeof(struct binary_op
);
898 OP(FILTER_OP_GT_S64
):
902 res
= (estack_bx_v
> estack_ax_v
);
903 estack_pop(stack
, top
, ax
, bx
);
905 next_pc
+= sizeof(struct binary_op
);
908 OP(FILTER_OP_LT_S64
):
912 res
= (estack_bx_v
< estack_ax_v
);
913 estack_pop(stack
, top
, ax
, bx
);
915 next_pc
+= sizeof(struct binary_op
);
918 OP(FILTER_OP_GE_S64
):
922 res
= (estack_bx_v
>= estack_ax_v
);
923 estack_pop(stack
, top
, ax
, bx
);
925 next_pc
+= sizeof(struct binary_op
);
928 OP(FILTER_OP_LE_S64
):
932 res
= (estack_bx_v
<= estack_ax_v
);
933 estack_pop(stack
, top
, ax
, bx
);
935 next_pc
+= sizeof(struct binary_op
);
939 OP(FILTER_OP_EQ_DOUBLE
):
940 OP(FILTER_OP_NE_DOUBLE
):
941 OP(FILTER_OP_GT_DOUBLE
):
942 OP(FILTER_OP_LT_DOUBLE
):
943 OP(FILTER_OP_GE_DOUBLE
):
944 OP(FILTER_OP_LE_DOUBLE
):
950 /* Mixed S64-double binary comparators */
951 OP(FILTER_OP_EQ_DOUBLE_S64
):
952 OP(FILTER_OP_NE_DOUBLE_S64
):
953 OP(FILTER_OP_GT_DOUBLE_S64
):
954 OP(FILTER_OP_LT_DOUBLE_S64
):
955 OP(FILTER_OP_GE_DOUBLE_S64
):
956 OP(FILTER_OP_LE_DOUBLE_S64
):
957 OP(FILTER_OP_EQ_S64_DOUBLE
):
958 OP(FILTER_OP_NE_S64_DOUBLE
):
959 OP(FILTER_OP_GT_S64_DOUBLE
):
960 OP(FILTER_OP_LT_S64_DOUBLE
):
961 OP(FILTER_OP_GE_S64_DOUBLE
):
962 OP(FILTER_OP_LE_S64_DOUBLE
):
967 OP(FILTER_OP_BIT_RSHIFT
):
971 /* Catch undefined behavior. */
972 if (unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
976 res
= ((uint64_t) estack_bx_v
>> (uint32_t) estack_ax_v
);
977 estack_pop(stack
, top
, ax
, bx
);
979 next_pc
+= sizeof(struct binary_op
);
982 OP(FILTER_OP_BIT_LSHIFT
):
986 /* Catch undefined behavior. */
987 if (unlikely(estack_ax_v
< 0 || estack_ax_v
>= 64)) {
991 res
= ((uint64_t) estack_bx_v
<< (uint32_t) estack_ax_v
);
992 estack_pop(stack
, top
, ax
, bx
);
994 next_pc
+= sizeof(struct binary_op
);
997 OP(FILTER_OP_BIT_AND
):
1001 res
= ((uint64_t) estack_bx_v
& (uint64_t) estack_ax_v
);
1002 estack_pop(stack
, top
, ax
, bx
);
1004 next_pc
+= sizeof(struct binary_op
);
1007 OP(FILTER_OP_BIT_OR
):
1011 res
= ((uint64_t) estack_bx_v
| (uint64_t) estack_ax_v
);
1012 estack_pop(stack
, top
, ax
, bx
);
1014 next_pc
+= sizeof(struct binary_op
);
1017 OP(FILTER_OP_BIT_XOR
):
1021 res
= ((uint64_t) estack_bx_v
^ (uint64_t) estack_ax_v
);
1022 estack_pop(stack
, top
, ax
, bx
);
1024 next_pc
+= sizeof(struct binary_op
);
1029 OP(FILTER_OP_UNARY_PLUS
):
1030 OP(FILTER_OP_UNARY_MINUS
):
1031 OP(FILTER_OP_UNARY_NOT
):
1032 printk(KERN_WARNING
"unsupported non-specialized bytecode op %u\n",
1033 (unsigned int) *(filter_opcode_t
*) pc
);
1038 OP(FILTER_OP_UNARY_BIT_NOT
):
1040 estack_ax_v
= ~(uint64_t) estack_ax_v
;
1041 next_pc
+= sizeof(struct unary_op
);
1045 OP(FILTER_OP_UNARY_PLUS_S64
):
1047 next_pc
+= sizeof(struct unary_op
);
1050 OP(FILTER_OP_UNARY_MINUS_S64
):
1052 estack_ax_v
= -estack_ax_v
;
1053 next_pc
+= sizeof(struct unary_op
);
1056 OP(FILTER_OP_UNARY_PLUS_DOUBLE
):
1057 OP(FILTER_OP_UNARY_MINUS_DOUBLE
):
1062 OP(FILTER_OP_UNARY_NOT_S64
):
1064 estack_ax_v
= !estack_ax_v
;
1065 next_pc
+= sizeof(struct unary_op
);
1068 OP(FILTER_OP_UNARY_NOT_DOUBLE
):
1077 struct logical_op
*insn
= (struct logical_op
*) pc
;
1079 /* If AX is 0, skip and evaluate to 0 */
1080 if (unlikely(estack_ax_v
== 0)) {
1081 dbg_printk("Jumping to bytecode offset %u\n",
1082 (unsigned int) insn
->skip_offset
);
1083 next_pc
= start_pc
+ insn
->skip_offset
;
1085 /* Pop 1 when jump not taken */
1086 estack_pop(stack
, top
, ax
, bx
);
1087 next_pc
+= sizeof(struct logical_op
);
1093 struct logical_op
*insn
= (struct logical_op
*) pc
;
1095 /* If AX is nonzero, skip and evaluate to 1 */
1097 if (unlikely(estack_ax_v
!= 0)) {
1099 dbg_printk("Jumping to bytecode offset %u\n",
1100 (unsigned int) insn
->skip_offset
);
1101 next_pc
= start_pc
+ insn
->skip_offset
;
1103 /* Pop 1 when jump not taken */
1104 estack_pop(stack
, top
, ax
, bx
);
1105 next_pc
+= sizeof(struct logical_op
);
1111 /* load field ref */
1112 OP(FILTER_OP_LOAD_FIELD_REF_STRING
):
1114 struct load_op
*insn
= (struct load_op
*) pc
;
1115 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1117 dbg_printk("load field ref offset %u type string\n",
1119 estack_push(stack
, top
, ax
, bx
);
1120 estack_ax(stack
, top
)->u
.s
.str
=
1121 *(const char * const *) &filter_stack_data
[ref
->offset
];
1122 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1123 dbg_printk("Filter warning: loading a NULL string.\n");
1127 estack_ax(stack
, top
)->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
1128 estack_ax(stack
, top
)->u
.s
.literal_type
=
1129 ESTACK_STRING_LITERAL_TYPE_NONE
;
1130 estack_ax(stack
, top
)->u
.s
.user
= 0;
1131 dbg_printk("ref load string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
1132 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1136 OP(FILTER_OP_LOAD_FIELD_REF_SEQUENCE
):
1138 struct load_op
*insn
= (struct load_op
*) pc
;
1139 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1141 dbg_printk("load field ref offset %u type sequence\n",
1143 estack_push(stack
, top
, ax
, bx
);
1144 estack_ax(stack
, top
)->u
.s
.seq_len
=
1145 *(unsigned long *) &filter_stack_data
[ref
->offset
];
1146 estack_ax(stack
, top
)->u
.s
.str
=
1147 *(const char **) (&filter_stack_data
[ref
->offset
1148 + sizeof(unsigned long)]);
1149 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1150 dbg_printk("Filter warning: loading a NULL sequence.\n");
1154 estack_ax(stack
, top
)->u
.s
.literal_type
=
1155 ESTACK_STRING_LITERAL_TYPE_NONE
;
1156 estack_ax(stack
, top
)->u
.s
.user
= 0;
1157 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1161 OP(FILTER_OP_LOAD_FIELD_REF_S64
):
1163 struct load_op
*insn
= (struct load_op
*) pc
;
1164 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1166 dbg_printk("load field ref offset %u type s64\n",
1168 estack_push(stack
, top
, ax
, bx
);
1170 ((struct literal_numeric
*) &filter_stack_data
[ref
->offset
])->v
;
1171 dbg_printk("ref load s64 %lld\n",
1172 (long long) estack_ax_v
);
1173 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1177 OP(FILTER_OP_LOAD_FIELD_REF_DOUBLE
):
1183 /* load from immediate operand */
1184 OP(FILTER_OP_LOAD_STRING
):
1186 struct load_op
*insn
= (struct load_op
*) pc
;
1188 dbg_printk("load string %s\n", insn
->data
);
1189 estack_push(stack
, top
, ax
, bx
);
1190 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1191 estack_ax(stack
, top
)->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
1192 estack_ax(stack
, top
)->u
.s
.literal_type
=
1193 ESTACK_STRING_LITERAL_TYPE_PLAIN
;
1194 estack_ax(stack
, top
)->u
.s
.user
= 0;
1195 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1199 OP(FILTER_OP_LOAD_STAR_GLOB_STRING
):
1201 struct load_op
*insn
= (struct load_op
*) pc
;
1203 dbg_printk("load globbing pattern %s\n", insn
->data
);
1204 estack_push(stack
, top
, ax
, bx
);
1205 estack_ax(stack
, top
)->u
.s
.str
= insn
->data
;
1206 estack_ax(stack
, top
)->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
1207 estack_ax(stack
, top
)->u
.s
.literal_type
=
1208 ESTACK_STRING_LITERAL_TYPE_STAR_GLOB
;
1209 estack_ax(stack
, top
)->u
.s
.user
= 0;
1210 next_pc
+= sizeof(struct load_op
) + strlen(insn
->data
) + 1;
1214 OP(FILTER_OP_LOAD_S64
):
1216 struct load_op
*insn
= (struct load_op
*) pc
;
1218 estack_push(stack
, top
, ax
, bx
);
1219 estack_ax_v
= ((struct literal_numeric
*) insn
->data
)->v
;
1220 dbg_printk("load s64 %lld\n",
1221 (long long) estack_ax_v
);
1222 next_pc
+= sizeof(struct load_op
)
1223 + sizeof(struct literal_numeric
);
1227 OP(FILTER_OP_LOAD_DOUBLE
):
1234 OP(FILTER_OP_CAST_TO_S64
):
1235 printk(KERN_WARNING
"unsupported non-specialized bytecode op %u\n",
1236 (unsigned int) *(filter_opcode_t
*) pc
);
1240 OP(FILTER_OP_CAST_DOUBLE_TO_S64
):
1246 OP(FILTER_OP_CAST_NOP
):
1248 next_pc
+= sizeof(struct cast_op
);
1252 /* get context ref */
1253 OP(FILTER_OP_GET_CONTEXT_REF_STRING
):
1255 struct load_op
*insn
= (struct load_op
*) pc
;
1256 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1257 struct lttng_ctx_field
*ctx_field
;
1258 union lttng_ctx_value v
;
1260 dbg_printk("get context ref offset %u type string\n",
1262 ctx_field
= <tng_static_ctx
->fields
[ref
->offset
];
1263 ctx_field
->get_value(ctx_field
, lttng_probe_ctx
, &v
);
1264 estack_push(stack
, top
, ax
, bx
);
1265 estack_ax(stack
, top
)->u
.s
.str
= v
.str
;
1266 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1267 dbg_printk("Filter warning: loading a NULL string.\n");
1271 estack_ax(stack
, top
)->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
1272 estack_ax(stack
, top
)->u
.s
.literal_type
=
1273 ESTACK_STRING_LITERAL_TYPE_NONE
;
1274 estack_ax(stack
, top
)->u
.s
.user
= 0;
1275 dbg_printk("ref get context string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
1276 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1280 OP(FILTER_OP_GET_CONTEXT_REF_S64
):
1282 struct load_op
*insn
= (struct load_op
*) pc
;
1283 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1284 struct lttng_ctx_field
*ctx_field
;
1285 union lttng_ctx_value v
;
1287 dbg_printk("get context ref offset %u type s64\n",
1289 ctx_field
= <tng_static_ctx
->fields
[ref
->offset
];
1290 ctx_field
->get_value(ctx_field
, lttng_probe_ctx
, &v
);
1291 estack_push(stack
, top
, ax
, bx
);
1292 estack_ax_v
= v
.s64
;
1293 dbg_printk("ref get context s64 %lld\n",
1294 (long long) estack_ax_v
);
1295 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1299 OP(FILTER_OP_GET_CONTEXT_REF_DOUBLE
):
1305 /* load userspace field ref */
1306 OP(FILTER_OP_LOAD_FIELD_REF_USER_STRING
):
1308 struct load_op
*insn
= (struct load_op
*) pc
;
1309 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1311 dbg_printk("load field ref offset %u type user string\n",
1313 estack_push(stack
, top
, ax
, bx
);
1314 estack_ax(stack
, top
)->u
.s
.user_str
=
1315 *(const char * const *) &filter_stack_data
[ref
->offset
];
1316 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1317 dbg_printk("Filter warning: loading a NULL string.\n");
1321 estack_ax(stack
, top
)->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
1322 estack_ax(stack
, top
)->u
.s
.literal_type
=
1323 ESTACK_STRING_LITERAL_TYPE_NONE
;
1324 estack_ax(stack
, top
)->u
.s
.user
= 1;
1325 dbg_printk("ref load string %s\n", estack_ax(stack
, top
)->u
.s
.str
);
1326 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1330 OP(FILTER_OP_LOAD_FIELD_REF_USER_SEQUENCE
):
1332 struct load_op
*insn
= (struct load_op
*) pc
;
1333 struct field_ref
*ref
= (struct field_ref
*) insn
->data
;
1335 dbg_printk("load field ref offset %u type user sequence\n",
1337 estack_push(stack
, top
, ax
, bx
);
1338 estack_ax(stack
, top
)->u
.s
.seq_len
=
1339 *(unsigned long *) &filter_stack_data
[ref
->offset
];
1340 estack_ax(stack
, top
)->u
.s
.user_str
=
1341 *(const char **) (&filter_stack_data
[ref
->offset
1342 + sizeof(unsigned long)]);
1343 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1344 dbg_printk("Filter warning: loading a NULL sequence.\n");
1348 estack_ax(stack
, top
)->u
.s
.literal_type
=
1349 ESTACK_STRING_LITERAL_TYPE_NONE
;
1350 estack_ax(stack
, top
)->u
.s
.user
= 1;
1351 next_pc
+= sizeof(struct load_op
) + sizeof(struct field_ref
);
1355 OP(FILTER_OP_GET_CONTEXT_ROOT
):
1357 dbg_printk("op get context root\n");
1358 estack_push(stack
, top
, ax
, bx
);
1359 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_CONTEXT
;
1360 /* "field" only needed for variants. */
1361 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
1362 next_pc
+= sizeof(struct load_op
);
1366 OP(FILTER_OP_GET_APP_CONTEXT_ROOT
):
1372 OP(FILTER_OP_GET_PAYLOAD_ROOT
):
1374 dbg_printk("op get app payload root\n");
1375 estack_push(stack
, top
, ax
, bx
);
1376 estack_ax(stack
, top
)->u
.ptr
.type
= LOAD_ROOT_PAYLOAD
;
1377 estack_ax(stack
, top
)->u
.ptr
.ptr
= filter_stack_data
;
1378 /* "field" only needed for variants. */
1379 estack_ax(stack
, top
)->u
.ptr
.field
= NULL
;
1380 next_pc
+= sizeof(struct load_op
);
1384 OP(FILTER_OP_GET_SYMBOL
):
1386 dbg_printk("op get symbol\n");
1387 switch (estack_ax(stack
, top
)->u
.ptr
.type
) {
1389 printk(KERN_WARNING
"Nested fields not implemented yet.\n");
1392 case LOAD_ROOT_CONTEXT
:
1393 case LOAD_ROOT_APP_CONTEXT
:
1394 case LOAD_ROOT_PAYLOAD
:
1396 * symbol lookup is performed by
1402 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_symbol
);
1406 OP(FILTER_OP_GET_SYMBOL_FIELD
):
1409 * Used for first variant encountered in a
1410 * traversal. Variants are not implemented yet.
1416 OP(FILTER_OP_GET_INDEX_U16
):
1418 struct load_op
*insn
= (struct load_op
*) pc
;
1419 struct get_index_u16
*index
= (struct get_index_u16
*) insn
->data
;
1421 dbg_printk("op get index u16\n");
1422 ret
= dynamic_get_index(lttng_probe_ctx
, bytecode
, index
->index
, estack_ax(stack
, top
));
1425 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
1426 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u16
);
1430 OP(FILTER_OP_GET_INDEX_U64
):
1432 struct load_op
*insn
= (struct load_op
*) pc
;
1433 struct get_index_u64
*index
= (struct get_index_u64
*) insn
->data
;
1435 dbg_printk("op get index u64\n");
1436 ret
= dynamic_get_index(lttng_probe_ctx
, bytecode
, index
->index
, estack_ax(stack
, top
));
1439 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
1440 next_pc
+= sizeof(struct load_op
) + sizeof(struct get_index_u64
);
1444 OP(FILTER_OP_LOAD_FIELD
):
1446 dbg_printk("op load field\n");
1447 ret
= dynamic_load_field(estack_ax(stack
, top
));
1450 estack_ax_v
= estack_ax(stack
, top
)->u
.v
;
1451 next_pc
+= sizeof(struct load_op
);
1455 OP(FILTER_OP_LOAD_FIELD_S8
):
1457 dbg_printk("op load field s8\n");
1459 estack_ax_v
= *(int8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1460 next_pc
+= sizeof(struct load_op
);
1463 OP(FILTER_OP_LOAD_FIELD_S16
):
1465 dbg_printk("op load field s16\n");
1467 estack_ax_v
= *(int16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1468 next_pc
+= sizeof(struct load_op
);
1471 OP(FILTER_OP_LOAD_FIELD_S32
):
1473 dbg_printk("op load field s32\n");
1475 estack_ax_v
= *(int32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1476 next_pc
+= sizeof(struct load_op
);
1479 OP(FILTER_OP_LOAD_FIELD_S64
):
1481 dbg_printk("op load field s64\n");
1483 estack_ax_v
= *(int64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1484 next_pc
+= sizeof(struct load_op
);
1487 OP(FILTER_OP_LOAD_FIELD_U8
):
1489 dbg_printk("op load field u8\n");
1491 estack_ax_v
= *(uint8_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1492 next_pc
+= sizeof(struct load_op
);
1495 OP(FILTER_OP_LOAD_FIELD_U16
):
1497 dbg_printk("op load field u16\n");
1499 estack_ax_v
= *(uint16_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1500 next_pc
+= sizeof(struct load_op
);
1503 OP(FILTER_OP_LOAD_FIELD_U32
):
1505 dbg_printk("op load field u32\n");
1507 estack_ax_v
= *(uint32_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1508 next_pc
+= sizeof(struct load_op
);
1511 OP(FILTER_OP_LOAD_FIELD_U64
):
1513 dbg_printk("op load field u64\n");
1515 estack_ax_v
= *(uint64_t *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1516 next_pc
+= sizeof(struct load_op
);
1519 OP(FILTER_OP_LOAD_FIELD_DOUBLE
):
1525 OP(FILTER_OP_LOAD_FIELD_STRING
):
1529 dbg_printk("op load field string\n");
1530 str
= (const char *) estack_ax(stack
, top
)->u
.ptr
.ptr
;
1531 estack_ax(stack
, top
)->u
.s
.str
= str
;
1532 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1533 dbg_printk("Filter warning: loading a NULL string.\n");
1537 estack_ax(stack
, top
)->u
.s
.seq_len
= LTTNG_SIZE_MAX
;
1538 estack_ax(stack
, top
)->u
.s
.literal_type
=
1539 ESTACK_STRING_LITERAL_TYPE_NONE
;
1540 next_pc
+= sizeof(struct load_op
);
1544 OP(FILTER_OP_LOAD_FIELD_SEQUENCE
):
1548 dbg_printk("op load field string sequence\n");
1549 ptr
= estack_ax(stack
, top
)->u
.ptr
.ptr
;
1550 estack_ax(stack
, top
)->u
.s
.seq_len
= *(unsigned long *) ptr
;
1551 estack_ax(stack
, top
)->u
.s
.str
= *(const char **) (ptr
+ sizeof(unsigned long));
1552 if (unlikely(!estack_ax(stack
, top
)->u
.s
.str
)) {
1553 dbg_printk("Filter warning: loading a NULL sequence.\n");
1557 estack_ax(stack
, top
)->u
.s
.literal_type
=
1558 ESTACK_STRING_LITERAL_TYPE_NONE
;
1559 next_pc
+= sizeof(struct load_op
);
1565 /* return 0 (discard) on error */