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
105 BPF_BTF_GET_FD_BY_ID,105 BPF_BTF_GET_FD_BY_ID,
106 BPF_TASK_FD_QUERY,106 BPF_TASK_FD_QUERY,
107 BPF_MAP_LOOKUP_AND_DELETE_ELEM,107 BPF_MAP_LOOKUP_AND_DELETE_ELEM,
108 BPF_MAP_FREEZE,
108};109};
109 110
110enum bpf_map_type {111enum bpf_map_type {
@@ -255,8 +256,19 @@ enum bpf_attach_type { · 144 unmodified lines
255 */256 */
256#define BPF_F_ANY_ALIGNMENT (1U << 1)257#define BPF_F_ANY_ALIGNMENT (1U << 1)
257 258
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 */
259#define BPF_PSEUDO_MAP_FD 1270#define BPF_PSEUDO_MAP_FD 1
271#define BPF_PSEUDO_MAP_VALUE 2
260 272
261/* when bpf_call->src_reg == BPF_PSEUDO_CALL, bpf_call->imm == pc-relative273/* when bpf_call->src_reg == BPF_PSEUDO_CALL, bpf_call->imm == pc-relative
262 * offset to another bpf function274 * offset to another bpf function
@@ -283,7 +295,7 @@ enum bpf_attach_type { · 20 unmodified lines
283 295
284#define BPF_OBJ_NAME_LEN 16U296#define BPF_OBJ_NAME_LEN 16U
285 297
286/* Flags for accessing BPF object */298/* Flags for accessing BPF object from syscall side. */
287#define BPF_F_RDONLY (1U << 3)299#define BPF_F_RDONLY (1U << 3)
288#define BPF_F_WRONLY (1U << 4)300#define BPF_F_WRONLY (1U << 4)
289 301
@@ -293,6 +305,10 @@ enum bpf_attach_type { · 3 unmodified lines
293/* Zero-initialize hash function seed. This should only be used for testing. */305/* Zero-initialize hash function seed. This should only be used for testing. */
294#define BPF_F_ZERO_SEED (1U << 6)306#define BPF_F_ZERO_SEED (1U << 6)
295 307
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
296/* flags for BPF_PROG_QUERY */312/* flags for BPF_PROG_QUERY */
297#define BPF_F_QUERY_EFFECTIVE (1U << 0)313#define BPF_F_QUERY_EFFECTIVE (1U << 0)
298 314
tools/include/uapi/linux/btf.h+28−4
@@ -39,11 +39,11 @@ struct btf_type { · 38 unmodified lines
39 * struct, union and fwd39 * struct, union and fwd
40 */40 */
41 __u32 info;41 __u32 info;
42 /* "size" is used by INT, ENUM, STRUCT and UNION.42 /* "size" is used by INT, ENUM, STRUCT, UNION and DATASEC.
43 * "size" tells the size of the type it is describing.43 * "size" tells the size of the type it is describing.
44 *44 *
45 * "type" is used by PTR, TYPEDEF, VOLATILE, CONST, RESTRICT,45 * "type" is used by PTR, TYPEDEF, VOLATILE, CONST, RESTRICT,
46 * FUNC and FUNC_PROTO.46 * FUNC, FUNC_PROTO and VAR.
47 * "type" is a type_id referring to another type.47 * "type" is a type_id referring to another type.
48 */48 */
49 union {49 union {
@@ -70,8 +70,10 @@ struct btf_type { · 20 unmodified lines
70#define BTF_KIND_RESTRICT 11 /* Restrict */70#define BTF_KIND_RESTRICT 11 /* Restrict */
71#define BTF_KIND_FUNC 12 /* Function */71#define BTF_KIND_FUNC 12 /* Function */
72#define BTF_KIND_FUNC_PROTO 13 /* Function Proto */72#define BTF_KIND_FUNC_PROTO 13 /* Function Proto */
73#define BTF_KIND_MAX 1373#define BTF_KIND_VAR 14 /* Variable */
74#define NR_BTF_KINDS 1474#define BTF_KIND_DATASEC 15 /* Section */
75#define BTF_KIND_MAX BTF_KIND_DATASEC
76#define NR_BTF_KINDS (BTF_KIND_MAX + 1)
75 77
76/* For some specific BTF_KIND, "struct btf_type" is immediately78/* For some specific BTF_KIND, "struct btf_type" is immediately
77 * followed by extra data.79 * followed by extra data.
@@ -138,4 +140,26 @@ struct btf_param { · 60 unmodified lines
138 __u32 type;140 __u32 type;
139};141};
140 142
143enum {
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 */
151struct 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 */
159struct btf_var_secinfo {
160 __u32 type;
161 __u32 offset;
162 __u32 size;
163};
164
141#endif /* _UAPI__LINUX_BTF_H__ */165#endif /* _UAPI__LINUX_BTF_H__ */