netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: bpf@vger.kernel.org
Cc: netdev@vger.kernel.org, ast@kernel.org, joe@wand.net.nz,
	yhs@fb.com, andrii.nakryiko@gmail.com, kafai@fb.com,
	Daniel Borkmann <daniel@iogearbox.net>
Subject: [PATCH bpf-next v4 09/16] bpf: sync {btf,bpf}.h uapi header from tools infrastructure
Date: Fri,  5 Apr 2019 22:59:35 +0200	[thread overview]
Message-ID: <e7d2f32680f308ec8452e7569518b5854c528cd2.1554497408.git.daniel@iogearbox.net> (raw)
In-Reply-To: <cover.1554497408.git.daniel@iogearbox.net>
In-Reply-To: <cover.1554497408.git.daniel@iogearbox.net>

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

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
---
 tools/include/uapi/linux/bpf.h | 24 ++++++++++++++++++++++--
 tools/include/uapi/linux/btf.h | 32 ++++++++++++++++++++++++++++----
 2 files changed, 50 insertions(+), 6 deletions(-)

diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 8370245..92588db 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -105,6 +105,7 @@ enum bpf_cmd {
 	BPF_BTF_GET_FD_BY_ID,
 	BPF_TASK_FD_QUERY,
 	BPF_MAP_LOOKUP_AND_DELETE_ELEM,
+	BPF_MAP_FREEZE,
 };
 
 enum bpf_map_type {
@@ -255,8 +256,19 @@ enum bpf_attach_type {
  */
 #define BPF_F_ANY_ALIGNMENT	(1U << 1)
 
-/* when bpf_ldimm64->src_reg == BPF_PSEUDO_MAP_FD, bpf_ldimm64->imm == fd */
+/* When BPF ldimm64's insn[0].src_reg != 0 then this can have
+ * two extensions:
+ *
+ * insn[0].src_reg:  BPF_PSEUDO_MAP_FD   BPF_PSEUDO_MAP_VALUE
+ * insn[0].imm:      map fd              map fd
+ * insn[1].imm:      0                   offset into value
+ * insn[0].off:      0                   lower 16 bit of map index
+ * insn[1].off:      0                   higher 16 bit of map index
+ * ldimm64 rewrite:  address of map      address of map[index]+offset
+ * verifier type:    CONST_PTR_TO_MAP    PTR_TO_MAP_VALUE
+ */
 #define BPF_PSEUDO_MAP_FD	1
+#define BPF_PSEUDO_MAP_VALUE	2
 
 /* when bpf_call->src_reg == BPF_PSEUDO_CALL, bpf_call->imm == pc-relative
  * offset to another bpf function
@@ -283,7 +295,7 @@ enum bpf_attach_type {
 
 #define BPF_OBJ_NAME_LEN 16U
 
-/* Flags for accessing BPF object */
+/* Flags for accessing BPF object from syscall side. */
 #define BPF_F_RDONLY		(1U << 3)
 #define BPF_F_WRONLY		(1U << 4)
 
@@ -293,6 +305,14 @@ enum bpf_attach_type {
 /* Zero-initialize hash function seed. This should only be used for testing. */
 #define BPF_F_ZERO_SEED		(1U << 6)
 
+/* Flags for accessing BPF object from program side. */
+#define BPF_F_RDONLY_PROG	(1U << 7)
+#define BPF_F_WRONLY_PROG	(1U << 8)
+#define BPF_F_ACCESS_MASK	(BPF_F_RDONLY |		\
+				 BPF_F_RDONLY_PROG |	\
+				 BPF_F_WRONLY |		\
+				 BPF_F_WRONLY_PROG)
+
 /* flags for BPF_PROG_QUERY */
 #define BPF_F_QUERY_EFFECTIVE	(1U << 0)
 
diff --git a/tools/include/uapi/linux/btf.h b/tools/include/uapi/linux/btf.h
index 7b7475e..9310652 100644
--- a/tools/include/uapi/linux/btf.h
+++ b/tools/include/uapi/linux/btf.h
@@ -39,11 +39,11 @@ struct btf_type {
 	 *             struct, union and fwd
 	 */
 	__u32 info;
-	/* "size" is used by INT, ENUM, STRUCT and UNION.
+	/* "size" is used by INT, ENUM, STRUCT, UNION and DATASEC.
 	 * "size" tells the size of the type it is describing.
 	 *
 	 * "type" is used by PTR, TYPEDEF, VOLATILE, CONST, RESTRICT,
-	 * FUNC and FUNC_PROTO.
+	 * FUNC, FUNC_PROTO and VAR.
 	 * "type" is a type_id referring to another type.
 	 */
 	union {
@@ -70,8 +70,10 @@ struct btf_type {
 #define BTF_KIND_RESTRICT	11	/* Restrict	*/
 #define BTF_KIND_FUNC		12	/* Function	*/
 #define BTF_KIND_FUNC_PROTO	13	/* Function Proto	*/
-#define BTF_KIND_MAX		13
-#define NR_BTF_KINDS		14
+#define BTF_KIND_VAR		14	/* Variable	*/
+#define BTF_KIND_DATASEC	15	/* Section	*/
+#define BTF_KIND_MAX		BTF_KIND_DATASEC
+#define NR_BTF_KINDS		(BTF_KIND_MAX + 1)
 
 /* For some specific BTF_KIND, "struct btf_type" is immediately
  * followed by extra data.
@@ -138,4 +140,26 @@ struct btf_param {
 	__u32	type;
 };
 
+enum {
+	BTF_VAR_STATIC = 0,
+	BTF_VAR_GLOBAL_ALLOCATED,
+};
+
+/* BTF_KIND_VAR is followed by a single "struct btf_var" to describe
+ * additional information related to the variable such as its linkage.
+ */
+struct btf_var {
+	__u32	linkage;
+};
+
+/* BTF_KIND_DATASEC is followed by multiple "struct btf_var_secinfo"
+ * to describe all BTF_KIND_VAR types it contains along with it's
+ * in-section offset as well as size.
+ */
+struct btf_var_secinfo {
+	__u32	type;
+	__u32	offset;
+	__u32	size;
+};
+
 #endif /* _UAPI__LINUX_BTF_H__ */
-- 
2.9.5


  parent reply	other threads:[~2019-04-05 21:00 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-05 20:59 [PATCH bpf-next v4 00/16] BPF support for global data Daniel Borkmann
2019-04-05 20:59 ` [PATCH bpf-next v4 01/16] bpf: implement lookup-free direct value access for maps Daniel Borkmann
2019-04-06  1:56   ` Alexei Starovoitov
2019-04-06 10:58     ` Daniel Borkmann
2019-04-06 16:54       ` Alexei Starovoitov
2019-04-06 23:55         ` Daniel Borkmann
2019-04-07  2:57           ` Alexei Starovoitov
2019-04-07 18:35             ` Daniel Borkmann
2019-04-05 20:59 ` [PATCH bpf-next v4 02/16] bpf: do not retain flags that are not tied to map lifetime Daniel Borkmann
2019-04-05 20:59 ` [PATCH bpf-next v4 03/16] bpf: add program side {rd,wr}only support for maps Daniel Borkmann
2019-04-05 20:59 ` [PATCH bpf-next v4 04/16] bpf: add syscall side map freeze support Daniel Borkmann
2019-04-05 20:59 ` [PATCH bpf-next v4 05/16] bpf: allow . char as part of the object name Daniel Borkmann
2019-04-05 20:59 ` [PATCH bpf-next v4 06/16] bpf: add specification for BTF Var and DataSec kinds Daniel Borkmann
2019-04-05 20:59 ` [PATCH bpf-next v4 07/16] bpf: kernel side support for BTF Var and DataSec Daniel Borkmann
2019-04-05 20:59 ` [PATCH bpf-next v4 08/16] bpf: allow for key-less BTF in array map Daniel Borkmann
2019-04-05 20:59 ` Daniel Borkmann [this message]
2019-04-05 20:59 ` [PATCH bpf-next v4 10/16] bpf, libbpf: refactor relocation handling Daniel Borkmann
2019-04-05 20:59 ` [PATCH bpf-next v4 11/16] bpf, libbpf: support global data/bss/rodata sections Daniel Borkmann
2019-04-05 20:59 ` [PATCH bpf-next v4 12/16] bpf, libbpf: add support for BTF Var and DataSec Daniel Borkmann
2019-04-05 20:59 ` [PATCH bpf-next v4 13/16] bpf: bpftool support for dumping data/bss/rodata sections Daniel Borkmann
2019-04-05 20:59 ` [PATCH bpf-next v4 14/16] bpf, selftest: test {rd,wr}only flags and direct value access Daniel Borkmann
2019-04-05 20:59 ` [PATCH bpf-next v4 15/16] bpf, selftest: test global data/bss/rodata sections Daniel Borkmann
2019-04-05 20:59 ` [PATCH bpf-next v4 16/16] bpf, selftest: add test cases for BTF Var and DataSec Daniel Borkmann
2019-04-06  5:57 ` [PATCH bpf-next v4 00/16] BPF support for global data Martin Lau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e7d2f32680f308ec8452e7569518b5854c528cd2.1554497408.git.daniel@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=andrii.nakryiko@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=joe@wand.net.nz \
    --cc=kafai@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).