aboutgitcodelistschat:MatrixIRC
path: root/cooker/emit.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2023-06-14 07:25:52 +0200
committerStefano Brivio <sbrivio@redhat.com>2023-06-14 07:25:52 +0200
commit00614c5e6702db8ac3f18a9e193c7a8382f16e6b (patch)
treeb8275d1060e994e18d7fbfead0244629752cb555 /cooker/emit.c
parent8bc937c1442d212926dadb6227b759966bc13925 (diff)
downloadseitan-00614c5e6702db8ac3f18a9e193c7a8382f16e6b.tar
seitan-00614c5e6702db8ac3f18a9e193c7a8382f16e6b.tar.gz
seitan-00614c5e6702db8ac3f18a9e193c7a8382f16e6b.tar.bz2
seitan-00614c5e6702db8ac3f18a9e193c7a8382f16e6b.tar.lz
seitan-00614c5e6702db8ac3f18a9e193c7a8382f16e6b.tar.xz
seitan-00614c5e6702db8ac3f18a9e193c7a8382f16e6b.tar.zst
seitan-00614c5e6702db8ac3f18a9e193c7a8382f16e6b.zip
cooker: Support for read(), OP_STORE, field-based filters
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'cooker/emit.c')
-rw-r--r--cooker/emit.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/cooker/emit.c b/cooker/emit.c
index 57533a1..a257398 100644
--- a/cooker/emit.c
+++ b/cooker/emit.c
@@ -164,6 +164,24 @@ void emit_load(struct gluten_ctx *g, struct gluten_offset dst,
die("Too many instructions");
}
+void emit_store(struct gluten_ctx *g, struct gluten_offset dst,
+ struct gluten_offset src, struct gluten_offset count)
+{
+ struct op *op = (struct op *)gluten_ptr(&g->g, g->ip);
+ struct op_store *store = &op->op.store;
+
+ op->type = OP_STORE;
+
+ store->dst = dst;
+ store->src = src;
+ store->count = count;
+
+ debug(" %i: OP_STORE: #%i", g->ip.offset);
+
+ if (++g->ip.offset > INST_MAX)
+ die("Too many instructions");
+}
+
/**
* emit_resolved() - Emit OP_RESOLVEFD instruction: resolve file descriptor with path
* @g: gluten context
@@ -540,7 +558,7 @@ static void gluten_link(struct gluten_ctx *g, enum jump_type type,
void emit_bpf_arg(int index, enum type type, union value v, union value mask,
enum op_cmp_type cmp)
{
- struct bpf_arg bpf;
+ struct bpf_field bpf;
/* gluten uses the comparison to skip to the next match, the BPF filter
* uses it to notify instead.
@@ -550,6 +568,8 @@ void emit_bpf_arg(int index, enum type type, union value v, union value mask,
else
bpf.cmp = (cmp == CMP_EQ) ? NE : EQ;
+ bpf.arg = index;
+
if (TYPE_IS_64BIT(type)) {
bpf.value.v64 = v.v_num;
bpf.op2.v64 = mask.v_num;
@@ -560,7 +580,7 @@ void emit_bpf_arg(int index, enum type type, union value v, union value mask,
bpf.type = BPF_U32;
}
- filter_add_arg(index, bpf);
+ filter_add_check(&bpf);
}
void link_block(struct gluten_ctx *g)