Skip to content

Commit

Permalink
feat: add support for s360x, ppc64le and riscv
Browse files Browse the repository at this point in the history
Log:
  • Loading branch information
hillwoodroc committed Jan 1, 2025
1 parent 1055a97 commit d385855
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/kernelmod/arg_extractor.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
#include <uapi/linux/ptrace.h>

Check warning on line 10 in src/kernelmod/arg_extractor.c

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <uapi/linux/ptrace.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#endif

#if defined(__powerpc64__)
#ifndef CONFIG_PPC64LE
#define CONFIG_PPC64LE 1
#endif
#endif

unsigned long get_arg(struct pt_regs* regs, int n)
{
/*
Expand Down Expand Up @@ -50,6 +56,34 @@ unsigned long get_arg(struct pt_regs* regs, int n)
case 3: return regs->regs[2];
case 4: return regs->regs[3];

#elif defined(CONFIG_S390X)

/* s390x argument registers: r2, r3, r4, r5 */
case 1: return regs->gprs[2];
case 2: return regs->gprs[3];
case 3: return regs->gprs[4];
case 4: return regs->gprs[5];

#elif defined(CONFIG_PPC64LE)

/* PPC64LE argument registers: r3, r4, r5, r6, r7, r8, r9, r10 */
case 1: return regs->gpr[3];
case 2: return regs->gpr[4];
case 3: return regs->gpr[5];
case 4: return regs->gpr[6];

#elif defined(CONFIG_RISCV)

/* RISC-V argument registers: a0, a1, a2, a3, a4, a5, a6, a7 */
case 1: return regs->a0;
case 2: return regs->a1;
case 3: return regs->a2;
case 4: return regs->a3;
case 5: return regs->a4;
case 6: return regs->a5;
case 7: return regs->a6;
case 8: return regs->a7;

#else
#error "The current architecture is not supported."

Expand Down

0 comments on commit d385855

Please sign in to comment.