Skip to content

Commit 10ebe83

Browse files
Alexei Starovoitovanakryiko
authored andcommitted
libbpf, selftests/bpf: Adjust libbpf, bpftool, selftests to match LLVM
The selftests use to tell LLVM about special pointers. For LLVM there is nothing "arena" about them. They are simply pointers in a different address space. Hence LLVM diff llvm/llvm-project#85161 renamed: . macro __BPF_FEATURE_ARENA_CAST -> __BPF_FEATURE_ADDR_SPACE_CAST . global variables in __attribute__((address_space(N))) are now placed in section named ".addr_space.N" instead of ".arena.N". Adjust libbpf, bpftool, and selftests to match LLVM. Signed-off-by: Alexei Starovoitov <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Acked-by: Stanislav Fomichev <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent ee498a3 commit 10ebe83

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

tools/bpf/bpftool/gen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ static bool get_datasec_ident(const char *sec_name, char *buf, size_t buf_sz)
121121
int i, n;
122122

123123
/* recognize hard coded LLVM section name */
124-
if (strcmp(sec_name, ".arena.1") == 0) {
124+
if (strcmp(sec_name, ".addr_space.1") == 0) {
125125
/* this is the name to use in skeleton */
126126
snprintf(buf, buf_sz, "arena");
127127
return true;

tools/lib/bpf/libbpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ struct bpf_struct_ops {
498498
#define KSYMS_SEC ".ksyms"
499499
#define STRUCT_OPS_SEC ".struct_ops"
500500
#define STRUCT_OPS_LINK_SEC ".struct_ops.link"
501-
#define ARENA_SEC ".arena.1"
501+
#define ARENA_SEC ".addr_space.1"
502502

503503
enum libbpf_map_type {
504504
LIBBPF_MAP_UNSPEC,

tools/testing/selftests/bpf/bpf_arena_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*/
3333
#endif
3434

35-
#if defined(__BPF_FEATURE_ARENA_CAST) && !defined(BPF_ARENA_FORCE_ASM)
35+
#if defined(__BPF_FEATURE_ADDR_SPACE_CAST) && !defined(BPF_ARENA_FORCE_ASM)
3636
#define __arena __attribute__((address_space(1)))
3737
#define cast_kern(ptr) /* nop for bpf prog. emitted by LLVM */
3838
#define cast_user(ptr) /* nop for bpf prog. emitted by LLVM */

tools/testing/selftests/bpf/progs/arena_htab.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ int zero = 0;
2222
SEC("syscall")
2323
int arena_htab_llvm(void *ctx)
2424
{
25-
#if defined(__BPF_FEATURE_ARENA_CAST) || defined(BPF_ARENA_FORCE_ASM)
25+
#if defined(__BPF_FEATURE_ADDR_SPACE_CAST) || defined(BPF_ARENA_FORCE_ASM)
2626
struct htab __arena *htab;
2727
__u64 i;
2828

tools/testing/selftests/bpf/progs/arena_list.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,21 @@ int list_sum;
3030
int cnt;
3131
bool skip = false;
3232

33-
#ifdef __BPF_FEATURE_ARENA_CAST
33+
#ifdef __BPF_FEATURE_ADDR_SPACE_CAST
3434
long __arena arena_sum;
3535
int __arena test_val = 1;
3636
struct arena_list_head __arena global_head;
3737
#else
38-
long arena_sum SEC(".arena.1");
39-
int test_val SEC(".arena.1");
38+
long arena_sum SEC(".addr_space.1");
39+
int test_val SEC(".addr_space.1");
4040
#endif
4141

4242
int zero;
4343

4444
SEC("syscall")
4545
int arena_list_add(void *ctx)
4646
{
47-
#ifdef __BPF_FEATURE_ARENA_CAST
47+
#ifdef __BPF_FEATURE_ADDR_SPACE_CAST
4848
__u64 i;
4949

5050
list_head = &global_head;
@@ -66,7 +66,7 @@ int arena_list_add(void *ctx)
6666
SEC("syscall")
6767
int arena_list_del(void *ctx)
6868
{
69-
#ifdef __BPF_FEATURE_ARENA_CAST
69+
#ifdef __BPF_FEATURE_ADDR_SPACE_CAST
7070
struct elem __arena *n;
7171
int sum = 0;
7272

tools/testing/selftests/bpf/progs/verifier_arena.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ SEC("syscall")
1919
__success __retval(0)
2020
int basic_alloc1(void *ctx)
2121
{
22-
#if defined(__BPF_FEATURE_ARENA_CAST)
22+
#if defined(__BPF_FEATURE_ADDR_SPACE_CAST)
2323
volatile int __arena *page1, *page2, *no_page, *page3;
2424

2525
page1 = bpf_arena_alloc_pages(&arena, NULL, 1, NUMA_NO_NODE, 0);
@@ -58,7 +58,7 @@ SEC("syscall")
5858
__success __retval(0)
5959
int basic_alloc2(void *ctx)
6060
{
61-
#if defined(__BPF_FEATURE_ARENA_CAST)
61+
#if defined(__BPF_FEATURE_ADDR_SPACE_CAST)
6262
volatile char __arena *page1, *page2, *page3, *page4;
6363

6464
page1 = bpf_arena_alloc_pages(&arena, NULL, 2, NUMA_NO_NODE, 0);

0 commit comments

Comments
 (0)