|
24 | 24 | #elif defined(__TARGET_ARCH_sparc)
|
25 | 25 | #define bpf_target_sparc
|
26 | 26 | #define bpf_target_defined
|
| 27 | +#elif defined(__TARGET_ARCH_riscv) |
| 28 | + #define bpf_target_riscv |
| 29 | + #define bpf_target_defined |
27 | 30 | #else
|
28 | 31 |
|
29 | 32 | /* Fall back to what the compiler says */
|
|
48 | 51 | #elif defined(__sparc__)
|
49 | 52 | #define bpf_target_sparc
|
50 | 53 | #define bpf_target_defined
|
| 54 | +#elif defined(__riscv) && __riscv_xlen == 64 |
| 55 | + #define bpf_target_riscv |
| 56 | + #define bpf_target_defined |
51 | 57 | #endif /* no compiler target */
|
52 | 58 |
|
53 | 59 | #endif
|
@@ -288,6 +294,32 @@ struct pt_regs;
|
288 | 294 | #define PT_REGS_IP_CORE(x) BPF_CORE_READ((x), pc)
|
289 | 295 | #endif
|
290 | 296 |
|
| 297 | +#elif defined(bpf_target_riscv) |
| 298 | + |
| 299 | +struct pt_regs; |
| 300 | +#define PT_REGS_RV const volatile struct user_regs_struct |
| 301 | +#define PT_REGS_PARM1(x) (((PT_REGS_RV *)(x))->a0) |
| 302 | +#define PT_REGS_PARM2(x) (((PT_REGS_RV *)(x))->a1) |
| 303 | +#define PT_REGS_PARM3(x) (((PT_REGS_RV *)(x))->a2) |
| 304 | +#define PT_REGS_PARM4(x) (((PT_REGS_RV *)(x))->a3) |
| 305 | +#define PT_REGS_PARM5(x) (((PT_REGS_RV *)(x))->a4) |
| 306 | +#define PT_REGS_RET(x) (((PT_REGS_RV *)(x))->ra) |
| 307 | +#define PT_REGS_FP(x) (((PT_REGS_RV *)(x))->s5) |
| 308 | +#define PT_REGS_RC(x) (((PT_REGS_RV *)(x))->a5) |
| 309 | +#define PT_REGS_SP(x) (((PT_REGS_RV *)(x))->sp) |
| 310 | +#define PT_REGS_IP(x) (((PT_REGS_RV *)(x))->epc) |
| 311 | + |
| 312 | +#define PT_REGS_PARM1_CORE(x) BPF_CORE_READ((PT_REGS_RV *)(x), a0) |
| 313 | +#define PT_REGS_PARM2_CORE(x) BPF_CORE_READ((PT_REGS_RV *)(x), a1) |
| 314 | +#define PT_REGS_PARM3_CORE(x) BPF_CORE_READ((PT_REGS_RV *)(x), a2) |
| 315 | +#define PT_REGS_PARM4_CORE(x) BPF_CORE_READ((PT_REGS_RV *)(x), a3) |
| 316 | +#define PT_REGS_PARM5_CORE(x) BPF_CORE_READ((PT_REGS_RV *)(x), a4) |
| 317 | +#define PT_REGS_RET_CORE(x) BPF_CORE_READ((PT_REGS_RV *)(x), ra) |
| 318 | +#define PT_REGS_FP_CORE(x) BPF_CORE_READ((PT_REGS_RV *)(x), fp) |
| 319 | +#define PT_REGS_RC_CORE(x) BPF_CORE_READ((PT_REGS_RV *)(x), a5) |
| 320 | +#define PT_REGS_SP_CORE(x) BPF_CORE_READ((PT_REGS_RV *)(x), sp) |
| 321 | +#define PT_REGS_IP_CORE(x) BPF_CORE_READ((PT_REGS_RV *)(x), epc) |
| 322 | + |
291 | 323 | #endif
|
292 | 324 |
|
293 | 325 | #if defined(bpf_target_powerpc)
|
|
0 commit comments