一些嵌入式开发板/设备默认没有开eBPF相关的选项,自己编译内核时,想要开启之,一般常规方法就是make menuconfig来一个个开,这样做的好处是,相关的依赖内核选项也会同时开启,内核代码仓库中有一个config工具脚本,可以让我们命令行方式免交互直接开启,但这种方法没有开启相关的依赖项。
为了方便一次性开启所有相关的内核选项,我记录并使用config命令开启并测试了所有相关选项。测试环境为5.10的ARM64开发板,理论5.15也是通用的。RISC-V现在有了debian与ubuntu的官方镜像,22.04.3的Ubuntu现在内核版本为5.19,我测试官方多数的内核选项都开启了,如果手上的RISC-V设备没有开启,可以参考下面的一把梭的命令,与ARM64一样的使用。rk3588的SOC提供的内核代码是支持交叉编译的,默认使用GCC编译,在开启eBPF与生成BTF这件事上,其实不用考虑切换到LLVM,现在的GCC提供了CTF技术支持,生成内核的vmlinux BTF文件一点问题也没有。
下面给出经过我测试后没有问题的脚本命令:
scripts/config --enable CONFIG_BPF_LSMscripts/config --enable CONFIG_KGDBscripts/config --enable CONFIG_FUNCTION_PROFILERscripts/config --enable CONFIG_FTRACE_SYSCALLSscripts/config --enable CONFIG_BPF_KPROBE_OVERRIDEscripts/config --enable CONFIG_TRACE_EVENT_INJECTscripts/config --enable CONFIG_HIST_TRIGGERSscripts/config --enable CONFIG_SCHED_TRACERscripts/config --enable CONFIG_IRQSOFF_TRACERscripts/config --enable CONFIG_FUNCTION_TRACERscripts/config --enable CONFIG_STACK_TRACERscripts/config --disable CONFIG_MAGIC_SYSRQscripts/config --enable CONFIG_IKHEADERSscripts/config --enable CONFIG_DEBUG_INFO_BTFscripts/config --enable CONFIG_DEBUG_INFOscripts/config --disable DEBUG_INFO_REDUCEDscripts/config --disable DEBUG_INFO_COMPRESSEDscripts/config --disable DEBUG_INFO_SPLITscripts/config --disable DEBUG_INFO_DWARF4scripts/config --disable GDB_SCRIPTSscripts/config --disable DEBUG_EFIscripts/config --disable ARM64_RELOC_TESTscripts/config --enable CONFIG_BPF_SYSCALLscripts/config --enable CONFIG_BPF_JITscripts/config --enable CONFIG_HAVE_BPF_JITscripts/config --enable CONFIG_HAVE_EBPF_JITscripts/config --enable CONFIG_MODULESscripts/config --enable CONFIG_BPFscripts/config --enable CONFIG_BPF_EVENTSscripts/config --enable CONFIG_PERF_EVENTSscripts/config --enable CONFIG_HAVE_PERF_EVENTSscripts/config --enable CONFIG_PROFILINGscripts/config --enable CONFIG_BPF_UNPRIV_DEFAULT_OFFscripts/config --enable CONFIG_CGROUP_BPFscripts/config --enable CONFIG_BPFILTERscripts/config --module CONFIG_BPFILTER_UMHscripts/config --module CONFIG_NET_CLS_BPFscripts/config --module CONFIG_NET_ACT_BPFscripts/config --enable CONFIG_BPF_STREAM_PARSERscripts/config --enable CONFIG_LWTUNNEL_BPFscripts/config --module CONFIG_NETFILTER_XT_MATCH_BPFscripts/config --enable CONFIG_IPV6_SEG6_BPFscripts/config --enable CONFIG_KPROBE_EVENTSscripts/config --enable CONFIG_KPROBESscripts/config --enable CONFIG_HAVE_KPROBESscripts/config --enable CONFIG_HAVE_REGS_AND_STACK_ACCESS_APIscripts/config --enable CONFIG_KPROBES_ON_FTRACEscripts/config --enable CONFIG_FPROBEscripts/config --enable CONFIG_BPF_KPROBE_OVERRIDEscripts/config --enable CONFIG_UPROBE_EVENTSscripts/config --enable CONFIG_ARCH_SUPPORTS_UPROBESscripts/config --enable CONFIG_UPROBESscripts/config --enable CONFIG_MMUscripts/config --enable CONFIG_TRACEPOINTSscripts/config --enable CONFIG_HAVE_SYSCALL_TRACEPOINTSscripts/config --enable CONFIG_BPF_LSMscripts/config --enable CONFIG_BPF_LIRC_MODE2scripts/config --module CONFIG_VSOCKETSscripts/config --module CONFIG_VSOCKETS_DIAGscripts/config --enable CONFIG_VHOST_VSOCKscripts/config --enable CONFIG_VHOST_NETscripts/config --enable CONFIG_VSOCKMONscripts/config --disable SERIAL_CONEXANT_DIGICOLORscripts/config --disable SERIAL_SPRDscripts/config --disable CONFIG_KPROBES_SANITY_TESTscripts/config --enable KGDB_HONOUR_BLOCKLISTscripts/config --enable BPF_JIT_ALWAYS_ONscripts/config --disable CONFIG_TRACEFS_DISABLE_AUTOMOUNTscripts/config --enable CONFIG_KALLSYMS_ALL
上面的config命令开启了eBPF相关的内核选项,也同时开启了虚拟化、调试相关以及相关依赖等选项,只需要执行一下就开启了。
如何使用?首先弄到相应设备的内核代码,将当前设备/boot/config-xxx复制到内核代码保存为.config文件,然后复制执行上面的命令,可以全部复制到终端窗口一次性粘贴后回车,整个过程只需要5秒钟就可以!接着就是编译与刷机测试效果。
推荐站内搜索:最好用的开发软件、免费开源系统、渗透测试工具云盘下载、最新渗透测试资料、最新黑客工具下载……




还没有评论,来说两句吧...