sync with latest libbpf repo
authorYonghong Song <yhs@fb.com>
Wed, 15 Sep 2021 06:53:18 +0000 (23:53 -0700)
committeryonghong-song <ys114321@gmail.com>
Wed, 15 Sep 2021 14:44:04 +0000 (07:44 -0700)
Sync with latest libbpf repo upto the following commit:
  5579664205e4 libbpf: Fix build with latest gcc/binutils with LTO

Signed-off-by: Yonghong Song <yhs@fb.com>
docs/kernel-versions.md
src/cc/compat/linux/virtual_bpf.h
src/cc/export/helpers.h
src/cc/libbpf
src/cc/libbpf.c

index 4e94d676d07e6f86c7c48be1aa5b495d1f2e1c90..564c45aaba4c957b9f50fd69c44415484cb85a45 100644 (file)
@@ -219,6 +219,7 @@ Helper | Kernel version | License | Commit |
 `BPF_FUNC_d_path()` | 5.10 |  | [`6e22ab9da793`](https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit?id=6e22ab9da79343532cd3cde39df25e5a5478c692)
 `BPF_FUNC_fib_lookup()` | 4.18 | GPL | [`87f5fc7e48dd`](https://git.kernel.org/cgit/linux/kernel/git/davem/net-next.git/commit/?id=87f5fc7e48dd3175b30dd03b41564e1a8e136323)
 `BPF_FUNC_for_each_map_elem()` | 5.13 | | [`69c087ba6225`](https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit?id=69c087ba6225b574afb6e505b72cb75242a3d844)
+`BPF_FUNC_get_attach_cookie()` | 5.15 |  | [`7adfc6c9b315`](https://github.com/torvalds/linux/commit/7adfc6c9b315e174cf8743b21b7b691c8766791b)
 `BPF_FUNC_get_current_ancestor_cgroup_id()` | 5.6 |  | [`b4490c5c4e02`](https://github.com/torvalds/linux/commit/b4490c5c4e023f09b7d27c9a9d3e7ad7d09ea6bf)
 `BPF_FUNC_get_cgroup_classid()` | 4.3 |  | [`8d20aabe1c76`](https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=8d20aabe1c76cccac544d9fcc3ad7823d9e98a2d)
 `BPF_FUNC_get_current_cgroup_id()` | 4.18 |  | [`bf6fa2c893c5`](https://github.com/torvalds/linux/commit/bf6fa2c893c5237b48569a13fa3c673041430b6c)
@@ -361,6 +362,7 @@ Helper | Kernel version | License | Commit |
 `BPF_FUNC_sysctl_get_new_value()` | 5.2 |  | [`4e63acdff864`](https://kernel.googlesource.com/pub/scm/linux/kernel/git/davem/net-next/+/4e63acdff864654cee0ac5aaeda3913798ee78f6)
 `BPF_FUNC_sysctl_set_new_value()` | 5.2 |  | [`4e63acdff864`](https://kernel.googlesource.com/pub/scm/linux/kernel/git/davem/net-next/+/4e63acdff864654cee0ac5aaeda3913798ee78f6)
 `BPF_FUNC_tail_call()` | 4.2 |  | [`04fd61ab36ec`](https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=04fd61ab36ec065e194ab5e74ae34a5240d992bb)
+`BPF_FUNC_task_pt_regs()` | 5.15 | GPL | [`dd6e10fbd9f`](https://github.com/torvalds/linux/commit/dd6e10fbd9fb86a571d925602c8a24bb4d09a2a7)
 `BPF_FUNC_task_storage_delete()` | 5.11 |  | [`4cf1bc1f1045`](https://github.com/torvalds/linux/commit/4cf1bc1f10452065a29d576fc5693fc4fab5b919)
 `BPF_FUNC_task_storage_get()` | 5.11 |  | [`4cf1bc1f1045`](https://github.com/torvalds/linux/commit/4cf1bc1f10452065a29d576fc5693fc4fab5b919)
 `BPF_FUNC_tcp_check_syncookie()` | 5.2 |  | [`399040847084`](https://kernel.googlesource.com/pub/scm/linux/kernel/git/davem/net-next/+/399040847084a69f345e0a52fd62f04654e0fce3)
index bf4bc3a6234f215318f474993fbb1119a342d4d2..8cf52e99e78915fcbf348939c0250f4ac24bbd08 100644 (file)
@@ -85,7 +85,7 @@ struct bpf_lpm_trie_key {
 
 struct bpf_cgroup_storage_key {
        __u64   cgroup_inode_id;        /* cgroup inode id */
-       __u32   attach_type;            /* program attach type */
+       __u32   attach_type;            /* program attach type (enum bpf_attach_type) */
 };
 
 union bpf_iter_link_info {
@@ -994,6 +994,7 @@ enum bpf_attach_type {
        BPF_SK_SKB_VERDICT,
        BPF_SK_REUSEPORT_SELECT,
        BPF_SK_REUSEPORT_SELECT_OR_MIGRATE,
+       BPF_PERF_EVENT,
        __MAX_BPF_ATTACH_TYPE
 };
 
@@ -1007,6 +1008,7 @@ enum bpf_link_type {
        BPF_LINK_TYPE_ITER = 4,
        BPF_LINK_TYPE_NETNS = 5,
        BPF_LINK_TYPE_XDP = 6,
+       BPF_LINK_TYPE_PERF_EVENT = 7,
 
        MAX_BPF_LINK_TYPE,
 };
@@ -1447,6 +1449,13 @@ union bpf_attr {
                                __aligned_u64   iter_info;      /* extra bpf_iter_link_info */
                                __u32           iter_info_len;  /* iter_info length */
                        };
+                       struct {
+                               /* black box user-provided value passed through
+                                * to BPF program at the execution time and
+                                * accessible through bpf_get_attach_cookie() BPF helper
+                                */
+                               __u64           bpf_cookie;
+                       } perf_event;
                };
        } link_create;
 
@@ -4848,6 +4857,27 @@ union bpf_attr {
  *             Get address of the traced function (for tracing and kprobe programs).
  *     Return
  *             Address of the traced function.
+ *
+ * u64 bpf_get_attach_cookie(void *ctx)
+ *     Description
+ *             Get bpf_cookie value provided (optionally) during the program
+ *             attachment. It might be different for each individual
+ *             attachment, even if BPF program itself is the same.
+ *             Expects BPF program context *ctx* as a first argument.
+ *
+ *             Supported for the following program types:
+ *                     - kprobe/uprobe;
+ *                     - tracepoint;
+ *                     - perf_event.
+ *     Return
+ *             Value specified by user at BPF link creation/attachment time
+ *             or 0, if it was not specified.
+ *
+ * long bpf_task_pt_regs(struct task_struct *task)
+ *     Description
+ *             Get the struct pt_regs associated with **task**.
+ *     Return
+ *             A pointer to struct pt_regs.
  */
 #define __BPF_FUNC_MAPPER(FN)          \
        FN(unspec),                     \
@@ -5024,6 +5054,8 @@ union bpf_attr {
        FN(timer_start),                \
        FN(timer_cancel),               \
        FN(get_func_ip),                \
+       FN(get_attach_cookie),          \
+       FN(task_pt_regs),               \
        /* */
 
 /* integer value in 'imm' field of BPF_CALL instruction selects which helper
index bcfee6653f2efcd2c33b4bb605b792ef0f38db7e..cd477d6982f0a98691ef1ed5aadb67528d773fbe 100644 (file)
@@ -898,6 +898,8 @@ static long (*bpf_timer_start)(struct bpf_timer *timer, __u64 nsecs, __u64 flags
 static long (*bpf_timer_cancel)(struct bpf_timer *timer) = (void *)BPF_FUNC_timer_cancel;
 
 static __u64 (*bpf_get_func_ip)(void *ctx) = (void *)BPF_FUNC_get_func_ip;
+static __u64 (*bpf_get_attach_cookie)(void *ctx) = (void *)BPF_FUNC_get_attach_cookie;
+static long (*bpf_task_pt_regs)(struct task_struct *task) = (void *)BPF_FUNC_task_pt_regs;
 
 /* llvm builtin functions that eBPF C program may use to
  * emit BPF_LD_ABS and BPF_LD_IND instructions
index a3c0cc19d4b93cb0b7088c5604b0cec1c6863fde..5579664205e42194e1921d69d0839f660c801a4d 160000 (submodule)
@@ -1 +1 @@
-Subproject commit a3c0cc19d4b93cb0b7088c5604b0cec1c6863fde
+Subproject commit 5579664205e42194e1921d69d0839f660c801a4d
index cf4b1423a304c9c94afafea64f0d7ca20610a482..986dc895de51be5b4497641447dc4d1e909a9601 100644 (file)
@@ -278,6 +278,8 @@ static struct bpf_helper helpers[] = {
   {"timer_start", "5.15"},
   {"timer_cancel", "5.15"},
   {"get_func_ip", "5.15"},
+  {"get_attach_cookie", "5.15"},
+  {"task_pt_regs", "5.15"},
 };
 
 static uint64_t ptr_to_u64(void *ptr)