~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/bpf/progs/arena_htab.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */
  3 #define BPF_NO_KFUNC_PROTOTYPES
  4 #include <vmlinux.h>
  5 #include <bpf/bpf_helpers.h>
  6 #include <bpf/bpf_tracing.h>
  7 #include <bpf/bpf_core_read.h>
  8 #include "bpf_experimental.h"
  9 
 10 struct {
 11         __uint(type, BPF_MAP_TYPE_ARENA);
 12         __uint(map_flags, BPF_F_MMAPABLE);
 13         __uint(max_entries, 100); /* number of pages */
 14 } arena SEC(".maps");
 15 
 16 #include "bpf_arena_htab.h"
 17 
 18 void __arena *htab_for_user;
 19 bool skip = false;
 20 
 21 int zero = 0;
 22 char __arena arr1[100000];
 23 char arr2[1000];
 24 
 25 SEC("syscall")
 26 int arena_htab_llvm(void *ctx)
 27 {
 28 #if defined(__BPF_FEATURE_ADDR_SPACE_CAST) || defined(BPF_ARENA_FORCE_ASM)
 29         struct htab __arena *htab;
 30         char __arena *arr = arr1;
 31         __u64 i;
 32 
 33         htab = bpf_alloc(sizeof(*htab));
 34         cast_kern(htab);
 35         htab_init(htab);
 36 
 37         cast_kern(arr);
 38 
 39         /* first run. No old elems in the table */
 40         for (i = zero; i < 100000 && can_loop; i++) {
 41                 htab_update_elem(htab, i, i);
 42                 arr[i] = i;
 43         }
 44 
 45         /* should replace some elems with new ones */
 46         for (i = zero; i < 1000 && can_loop; i++) {
 47                 htab_update_elem(htab, i, i);
 48                 /* Access mem to make the verifier use bounded loop logic */
 49                 arr2[i] = i;
 50         }
 51         cast_user(htab);
 52         htab_for_user = htab;
 53 #else
 54         skip = true;
 55 #endif
 56         return 0;
 57 }
 58 
 59 char _license[] SEC("license") = "GPL";
 60 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php