headers/vmlinux: Add arch specific vmlinux.h defines

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
This commit is contained in:
Jesper Dangaard Brouer
2021-06-01 16:12:43 +02:00
parent f34f8d5787
commit 064bc31354
4 changed files with 52 additions and 8 deletions

View File

@@ -0,0 +1,29 @@
#ifndef __VMLINUX_ARCH_X86_H__
#define __VMLINUX_ARCH_X86_H__
struct pt_regs {
long unsigned int r15;
long unsigned int r14;
long unsigned int r13;
long unsigned int r12;
long unsigned int bp;
long unsigned int bx;
long unsigned int r11;
long unsigned int r10;
long unsigned int r9;
long unsigned int r8;
long unsigned int ax;
long unsigned int cx;
long unsigned int dx;
long unsigned int si;
long unsigned int di;
long unsigned int orig_ax;
long unsigned int ip;
long unsigned int cs;
long unsigned int flags;
long unsigned int sp;
long unsigned int ss;
};
#endif /* __VMLINUX_ARCH_X86_H__ */

View File

@@ -9,10 +9,6 @@
*/
#ifndef __VMLINUX_H__
#define __VMLINUX_H__
/*
* Notice: Defining __VMLINUX_H__ (or __KERNEL__) cause <bpf/bpf_tracing.h>
* header file to define architecture specific PT_REGS_PARM's.
*/
#include <linux/types.h> /* Needed for __uNN in vmlinux/vmlinux_types.h */
@@ -24,6 +20,22 @@
#include "vmlinux/vmlinux_common.h"
#include "vmlinux/vmlinux_net.h"
/*
* Notice: Defining __VMLINUX_H__ (or __KERNEL__) cause <bpf/bpf_tracing.h>
* 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
#endif

View File

@@ -1,9 +1,5 @@
# SPDX-License-Identifier: GPL-2.0
# The BPF tracing header (/usr/include/bpf/bpf_tracing.h) need to know
# CPU architecture due to PT_REGS_PARM resolution of ASM call convention
ARCH := $(shell uname -m | sed 's/x86_64/x86/' | sed 's/aarch64/arm64/' | sed 's/ppc64le/powerpc/' | sed 's/mips.*/mips/')
USER_TARGETS := ktrace01
BPF_TARGETS := ktrace01_kern

View File

@@ -33,6 +33,13 @@ ifeq ($(SYSTEM_LIBBPF),n)
LIBBPF_SOURCES := $(wildcard $(LIBBPF_DIR)/src/*.[ch])
endif
# The BPF tracing header (/usr/include/bpf/bpf_tracing.h) need to know
# CPU architecture due to PT_REGS_PARM resolution of ASM call convention
#
ARCH := $(shell uname -m | sed 's/x86_64/x86/' | sed 's/aarch64/arm64/' | sed 's/ppc64le/powerpc/' | sed 's/mips.*/mips/')
BPF_CFLAGS += -D__TARGET_ARCH_$(ARCH)
# BPF-prog kern and userspace shares struct via header file:
KERN_USER_H ?= $(wildcard common_kern_user.h)