History

bpf: sync {btf, bpf}.h uapi header from tools infrastructure

Pull in latest changes from both headers, so we can make use of them in libbpf.

Daniel Borkmann committed 7 years ago

Commit c83fef61 parent 2824ecb2 files · +46 −6Browse files

Showing the changes to tools/include/uapi/linux (2 of 2 files). Show all

Unified · Split

2 files
  1. tools/include/uapi/linux/bpf.h +18 −2
  2. tools/include/uapi/linux/btf.h +28 −4
tools/include/uapi/linux/bpf.h+18−2
@@ -105,6 +105,7 @@ enum bpf_cmd { · 104 unmodified lines
105105 BPF_BTF_GET_FD_BY_ID,
106106 BPF_TASK_FD_QUERY,
107107 BPF_MAP_LOOKUP_AND_DELETE_ELEM,
108+ BPF_MAP_FREEZE,
108109 };
109110
110111 enum bpf_map_type {
@@ -255,8 +256,19 @@ enum bpf_attach_type { · 144 unmodified lines
255256 */
256257 #define BPF_F_ANY_ALIGNMENT (1U << 1)
257258
258−/* when bpf_ldimm64->src_reg == BPF_PSEUDO_MAP_FD, bpf_ldimm64->imm == fd */
259+/* When BPF ldimm64's insn[0].src_reg != 0 then this can have
260+ * two extensions:
261+ *
262+ * insn[0].src_reg: BPF_PSEUDO_MAP_FD BPF_PSEUDO_MAP_VALUE
263+ * insn[0].imm: map fd map fd
264+ * insn[1].imm: 0 offset into value
265+ * insn[0].off: 0 0
266+ * insn[1].off: 0 0
267+ * ldimm64 rewrite: address of map address of map[0]+offset
268+ * verifier type: CONST_PTR_TO_MAP PTR_TO_MAP_VALUE
269+ */
259270 #define BPF_PSEUDO_MAP_FD 1
271+#define BPF_PSEUDO_MAP_VALUE 2
260272
261273 /* when bpf_call->src_reg == BPF_PSEUDO_CALL, bpf_call->imm == pc-relative
262274 * offset to another bpf function
@@ -283,7 +295,7 @@ enum bpf_attach_type { · 20 unmodified lines
283295
284296 #define BPF_OBJ_NAME_LEN 16U
285297
286−/* Flags for accessing BPF object */
298+/* Flags for accessing BPF object from syscall side. */
287299 #define BPF_F_RDONLY (1U << 3)
288300 #define BPF_F_WRONLY (1U << 4)
289301
@@ -293,6 +305,10 @@ enum bpf_attach_type { · 3 unmodified lines
293305 /* Zero-initialize hash function seed. This should only be used for testing. */
294306 #define BPF_F_ZERO_SEED (1U << 6)
295307
308+/* Flags for accessing BPF object from program side. */
309+#define BPF_F_RDONLY_PROG (1U << 7)
310+#define BPF_F_WRONLY_PROG (1U << 8)
311+
296312 /* flags for BPF_PROG_QUERY */
297313 #define BPF_F_QUERY_EFFECTIVE (1U << 0)
298314
tools/include/uapi/linux/btf.h+28−4
@@ -39,11 +39,11 @@ struct btf_type { · 38 unmodified lines
3939 * struct, union and fwd
4040 */
4141 __u32 info;
42− /* "size" is used by INT, ENUM, STRUCT and UNION.
42+ /* "size" is used by INT, ENUM, STRUCT, UNION and DATASEC.
4343 * "size" tells the size of the type it is describing.
4444 *
4545 * "type" is used by PTR, TYPEDEF, VOLATILE, CONST, RESTRICT,
46− * FUNC and FUNC_PROTO.
46+ * FUNC, FUNC_PROTO and VAR.
4747 * "type" is a type_id referring to another type.
4848 */
4949 union {
@@ -70,8 +70,10 @@ struct btf_type { · 20 unmodified lines
7070 #define BTF_KIND_RESTRICT 11 /* Restrict */
7171 #define BTF_KIND_FUNC 12 /* Function */
7272 #define BTF_KIND_FUNC_PROTO 13 /* Function Proto */
73−#define BTF_KIND_MAX 13
74−#define NR_BTF_KINDS 14
73+#define BTF_KIND_VAR 14 /* Variable */
74+#define BTF_KIND_DATASEC 15 /* Section */
75+#define BTF_KIND_MAX BTF_KIND_DATASEC
76+#define NR_BTF_KINDS (BTF_KIND_MAX + 1)
7577
7678 /* For some specific BTF_KIND, "struct btf_type" is immediately
7779 * followed by extra data.
@@ -138,4 +140,26 @@ struct btf_param { · 60 unmodified lines
138140 __u32 type;
139141 };
140142
143+enum {
144+ BTF_VAR_STATIC = 0,
145+ BTF_VAR_GLOBAL_ALLOCATED,
146+};
147+
148+/* BTF_KIND_VAR is followed by a single "struct btf_var" to describe
149+ * additional information related to the variable such as its linkage.
150+ */
151+struct btf_var {
152+ __u32 linkage;
153+};
154+
155+/* BTF_KIND_DATASEC is followed by multiple "struct btf_var_secinfo"
156+ * to describe all BTF_KIND_VAR types it contains along with it's
157+ * in-section offset as well as size.
158+ */
159+struct btf_var_secinfo {
160+ __u32 type;
161+ __u32 offset;
162+ __u32 size;
163+};
164+
141165 #endif /* _UAPI__LINUX_BTF_H__ */