#endif
+#define IS_INTEGER_REGISTER(reg_type) \
+ (reg_type == REG_U64 || reg_type == REG_S64)
+
static int context_get_index(struct lttng_ctx *ctx,
struct load_ptr *ptr,
uint32_t idx)
return 0;
}
-static int dynamic_get_index(struct lttng_session *session,
+static int dynamic_get_index(struct lttng_ctx *ctx,
struct bytecode_runtime *runtime,
uint64_t index, struct estack_entry *stack_top)
{
case LOAD_ROOT_CONTEXT:
case LOAD_ROOT_APP_CONTEXT: /* Fall-through */
{
- struct lttng_ctx *ctx;
-
- ctx = rcu_dereference(session->ctx);
ret = context_get_index(ctx,
&stack_top->u.ptr,
gid->ctx_index);
case OBJECT_TYPE_U8:
dbg_printf("op load field u8\n");
stack_top->u.v = *(uint8_t *) stack_top->u.ptr.ptr;
- stack_top->type = REG_S64;
+ stack_top->type = REG_U64;
break;
case OBJECT_TYPE_U16:
{
if (stack_top->u.ptr.rev_bo)
tmp = bswap_16(tmp);
stack_top->u.v = tmp;
- stack_top->type = REG_S64;
+ stack_top->type = REG_U64;
break;
}
case OBJECT_TYPE_U32:
if (stack_top->u.ptr.rev_bo)
tmp = bswap_32(tmp);
stack_top->u.v = tmp;
- stack_top->type = REG_S64;
+ stack_top->type = REG_U64;
break;
}
case OBJECT_TYPE_U64:
if (stack_top->u.ptr.rev_bo)
tmp = bswap_64(tmp);
stack_top->u.v = tmp;
- stack_top->type = REG_S64;
+ stack_top->type = REG_U64;
break;
}
case OBJECT_TYPE_DOUBLE:
const char *filter_stack_data)
{
struct bytecode_runtime *bytecode = filter_data;
- struct lttng_session *session = bytecode->p.session;
+ struct lttng_ctx *ctx = rcu_dereference(*bytecode->p.pctx);
void *pc, *next_pc, *start_pc;
int ret = -EINVAL;
uint64_t retval = 0;
/* Handle dynamic typing. */
switch (estack_ax_t) {
case REG_S64:
+ case REG_U64:
retval = !!estack_ax_v;
break;
case REG_DOUBLE:
{
/* Dynamic typing. */
switch (estack_ax_t) {
- case REG_S64:
+ case REG_S64: /* Fall-through */
+ case REG_U64:
switch (estack_bx_t) {
- case REG_S64:
+ case REG_S64: /* Fall-through */
+ case REG_U64:
JUMP_TO(FILTER_OP_EQ_S64);
case REG_DOUBLE:
JUMP_TO(FILTER_OP_EQ_DOUBLE_S64);
break;
case REG_DOUBLE:
switch (estack_bx_t) {
- case REG_S64:
+ case REG_S64: /* Fall-through */
+ case REG_U64:
JUMP_TO(FILTER_OP_EQ_S64_DOUBLE);
case REG_DOUBLE:
JUMP_TO(FILTER_OP_EQ_DOUBLE);
case REG_STRING:
switch (estack_bx_t) {
case REG_S64: /* Fall-through */
+ case REG_U64: /* Fall-through */
case REG_DOUBLE:
ret = -EINVAL;
goto end;
case REG_STAR_GLOB_STRING:
switch (estack_bx_t) {
case REG_S64: /* Fall-through */
+ case REG_U64: /* Fall-through */
case REG_DOUBLE:
ret = -EINVAL;
goto end;
{
/* Dynamic typing. */
switch (estack_ax_t) {
- case REG_S64:
+ case REG_S64: /* Fall-through */
+ case REG_U64:
switch (estack_bx_t) {
- case REG_S64:
+ case REG_S64: /* Fall-through */
+ case REG_U64:
JUMP_TO(FILTER_OP_NE_S64);
case REG_DOUBLE:
JUMP_TO(FILTER_OP_NE_DOUBLE_S64);
break;
case REG_DOUBLE:
switch (estack_bx_t) {
- case REG_S64:
+ case REG_S64: /* Fall-through */
+ case REG_U64:
JUMP_TO(FILTER_OP_NE_S64_DOUBLE);
case REG_DOUBLE:
JUMP_TO(FILTER_OP_NE_DOUBLE);
case REG_STRING:
switch (estack_bx_t) {
case REG_S64: /* Fall-through */
+ case REG_U64:
case REG_DOUBLE:
ret = -EINVAL;
goto end;
case REG_STAR_GLOB_STRING:
switch (estack_bx_t) {
case REG_S64: /* Fall-through */
+ case REG_U64:
case REG_DOUBLE:
ret = -EINVAL;
goto end;
{
/* Dynamic typing. */
switch (estack_ax_t) {
- case REG_S64:
+ case REG_S64: /* Fall-through */
+ case REG_U64:
switch (estack_bx_t) {
- case REG_S64:
+ case REG_S64: /* Fall-through */
+ case REG_U64:
JUMP_TO(FILTER_OP_GT_S64);
case REG_DOUBLE:
JUMP_TO(FILTER_OP_GT_DOUBLE_S64);
break;
case REG_DOUBLE:
switch (estack_bx_t) {
- case REG_S64:
+ case REG_S64: /* Fall-through */
+ case REG_U64:
JUMP_TO(FILTER_OP_GT_S64_DOUBLE);
case REG_DOUBLE:
JUMP_TO(FILTER_OP_GT_DOUBLE);
case REG_STRING:
switch (estack_bx_t) {
case REG_S64: /* Fall-through */
+ case REG_U64: /* Fall-through */
case REG_DOUBLE: /* Fall-through */
case REG_STAR_GLOB_STRING:
ret = -EINVAL;
{
/* Dynamic typing. */
switch (estack_ax_t) {
- case REG_S64:
+ case REG_S64: /* Fall-through */
+ case REG_U64:
switch (estack_bx_t) {
- case REG_S64:
+ case REG_S64: /* Fall-through */
+ case REG_U64:
JUMP_TO(FILTER_OP_LT_S64);
case REG_DOUBLE:
JUMP_TO(FILTER_OP_LT_DOUBLE_S64);
break;
case REG_DOUBLE:
switch (estack_bx_t) {
- case REG_S64:
+ case REG_S64: /* Fall-through */
+ case REG_U64:
JUMP_TO(FILTER_OP_LT_S64_DOUBLE);
case REG_DOUBLE:
JUMP_TO(FILTER_OP_LT_DOUBLE);
case REG_STRING:
switch (estack_bx_t) {
case REG_S64: /* Fall-through */
+ case REG_U64: /* Fall-through */
case REG_DOUBLE: /* Fall-through */
case REG_STAR_GLOB_STRING:
ret = -EINVAL;
{
/* Dynamic typing. */
switch (estack_ax_t) {
- case REG_S64:
+ case REG_S64: /* Fall-through */
+ case REG_U64:
switch (estack_bx_t) {
- case REG_S64:
+ case REG_S64: /* Fall-through */
+ case REG_U64:
JUMP_TO(FILTER_OP_GE_S64);
case REG_DOUBLE:
JUMP_TO(FILTER_OP_GE_DOUBLE_S64);
break;
case REG_DOUBLE:
switch (estack_bx_t) {
- case REG_S64:
+ case REG_S64: /* Fall-through */
+ case REG_U64:
JUMP_TO(FILTER_OP_GE_S64_DOUBLE);
case REG_DOUBLE:
JUMP_TO(FILTER_OP_GE_DOUBLE);
case REG_STRING:
switch (estack_bx_t) {
case REG_S64: /* Fall-through */
+ case REG_U64: /* Fall-through */
case REG_DOUBLE: /* Fall-through */
case REG_STAR_GLOB_STRING:
ret = -EINVAL;
{
/* Dynamic typing. */
switch (estack_ax_t) {
- case REG_S64:
+ case REG_S64: /* Fall-through */
+ case REG_U64:
switch (estack_bx_t) {
- case REG_S64:
+ case REG_S64: /* Fall-through */
+ case REG_U64:
JUMP_TO(FILTER_OP_LE_S64);
case REG_DOUBLE:
JUMP_TO(FILTER_OP_LE_DOUBLE_S64);
break;
case REG_DOUBLE:
switch (estack_bx_t) {
- case REG_S64:
+ case REG_S64: /* Fall-through */
+ case REG_U64:
JUMP_TO(FILTER_OP_LE_S64_DOUBLE);
case REG_DOUBLE:
JUMP_TO(FILTER_OP_LE_DOUBLE);
case REG_STRING:
switch (estack_bx_t) {
case REG_S64: /* Fall-through */
+ case REG_U64: /* Fall-through */
case REG_DOUBLE: /* Fall-through */
case REG_STAR_GLOB_STRING:
ret = -EINVAL;
{
int64_t res;
- /* Dynamic typing. */
- if (estack_ax_t != REG_S64 || estack_bx_t != REG_S64) {
+ if (!IS_INTEGER_REGISTER(estack_ax_t) || !IS_INTEGER_REGISTER(estack_bx_t)) {
ret = -EINVAL;
goto end;
}
+
/* Catch undefined behavior. */
if (caa_unlikely(estack_ax_v < 0 || estack_ax_v >= 64)) {
ret = -EINVAL;
res = ((uint64_t) estack_bx_v >> (uint32_t) estack_ax_v);
estack_pop(stack, top, ax, bx, ax_t, bx_t);
estack_ax_v = res;
- estack_ax_t = REG_S64;
+ estack_ax_t = REG_U64;
next_pc += sizeof(struct binary_op);
PO;
}
{
int64_t res;
- /* Dynamic typing. */
- if (estack_ax_t != REG_S64 || estack_bx_t != REG_S64) {
+ if (!IS_INTEGER_REGISTER(estack_ax_t) || !IS_INTEGER_REGISTER(estack_bx_t)) {
ret = -EINVAL;
goto end;
}
+
/* Catch undefined behavior. */
if (caa_unlikely(estack_ax_v < 0 || estack_ax_v >= 64)) {
ret = -EINVAL;
res = ((uint64_t) estack_bx_v << (uint32_t) estack_ax_v);
estack_pop(stack, top, ax, bx, ax_t, bx_t);
estack_ax_v = res;
- estack_ax_t = REG_S64;
+ estack_ax_t = REG_U64;
next_pc += sizeof(struct binary_op);
PO;
}
{
int64_t res;
- /* Dynamic typing. */
- if (estack_ax_t != REG_S64 || estack_bx_t != REG_S64) {
+ if (!IS_INTEGER_REGISTER(estack_ax_t) || !IS_INTEGER_REGISTER(estack_bx_t)) {
ret = -EINVAL;
goto end;
}
res = ((uint64_t) estack_bx_v & (uint64_t) estack_ax_v);
estack_pop(stack, top, ax, bx, ax_t, bx_t);
estack_ax_v = res;
- estack_ax_t = REG_S64;
+ estack_ax_t = REG_U64;
next_pc += sizeof(struct binary_op);
PO;
}
{
int64_t res;
- /* Dynamic typing. */
- if (estack_ax_t != REG_S64 || estack_bx_t != REG_S64) {
+ if (!IS_INTEGER_REGISTER(estack_ax_t) || !IS_INTEGER_REGISTER(estack_bx_t)) {
ret = -EINVAL;
goto end;
}
res = ((uint64_t) estack_bx_v | (uint64_t) estack_ax_v);
estack_pop(stack, top, ax, bx, ax_t, bx_t);
estack_ax_v = res;
- estack_ax_t = REG_S64;
+ estack_ax_t = REG_U64;
next_pc += sizeof(struct binary_op);
PO;
}
{
int64_t res;
- /* Dynamic typing. */
- if (estack_ax_t != REG_S64 || estack_bx_t != REG_S64) {
+ if (!IS_INTEGER_REGISTER(estack_ax_t) || !IS_INTEGER_REGISTER(estack_bx_t)) {
ret = -EINVAL;
goto end;
}
res = ((uint64_t) estack_bx_v ^ (uint64_t) estack_ax_v);
estack_pop(stack, top, ax, bx, ax_t, bx_t);
estack_ax_v = res;
- estack_ax_t = REG_S64;
+ estack_ax_t = REG_U64;
next_pc += sizeof(struct binary_op);
PO;
}
/* Dynamic typing. */
switch (estack_ax_t) {
case REG_S64: /* Fall-through. */
+ case REG_U64:
JUMP_TO(FILTER_OP_UNARY_PLUS_S64);
case REG_DOUBLE:
JUMP_TO(FILTER_OP_UNARY_PLUS_DOUBLE);
{
/* Dynamic typing. */
switch (estack_ax_t) {
- case REG_S64:
+ case REG_S64: /* Fall-through. */
+ case REG_U64:
JUMP_TO(FILTER_OP_UNARY_MINUS_S64);
case REG_DOUBLE:
JUMP_TO(FILTER_OP_UNARY_MINUS_DOUBLE);
{
/* Dynamic typing. */
switch (estack_ax_t) {
- case REG_S64:
+ case REG_S64: /* Fall-through. */
+ case REG_U64:
JUMP_TO(FILTER_OP_UNARY_NOT_S64);
case REG_DOUBLE:
JUMP_TO(FILTER_OP_UNARY_NOT_DOUBLE);
OP(FILTER_OP_UNARY_BIT_NOT):
{
/* Dynamic typing. */
- if (estack_ax_t != REG_S64) {
+ if (!IS_INTEGER_REGISTER(estack_ax_t)) {
ret = -EINVAL;
goto end;
}
estack_ax_v = ~(uint64_t) estack_ax_v;
+ estack_ax_t = REG_U64;
next_pc += sizeof(struct unary_op);
PO;
}
OP(FILTER_OP_UNARY_NOT_S64):
{
estack_ax_v = !estack_ax_v;
+ estack_ax_t = REG_S64;
next_pc += sizeof(struct unary_op);
PO;
}
{
struct logical_op *insn = (struct logical_op *) pc;
- if (estack_ax_t != REG_S64) {
+ if (estack_ax_t != REG_S64 && estack_ax_t != REG_U64) {
ret = -EINVAL;
goto end;
}
{
struct logical_op *insn = (struct logical_op *) pc;
- if (estack_ax_t != REG_S64) {
+ if (estack_ax_t != REG_S64 && estack_ax_t != REG_U64) {
ret = -EINVAL;
goto end;
}
JUMP_TO(FILTER_OP_CAST_NOP);
case REG_DOUBLE:
JUMP_TO(FILTER_OP_CAST_DOUBLE_TO_S64);
+ case REG_U64:
+ estack_ax_t = REG_S64;
+ next_pc += sizeof(struct cast_op);
case REG_STRING: /* Fall-through */
case REG_STAR_GLOB_STRING:
ret = -EINVAL;
{
struct load_op *insn = (struct load_op *) pc;
struct field_ref *ref = (struct field_ref *) insn->data;
- struct lttng_ctx *ctx;
struct lttng_ctx_field *ctx_field;
struct lttng_ctx_value v;
dbg_printf("get context ref offset %u type dynamic\n",
ref->offset);
- ctx = rcu_dereference(session->ctx);
ctx_field = &ctx->fields[ref->offset];
ctx_field->get_value(ctx_field, &v);
estack_push(stack, top, ax, bx, ax_t, bx_t);
{
struct load_op *insn = (struct load_op *) pc;
struct field_ref *ref = (struct field_ref *) insn->data;
- struct lttng_ctx *ctx;
struct lttng_ctx_field *ctx_field;
struct lttng_ctx_value v;
dbg_printf("get context ref offset %u type string\n",
ref->offset);
- ctx = rcu_dereference(session->ctx);
ctx_field = &ctx->fields[ref->offset];
ctx_field->get_value(ctx_field, &v);
estack_push(stack, top, ax, bx, ax_t, bx_t);
{
struct load_op *insn = (struct load_op *) pc;
struct field_ref *ref = (struct field_ref *) insn->data;
- struct lttng_ctx *ctx;
struct lttng_ctx_field *ctx_field;
struct lttng_ctx_value v;
dbg_printf("get context ref offset %u type s64\n",
ref->offset);
- ctx = rcu_dereference(session->ctx);
ctx_field = &ctx->fields[ref->offset];
ctx_field->get_value(ctx_field, &v);
estack_push(stack, top, ax, bx, ax_t, bx_t);
{
struct load_op *insn = (struct load_op *) pc;
struct field_ref *ref = (struct field_ref *) insn->data;
- struct lttng_ctx *ctx;
struct lttng_ctx_field *ctx_field;
struct lttng_ctx_value v;
dbg_printf("get context ref offset %u type double\n",
ref->offset);
- ctx = rcu_dereference(session->ctx);
ctx_field = &ctx->fields[ref->offset];
ctx_field->get_value(ctx_field, &v);
estack_push(stack, top, ax, bx, ax_t, bx_t);
struct get_index_u16 *index = (struct get_index_u16 *) insn->data;
dbg_printf("op get index u16\n");
- ret = dynamic_get_index(session, bytecode, index->index, estack_ax(stack, top));
+ ret = dynamic_get_index(ctx, bytecode, index->index, estack_ax(stack, top));
if (ret)
goto end;
estack_ax_v = estack_ax(stack, top)->u.v;
struct get_index_u64 *index = (struct get_index_u64 *) insn->data;
dbg_printf("op get index u64\n");
- ret = dynamic_get_index(session, bytecode, index->index, estack_ax(stack, top));
+ ret = dynamic_get_index(ctx, bytecode, index->index, estack_ax(stack, top));
if (ret)
goto end;
estack_ax_v = estack_ax(stack, top)->u.v;
dbg_printf("op load field u8\n");
estack_ax_v = *(uint8_t *) estack_ax(stack, top)->u.ptr.ptr;
- estack_ax_t = REG_S64;
+ estack_ax_t = REG_U64;
next_pc += sizeof(struct load_op);
PO;
}
dbg_printf("op load field u16\n");
estack_ax_v = *(uint16_t *) estack_ax(stack, top)->u.ptr.ptr;
- estack_ax_t = REG_S64;
+ estack_ax_t = REG_U64;
next_pc += sizeof(struct load_op);
PO;
}
dbg_printf("op load field u32\n");
estack_ax_v = *(uint32_t *) estack_ax(stack, top)->u.ptr.ptr;
- estack_ax_t = REG_S64;
+ estack_ax_t = REG_U64;
next_pc += sizeof(struct load_op);
PO;
}
dbg_printf("op load field u64\n");
estack_ax_v = *(uint64_t *) estack_ax(stack, top)->u.ptr.ptr;
- estack_ax_t = REG_S64;
+ estack_ax_t = REG_U64;
next_pc += sizeof(struct load_op);
PO;
}