]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - tools/testing/selftests/bpf/progs/test_mmap.c
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2019 Facebook
6 #include "bpf_helpers.h"
8 char _license
[] SEC("license") = "GPL";
11 __uint(type
, BPF_MAP_TYPE_ARRAY
);
12 __uint(max_entries
, 512 * 4); /* at least 4 pages of data */
13 __uint(map_flags
, BPF_F_MMAPABLE
);
16 } data_map
SEC(".maps");
18 static volatile __u64 in_val
;
19 static volatile __u64 out_val
;
21 SEC("raw_tracepoint/sys_enter")
22 int test_mmap(void *ctx
)
24 int zero
= 0, one
= 1, two
= 2, far
= 1500;
29 /* data_map[2] = in_val; */
30 bpf_map_update_elem(&data_map
, &two
, (const void *)&in_val
, 0);
32 /* data_map[1] = data_map[0] * 2; */
33 p
= bpf_map_lookup_elem(&data_map
, &zero
);
36 bpf_map_update_elem(&data_map
, &one
, &val
, 0);
39 /* data_map[far] = in_val * 3; */
41 bpf_map_update_elem(&data_map
, &far
, &val
, 0);