diff --git a/headers/vmlinux/arch/arm64/vmlinux.h b/headers/vmlinux/arch/arm64/vmlinux.h new file mode 100644 index 0000000..b7958b3 --- /dev/null +++ b/headers/vmlinux/arch/arm64/vmlinux.h @@ -0,0 +1,38 @@ +#ifndef __VMLINUX_ARCH_ARM64_H__ +#define __VMLINUX_ARCH_ARM64_H__ + +#ifdef __BPF_TRACING_H__ +/* Expected include */ +#ifndef bpf_target_defined +#warning "Tracing need __TARGET_ARCH_arm64 defined" +#endif +#endif /* __BPF_TRACING_H__ */ + +struct user_pt_regs { + __u64 regs[31]; + __u64 sp; + __u64 pc; + __u64 pstate; +}; + +struct pt_regs { + union { + struct user_pt_regs user_regs; + struct { + u64 regs[31]; + u64 sp; + u64 pc; + u64 pstate; + }; + }; + u64 orig_x0; + s32 syscallno; + u32 unused2; + u64 orig_addr_limit; + u64 pmr_save; + u64 stackframe[2]; + u64 lockdep_hardirqs; + u64 exit_rcu; +}; + +#endif /* __VMLINUX_ARCH_ARM64_H__ */ diff --git a/headers/vmlinux/arch/powerpc/vmlinux.h b/headers/vmlinux/arch/powerpc/vmlinux.h new file mode 100644 index 0000000..3ae4acc --- /dev/null +++ b/headers/vmlinux/arch/powerpc/vmlinux.h @@ -0,0 +1,55 @@ +#ifndef __VMLINUX_ARCH_POWERPC_H__ +#define __VMLINUX_ARCH_POWERPC_H__ + +#ifdef __BPF_TRACING_H__ +/* Expected include */ +#ifndef bpf_target_defined +#warning "Tracing need __TARGET_ARCH_powerpc defined" +#endif +#endif /* __BPF_TRACING_H__ */ + +struct user_pt_regs { + long unsigned int gpr[32]; + long unsigned int nip; + long unsigned int msr; + long unsigned int orig_gpr3; + long unsigned int ctr; + long unsigned int link; + long unsigned int xer; + long unsigned int ccr; + long unsigned int softe; + long unsigned int trap; + long unsigned int dar; + long unsigned int dsisr; + long unsigned int result; +}; + +struct pt_regs { + union { + struct user_pt_regs user_regs; + struct { + long unsigned int gpr[32]; + long unsigned int nip; + long unsigned int msr; + long unsigned int orig_gpr3; + long unsigned int ctr; + long unsigned int link; + long unsigned int xer; + long unsigned int ccr; + long unsigned int softe; + long unsigned int trap; + long unsigned int dar; + long unsigned int dsisr; + long unsigned int result; + }; + }; + union { + struct { + long unsigned int ppr; + long unsigned int kuap; + }; + long unsigned int __pad[2]; + }; +}; + +#endif /* __VMLINUX_ARCH_POWERPC_H__ */ diff --git a/headers/vmlinux/arch/x86/vmlinux.h b/headers/vmlinux/arch/x86/vmlinux.h index d02ec90..1f91f08 100644 --- a/headers/vmlinux/arch/x86/vmlinux.h +++ b/headers/vmlinux/arch/x86/vmlinux.h @@ -1,6 +1,12 @@ #ifndef __VMLINUX_ARCH_X86_H__ #define __VMLINUX_ARCH_X86_H__ +#ifdef __BPF_TRACING_H__ +/* Expected include */ +#ifndef bpf_target_defined +#warning "Tracing need __TARGET_ARCH_x86 defined" +#endif +#endif /* __BPF_TRACING_H__ */ struct pt_regs { long unsigned int r15; diff --git a/headers/vmlinux_local.h b/headers/vmlinux_local.h index 53a63e0..a7de6c3 100644 --- a/headers/vmlinux_local.h +++ b/headers/vmlinux_local.h @@ -18,23 +18,11 @@ #include "vmlinux/vmlinux_types.h" #include "vmlinux/vmlinux_common.h" + +#include "vmlinux/vmlinux_arch.h" + #include "vmlinux/vmlinux_net.h" -/* - * Notice: Defining __VMLINUX_H__ (or __KERNEL__) cause - * header file to define architecture specific PT_REGS_PARM's. - * - * When using '-target bpf' the fallback mechanism doesn't detect right arch - * via compiler defines. - * - * Makefile system in lib/common.mk detect ARCH and defines the - * defines __TARGET_ARCH_$(ARCH) matched on below. - */ -#if defined(__TARGET_ARCH_x86) -#include "vmlinux/arch/x86/vmlinux.h" -#else -#warning "Makefile for BPF-tracing on this arch: not supported yet" -#endif #ifndef BPF_NO_PRESERVE_ACCESS_INDEX #pragma clang attribute pop diff --git a/ktrace-CO-RE/Makefile b/ktrace-CO-RE/Makefile index 3c69d6c..f7e101f 100644 --- a/ktrace-CO-RE/Makefile +++ b/ktrace-CO-RE/Makefile @@ -7,4 +7,5 @@ LIB_DIR = ../lib include $(LIB_DIR)/common.mk -BPF_CFLAGS += -D__TARGET_ARCH_$(ARCH) +# The __TARGET_ARCH_xxx is defined in lib/common.mk +# BPF_CFLAGS += -D__TARGET_ARCH_$(ARCH)