Skip to content

Commit

Permalink
fix optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcacheux committed Jan 2, 2025
1 parent 797547b commit 9aaeebb
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions pkg/security/ebpf/c/include/constants/fentry_macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,20 @@ typedef unsigned long long ctx_t;
u64 __attribute__((always_inline)) CTX_PARMRET(ctx_t *ctx) {
u64 argc;
LOAD_CONSTANT("fentry_func_argc", argc);

u64 ret = 0;
#define CTX_PARMRET_CASE(n) case n: asm("%0 = *(u64 *)(%1 +%2)" : "=r"(ret) : "r"(ctx), "i"(n * 8)); break;
switch (argc) {
case 0:
return ctx[0];
case 1:
return ctx[1];
case 2:
return ctx[2];
case 3:
return ctx[3];
case 4:
return ctx[4];
case 5:
return ctx[5];
case 6:
return ctx[6];
CTX_PARMRET_CASE(0)
CTX_PARMRET_CASE(1)
CTX_PARMRET_CASE(2)
CTX_PARMRET_CASE(3)
CTX_PARMRET_CASE(4)
CTX_PARMRET_CASE(5)
CTX_PARMRET_CASE(6)
}
return 0;
return ret;
#undef CTX_PARMRET_CASE
}

#define SYSCALL_PARMRET(ctx) CTX_PARMRET(ctx)
Expand Down

0 comments on commit 9aaeebb

Please sign in to comment.