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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/bpf/progs/test_ksyms_btf.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) 2020 Google */
  3 
  4 #include "vmlinux.h"
  5 
  6 #include <bpf/bpf_helpers.h>
  7 
  8 __u64 out__runqueues_addr = -1;
  9 __u64 out__bpf_prog_active_addr = -1;
 10 
 11 __u32 out__rq_cpu = -1; /* percpu struct fields */
 12 int out__bpf_prog_active = -1; /* percpu int */
 13 
 14 __u32 out__this_rq_cpu = -1;
 15 int out__this_bpf_prog_active = -1;
 16 
 17 __u32 out__cpu_0_rq_cpu = -1; /* cpu_rq(0)->cpu */
 18 
 19 extern const struct rq runqueues __ksym; /* struct type global var. */
 20 extern const int bpf_prog_active __ksym; /* int type global var. */
 21 
 22 SEC("raw_tp/sys_enter")
 23 int handler(const void *ctx)
 24 {
 25         struct rq *rq;
 26         int *active;
 27         __u32 cpu;
 28 
 29         out__runqueues_addr = (__u64)&runqueues;
 30         out__bpf_prog_active_addr = (__u64)&bpf_prog_active;
 31 
 32         cpu = bpf_get_smp_processor_id();
 33 
 34         /* test bpf_per_cpu_ptr() */
 35         rq = (struct rq *)bpf_per_cpu_ptr(&runqueues, cpu);
 36         if (rq)
 37                 out__rq_cpu = rq->cpu;
 38         active = (int *)bpf_per_cpu_ptr(&bpf_prog_active, cpu);
 39         if (active)
 40                 out__bpf_prog_active = *active;
 41 
 42         rq = (struct rq *)bpf_per_cpu_ptr(&runqueues, 0);
 43         if (rq) /* should always be valid, but we can't spare the check. */
 44                 out__cpu_0_rq_cpu = rq->cpu;
 45 
 46         /* test bpf_this_cpu_ptr */
 47         rq = (struct rq *)bpf_this_cpu_ptr(&runqueues);
 48         out__this_rq_cpu = rq->cpu;
 49         active = (int *)bpf_this_cpu_ptr(&bpf_prog_active);
 50         out__this_bpf_prog_active = *active;
 51 
 52         return 0;
 53 }
 54 
 55 char _license[] SEC("license") = "GPL";
 56 

~ [ 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