Skip to content

Commit 51a54de

Browse files
committed
WIP: bpf, arm: Fix up bpf_user_pt_regs_t
This type by default uses struct pt_regs and embeds 'unsigned long' elems which don't play nicely between 32-bit kernel and 64-bit BPF space. Try creating a custom version for arm32. Also hoping to fix following test error: tester_init:PASS:tester_log_buf 0 nsec process_subtest:PASS:obj_open_mem 0 nsec process_subtest:PASS:specs_alloc 0 nsec run_subtest:PASS:obj_open_mem 0 nsec libbpf: prog 'kprobe_resolved_ctx': BPF program load failed: -EINVAL libbpf: prog 'kprobe_resolved_ctx': failed to load: -EINVAL libbpf: failed to load object 'test_global_func_ctx_args' run_subtest:FAIL:unexpected_load_failure unexpected error: -22 (errno 22) VERIFIER LOG: ============= arg#0 reference type('UNKNOWN ') size cannot be determined: -22 0: R1=ctx() R10=fp0 ; return kprobe_struct_ctx_subprog(ctx); @ test_global_func_ctx_args.c:57 0: (85) call pc+1 invalid bpf_context access off=71 size=1 is_valid_access=kprobe_prog_is_valid_access Caller passes invalid args into func#1 ('kprobe_struct_ctx_subprog') processed 1 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0 ============= kernel-patches#444/20 test_global_funcs/kprobe_resolved_ctx:FAIL Signed-off-by: Tony Ambardar <tony.ambardar@gmail.com>
1 parent 06f7d8f commit 51a54de

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

arch/arm/include/asm/perf_event.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
#ifndef __ARM_PERF_EVENT_H__
99
#define __ARM_PERF_EVENT_H__
1010

11+
#ifdef CONFIG_PERF_EVENTS
12+
#define perf_arch_bpf_user_pt_regs(regs) (struct pt_regs___bpf *)regs
13+
#endif
14+
1115
#define perf_arch_fetch_caller_regs(regs, __ip) { \
1216
(regs)->ARM_pc = (__ip); \
1317
frame_pointer((regs)) = (unsigned long) __builtin_frame_address(0); \
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2+
#ifndef _UAPI__ASM_BPF_PERF_EVENT_H__
3+
#define _UAPI__ASM_BPF_PERF_EVENT_H__
4+
5+
struct pt_regs___bpf {
6+
unsigned int uregs[18];
7+
};
8+
9+
typedef struct pt_regs___bpf bpf_user_pt_regs_t;
10+
11+
#endif /* _UAPI__ASM_BPF_PERF_EVENT_H__ */

tools/include/uapi/asm/bpf_perf_event.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#if defined(__aarch64__)
22
#include "../../arch/arm64/include/uapi/asm/bpf_perf_event.h"
3+
#elif defined(__arm__)
4+
#include "../../arch/arm/include/uapi/asm/bpf_perf_event.h"
35
#elif defined(__arc__)
46
#include "../../arch/arc/include/uapi/asm/bpf_perf_event.h"
57
#elif defined(__s390__)

0 commit comments

Comments
 (0)