@@ -27,3 +27,9 @@ int qemu_ubpf_prepare(UbpfState *u_ebpf, char *code_path)
{
return 0;
}
+
+uint64_t qemu_ubpf_run_once(UbpfState *u_ebpf, void *target,
+ size_t target_len)
+{
+ return 0;
+}
@@ -199,3 +199,19 @@ int qemu_ubpf_prepare(UbpfState *u_ebpf, char *code_path)
return 0;
}
+
+uint64_t qemu_ubpf_run_once(UbpfState *u_ebpf, void *target,
+ size_t target_len)
+{
+ uint64_t result;
+
+ if (u_ebpf->jit) {
+ result = u_ebpf->fn(target, target_len);
+ } else {
+ if (ubpf_exec(u_ebpf->vm, target, target_len, &result) < 0) {
+ result = UINT64_MAX;
+ }
+ }
+
+ return result;
+}
@@ -38,5 +38,7 @@ bool qemu_ubpf_read_code(UbpfState *u_ebpf, char *path);
bool qemu_ubpf_read_target(UbpfState *u_ebpf, char *path);
void qemu_ubpf_init_jit(UbpfState *u_ebpf, bool jit);
int qemu_ubpf_prepare(UbpfState *u_ebpf, char *code_path);
+uint64_t qemu_ubpf_run_once(UbpfState *u_ebpf, void *target,
+ size_t target_len);
#endif /* QEMU_UBPF_H */
Before running this function, we need to ensure that the userspace ebpf program has been loaded correctly. Signed-off-by: Zhang Chen <chen.zhang@intel.com> --- ebpf/ubpf-stub.c | 6 ++++++ ebpf/ubpf.c | 16 ++++++++++++++++ ebpf/ubpf.h | 2 ++ 3 files changed, 24 insertions(+)