Skip to contentSkip to conversation

BPF support for global data

PATCH Superseded Daniel Borkmann 9 participants 47 messages Feb 28, 2019 – Mar 5, 2019

Subsystems (8)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Daniel Borkmann

author maintainer
#0 lore raw

v2 cover BPF support for global data

This series is a major rework of previously submitted libbpf patches [0] in order to add global data support for BPF. The kernel has been extended to add proper infrastructure that allows for full .bss/.data/.rodata sections on BPF loader side based upon feedback from LPC discussions [1]. Latter support is then also added into libbpf in this series which allows for more natural C-like programming of BPF programs. For more information on loader, please refer to 'bpf, libbpf: support global data/bss/ rodata sections' patch in this series. Joint work with Joe Stringer.

Thanks a lot!

v1 -> v2:
- Instead of 32-bit static data, implement full global data support.

[0] https://patchwork.ozlabs.org/cover/1040290/
[1] http://vger.kernel.org/lpc-bpf2018.html#session-3

Daniel Borkmann (5):
bpf: implement lookup-free direct value access
bpf: add program side {rd,wr}only support
bpf, obj: allow . char as part of the name
bpf, libbpf: support global data/bss/rodata sections bpf, selftest: test {rd,wr}only flags and direct value access

Joe Stringer (2):
bpf, libbpf: refactor relocation handling bpf, selftest: test global data/bss/rodata sections

 include/linux/bpf.h                           |  24 ++
 include/linux/bpf_verifier.h                  |   4 +
 include/uapi/linux/bpf.h                      |  16 +-
 kernel/bpf/arraymap.c                         |  35 +-
 kernel/bpf/core.c                             |   3 +-
 kernel/bpf/disasm.c                           |   5 +-
 kernel/bpf/hashtab.c                          |   2 +-
 kernel/bpf/local_storage.c                    |   2 +-
 kernel/bpf/lpm_trie.c                         |   2 +-
 kernel/bpf/queue_stack_maps.c                 |   3 +-
 kernel/bpf/syscall.c                          |  35 +-
 kernel/bpf/verifier.c                         | 103 ++++--
 tools/bpf/bpftool/xlated_dumper.c             |   3 +
 tools/include/linux/filter.h                  |  19 +-
 tools/include/uapi/linux/bpf.h                |  16 +-
 tools/lib/bpf/libbpf.c                        | 321 ++++++++++++++----
 tools/testing/selftests/bpf/bpf_helpers.h     |   2 +-
 .../selftests/bpf/progs/test_global_data.c    |  61 ++++
 tools/testing/selftests/bpf/test_progs.c      |  50 +++
 tools/testing/selftests/bpf/test_verifier.c   |  40 ++-
 .../selftests/bpf/verifier/array_access.c     | 159 +++++++++
 .../bpf/verifier/direct_value_access.c        | 170 ++++++++++
 22 files changed, 955 insertions(+), 120 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/progs/test_global_data.c
 create mode 100644 tools/testing/selftests/bpf/verifier/direct_value_access.c
Signature · 1 line
2.17.1
author maintainer
#1 lore raw

PATCH v2 1/7 bpf: implement lookup-free direct value access

This generic extension to BPF maps allows for directly loading an address residing inside a BPF map value as a single BPF ldimm64 instruction.

The idea is similar to what BPF_PSEUDO_MAP_FD does today, which is a special src_reg flag for ldimm64 instruction that indicates that inside the first part of the double insns's imm field is a file descriptor which the verifier then replaces as a full 64bit address of the map into both imm parts.

For the newly added BPF_PSEUDO_MAP_VALUE src_reg flag, the idea is similar: the first part of the double insns's imm field is again a file descriptor corresponding to the map, and the second part of the imm field is an offset. The verifier will then replace both imm parts with an address that points into the BPF map value for maps that support this operation. BPF_PSEUDO_MAP_VALUE is a distinct flag as otherwise with BPF_PSEUDO_MAP_FD we could not differ offset 0 between load of map pointer versus load of map's value at offset 0.

This allows for efficiently retrieving an address to a map value memory area without having to issue a helper call which needs to prepare registers according to calling convention, etc, without needing the extra NULL test, and without having to add the offset in an additional instruction to the value base pointer.

The verifier then treats the destination register as PTR_TO_MAP_VALUE with constant reg->off from the user passed offset from the second imm field, and guarantees that this is within bounds of the map value. Any subsequent operations are normally treated as typical map value handling without anything else needed for verification.

The two map operations for direct value access have been added to array map for now. In future other types could be supported as well depending on the use case. The main use case for this commit is to allow for BPF loader support for global variables that reside in .data/.rodata/.bss sections such that we can directly load the address of them with minimal additional infrastructure required. Loader support has been added in subsequent commits for libbpf library.

---
 include/linux/bpf.h               |  6 +++
 include/linux/bpf_verifier.h      |  4 ++
 include/uapi/linux/bpf.h          |  6 ++-
 kernel/bpf/arraymap.c             | 33 ++++++++++++++
 kernel/bpf/core.c                 |  3 +-
 kernel/bpf/disasm.c               |  5 ++-
 kernel/bpf/syscall.c              | 29 +++++++++---
 kernel/bpf/verifier.c             | 73 +++++++++++++++++++++++--------
 tools/bpf/bpftool/xlated_dumper.c |  3 ++
 tools/include/uapi/linux/bpf.h    |  6 ++-
 10 files changed, 138 insertions(+), 30 deletions(-)
include/linux/bpf.h +6 -0
index a2132e09dc1c..bdcc6e2a9977 100644
@@ -57,6 +57,12 @@ struct bpf_map_ops {
 			     const struct btf *btf,
 			     const struct btf_type *key_type,
 			     const struct btf_type *value_type);
+
+	/* Direct value access helpers. */
+	int (*map_direct_value_access)(const struct bpf_map *map,
+				       u32 off, u64 *imm);
+	int (*map_direct_value_offset)(const struct bpf_map *map,
+				       u64 imm, u32 *off);
 };
 
 struct bpf_map {
include/linux/bpf_verifier.h +4 -0
index 69f7a3449eda..6e28f1c24710 100644
@@ -183,6 +183,10 @@ struct bpf_insn_aux_data {
 		unsigned long map_state;	/* pointer/poison value for maps */
 		s32 call_imm;			/* saved imm field of call insn */
 		u32 alu_limit;			/* limit for add/sub register with pointer */
+		struct {
+			u32 map_index;		/* index into used_maps[] */
+			u32 map_off;		/* offset from value base address */
+		};
 	};
 	int ctx_field_size; /* the ctx field size for load insn, maybe 0 */
 	int sanitize_stack_off; /* stack slot to be cleared */
include/uapi/linux/bpf.h +5 -1
index 2e308e90ffea..8884072e1a46 100644
@@ -255,8 +255,12 @@ 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->src_reg == BPF_PSEUDO_MAP_{FD,VALUE}, then
+ * bpf_ldimm64's insn[0]->imm == fd in both cases. Additionally,
+ * for BPF_PSEUDO_MAP_VALUE, insn[1]->imm == offset into 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
kernel/bpf/arraymap.c +33 -0
index c72e0d8e1e65..3e5969c0c979 100644
@@ -160,6 +160,37 @@ static void *array_map_lookup_elem(struct bpf_map *map, void *key)
 	return array->value + array->elem_size * (index & array->index_mask);
 }
 
+static int array_map_direct_value_access(const struct bpf_map *map, u32 off,
+					 u64 *imm)
+{
+	struct bpf_array *array = container_of(map, struct bpf_array, map);
+
+	if (map->max_entries != 1)
+		return -ENOTSUPP;
+	if (off >= map->value_size)
+		return -EINVAL;
+
+	*imm = (unsigned long)array->value;
+	return 0;
+}
+
+static int array_map_direct_value_offset(const struct bpf_map *map, u64 imm,
+					 u32 *off)
+{
+	struct bpf_array *array = container_of(map, struct bpf_array, map);
+	unsigned long range = map->value_size;
+	unsigned long base  = array->value;
+	unsigned long addr  = imm;
+
+	if (map->max_entries != 1)
+		return -ENOENT;
+	if (addr < base || addr >= base + range)
+		return -ENOENT;
+
+	*off = addr - base;
+	return 0;
+}
+
 /* emit BPF instructions equivalent to C code of array_map_lookup_elem() */
 static u32 array_map_gen_lookup(struct bpf_map *map, struct bpf_insn *insn_buf)
 {
@@ -419,6 +450,8 @@ const struct bpf_map_ops array_map_ops = {
 	.map_update_elem = array_map_update_elem,
 	.map_delete_elem = array_map_delete_elem,
 	.map_gen_lookup = array_map_gen_lookup,
+	.map_direct_value_access = array_map_direct_value_access,
+	.map_direct_value_offset = array_map_direct_value_offset,
 	.map_seq_show_elem = array_map_seq_show_elem,
 	.map_check_btf = array_map_check_btf,
 };
kernel/bpf/core.c +2 -1
index 1c14c347f3cf..49fc0ff14537 100644
@@ -286,7 +286,8 @@ int bpf_prog_calc_tag(struct bpf_prog *fp)
 		dst[i] = fp->insnsi[i];
 		if (!was_ld_map &&
 		    dst[i].code == (BPF_LD | BPF_IMM | BPF_DW) &&
-		    dst[i].src_reg == BPF_PSEUDO_MAP_FD) {
+		    (dst[i].src_reg == BPF_PSEUDO_MAP_FD ||
+		     dst[i].src_reg == BPF_PSEUDO_MAP_VALUE)) {
 			was_ld_map = true;
 			dst[i].imm = 0;
 		} else if (was_ld_map &&
kernel/bpf/disasm.c +3 -2
index de73f55e42fd..d9ce383c0f9c 100644
@@ -205,10 +205,11 @@ void print_bpf_insn(const struct bpf_insn_cbs *cbs,
 			 * part of the ldimm64 insn is accessible.
 			 */
 			u64 imm = ((u64)(insn + 1)->imm << 32) | (u32)insn->imm;
-			bool map_ptr = insn->src_reg == BPF_PSEUDO_MAP_FD;
+			bool is_ptr = insn->src_reg == BPF_PSEUDO_MAP_FD ||
+				      insn->src_reg == BPF_PSEUDO_MAP_VALUE;
 			char tmp[64];
 
-			if (map_ptr && !allow_ptr_leaks)
+			if (is_ptr && !allow_ptr_leaks)
 				imm = 0;
 
 			verbose(cbs->private_data, "(%02x) r%d = %s\n",
kernel/bpf/syscall.c +22 -7
index 174581dfe225..d3ef45e01d7a 100644
@@ -2061,13 +2061,27 @@ static int bpf_map_get_fd_by_id(const union bpf_attr *attr)
 }
 
 static const struct bpf_map *bpf_map_from_imm(const struct bpf_prog *prog,
-					      unsigned long addr)
+					      unsigned long addr, u32 *off,
+					      u32 *type)
 {
+	const struct bpf_map *map;
 	int i;
 
-	for (i = 0; i < prog->aux->used_map_cnt; i++)
-		if (prog->aux->used_maps[i] == (void *)addr)
-			return prog->aux->used_maps[i];
+	*off = *type = 0;
+	for (i = 0; i < prog->aux->used_map_cnt; i++) {
+		map = prog->aux->used_maps[i];
+		if (map == (void *)addr) {
+			*type = BPF_PSEUDO_MAP_FD;
+			return map;
+		}
+		if (!map->ops->map_direct_value_offset)
+			continue;
+		if (!map->ops->map_direct_value_offset(map, addr, off)) {
+			*type = BPF_PSEUDO_MAP_VALUE;
+			return map;
+		}
+	}
+
 	return NULL;
 }
 
@@ -2075,6 +2089,7 @@ static struct bpf_insn *bpf_insn_prepare_dump(const struct bpf_prog *prog)
 {
 	const struct bpf_map *map;
 	struct bpf_insn *insns;
+	u32 off, type;
 	u64 imm;
 	int i;
 
@@ -2102,11 +2117,11 @@ static struct bpf_insn *bpf_insn_prepare_dump(const struct bpf_prog *prog)
 			continue;
 
 		imm = ((u64)insns[i + 1].imm << 32) | (u32)insns[i].imm;
-		map = bpf_map_from_imm(prog, imm);
+		map = bpf_map_from_imm(prog, imm, &off, &type);
 		if (map) {
-			insns[i].src_reg = BPF_PSEUDO_MAP_FD;
+			insns[i].src_reg = type;
 			insns[i].imm = map->id;
-			insns[i + 1].imm = 0;
+			insns[i + 1].imm = off;
 			continue;
 		}
 	}
kernel/bpf/verifier.c +55 -18

122 lines not on this page · raw message

tools/bpf/bpftool/xlated_dumper.c +3 -0
index 7073dbe1ff27..0bb17bf88b18 100644
@@ -195,6 +195,9 @@ static const char *print_imm(void *private_data,
 	if (insn->src_reg == BPF_PSEUDO_MAP_FD)
 		snprintf(dd->scratch_buff, sizeof(dd->scratch_buff),
 			 "map[id:%u]", insn->imm);
+	else if (insn->src_reg == BPF_PSEUDO_MAP_VALUE)
+		snprintf(dd->scratch_buff, sizeof(dd->scratch_buff),
+			 "map[id:%u][0]+%u", insn->imm, (insn + 1)->imm);
 	else
 		snprintf(dd->scratch_buff, sizeof(dd->scratch_buff),
 			 "0x%llx", (unsigned long long)full_imm);
tools/include/uapi/linux/bpf.h +5 -1
index 2e308e90ffea..8884072e1a46 100644
@@ -255,8 +255,12 @@ 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->src_reg == BPF_PSEUDO_MAP_{FD,VALUE}, then
+ * bpf_ldimm64's insn[0]->imm == fd in both cases. Additionally,
+ * for BPF_PSEUDO_MAP_VALUE, insn[1]->imm == offset into 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
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH bpf-next v2 1/7] bpf: implement lookup-free direct value access

I love your patch! Perhaps something to improve:

Hi Daniel,

I love your patch! Perhaps something to improve:

[auto build test WARNING on bpf-next/master]

url:    https://github.com/0day-ci/linux/commits/Daniel-Borkmann/BPF-support-for-global-data/20190301-112203
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
config: x86_64-randconfig-x017-201908 (attached as .config)
compiler: gcc-8 (Debian 8.2.0-21) 8.2.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

kernel//bpf/arraymap.c: In function 'array_map_direct_value_offset':

>> kernel//bpf/arraymap.c:182:24: warning: initialization of 'long unsigned int' from 'char *' makes integer from pointer without a cast [-Wint-conversion]
     unsigned long base  = array->value;
                           ^~~~~

vim +182 kernel//bpf/arraymap.c

176
177 static int array_map_direct_value_offset(const struct bpf_map *map, u64 imm,
178 u32 *off)
179 {
180 struct bpf_array *array = container_of(map, struct bpf_array, map);
181 unsigned long range = map->value_size;

 > 182		unsigned long base  = array->value;

183 unsigned long addr = imm;
184
185 if (map->max_entries != 1)
186 return -ENOENT;
187 if (addr < base || addr >= base + range)
188 return -ENOENT;
189
190 *off = addr - base;
191 return 0;
192 }
193

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#3 lore raw

Re: [PATCH bpf-next v2 1/7] bpf: implement lookup-free direct value access

In reply to Daniel Borkmann
Quoted 4 lines · Daniel Borkmann

This generic extension to BPF maps allows for directly loading an address residing inside a BPF map value as a single BPF ldimm64 instruction.

This is great! I'm going to review code more thoroughly tomorrow, but I also have few questions/suggestions I'd like to discuss, if you don't mind.

Quoted 7 lines

The idea is similar to what BPF_PSEUDO_MAP_FD does today, which is a special src_reg flag for ldimm64 instruction that indicates that inside the first part of the double insns's imm field is a file descriptor which the verifier then replaces as a full 64bit address of the map into both imm parts.

Quoted 9 lines

For the newly added BPF_PSEUDO_MAP_VALUE src_reg flag, the idea is similar: the first part of the double insns's imm field is again a file descriptor corresponding to the map, and the second part of the imm field is an offset. The verifier will then replace both imm parts with an address that points into the BPF map value for maps that support this operation. BPF_PSEUDO_MAP_VALUE is a distinct flag as otherwise with BPF_PSEUDO_MAP_FD we could not differ offset 0 between load of map pointer versus load of map's value at offset 0.

Is having both BPF_PSEUDO_MAP_FD and BPF_PSEUDO_MAP_VALUE a desirable thing? I'm asking because it's seems like it would be really simple to stick to using just BPF_PSEUDO_MAP_FD and then interpret imm differently depending on whether it's 0 or not. E.g., we can say that imm=0 is old BPF_PSEUDO_MAP_FD behavior (loading map addr), but any other imm value X is really just (X-1) offset into map's value? Or, given that valid offset is limited to 1<<29, we can set highest-order bit to 1 and lower bits would be offset? In other words, if we just need too carve out zero as a special case, then it's easy to do and we can avoid adding new BPF_PSEUDO_MAP_VALUE.

Quoted 6 lines

This allows for efficiently retrieving an address to a map value memory area without having to issue a helper call which needs to prepare registers according to calling convention, etc, without needing the extra NULL test, and without having to add the offset in an additional instruction to the value base pointer.

It seems like we allow this only for arrays of size 1 right now. We can easily generalize this to support not just offset into map's value, but also specifying integer key (i.e., array index) by utilizing off fields (16-bit + 16-bit). This would allow to eliminate any bpf_map_update_elem calls to array maps altogether by allowing to provide both array index and offset into value in one BPF instruction. Do you think it's a good addition?

Quoted 7 lines

The verifier then treats the destination register as PTR_TO_MAP_VALUE with constant reg->off from the user passed offset from the second imm field, and guarantees that this is within bounds of the map value. Any subsequent operations are normally treated as typical map value handling without anything else needed for verification.

Quoted 8 lines

The two map operations for direct value access have been added to array map for now. In future other types could be supported as well depending on the use case. The main use case for this commit is to allow for BPF loader support for global variables that reside in .data/.rodata/.bss sections such that we can directly load the address of them with minimal additional infrastructure required. Loader support has been added in subsequent commits for libbpf library.

I was considering adding a new kind of map representing contiguous block of memory (e.g., how about BPF_MAP_TYPE_HEAP or BPF_MAP_TYPE_BLOB?). It's keys would be offset into that memory region. Value size is size of the memory region, but it would allow reading smaller chunks of memory as values. This would provide convenient interface for poking at global variables from userland, given offset.

Libbpf itself would provide higher-level API as well, if there is corresponding BTF type information describing layout of .data/.bss/.rodata, so that applications can fetch variables by name and/or offset, whichever is more convenient. Together with bpf_spinlock this would allow easy way to customize subsets of global variables in atomic fashion.

Do you think that would work? Using array is a bit limiting, because it doesn't allow to do partial reads/updates, while BPF_MAP_TYPE_HEAP would be single big value that allows partial reading/updating.

Quoted 374 lines
---
 include/linux/bpf.h               |  6 +++
 include/linux/bpf_verifier.h      |  4 ++
 include/uapi/linux/bpf.h          |  6 ++-
 kernel/bpf/arraymap.c             | 33 ++++++++++++++
 kernel/bpf/core.c                 |  3 +-
 kernel/bpf/disasm.c               |  5 ++-
 kernel/bpf/syscall.c              | 29 +++++++++---
 kernel/bpf/verifier.c             | 73 +++++++++++++++++++++++--------
 tools/bpf/bpftool/xlated_dumper.c |  3 ++
 tools/include/uapi/linux/bpf.h    |  6 ++-
 10 files changed, 138 insertions(+), 30 deletions(-)
include/linux/bpf.h +6 -0
index a2132e09dc1c..bdcc6e2a9977 100644
@@ -57,6 +57,12 @@ struct bpf_map_ops {
                             const struct btf *btf,
                             const struct btf_type *key_type,
                             const struct btf_type *value_type);
+
+       /* Direct value access helpers. */
+       int (*map_direct_value_access)(const struct bpf_map *map,
+                                      u32 off, u64 *imm);
+       int (*map_direct_value_offset)(const struct bpf_map *map,
+                                      u64 imm, u32 *off);
 };
 
 struct bpf_map {
include/linux/bpf_verifier.h +4 -0
index 69f7a3449eda..6e28f1c24710 100644
@@ -183,6 +183,10 @@ struct bpf_insn_aux_data {
                unsigned long map_state;        /* pointer/poison value for maps */
                s32 call_imm;                   /* saved imm field of call insn */
                u32 alu_limit;                  /* limit for add/sub register with pointer */
+               struct {
+                       u32 map_index;          /* index into used_maps[] */
+                       u32 map_off;            /* offset from value base address */
+               };
        };
        int ctx_field_size; /* the ctx field size for load insn, maybe 0 */
        int sanitize_stack_off; /* stack slot to be cleared */
include/uapi/linux/bpf.h +5 -1
index 2e308e90ffea..8884072e1a46 100644
@@ -255,8 +255,12 @@ 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->src_reg == BPF_PSEUDO_MAP_{FD,VALUE}, then
+ * bpf_ldimm64's insn[0]->imm == fd in both cases. Additionally,
+ * for BPF_PSEUDO_MAP_VALUE, insn[1]->imm == offset into 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
kernel/bpf/arraymap.c +33 -0
index c72e0d8e1e65..3e5969c0c979 100644
@@ -160,6 +160,37 @@ static void *array_map_lookup_elem(struct bpf_map *map, void *key)
        return array->value + array->elem_size * (index & array->index_mask);
 }
 
+static int array_map_direct_value_access(const struct bpf_map *map, u32 off,
+                                        u64 *imm)
+{
+       struct bpf_array *array = container_of(map, struct bpf_array, map);
+
+       if (map->max_entries != 1)
+               return -ENOTSUPP;
+       if (off >= map->value_size)
+               return -EINVAL;
+
+       *imm = (unsigned long)array->value;
+       return 0;
+}
+
+static int array_map_direct_value_offset(const struct bpf_map *map, u64 imm,
+                                        u32 *off)
+{
+       struct bpf_array *array = container_of(map, struct bpf_array, map);
+       unsigned long range = map->value_size;
+       unsigned long base  = array->value;
+       unsigned long addr  = imm;
+
+       if (map->max_entries != 1)
+               return -ENOENT;
+       if (addr < base || addr >= base + range)
+               return -ENOENT;
+
+       *off = addr - base;
+       return 0;
+}
+
 /* emit BPF instructions equivalent to C code of array_map_lookup_elem() */
 static u32 array_map_gen_lookup(struct bpf_map *map, struct bpf_insn *insn_buf)
 {
@@ -419,6 +450,8 @@ const struct bpf_map_ops array_map_ops = {
        .map_update_elem = array_map_update_elem,
        .map_delete_elem = array_map_delete_elem,
        .map_gen_lookup = array_map_gen_lookup,
+       .map_direct_value_access = array_map_direct_value_access,
+       .map_direct_value_offset = array_map_direct_value_offset,
        .map_seq_show_elem = array_map_seq_show_elem,
        .map_check_btf = array_map_check_btf,
 };
kernel/bpf/core.c +2 -1
index 1c14c347f3cf..49fc0ff14537 100644
@@ -286,7 +286,8 @@ int bpf_prog_calc_tag(struct bpf_prog *fp)
                dst[i] = fp->insnsi[i];
                if (!was_ld_map &&
                    dst[i].code == (BPF_LD | BPF_IMM | BPF_DW) &&
-                   dst[i].src_reg == BPF_PSEUDO_MAP_FD) {
+                   (dst[i].src_reg == BPF_PSEUDO_MAP_FD ||
+                    dst[i].src_reg == BPF_PSEUDO_MAP_VALUE)) {
                        was_ld_map = true;
                        dst[i].imm = 0;
                } else if (was_ld_map &&
kernel/bpf/disasm.c +3 -2
index de73f55e42fd..d9ce383c0f9c 100644
@@ -205,10 +205,11 @@ void print_bpf_insn(const struct bpf_insn_cbs *cbs,
                         * part of the ldimm64 insn is accessible.
                         */
                        u64 imm = ((u64)(insn + 1)->imm << 32) | (u32)insn->imm;
-                       bool map_ptr = insn->src_reg == BPF_PSEUDO_MAP_FD;
+                       bool is_ptr = insn->src_reg == BPF_PSEUDO_MAP_FD ||
+                                     insn->src_reg == BPF_PSEUDO_MAP_VALUE;
                        char tmp[64];
 
-                       if (map_ptr && !allow_ptr_leaks)
+                       if (is_ptr && !allow_ptr_leaks)
                                imm = 0;
 
                        verbose(cbs->private_data, "(%02x) r%d = %s\n",
kernel/bpf/syscall.c +22 -7
index 174581dfe225..d3ef45e01d7a 100644
@@ -2061,13 +2061,27 @@ static int bpf_map_get_fd_by_id(const union bpf_attr *attr)
 }
 
 static const struct bpf_map *bpf_map_from_imm(const struct bpf_prog *prog,
-                                             unsigned long addr)
+                                             unsigned long addr, u32 *off,
+                                             u32 *type)
 {
+       const struct bpf_map *map;
        int i;
 
-       for (i = 0; i < prog->aux->used_map_cnt; i++)
-               if (prog->aux->used_maps[i] == (void *)addr)
-                       return prog->aux->used_maps[i];
+       *off = *type = 0;
+       for (i = 0; i < prog->aux->used_map_cnt; i++) {
+               map = prog->aux->used_maps[i];
+               if (map == (void *)addr) {
+                       *type = BPF_PSEUDO_MAP_FD;
+                       return map;
+               }
+               if (!map->ops->map_direct_value_offset)
+                       continue;
+               if (!map->ops->map_direct_value_offset(map, addr, off)) {
+                       *type = BPF_PSEUDO_MAP_VALUE;
+                       return map;
+               }
+       }
+
        return NULL;
 }
 
@@ -2075,6 +2089,7 @@ static struct bpf_insn *bpf_insn_prepare_dump(const struct bpf_prog *prog)
 {
        const struct bpf_map *map;
        struct bpf_insn *insns;
+       u32 off, type;
        u64 imm;
        int i;
 
@@ -2102,11 +2117,11 @@ static struct bpf_insn *bpf_insn_prepare_dump(const struct bpf_prog *prog)
                        continue;
 
                imm = ((u64)insns[i + 1].imm << 32) | (u32)insns[i].imm;
-               map = bpf_map_from_imm(prog, imm);
+               map = bpf_map_from_imm(prog, imm, &off, &type);
                if (map) {
-                       insns[i].src_reg = BPF_PSEUDO_MAP_FD;
+                       insns[i].src_reg = type;
                        insns[i].imm = map->id;
-                       insns[i + 1].imm = 0;
+                       insns[i + 1].imm = off;
                        continue;
                }
        }
kernel/bpf/verifier.c +55 -18
index 0e4edd7e3c5f..3ad05dda6e9d 100644
@@ -4944,18 +4944,12 @@ static int check_cond_jmp_op(struct bpf_verifier_env *env,
        return 0;
 }
 
-/* return the map pointer stored inside BPF_LD_IMM64 instruction */
-static struct bpf_map *ld_imm64_to_map_ptr(struct bpf_insn *insn)
-{
-       u64 imm64 = ((u64) (u32) insn[0].imm) | ((u64) (u32) insn[1].imm) << 32;
-
-       return (struct bpf_map *) (unsigned long) imm64;
-}
-
 /* verify BPF_LD_IMM64 instruction */
 static int check_ld_imm(struct bpf_verifier_env *env, struct bpf_insn *insn)
 {
+       struct bpf_insn_aux_data *aux = cur_aux(env);
        struct bpf_reg_state *regs = cur_regs(env);
+       struct bpf_map *map;
        int err;
 
        if (BPF_SIZE(insn->code) != BPF_DW) {
@@ -4979,11 +4973,22 @@ static int check_ld_imm(struct bpf_verifier_env *env, struct bpf_insn *insn)
                return 0;
        }
 
-       /* replace_map_fd_with_map_ptr() should have caught bad ld_imm64 */
-       BUG_ON(insn->src_reg != BPF_PSEUDO_MAP_FD);
+       map = env->used_maps[aux->map_index];
+       mark_reg_known_zero(env, regs, insn->dst_reg);
+       regs[insn->dst_reg].map_ptr = map;
+
+       if (insn->src_reg == BPF_PSEUDO_MAP_VALUE) {
+               regs[insn->dst_reg].type = PTR_TO_MAP_VALUE;
+               regs[insn->dst_reg].off = aux->map_off;
+               if (map_value_has_spin_lock(map))
+                       regs[insn->dst_reg].id = ++env->id_gen;
+       } else if (insn->src_reg == BPF_PSEUDO_MAP_FD) {
+               regs[insn->dst_reg].type = CONST_PTR_TO_MAP;
+       } else {
+               verbose(env, "bpf verifier is misconfigured\n");
+               return -EINVAL;
+       }
 
-       regs[insn->dst_reg].type = CONST_PTR_TO_MAP;
-       regs[insn->dst_reg].map_ptr = ld_imm64_to_map_ptr(insn);
        return 0;
 }
 
@@ -6664,8 +6669,10 @@ static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env)
                }
 
                if (insn[0].code == (BPF_LD | BPF_IMM | BPF_DW)) {
+                       struct bpf_insn_aux_data *aux;
                        struct bpf_map *map;
                        struct fd f;
+                       u64 addr;
 
                        if (i == insn_cnt - 1 || insn[1].code != 0 ||
                            insn[1].dst_reg != 0 || insn[1].src_reg != 0 ||
@@ -6677,8 +6684,8 @@ static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env)
                        if (insn->src_reg == 0)
                                /* valid generic load 64-bit imm */
                                goto next_insn;
-
-                       if (insn->src_reg != BPF_PSEUDO_MAP_FD) {
+                       if (insn->src_reg != BPF_PSEUDO_MAP_FD &&
+                           insn->src_reg != BPF_PSEUDO_MAP_VALUE) {
                                verbose(env,
                                        "unrecognized bpf_ld_imm64 insn\n");
                                return -EINVAL;
@@ -6698,16 +6705,44 @@ static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env)
                                return err;
                        }
 
-                       /* store map pointer inside BPF_LD_IMM64 instruction */
-                       insn[0].imm = (u32) (unsigned long) map;
-                       insn[1].imm = ((u64) (unsigned long) map) >> 32;
+                       aux = &env->insn_aux_data[i];
+                       if (insn->src_reg == BPF_PSEUDO_MAP_FD) {
+                               addr = (unsigned long)map;
+                       } else {
+                               u32 off = insn[1].imm;
+
+                               if (off >= BPF_MAX_VAR_OFF) {
+                                       verbose(env, "direct value offset of %u is not allowed\n",
+                                               off);
+                                       return -EINVAL;
+                               }
+                               if (!map->ops->map_direct_value_access) {
+                                       verbose(env, "no direct value access support for this map type\n");
+                                       return -EINVAL;
+                               }
+
+                               err = map->ops->map_direct_value_access(map, off, &addr);
+                               if (err) {
+                                       verbose(env, "invalid access to map value pointer, value_size=%u off=%u\n",
+                                               map->value_size, off);
+                                       return err;
+                               }
+
+                               aux->map_off = off;
+                               addr += off;
+                       }
+
+                       insn[0].imm = (u32)addr;
+                       insn[1].imm = addr >> 32;
 
                        /* check whether we recorded this map already */
-                       for (j = 0; j < env->used_map_cnt; j++)
+                       for (j = 0; j < env->used_map_cnt; j++) {
                                if (env->used_maps[j] == map) {
+                                       aux->map_index = j;
                                        fdput(f);
                                        goto next_insn;
                                }
+                       }
 
                        if (env->used_map_cnt >= MAX_USED_MAPS) {
                                fdput(f);
@@ -6724,6 +6759,8 @@ static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env)
                                fdput(f);
                                return PTR_ERR(map);
                        }
+
+                       aux->map_index = env->used_map_cnt;
                        env->used_maps[env->used_map_cnt++] = map;
 
                        if (bpf_map_is_cgroup_storage(map) &&
tools/bpf/bpftool/xlated_dumper.c +3 -0
index 7073dbe1ff27..0bb17bf88b18 100644
@@ -195,6 +195,9 @@ static const char *print_imm(void *private_data,
        if (insn->src_reg == BPF_PSEUDO_MAP_FD)
                snprintf(dd->scratch_buff, sizeof(dd->scratch_buff),
                         "map[id:%u]", insn->imm);
+       else if (insn->src_reg == BPF_PSEUDO_MAP_VALUE)
+               snprintf(dd->scratch_buff, sizeof(dd->scratch_buff),
+                        "map[id:%u][0]+%u", insn->imm, (insn + 1)->imm);
        else
                snprintf(dd->scratch_buff, sizeof(dd->scratch_buff),
                         "0x%llx", (unsigned long long)full_imm);
tools/include/uapi/linux/bpf.h +5 -2
index 2e308e90ffea..8884072e1a46 100644
@@ -255,8 +255,12 @@ 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->src_reg == BPF_PSEUDO_MAP_{FD,VALUE}, then
+ * bpf_ldimm64's insn[0]->imm == fd in both cases. Additionally,
+ * for BPF_PSEUDO_MAP_VALUE, insn[1]->imm == offset into 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
--

2.17.1

author maintainer
#4 lore raw

Re: [PATCH bpf-next v2 1/7] bpf: implement lookup-free direct value access

Quoted 9 lines · Andrii Nakryiko
Quoted 4 lines · Daniel Borkmann

This generic extension to BPF maps allows for directly loading an address residing inside a BPF map value as a single BPF ldimm64 instruction.

This is great! I'm going to review code more thoroughly tomorrow, but I also have few questions/suggestions I'd like to discuss, if you don't mind.

Awesome, thanks!

Quoted 16 lines
Quoted 6 lines

The idea is similar to what BPF_PSEUDO_MAP_FD does today, which is a special src_reg flag for ldimm64 instruction that indicates that inside the first part of the double insns's imm field is a file descriptor which the verifier then replaces as a full 64bit address of the map into both imm parts.

Quoted 9 lines

For the newly added BPF_PSEUDO_MAP_VALUE src_reg flag, the idea is similar: the first part of the double insns's imm field is again a file descriptor corresponding to the map, and the second part of the imm field is an offset. The verifier will then replace both imm parts with an address that points into the BPF map value for maps that support this operation. BPF_PSEUDO_MAP_VALUE is a distinct flag as otherwise with BPF_PSEUDO_MAP_FD we could not differ offset 0 between load of map pointer versus load of map's value at offset 0.

Quoted 10 lines

Is having both BPF_PSEUDO_MAP_FD and BPF_PSEUDO_MAP_VALUE a desirable thing? I'm asking because it's seems like it would be really simple to stick to using just BPF_PSEUDO_MAP_FD and then interpret imm differently depending on whether it's 0 or not. E.g., we can say that imm=0 is old BPF_PSEUDO_MAP_FD behavior (loading map addr), but any other imm value X is really just (X-1) offset into map's value? Or, given that valid offset is limited to 1<<29, we can set highest-order bit to 1 and lower bits would be offset? In other words, if we just need too carve out zero as a special case, then it's easy to do and we can avoid adding new BPF_PSEUDO_MAP_VALUE.

Was thinking about reusing BPF_PSEUDO_MAP_FD initially as mentioned in here, but went for BPF_PSEUDO_MAP_VALUE eventually to have a straight forward mapping. Your suggestion could be done, but it feels more complex than necessary, imho, meaning it might confuse users trying to make sense of a insn dump or verifier output wondering whether the off by one is a bug or not, which won't happen if the offset is exactly the same value as LLVM emits. There is also one more unfortunate reason which I noticed while implementing: in replace_map_fd_with_map_ptr() we never enforced that for BPF_PSEUDO_MAP_FD insns the second imm part must be 0, meaning it could also have a garbage value which would then break loaders in the wild; with the code today this is ignored and then overridden by the map address. We could try to push a patch to stable to reject anything non-zero in the second imm for BPF_PSEUDO_MAP_FD and see if anyone actually notices, and then use some higher-order bit as a selector, but that still would need some extra handling to make the offset clear for users wrt dumps; I can give it a try though to check how much more complex it gets. Worst case if something should really break somewhere, we might need to revert the imm==0 rejection though. Overall, BPF_PSEUDO_MAP_VALUE felt slightly more suitable to me.

Quoted 6 lines
Quoted 5 lines

This allows for efficiently retrieving an address to a map value memory area without having to issue a helper call which needs to prepare registers according to calling convention, etc, without needing the extra NULL test, and without having to add the offset in an additional instruction to the value base pointer.

Quoted 7 lines

It seems like we allow this only for arrays of size 1 right now. We can easily generalize this to support not just offset into map's value, but also specifying integer key (i.e., array index) by utilizing off fields (16-bit + 16-bit). This would allow to eliminate any bpf_map_update_elem calls to array maps altogether by allowing to provide both array index and offset into value in one BPF instruction. Do you think it's a good addition?

Yeah, I've been thinking about this as well that for array-like maps it's easy to support and at the same time lifts the restriction, too. I think it would be useful and straight forward to implement, I can include it into v3.

Quoted 30 lines
Quoted 6 lines

The verifier then treats the destination register as PTR_TO_MAP_VALUE with constant reg->off from the user passed offset from the second imm field, and guarantees that this is within bounds of the map value. Any subsequent operations are normally treated as typical map value handling without anything else needed for verification.

Quoted 8 lines

The two map operations for direct value access have been added to array map for now. In future other types could be supported as well depending on the use case. The main use case for this commit is to allow for BPF loader support for global variables that reside in .data/.rodata/.bss sections such that we can directly load the address of them with minimal additional infrastructure required. Loader support has been added in subsequent commits for libbpf library.

I was considering adding a new kind of map representing contiguous block of memory (e.g., how about BPF_MAP_TYPE_HEAP or BPF_MAP_TYPE_BLOB?). It's keys would be offset into that memory region. Value size is size of the memory region, but it would allow reading smaller chunks of memory as values. This would provide convenient interface for poking at global variables from userland, given offset.

Libbpf itself would provide higher-level API as well, if there is corresponding BTF type information describing layout of .data/.bss/.rodata, so that applications can fetch variables by name and/or offset, whichever is more convenient. Together with bpf_spinlock this would allow easy way to customize subsets of global variables in atomic fashion.

Quoted 3 lines

Do you think that would work? Using array is a bit limiting, because it doesn't allow to do partial reads/updates, while BPF_MAP_TYPE_HEAP would be single big value that allows partial reading/updating.

If I understand it correctly, the main difference this would have is to be able to use spin_locks in a more fine-grained fashion, right? Meaning, partial reads/updates of the memory area under spin_lock as opposed to having to lock over the full area? Yeah, sounds like a reasonable extension to me that could be done on top of the series, presumably most of the array map logic could also be reused for this which is nice.

Thanks a lot,
Daniel

#5 lore raw

Re: [PATCH bpf-next v2 1/7] bpf: implement lookup-free direct value access

Quoted 1 line · Daniel Borkmann

Overall, BPF_PSEUDO_MAP_VALUE felt slightly more suitable to me.

FWIW +1 I think different type is way cleaner here.

#6 lore raw

Re: [PATCH bpf-next v2 1/7] bpf: implement lookup-free direct value access

In reply to Daniel Borkmann
Quoted 52 lines · Daniel Borkmann
Quoted 9 lines · Andrii Nakryiko
Quoted 4 lines · Daniel Borkmann

This generic extension to BPF maps allows for directly loading an address residing inside a BPF map value as a single BPF ldimm64 instruction.

This is great! I'm going to review code more thoroughly tomorrow, but I also have few questions/suggestions I'd like to discuss, if you don't mind.

Awesome, thanks!

Quoted 16 lines
Quoted 6 lines

The idea is similar to what BPF_PSEUDO_MAP_FD does today, which is a special src_reg flag for ldimm64 instruction that indicates that inside the first part of the double insns's imm field is a file descriptor which the verifier then replaces as a full 64bit address of the map into both imm parts.

Quoted 9 lines

For the newly added BPF_PSEUDO_MAP_VALUE src_reg flag, the idea is similar: the first part of the double insns's imm field is again a file descriptor corresponding to the map, and the second part of the imm field is an offset. The verifier will then replace both imm parts with an address that points into the BPF map value for maps that support this operation. BPF_PSEUDO_MAP_VALUE is a distinct flag as otherwise with BPF_PSEUDO_MAP_FD we could not differ offset 0 between load of map pointer versus load of map's value at offset 0.

Quoted 10 lines

Is having both BPF_PSEUDO_MAP_FD and BPF_PSEUDO_MAP_VALUE a desirable thing? I'm asking because it's seems like it would be really simple to stick to using just BPF_PSEUDO_MAP_FD and then interpret imm differently depending on whether it's 0 or not. E.g., we can say that imm=0 is old BPF_PSEUDO_MAP_FD behavior (loading map addr), but any other imm value X is really just (X-1) offset into map's value? Or, given that valid offset is limited to 1<<29, we can set highest-order bit to 1 and lower bits would be offset? In other words, if we just need too carve out zero as a special case, then it's easy to do and we can avoid adding new BPF_PSEUDO_MAP_VALUE.

Was thinking about reusing BPF_PSEUDO_MAP_FD initially as mentioned in here, but went for BPF_PSEUDO_MAP_VALUE eventually to have a straight forward mapping. Your suggestion could be done, but it feels more complex than necessary, imho, meaning it might confuse users trying to make sense of a insn dump or verifier output wondering whether the off by one is a bug or not, which won't happen if the offset is exactly the same value as LLVM emits. There is also one more unfortunate reason which I noticed while implementing: in replace_map_fd_with_map_ptr() we never enforced that for BPF_PSEUDO_MAP_FD insns the second imm part must be 0, meaning it could also have a garbage value which would then break loaders in the wild; with the code today this is ignored and then

Quoted 8 lines

overridden by the map address. We could try to push a patch to stable to reject anything non-zero in the second imm for BPF_PSEUDO_MAP_FD and see if anyone actually notices, and then use some higher-order bit as a selector, but that still would need some extra handling to make the offset clear for users wrt dumps; I can give it a try though to check how much more complex it gets. Worst case if something should really break somewhere, we might need to revert the imm==0 rejection though. Overall, BPF_PSEUDO_MAP_VALUE felt slightly more suitable to me.

Yeah, make sense, BPF_PSEUDO_MAP_VALUE is more explicit.

Quoted 50 lines
Quoted 7 lines
Quoted 6 lines

This allows for efficiently retrieving an address to a map value memory area without having to issue a helper call which needs to prepare registers according to calling convention, etc, without needing the extra NULL test, and without having to add the offset in an additional instruction to the value base pointer.

Quoted 7 lines

It seems like we allow this only for arrays of size 1 right now. We can easily generalize this to support not just offset into map's value, but also specifying integer key (i.e., array index) by utilizing off fields (16-bit + 16-bit). This would allow to eliminate any bpf_map_update_elem calls to array maps altogether by allowing to provide both array index and offset into value in one BPF instruction. Do you think it's a good addition?

Yeah, I've been thinking about this as well that for array-like maps it's easy to support and at the same time lifts the restriction, too. I think it would be useful and straight forward to implement, I can include it into v3.

Quoted 30 lines
Quoted 6 lines

The verifier then treats the destination register as PTR_TO_MAP_VALUE with constant reg->off from the user passed offset from the second imm field, and guarantees that this is within bounds of the map value. Any subsequent operations are normally treated as typical map value handling without anything else needed for verification.

Quoted 8 lines

The two map operations for direct value access have been added to array map for now. In future other types could be supported as well depending on the use case. The main use case for this commit is to allow for BPF loader support for global variables that reside in .data/.rodata/.bss sections such that we can directly load the address of them with minimal additional infrastructure required. Loader support has been added in subsequent commits for libbpf library.

I was considering adding a new kind of map representing contiguous block of memory (e.g., how about BPF_MAP_TYPE_HEAP or BPF_MAP_TYPE_BLOB?). It's keys would be offset into that memory region. Value size is size of the memory region, but it would allow reading smaller chunks of memory as values. This would provide convenient interface for poking at global variables from userland, given offset.

Libbpf itself would provide higher-level API as well, if there is corresponding BTF type information describing layout of .data/.bss/.rodata, so that applications can fetch variables by name and/or offset, whichever is more convenient. Together with bpf_spinlock this would allow easy way to customize subsets of global variables in atomic fashion.

Quoted 6 lines
Quoted 3 lines

Do you think that would work? Using array is a bit limiting, because it doesn't allow to do partial reads/updates, while BPF_MAP_TYPE_HEAP would be single big value that allows partial reading/updating.

If I understand it correctly, the main difference this would have is to be able to use spin_locks in a more fine-grained fashion, right?

spin_lock is just a nice bonus, if there is any manipulation that isn't <= 8 byte long that needs to be done atomically.

The reason for this new type of map is actually ability to update global variables from outside BPF program in granular fashion. E.g., turning on some extra debug output temporarily, tuning parameters, changing PID to trace, etc, without stopping and reloading BPF program. With array, it's all-or-nothing: to update anything you have to overwrite entire .data section. As I mentioned, if we can get BTF type information for entirety of .data, it would allow to manipulate those variables by name even with generic tools like bpftool.

Quoted 8 lines

Meaning, partial reads/updates of the memory area under spin_lock as opposed to having to lock over the full area? Yeah, sounds like a reasonable extension to me that could be done on top of the series, presumably most of the array map logic could also be reused for this which is nice.

Thanks a lot,
Daniel

#7 lore raw

Re: [PATCH bpf-next v2 1/7] bpf: implement lookup-free direct value access

Quoted 10 lines · Andrii Nakryiko
Quoted 6 lines
Quoted 3 lines

Do you think that would work? Using array is a bit limiting, because it doesn't allow to do partial reads/updates, while BPF_MAP_TYPE_HEAP would be single big value that allows partial reading/updating.

If I understand it correctly, the main difference this would have is to be able to use spin_locks in a more fine-grained fashion, right?

spin_lock is just a nice bonus, if there is any manipulation that isn't <= 8 byte long that needs to be done atomically.

Quoted 8 lines

The reason for this new type of map is actually ability to update global variables from outside BPF program in granular fashion. E.g., turning on some extra debug output temporarily, tuning parameters, changing PID to trace, etc, without stopping and reloading BPF program. With array, it's all-or-nothing: to update anything you have to overwrite entire .data section. As I mentioned, if we can get BTF type information for entirety of .data, it would allow to manipulate those variables by name even with generic tools like bpftool.

Sounds like you'd almost want to mmap the value ;)

#8 lore raw

Re: [PATCH bpf-next v2 1/7] bpf: implement lookup-free direct value access

In reply to Daniel Borkmann
Quoted 32 lines · Daniel Borkmann

This generic extension to BPF maps allows for directly loading an address residing inside a BPF map value as a single BPF ldimm64 instruction.

The idea is similar to what BPF_PSEUDO_MAP_FD does today, which is a special src_reg flag for ldimm64 instruction that indicates that inside the first part of the double insns's imm field is a file descriptor which the verifier then replaces as a full 64bit address of the map into both imm parts.

For the newly added BPF_PSEUDO_MAP_VALUE src_reg flag, the idea is similar: the first part of the double insns's imm field is again a file descriptor corresponding to the map, and the second part of the imm field is an offset. The verifier will then replace both imm parts with an address that points into the BPF map value for maps that support this operation. BPF_PSEUDO_MAP_VALUE is a distinct flag as otherwise with BPF_PSEUDO_MAP_FD we could not differ offset 0 between load of map pointer versus load of map's value at offset 0.

This allows for efficiently retrieving an address to a map value memory area without having to issue a helper call which needs to prepare registers according to calling convention, etc, without needing the extra NULL test, and without having to add the offset in an additional instruction to the value base pointer.

The verifier then treats the destination register as PTR_TO_MAP_VALUE with constant reg->off from the user passed offset from the second imm field, and guarantees that this is within bounds of the map value. Any subsequent operations are normally treated as typical map value handling without anything else needed for verification.

Quoted 8 lines

The two map operations for direct value access have been added to array map for now. In future other types could be supported as well depending on the use case. The main use case for this commit is to allow for BPF loader support for global variables that reside in .data/.rodata/.bss sections such that we can directly load the address of them with minimal additional infrastructure required. Loader support has been added in subsequent commits for libbpf library.

The patch version #1 provides a way to replace the load with immediate (presumably read-only data). This will be good for the use case like below:

    if (static_variable_kernel_version == V1) {
        /* code here will work for kernel V1 */
        ... access helpers available for V1 ...
    } else if (static_variable_kernel_version == V2) {
        /* code here will work for kernel V2 */
        ... access helpers available for V2 ...
    }

The approach here did not replace the map value access with values from e.g., readonly section for which libbpf could provide an interface to fill in data from user.

This may require a little more analysis, e.g.,

    ptr = ld_imm64 from a readonly section
    ...
    *(u32 *)ptr;
    *(u64 *)(ptr + 8);
    ...

Do you think we could do this in kernel verifier or we should push the whole readonly stuff into user space?

Quoted 372 lines
---
  include/linux/bpf.h               |  6 +++
  include/linux/bpf_verifier.h      |  4 ++
  include/uapi/linux/bpf.h          |  6 ++-
  kernel/bpf/arraymap.c             | 33 ++++++++++++++
  kernel/bpf/core.c                 |  3 +-
  kernel/bpf/disasm.c               |  5 ++-
  kernel/bpf/syscall.c              | 29 +++++++++---
  kernel/bpf/verifier.c             | 73 +++++++++++++++++++++++--------
  tools/bpf/bpftool/xlated_dumper.c |  3 ++
  tools/include/uapi/linux/bpf.h    |  6 ++-
  10 files changed, 138 insertions(+), 30 deletions(-)
include/linux/bpf.h +6 -0
index a2132e09dc1c..bdcc6e2a9977 100644
@@ -57,6 +57,12 @@ struct bpf_map_ops {
  			     const struct btf *btf,
  			     const struct btf_type *key_type,
  			     const struct btf_type *value_type);
+
+	/* Direct value access helpers. */
+	int (*map_direct_value_access)(const struct bpf_map *map,
+				       u32 off, u64 *imm);
+	int (*map_direct_value_offset)(const struct bpf_map *map,
+				       u64 imm, u32 *off);
  };
 
  struct bpf_map {
include/linux/bpf_verifier.h +4 -0
index 69f7a3449eda..6e28f1c24710 100644
@@ -183,6 +183,10 @@ struct bpf_insn_aux_data {
  		unsigned long map_state;	/* pointer/poison value for maps */
  		s32 call_imm;			/* saved imm field of call insn */
  		u32 alu_limit;			/* limit for add/sub register with pointer */
+		struct {
+			u32 map_index;		/* index into used_maps[] */
+			u32 map_off;		/* offset from value base address */
+		};
  	};
  	int ctx_field_size; /* the ctx field size for load insn, maybe 0 */
  	int sanitize_stack_off; /* stack slot to be cleared */
include/uapi/linux/bpf.h +5 -1
index 2e308e90ffea..8884072e1a46 100644
@@ -255,8 +255,12 @@ 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->src_reg == BPF_PSEUDO_MAP_{FD,VALUE}, then
+ * bpf_ldimm64's insn[0]->imm == fd in both cases. Additionally,
+ * for BPF_PSEUDO_MAP_VALUE, insn[1]->imm == offset into 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
kernel/bpf/arraymap.c +33 -0
index c72e0d8e1e65..3e5969c0c979 100644
@@ -160,6 +160,37 @@ static void *array_map_lookup_elem(struct bpf_map *map, void *key)
  	return array->value + array->elem_size * (index & array->index_mask);
  }
 
+static int array_map_direct_value_access(const struct bpf_map *map, u32 off,
+					 u64 *imm)
+{
+	struct bpf_array *array = container_of(map, struct bpf_array, map);
+
+	if (map->max_entries != 1)
+		return -ENOTSUPP;
+	if (off >= map->value_size)
+		return -EINVAL;
+
+	*imm = (unsigned long)array->value;
+	return 0;
+}
+
+static int array_map_direct_value_offset(const struct bpf_map *map, u64 imm,
+					 u32 *off)
+{
+	struct bpf_array *array = container_of(map, struct bpf_array, map);
+	unsigned long range = map->value_size;
+	unsigned long base  = array->value;
+	unsigned long addr  = imm;
+
+	if (map->max_entries != 1)
+		return -ENOENT;
+	if (addr < base || addr >= base + range)
+		return -ENOENT;
+
+	*off = addr - base;
+	return 0;
+}
+
  /* emit BPF instructions equivalent to C code of array_map_lookup_elem() */
  static u32 array_map_gen_lookup(struct bpf_map *map, struct bpf_insn *insn_buf)
  {
@@ -419,6 +450,8 @@ const struct bpf_map_ops array_map_ops = {
  	.map_update_elem = array_map_update_elem,
  	.map_delete_elem = array_map_delete_elem,
  	.map_gen_lookup = array_map_gen_lookup,
+	.map_direct_value_access = array_map_direct_value_access,
+	.map_direct_value_offset = array_map_direct_value_offset,
  	.map_seq_show_elem = array_map_seq_show_elem,
  	.map_check_btf = array_map_check_btf,
  };
kernel/bpf/core.c +2 -1
index 1c14c347f3cf..49fc0ff14537 100644
@@ -286,7 +286,8 @@ int bpf_prog_calc_tag(struct bpf_prog *fp)
  		dst[i] = fp->insnsi[i];
  		if (!was_ld_map &&
  		    dst[i].code == (BPF_LD | BPF_IMM | BPF_DW) &&
-		    dst[i].src_reg == BPF_PSEUDO_MAP_FD) {
+		    (dst[i].src_reg == BPF_PSEUDO_MAP_FD ||
+		     dst[i].src_reg == BPF_PSEUDO_MAP_VALUE)) {
  			was_ld_map = true;
  			dst[i].imm = 0;
  		} else if (was_ld_map &&
kernel/bpf/disasm.c +3 -2
index de73f55e42fd..d9ce383c0f9c 100644
@@ -205,10 +205,11 @@ void print_bpf_insn(const struct bpf_insn_cbs *cbs,
  			 * part of the ldimm64 insn is accessible.
  			 */
  			u64 imm = ((u64)(insn + 1)->imm << 32) | (u32)insn->imm;
-			bool map_ptr = insn->src_reg == BPF_PSEUDO_MAP_FD;
+			bool is_ptr = insn->src_reg == BPF_PSEUDO_MAP_FD ||
+				      insn->src_reg == BPF_PSEUDO_MAP_VALUE;
  			char tmp[64];
 
-			if (map_ptr && !allow_ptr_leaks)
+			if (is_ptr && !allow_ptr_leaks)
  				imm = 0;
 
  			verbose(cbs->private_data, "(%02x) r%d = %s\n",
kernel/bpf/syscall.c +22 -7
index 174581dfe225..d3ef45e01d7a 100644
@@ -2061,13 +2061,27 @@ static int bpf_map_get_fd_by_id(const union bpf_attr *attr)
  }
 
  static const struct bpf_map *bpf_map_from_imm(const struct bpf_prog *prog,
-					      unsigned long addr)
+					      unsigned long addr, u32 *off,
+					      u32 *type)
  {
+	const struct bpf_map *map;
  	int i;
 
-	for (i = 0; i < prog->aux->used_map_cnt; i++)
-		if (prog->aux->used_maps[i] == (void *)addr)
-			return prog->aux->used_maps[i];
+	*off = *type = 0;
+	for (i = 0; i < prog->aux->used_map_cnt; i++) {
+		map = prog->aux->used_maps[i];
+		if (map == (void *)addr) {
+			*type = BPF_PSEUDO_MAP_FD;
+			return map;
+		}
+		if (!map->ops->map_direct_value_offset)
+			continue;
+		if (!map->ops->map_direct_value_offset(map, addr, off)) {
+			*type = BPF_PSEUDO_MAP_VALUE;
+			return map;
+		}
+	}
+
  	return NULL;
  }
 
@@ -2075,6 +2089,7 @@ static struct bpf_insn *bpf_insn_prepare_dump(const struct bpf_prog *prog)
  {
  	const struct bpf_map *map;
  	struct bpf_insn *insns;
+	u32 off, type;
  	u64 imm;
  	int i;
 
@@ -2102,11 +2117,11 @@ static struct bpf_insn *bpf_insn_prepare_dump(const struct bpf_prog *prog)
  			continue;
 
  		imm = ((u64)insns[i + 1].imm << 32) | (u32)insns[i].imm;
-		map = bpf_map_from_imm(prog, imm);
+		map = bpf_map_from_imm(prog, imm, &off, &type);
  		if (map) {
-			insns[i].src_reg = BPF_PSEUDO_MAP_FD;
+			insns[i].src_reg = type;
  			insns[i].imm = map->id;
-			insns[i + 1].imm = 0;
+			insns[i + 1].imm = off;
  			continue;
  		}
  	}
kernel/bpf/verifier.c +55 -18
index 0e4edd7e3c5f..3ad05dda6e9d 100644
@@ -4944,18 +4944,12 @@ static int check_cond_jmp_op(struct bpf_verifier_env *env,
  	return 0;
  }
 
-/* return the map pointer stored inside BPF_LD_IMM64 instruction */
-static struct bpf_map *ld_imm64_to_map_ptr(struct bpf_insn *insn)
-{
-	u64 imm64 = ((u64) (u32) insn[0].imm) | ((u64) (u32) insn[1].imm) << 32;
-
-	return (struct bpf_map *) (unsigned long) imm64;
-}
-
  /* verify BPF_LD_IMM64 instruction */
  static int check_ld_imm(struct bpf_verifier_env *env, struct bpf_insn *insn)
  {
+	struct bpf_insn_aux_data *aux = cur_aux(env);
  	struct bpf_reg_state *regs = cur_regs(env);
+	struct bpf_map *map;
  	int err;
 
  	if (BPF_SIZE(insn->code) != BPF_DW) {
@@ -4979,11 +4973,22 @@ static int check_ld_imm(struct bpf_verifier_env *env, struct bpf_insn *insn)
  		return 0;
  	}
 
-	/* replace_map_fd_with_map_ptr() should have caught bad ld_imm64 */
-	BUG_ON(insn->src_reg != BPF_PSEUDO_MAP_FD);
+	map = env->used_maps[aux->map_index];
+	mark_reg_known_zero(env, regs, insn->dst_reg);
+	regs[insn->dst_reg].map_ptr = map;
+
+	if (insn->src_reg == BPF_PSEUDO_MAP_VALUE) {
+		regs[insn->dst_reg].type = PTR_TO_MAP_VALUE;
+		regs[insn->dst_reg].off = aux->map_off;
+		if (map_value_has_spin_lock(map))
+			regs[insn->dst_reg].id = ++env->id_gen;
+	} else if (insn->src_reg == BPF_PSEUDO_MAP_FD) {
+		regs[insn->dst_reg].type = CONST_PTR_TO_MAP;
+	} else {
+		verbose(env, "bpf verifier is misconfigured\n");
+		return -EINVAL;
+	}
 
-	regs[insn->dst_reg].type = CONST_PTR_TO_MAP;
-	regs[insn->dst_reg].map_ptr = ld_imm64_to_map_ptr(insn);
  	return 0;
  }
 
@@ -6664,8 +6669,10 @@ static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env)
  		}
 
  		if (insn[0].code == (BPF_LD | BPF_IMM | BPF_DW)) {
+			struct bpf_insn_aux_data *aux;
  			struct bpf_map *map;
  			struct fd f;
+			u64 addr;
 
  			if (i == insn_cnt - 1 || insn[1].code != 0 ||
  			    insn[1].dst_reg != 0 || insn[1].src_reg != 0 ||
@@ -6677,8 +6684,8 @@ static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env)
  			if (insn->src_reg == 0)
  				/* valid generic load 64-bit imm */
  				goto next_insn;
-
-			if (insn->src_reg != BPF_PSEUDO_MAP_FD) {
+			if (insn->src_reg != BPF_PSEUDO_MAP_FD &&
+			    insn->src_reg != BPF_PSEUDO_MAP_VALUE) {
  				verbose(env,
  					"unrecognized bpf_ld_imm64 insn\n");
  				return -EINVAL;
@@ -6698,16 +6705,44 @@ static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env)
  				return err;
  			}
 
-			/* store map pointer inside BPF_LD_IMM64 instruction */
-			insn[0].imm = (u32) (unsigned long) map;
-			insn[1].imm = ((u64) (unsigned long) map) >> 32;
+			aux = &env->insn_aux_data[i];
+			if (insn->src_reg == BPF_PSEUDO_MAP_FD) {
+				addr = (unsigned long)map;
+			} else {
+				u32 off = insn[1].imm;
+
+				if (off >= BPF_MAX_VAR_OFF) {
+					verbose(env, "direct value offset of %u is not allowed\n",
+						off);
+					return -EINVAL;
+				}
+				if (!map->ops->map_direct_value_access) {
+					verbose(env, "no direct value access support for this map type\n");
+					return -EINVAL;
+				}
+
+				err = map->ops->map_direct_value_access(map, off, &addr);
+				if (err) {
+					verbose(env, "invalid access to map value pointer, value_size=%u off=%u\n",
+						map->value_size, off);
+					return err;
+				}
+
+				aux->map_off = off;
+				addr += off;
+			}
+
+			insn[0].imm = (u32)addr;
+			insn[1].imm = addr >> 32;
 
  			/* check whether we recorded this map already */
-			for (j = 0; j < env->used_map_cnt; j++)
+			for (j = 0; j < env->used_map_cnt; j++) {
  				if (env->used_maps[j] == map) {
+					aux->map_index = j;
  					fdput(f);
  					goto next_insn;
  				}
+			}
 
  			if (env->used_map_cnt >= MAX_USED_MAPS) {
  				fdput(f);
@@ -6724,6 +6759,8 @@ static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env)
  				fdput(f);
  				return PTR_ERR(map);
  			}
+
+			aux->map_index = env->used_map_cnt;
  			env->used_maps[env->used_map_cnt++] = map;
 
  			if (bpf_map_is_cgroup_storage(map) &&
tools/bpf/bpftool/xlated_dumper.c +3 -0
index 7073dbe1ff27..0bb17bf88b18 100644
@@ -195,6 +195,9 @@ static const char *print_imm(void *private_data,
  	if (insn->src_reg == BPF_PSEUDO_MAP_FD)
  		snprintf(dd->scratch_buff, sizeof(dd->scratch_buff),
  			 "map[id:%u]", insn->imm);
+	else if (insn->src_reg == BPF_PSEUDO_MAP_VALUE)
+		snprintf(dd->scratch_buff, sizeof(dd->scratch_buff),
+			 "map[id:%u][0]+%u", insn->imm, (insn + 1)->imm);
  	else
  		snprintf(dd->scratch_buff, sizeof(dd->scratch_buff),
  			 "0x%llx", (unsigned long long)full_imm);
tools/include/uapi/linux/bpf.h +5 -1
index 2e308e90ffea..8884072e1a46 100644
@@ -255,8 +255,12 @@ 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->src_reg == BPF_PSEUDO_MAP_{FD,VALUE}, then
+ * bpf_ldimm64's insn[0]->imm == fd in both cases. Additionally,
+ * for BPF_PSEUDO_MAP_VALUE, insn[1]->imm == offset into 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
author maintainer
#9 lore raw

Re: [PATCH bpf-next v2 1/7] bpf: implement lookup-free direct value access

Quoted 59 lines · Yonghong Song
Quoted 32 lines · Daniel Borkmann

This generic extension to BPF maps allows for directly loading an address residing inside a BPF map value as a single BPF ldimm64 instruction.

The idea is similar to what BPF_PSEUDO_MAP_FD does today, which is a special src_reg flag for ldimm64 instruction that indicates that inside the first part of the double insns's imm field is a file descriptor which the verifier then replaces as a full 64bit address of the map into both imm parts.

For the newly added BPF_PSEUDO_MAP_VALUE src_reg flag, the idea is similar: the first part of the double insns's imm field is again a file descriptor corresponding to the map, and the second part of the imm field is an offset. The verifier will then replace both imm parts with an address that points into the BPF map value for maps that support this operation. BPF_PSEUDO_MAP_VALUE is a distinct flag as otherwise with BPF_PSEUDO_MAP_FD we could not differ offset 0 between load of map pointer versus load of map's value at offset 0.

This allows for efficiently retrieving an address to a map value memory area without having to issue a helper call which needs to prepare registers according to calling convention, etc, without needing the extra NULL test, and without having to add the offset in an additional instruction to the value base pointer.

The verifier then treats the destination register as PTR_TO_MAP_VALUE with constant reg->off from the user passed offset from the second imm field, and guarantees that this is within bounds of the map value. Any subsequent operations are normally treated as typical map value handling without anything else needed for verification.

Quoted 8 lines

The two map operations for direct value access have been added to array map for now. In future other types could be supported as well depending on the use case. The main use case for this commit is to allow for BPF loader support for global variables that reside in .data/.rodata/.bss sections such that we can directly load the address of them with minimal additional infrastructure required. Loader support has been added in subsequent commits for libbpf library.

The patch version #1 provides a way to replace the load with immediate (presumably read-only data). This will be good for the use case like below:

    if (static_variable_kernel_version == V1) {
        /* code here will work for kernel V1 */
        ... access helpers available for V1 ...
    } else if (static_variable_kernel_version == V2) {
        /* code here will work for kernel V2 */
        ... access helpers available for V2 ...
    }

The approach here did not replace the map value access with values from e.g., readonly section for which libbpf could provide an interface to fill in data from user.

This may require a little more analysis, e.g.,

Quoted 8 lines
    ptr = ld_imm64 from a readonly section
    ...
    *(u32 *)ptr;
    *(u64 *)(ptr + 8);
    ...

Do you think we could do this in kernel verifier or we should push the whole readonly stuff into user space?

And in your case the static_variable_kernel_version would be determined at runtime, for example, where you then would want to eliminate all the other branches, right? Meaning, you'd need a way to turn this into a imm load such that verifier will detect these dead branches and patch them out, which it should already be able to do. How would you mark these special vars like static_variable_kernel_version such that they have special treatment from the rest, some sort of builtin? Potentially one could get away with doing this from loader side if it's simple enough, though one thing that would be good to avoid is to duplicate all the complex branch fixup logic etc that we have in kernel already. Are you thinking to mark these via BTF in some way such that loader does inline replacement?

Thanks,
Daniel

#10 lore raw

Re: [PATCH bpf-next v2 1/7] bpf: implement lookup-free direct value access

Quoted 66 lines · Daniel Borkmann
Quoted 65 lines · Yonghong Song
Quoted 32 lines · Daniel Borkmann

This generic extension to BPF maps allows for directly loading an address residing inside a BPF map value as a single BPF ldimm64 instruction.

The idea is similar to what BPF_PSEUDO_MAP_FD does today, which is a special src_reg flag for ldimm64 instruction that indicates that inside the first part of the double insns's imm field is a file descriptor which the verifier then replaces as a full 64bit address of the map into both imm parts.

For the newly added BPF_PSEUDO_MAP_VALUE src_reg flag, the idea is similar: the first part of the double insns's imm field is again a file descriptor corresponding to the map, and the second part of the imm field is an offset. The verifier will then replace both imm parts with an address that points into the BPF map value for maps that support this operation. BPF_PSEUDO_MAP_VALUE is a distinct flag as otherwise with BPF_PSEUDO_MAP_FD we could not differ offset 0 between load of map pointer versus load of map's value at offset 0.

This allows for efficiently retrieving an address to a map value memory area without having to issue a helper call which needs to prepare registers according to calling convention, etc, without needing the extra NULL test, and without having to add the offset in an additional instruction to the value base pointer.

The verifier then treats the destination register as PTR_TO_MAP_VALUE with constant reg->off from the user passed offset from the second imm field, and guarantees that this is within bounds of the map value. Any subsequent operations are normally treated as typical map value handling without anything else needed for verification.

Quoted 8 lines

The two map operations for direct value access have been added to array map for now. In future other types could be supported as well depending on the use case. The main use case for this commit is to allow for BPF loader support for global variables that reside in .data/.rodata/.bss sections such that we can directly load the address of them with minimal additional infrastructure required. Loader support has been added in subsequent commits for libbpf library.

The patch version #1 provides a way to replace the load with immediate (presumably read-only data). This will be good for the use case like below:

     if (static_variable_kernel_version == V1) {
         /* code here will work for kernel V1 */
         ... access helpers available for V1 ...
     } else if (static_variable_kernel_version == V2) {
         /* code here will work for kernel V2 */
         ... access helpers available for V2 ...
     }

The approach here did not replace the map value access with values from e.g., readonly section for which libbpf could provide an interface to fill in data from user.

This may require a little more analysis, e.g.,

     ptr = ld_imm64 from a readonly section
     ...
     *(u32 *)ptr;
     *(u64 *)(ptr + 8);
     ...
Quoted 7 lines
Quoted 2 lines

Do you think we could do this in kernel verifier or we should push the whole readonly stuff into user space?

And in your case the static_variable_kernel_version would be determined at runtime, for example, where you then would want to eliminate all the other branches, right? Meaning, you'd need a way to turn this into a imm load such that verifier will detect these dead branches and patch them

Yes, the program will be compiled once and deployed to many hosts with different kernel versions. Different hosts may have different kernel versions. The static_variable_kernel_version is determined

Quoted 3 lines

out, which it should already be able to do. How would you mark these special vars like static_variable_kernel_version such that they have special treatment from the rest, some sort of builtin? Potentially one

A libbpf API is needed to assign a particular value to a readonly section value. For example, a bpf program may look like:

-bash-4.4$ cat g1.c
static volatile const unsigned __kernel_version;
int prog() {
unsigned kernel_ver = __kernel_version;

if (kernel_ver == 411)

     return 0;
   else if (kernel_ver == 416)
     return 1;

return 2;
}
-bash-4.4$ clang -target bpf -O2 -c g1.c

-bash-4.4$ llvm-readelf -r g1.o

Relocation section '.rel.text' at offset 0x178 contains 1 entries:
Offset Info Type Symbol's
Value Symbol's Name
0000000000000000 0000000500000001 R_BPF_64_64 0000000000000000 .rodata
-bash-4.4$ llvm-objdump -d g1.o

g1.o: file format ELF64-BPF

Disassembly of section .text:
0000000000000000 prog:

        0:       18 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
r1 = 0 ll
        2:       61 11 00 00 00 00 00 00         r1 = *(u32 *)(r1 + 0)
        3:       b7 02 00 00 01 00 00 00         r2 = 1
        4:       15 01 01 00 a0 01 00 00         if r1 == 416 goto +1 
<LBB0_2>
        5:       b7 02 00 00 02 00 00 00         r2 = 2

0000000000000030 LBB0_2:

        6:       b7 00 00 00 00 00 00 00         r0 = 0
        7:       15 01 01 00 9b 01 00 00         if r1 == 411 goto +1 
<LBB0_4>
        8:       bf 20 00 00 00 00 00 00         r0 = r2

0000000000000048 LBB0_4:

        9:       95 00 00 00 00 00 00 00         exit

-bash-4.4$ llvm-readelf -S g1.o
There are 9 section headers, starting at offset 0x1f8:

Section Headers:
[Nr] Name Type Address Off Size
ES Flg Lk Inf Al
[ 0] NULL 0000000000000000 000000 000000
00 0 0 0
[ 1] .strtab STRTAB 0000000000000000 000189 000068
00 0 0 1
[ 2] .text PROGBITS 0000000000000000 000040 000050
00 AX 0 0 8
[ 3] .rel.text REL 0000000000000000 000178 000010
10 8 2 8
[ 4] .rodata PROGBITS 0000000000000000 000090 000004
00 A 0 0 4
[ 5] .BTF PROGBITS 0000000000000000 000094 000019
00 0 0 1
[ 6] .BTF.ext PROGBITS 0000000000000000 0000ad 000020
00 0 0 1
[ 7] .llvm_addrsig LLVM_ADDRSIG 0000000000000000 000188 000001
00 E 8 0 1
[ 8] .symtab SYMTAB 0000000000000000 0000d0 0000a8
18 1 6 8
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), l (large) I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown) O (extra OS processing required) o (OS specific), p (processor specific)
-bash-4.4$ llvm-readelf -s g1.o

Symbol table '.symtab' contains 7 entries:

    Num:    Value          Size Type    Bind   Vis      Ndx Name
      0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
      1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS g1.c
      2: 0000000000000030     0 NOTYPE  LOCAL  DEFAULT    2 LBB0_2
      3: 0000000000000048     0 NOTYPE  LOCAL  DEFAULT    2 LBB0_4
      4: 0000000000000000     4 OBJECT  LOCAL  DEFAULT    4 __kernel_version
      5: 0000000000000000     0 SECTION LOCAL  DEFAULT    4 .rodata
      6: 0000000000000000    80 FUNC    GLOBAL DEFAULT    2 prog

-bash-4.4$

The relocation is for the first insn.
The address is the start of .rodata section, which happens to match variable __kernel_version (size 4).

The libbpf API can provide a way for user to assign a value to readonly section. In this particular case, e.g., on HostA, __kernel_version is assigned to 416, which means the first 4 bytes of .rodata is modified to have value 416. Considering this is a generic interface, the API may look like
bpf_object__change_readonly_value(const char *var_name, void *val_buf,

     unsigned var_buf_size);

The libbpf will change the value if there is a "var_name" in rodata section and val_buf_size matches the size in the symbol table.

Quoted 3 lines

could get away with doing this from loader side if it's simple enough, though one thing that would be good to avoid is to duplicate all the complex branch fixup logic etc that we have in kernel already. Are you

I totally agree that kernel is already able to prune dead codes while maintaining correct func/line info. We should do that part in kernel.

Let us look at the byte codes,

0000000000000000 prog:

        0:       r1 = 0 ll
        2:       r1 = *(u32 *)(r1 + 0)
        3:       r2 = 1
        4:       if r1 == 416 goto +1 <LBB0_2>
        5:       r2 = 2

0000000000000030 LBB0_2:

        6:       r0 = 0
        7:       if r1 == 411 goto +1 <LBB0_4>
        8:       r0 = r2

0000000000000048 LBB0_4:
9: exit

Here, the goal is to let r1 at insn #2 get the constant.
Do you think we can get it from the kernel? In this particular case, insn #0, get a romap_ptr with addr of rodata section offset 0, insn #2, load u32 from romap offset 0, the value is already populated, e.g., 416.

The verifier is path sensitive, will need extra care to perform such transformation in case it is invalid in different paths. Maybe slightly extension of verifier is able to do this? Initially we do not need to handle complicated cases. Most global/static variable accesses are all like
r1 = #num ll
r1 = *(type *)(r1 + offset)
If there is branch into the middle of the above pair of insns and r1 is romap_ptr, it is totally safe to replace the second insn as r1 = constant which can enable later dead code elimination. If all read only region access are converted to constants, "r1 = #num ll" ld_imm64 insns can be removed as well.

Quoted 2 lines

thinking to mark these via BTF in some way such that loader does inline replacement?

I have not thought about BTF. BTF could provide information about insn #2 referring to a particular readonly section location. But looks like verifier is able to track it as well in the above?

Let us first study whether without BTF is okay. If needed, we can go through BTF path with compiler assistance.

Quoted 4 lines

Thanks,
Daniel

#11 lore raw

Re: [PATCH bpf-next v2 1/7] bpf: implement lookup-free direct value access

In reply to Daniel Borkmann
Quoted 3 lines · Daniel Borkmann

This generic extension to BPF maps allows for directly loading an address residing inside a BPF map value as a single BPF ldimm64 instruction.

[...]

Quoted 19 lines
kernel/bpf/verifier.c +12 -3
@@ -6698,16 +6705,44 @@ static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env)
                                return err;
                        }
 
-                       /* store map pointer inside BPF_LD_IMM64 instruction */
-                       insn[0].imm = (u32) (unsigned long) map;
-                       insn[1].imm = ((u64) (unsigned long) map) >> 32;
+                       aux = &env->insn_aux_data[i];
+                       if (insn->src_reg == BPF_PSEUDO_MAP_FD) {
+                               addr = (unsigned long)map;
+                       } else {
+                               u32 off = insn[1].imm;
+
+                               if (off >= BPF_MAX_VAR_OFF) {
+                                       verbose(env, "direct value offset of %u is not allowed\n",
+                                               off);
+                                       return -EINVAL;
+                               }
+                               if (!map->ops->map_direct_value_access) {

kernel/bpf/verifier.c static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env) · line 6729

Quoted 10 lines
kernel/bpf/verifier.c +10 -0
+                                       verbose(env, "no direct value access support for this map type\n");
+                                       return -EINVAL;
+                               }
+
+                               err = map->ops->map_direct_value_access(map, off, &addr);
+                               if (err) {
+                                       verbose(env, "invalid access to map value pointer, value_size=%u off=%u\n",
+                                               map->value_size, off);
+                                       return err;
+                               }

All these error returns need fdput(f), I think.

#12 lore raw

Re: [PATCH bpf-next v2 1/7] bpf: implement lookup-free direct value access

In reply to Daniel Borkmann
Quoted 301 lines · Daniel Borkmann

This generic extension to BPF maps allows for directly loading an address residing inside a BPF map value as a single BPF ldimm64 instruction.

The idea is similar to what BPF_PSEUDO_MAP_FD does today, which is a special src_reg flag for ldimm64 instruction that indicates that inside the first part of the double insns's imm field is a file descriptor which the verifier then replaces as a full 64bit address of the map into both imm parts.

For the newly added BPF_PSEUDO_MAP_VALUE src_reg flag, the idea is similar: the first part of the double insns's imm field is again a file descriptor corresponding to the map, and the second part of the imm field is an offset. The verifier will then replace both imm parts with an address that points into the BPF map value for maps that support this operation. BPF_PSEUDO_MAP_VALUE is a distinct flag as otherwise with BPF_PSEUDO_MAP_FD we could not differ offset 0 between load of map pointer versus load of map's value at offset 0.

This allows for efficiently retrieving an address to a map value memory area without having to issue a helper call which needs to prepare registers according to calling convention, etc, without needing the extra NULL test, and without having to add the offset in an additional instruction to the value base pointer.

The verifier then treats the destination register as PTR_TO_MAP_VALUE with constant reg->off from the user passed offset from the second imm field, and guarantees that this is within bounds of the map value. Any subsequent operations are normally treated as typical map value handling without anything else needed for verification.

The two map operations for direct value access have been added to array map for now. In future other types could be supported as well depending on the use case. The main use case for this commit is to allow for BPF loader support for global variables that reside in .data/.rodata/.bss sections such that we can directly load the address of them with minimal additional infrastructure required. Loader support has been added in subsequent commits for libbpf library.

---
 include/linux/bpf.h               |  6 +++
 include/linux/bpf_verifier.h      |  4 ++
 include/uapi/linux/bpf.h          |  6 ++-
 kernel/bpf/arraymap.c             | 33 ++++++++++++++
 kernel/bpf/core.c                 |  3 +-
 kernel/bpf/disasm.c               |  5 ++-
 kernel/bpf/syscall.c              | 29 +++++++++---
 kernel/bpf/verifier.c             | 73 +++++++++++++++++++++++--------
 tools/bpf/bpftool/xlated_dumper.c |  3 ++
 tools/include/uapi/linux/bpf.h    |  6 ++-
 10 files changed, 138 insertions(+), 30 deletions(-)
include/linux/bpf.h +6 -0
index a2132e09dc1c..bdcc6e2a9977 100644
@@ -57,6 +57,12 @@ struct bpf_map_ops {
                             const struct btf *btf,
                             const struct btf_type *key_type,
                             const struct btf_type *value_type);
+
+       /* Direct value access helpers. */
+       int (*map_direct_value_access)(const struct bpf_map *map,
+                                      u32 off, u64 *imm);
+       int (*map_direct_value_offset)(const struct bpf_map *map,
+                                      u64 imm, u32 *off);
 };
 
 struct bpf_map {
include/linux/bpf_verifier.h +4 -0
index 69f7a3449eda..6e28f1c24710 100644
@@ -183,6 +183,10 @@ struct bpf_insn_aux_data {
                unsigned long map_state;        /* pointer/poison value for maps */
                s32 call_imm;                   /* saved imm field of call insn */
                u32 alu_limit;                  /* limit for add/sub register with pointer */
+               struct {
+                       u32 map_index;          /* index into used_maps[] */
+                       u32 map_off;            /* offset from value base address */
+               };
        };
        int ctx_field_size; /* the ctx field size for load insn, maybe 0 */
        int sanitize_stack_off; /* stack slot to be cleared */
include/uapi/linux/bpf.h +5 -1
index 2e308e90ffea..8884072e1a46 100644
@@ -255,8 +255,12 @@ 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->src_reg == BPF_PSEUDO_MAP_{FD,VALUE}, then
+ * bpf_ldimm64's insn[0]->imm == fd in both cases. Additionally,
+ * for BPF_PSEUDO_MAP_VALUE, insn[1]->imm == offset into 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
kernel/bpf/arraymap.c +33 -0
index c72e0d8e1e65..3e5969c0c979 100644
@@ -160,6 +160,37 @@ static void *array_map_lookup_elem(struct bpf_map *map, void *key)
        return array->value + array->elem_size * (index & array->index_mask);
 }
 
+static int array_map_direct_value_access(const struct bpf_map *map, u32 off,
+                                        u64 *imm)
+{
+       struct bpf_array *array = container_of(map, struct bpf_array, map);
+
+       if (map->max_entries != 1)
+               return -ENOTSUPP;
+       if (off >= map->value_size)
+               return -EINVAL;
+
+       *imm = (unsigned long)array->value;
+       return 0;
+}
+
+static int array_map_direct_value_offset(const struct bpf_map *map, u64 imm,
+                                        u32 *off)
+{
+       struct bpf_array *array = container_of(map, struct bpf_array, map);
+       unsigned long range = map->value_size;
+       unsigned long base  = array->value;
+       unsigned long addr  = imm;
+
+       if (map->max_entries != 1)
+               return -ENOENT;
+       if (addr < base || addr >= base + range)
+               return -ENOENT;
+
+       *off = addr - base;
+       return 0;
+}
+
 /* emit BPF instructions equivalent to C code of array_map_lookup_elem() */
 static u32 array_map_gen_lookup(struct bpf_map *map, struct bpf_insn *insn_buf)
 {
@@ -419,6 +450,8 @@ const struct bpf_map_ops array_map_ops = {
        .map_update_elem = array_map_update_elem,
        .map_delete_elem = array_map_delete_elem,
        .map_gen_lookup = array_map_gen_lookup,
+       .map_direct_value_access = array_map_direct_value_access,
+       .map_direct_value_offset = array_map_direct_value_offset,
        .map_seq_show_elem = array_map_seq_show_elem,
        .map_check_btf = array_map_check_btf,
 };
kernel/bpf/core.c +2 -1
index 1c14c347f3cf..49fc0ff14537 100644
@@ -286,7 +286,8 @@ int bpf_prog_calc_tag(struct bpf_prog *fp)
                dst[i] = fp->insnsi[i];
                if (!was_ld_map &&
                    dst[i].code == (BPF_LD | BPF_IMM | BPF_DW) &&
-                   dst[i].src_reg == BPF_PSEUDO_MAP_FD) {
+                   (dst[i].src_reg == BPF_PSEUDO_MAP_FD ||
+                    dst[i].src_reg == BPF_PSEUDO_MAP_VALUE)) {
                        was_ld_map = true;
                        dst[i].imm = 0;
                } else if (was_ld_map &&
kernel/bpf/disasm.c +3 -2
index de73f55e42fd..d9ce383c0f9c 100644
@@ -205,10 +205,11 @@ void print_bpf_insn(const struct bpf_insn_cbs *cbs,
                         * part of the ldimm64 insn is accessible.
                         */
                        u64 imm = ((u64)(insn + 1)->imm << 32) | (u32)insn->imm;
-                       bool map_ptr = insn->src_reg == BPF_PSEUDO_MAP_FD;
+                       bool is_ptr = insn->src_reg == BPF_PSEUDO_MAP_FD ||
+                                     insn->src_reg == BPF_PSEUDO_MAP_VALUE;
                        char tmp[64];
 
-                       if (map_ptr && !allow_ptr_leaks)
+                       if (is_ptr && !allow_ptr_leaks)
                                imm = 0;
 
                        verbose(cbs->private_data, "(%02x) r%d = %s\n",
kernel/bpf/syscall.c +22 -7
index 174581dfe225..d3ef45e01d7a 100644
@@ -2061,13 +2061,27 @@ static int bpf_map_get_fd_by_id(const union bpf_attr *attr)
 }
 
 static const struct bpf_map *bpf_map_from_imm(const struct bpf_prog *prog,
-                                             unsigned long addr)
+                                             unsigned long addr, u32 *off,
+                                             u32 *type)
 {
+       const struct bpf_map *map;
        int i;
 
-       for (i = 0; i < prog->aux->used_map_cnt; i++)
-               if (prog->aux->used_maps[i] == (void *)addr)
-                       return prog->aux->used_maps[i];
+       *off = *type = 0;
+       for (i = 0; i < prog->aux->used_map_cnt; i++) {
+               map = prog->aux->used_maps[i];
+               if (map == (void *)addr) {
+                       *type = BPF_PSEUDO_MAP_FD;
+                       return map;
+               }
+               if (!map->ops->map_direct_value_offset)
+                       continue;
+               if (!map->ops->map_direct_value_offset(map, addr, off)) {
+                       *type = BPF_PSEUDO_MAP_VALUE;
+                       return map;
+               }
+       }
+
        return NULL;
 }
 
@@ -2075,6 +2089,7 @@ static struct bpf_insn *bpf_insn_prepare_dump(const struct bpf_prog *prog)
 {
        const struct bpf_map *map;
        struct bpf_insn *insns;
+       u32 off, type;
        u64 imm;
        int i;
 
@@ -2102,11 +2117,11 @@ static struct bpf_insn *bpf_insn_prepare_dump(const struct bpf_prog *prog)
                        continue;
 
                imm = ((u64)insns[i + 1].imm << 32) | (u32)insns[i].imm;
-               map = bpf_map_from_imm(prog, imm);
+               map = bpf_map_from_imm(prog, imm, &off, &type);
                if (map) {
-                       insns[i].src_reg = BPF_PSEUDO_MAP_FD;
+                       insns[i].src_reg = type;
                        insns[i].imm = map->id;
-                       insns[i + 1].imm = 0;
+                       insns[i + 1].imm = off;
                        continue;
                }
        }
kernel/bpf/verifier.c +17 -12
index 0e4edd7e3c5f..3ad05dda6e9d 100644
@@ -4944,18 +4944,12 @@ static int check_cond_jmp_op(struct bpf_verifier_env *env,
        return 0;
 }
 
-/* return the map pointer stored inside BPF_LD_IMM64 instruction */
-static struct bpf_map *ld_imm64_to_map_ptr(struct bpf_insn *insn)
-{
-       u64 imm64 = ((u64) (u32) insn[0].imm) | ((u64) (u32) insn[1].imm) << 32;
-
-       return (struct bpf_map *) (unsigned long) imm64;
-}
-
 /* verify BPF_LD_IMM64 instruction */
 static int check_ld_imm(struct bpf_verifier_env *env, struct bpf_insn *insn)
 {
+       struct bpf_insn_aux_data *aux = cur_aux(env);
        struct bpf_reg_state *regs = cur_regs(env);
+       struct bpf_map *map;
        int err;
 
        if (BPF_SIZE(insn->code) != BPF_DW) {
@@ -4979,11 +4973,22 @@ static int check_ld_imm(struct bpf_verifier_env *env, struct bpf_insn *insn)
                return 0;
        }
 
-       /* replace_map_fd_with_map_ptr() should have caught bad ld_imm64 */
-       BUG_ON(insn->src_reg != BPF_PSEUDO_MAP_FD);
+       map = env->used_maps[aux->map_index];
+       mark_reg_known_zero(env, regs, insn->dst_reg);
+       regs[insn->dst_reg].map_ptr = map;
+
+       if (insn->src_reg == BPF_PSEUDO_MAP_VALUE) {
+               regs[insn->dst_reg].type = PTR_TO_MAP_VALUE;
+               regs[insn->dst_reg].off = aux->map_off;
+               if (map_value_has_spin_lock(map))
+                       regs[insn->dst_reg].id = ++env->id_gen;
+       } else if (insn->src_reg == BPF_PSEUDO_MAP_FD) {
+               regs[insn->dst_reg].type = CONST_PTR_TO_MAP;
+       } else {
+               verbose(env, "bpf verifier is misconfigured\n");
+               return -EINVAL;
+       }
 
-       regs[insn->dst_reg].type = CONST_PTR_TO_MAP;
-       regs[insn->dst_reg].map_ptr = ld_imm64_to_map_ptr(insn);
        return 0;
 }
 

kernel/bpf/verifier.c static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env) · line 6678

Quoted 10 lines
kernel/bpf/verifier.c +2 -0
@@ -6664,8 +6669,10 @@ static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env)
                }
 
                if (insn[0].code == (BPF_LD | BPF_IMM | BPF_DW)) {
+                       struct bpf_insn_aux_data *aux;
                        struct bpf_map *map;
                        struct fd f;
+                       u64 addr;
 
                        if (i == insn_cnt - 1 || insn[1].code != 0 ||
                            insn[1].dst_reg != 0 || insn[1].src_reg != 0 ||

Next line after this one rejects ldimm64 instructions with off != 0. This check needs to be changed, depending on whether src_reg == BPF_PSEUDO_MAP_VALUE, right?

This is also to the previously discussed question of not enforcing offset (imm=0 in 2nd part of insn) for BPF_PSEUDO_MAP_FD. Seems like verifier *does* enforce that (not that I'm advocating for re-using BPF_PSEUDO_MAP_FD, just stumbled on this bit when going through verifier code).

Quoted 104 lines
kernel/bpf/verifier.c +36 -6
@@ -6677,8 +6684,8 @@ static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env)
                        if (insn->src_reg == 0)
                                /* valid generic load 64-bit imm */
                                goto next_insn;
-
-                       if (insn->src_reg != BPF_PSEUDO_MAP_FD) {
+                       if (insn->src_reg != BPF_PSEUDO_MAP_FD &&
+                           insn->src_reg != BPF_PSEUDO_MAP_VALUE) {
                                verbose(env,
                                        "unrecognized bpf_ld_imm64 insn\n");
                                return -EINVAL;
@@ -6698,16 +6705,44 @@ static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env)
                                return err;
                        }
 
-                       /* store map pointer inside BPF_LD_IMM64 instruction */
-                       insn[0].imm = (u32) (unsigned long) map;
-                       insn[1].imm = ((u64) (unsigned long) map) >> 32;
+                       aux = &env->insn_aux_data[i];
+                       if (insn->src_reg == BPF_PSEUDO_MAP_FD) {
+                               addr = (unsigned long)map;
+                       } else {
+                               u32 off = insn[1].imm;
+
+                               if (off >= BPF_MAX_VAR_OFF) {
+                                       verbose(env, "direct value offset of %u is not allowed\n",
+                                               off);
+                                       return -EINVAL;
+                               }
+                               if (!map->ops->map_direct_value_access) {
+                                       verbose(env, "no direct value access support for this map type\n");
+                                       return -EINVAL;
+                               }
+
+                               err = map->ops->map_direct_value_access(map, off, &addr);
+                               if (err) {
+                                       verbose(env, "invalid access to map value pointer, value_size=%u off=%u\n",
+                                               map->value_size, off);
+                                       return err;
+                               }
+
+                               aux->map_off = off;
+                               addr += off;
+                       }
+
+                       insn[0].imm = (u32)addr;
+                       insn[1].imm = addr >> 32;
 
                        /* check whether we recorded this map already */
-                       for (j = 0; j < env->used_map_cnt; j++)
+                       for (j = 0; j < env->used_map_cnt; j++) {
                                if (env->used_maps[j] == map) {
+                                       aux->map_index = j;
                                        fdput(f);
                                        goto next_insn;
                                }
+                       }
 
                        if (env->used_map_cnt >= MAX_USED_MAPS) {
                                fdput(f);
@@ -6724,6 +6759,8 @@ static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env)
                                fdput(f);
                                return PTR_ERR(map);
                        }
+
+                       aux->map_index = env->used_map_cnt;
                        env->used_maps[env->used_map_cnt++] = map;
 
                        if (bpf_map_is_cgroup_storage(map) &&
tools/bpf/bpftool/xlated_dumper.c +3 -0
index 7073dbe1ff27..0bb17bf88b18 100644
@@ -195,6 +195,9 @@ static const char *print_imm(void *private_data,
        if (insn->src_reg == BPF_PSEUDO_MAP_FD)
                snprintf(dd->scratch_buff, sizeof(dd->scratch_buff),
                         "map[id:%u]", insn->imm);
+       else if (insn->src_reg == BPF_PSEUDO_MAP_VALUE)
+               snprintf(dd->scratch_buff, sizeof(dd->scratch_buff),
+                        "map[id:%u][0]+%u", insn->imm, (insn + 1)->imm);
        else
                snprintf(dd->scratch_buff, sizeof(dd->scratch_buff),
                         "0x%llx", (unsigned long long)full_imm);
tools/include/uapi/linux/bpf.h +5 -2
index 2e308e90ffea..8884072e1a46 100644
@@ -255,8 +255,12 @@ 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->src_reg == BPF_PSEUDO_MAP_{FD,VALUE}, then
+ * bpf_ldimm64's insn[0]->imm == fd in both cases. Additionally,
+ * for BPF_PSEUDO_MAP_VALUE, insn[1]->imm == offset into 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
--

2.17.1

author maintainer
#13 lore raw

Re: [PATCH bpf-next v2 1/7] bpf: implement lookup-free direct value access

Quoted 1 line · Andrii Nakryiko

On Thu, Feb 28, 2019 at 3:31 PM Daniel Borkmann <[email protected]> wrote:

[...]

Quoted 9 lines
Quoted 9 lines
(quoted diff) +2 -0
@@ -6664,8 +6669,10 @@ static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env)
                }
 
                if (insn[0].code == (BPF_LD | BPF_IMM | BPF_DW)) {
+                       struct bpf_insn_aux_data *aux;
                        struct bpf_map *map;
                        struct fd f;
+                       u64 addr;
 
Quoted 6 lines

Review static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env) · line 6678

Quoted 2 lines
(quoted diff) +0 -0
                        if (i == insn_cnt - 1 || insn[1].code != 0 ||
                            insn[1].dst_reg != 0 || insn[1].src_reg != 0 ||

Next line after this one rejects ldimm64 instructions with off != 0. This check needs to be changed, depending on whether src_reg == BPF_PSEUDO_MAP_VALUE, right?

Yes, that's correct, I already have that changed in my local branch for supporting non-zero off.

Quoted 5 lines

This is also to the previously discussed question of not enforcing offset (imm=0 in 2nd part of insn) for BPF_PSEUDO_MAP_FD. Seems like verifier *does* enforce that (not that I'm advocating for re-using BPF_PSEUDO_MAP_FD, just stumbled on this bit when going through verifier code).

Not really, lets test:

[...]

        .insns = {
        BPF_MOV64_IMM(BPF_REG_0, 0),
        BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, BPF_REG_1,
                     BPF_PSEUDO_MAP_FD, 0, 0),
        BPF_RAW_INSN(0, 0, 0, 0, 0xfefefe),
        BPF_EXIT_INSN(),
        },

[...]

#545/p test14 ld_imm64: reject 2nd imm != 0 FAIL
Unexpected success to load!
0: (b7) r0 = 0
1: (18) r1 = 0xffff97e612486400
3: (95) exit
processed 3 insns (limit 131072), stack depth 0
Summary: 0 PASSED, 0 SKIPPED, 2 FAILED

So I still think it would be worth doing something like the below for bpf:

From 290f739ae6bab7b0709d327855a1812f9022beed Mon Sep 17 00:00:00 2001
From: Daniel Borkmann <[email protected]>
Date: Mon, 4 Mar 2019 14:22:41 +0000
Subject: [PATCH bpf] bpf: fix replace_map_fd_with_map_ptr wrt ldimm64 wrt second imm field

Non-zero imm value in the second part of the ldimm64 instruction for BPF_PSEUDO_MAP_FD is invalid, and thus must be rejected. The map fd only ever sits in the first instructions' imm field. None of the BPF loaders known to us are using it, so risk of regression is minimal. For clarity and consistency, the few insn->{src_reg,imm} occurences are rewritten into insn[0].{src_reg,imm}. Add a test case to the BPF selftest suite as well.

Fixes 0246e64d9a5f ("bpf: handle pseudo BPF_LD_IMM64 insn")
---
 kernel/bpf/verifier.c                           | 10 +++++-----
 tools/testing/selftests/bpf/verifier/ld_imm64.c | 17 +++++++++++++++--
 2 files changed, 20 insertions(+), 7 deletions(-)
kernel/bpf/verifier.c +5 -5
index 0e4edd7e3c5f..c8d2a948db37 100644
@@ -6678,17 +6678,17 @@ static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env)
 				/* valid generic load 64-bit imm */
 				goto next_insn;
 
-			if (insn->src_reg != BPF_PSEUDO_MAP_FD) {
-				verbose(env,
-					"unrecognized bpf_ld_imm64 insn\n");
+			if (insn[0].src_reg != BPF_PSEUDO_MAP_FD ||
+			    insn[1].imm != 0) {
+				verbose(env, "unrecognized bpf_ld_imm64 insn\n");
 				return -EINVAL;
 			}
 
-			f = fdget(insn->imm);
+			f = fdget(insn[0].imm);
 			map = __bpf_map_get(f);
 			if (IS_ERR(map)) {
 				verbose(env, "fd %d is not pointing to valid bpf_map\n",
-					insn->imm);
+					insn[0].imm);
 				return PTR_ERR(map);
 			}
 
tools/testing/selftests/bpf/verifier/ld_imm64.c +15 -2
index 28b8c805a293..4a1ff4560a8a 100644
@@ -121,8 +121,8 @@
 	"test12 ld_imm64",
 	.insns = {
 	BPF_MOV64_IMM(BPF_REG_1, 0),
-	BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, BPF_REG_1, 0, 1),
-	BPF_RAW_INSN(0, 0, 0, 0, 1),
+	BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, BPF_REG_1, 0, 999),
+	BPF_RAW_INSN(0, 0, 0, 0, 0),
 	BPF_EXIT_INSN(),
 	},
 	.errstr = "not pointing to valid bpf_map",
@@ -139,3 +139,16 @@
 	.errstr = "invalid bpf_ld_imm64 insn",
 	.result = REJECT,
 },
+{
+	"test14 ld_imm64: reject 2nd imm != 0",
+	.insns = {
+	BPF_MOV64_IMM(BPF_REG_0, 0),
+	BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, BPF_REG_1,
+		     BPF_PSEUDO_MAP_FD, 0, 0),
+	BPF_RAW_INSN(0, 0, 0, 0, 0xfefefe),
+	BPF_EXIT_INSN(),
+	},
+	.fixup_map_hash_48b = { 1 },
+	.errstr = "unrecognized bpf_ld_imm64 insn",
+	.result = REJECT,
+},
Signature · 1 line
2.17.1
#14 lore raw

Re: [PATCH bpf-next v2 1/7] bpf: implement lookup-free direct value access

Quoted 23 lines · Daniel Borkmann
Quoted 1 line · Andrii Nakryiko

On Thu, Feb 28, 2019 at 3:31 PM Daniel Borkmann <[email protected]> wrote:

[...]

Quoted 9 lines
Quoted 9 lines
(quoted diff) +2 -0
@@ -6664,8 +6669,10 @@ static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env)
                }
 
                if (insn[0].code == (BPF_LD | BPF_IMM | BPF_DW)) {
+                       struct bpf_insn_aux_data *aux;
                        struct bpf_map *map;
                        struct fd f;
+                       u64 addr;
 
Quoted 6 lines

Review static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env) · line 6678

Quoted 2 lines
(quoted diff) +0 -0
                        if (i == insn_cnt - 1 || insn[1].code != 0 ||
                            insn[1].dst_reg != 0 || insn[1].src_reg != 0 ||

Next line after this one rejects ldimm64 instructions with off != 0. This check needs to be changed, depending on whether src_reg == BPF_PSEUDO_MAP_VALUE, right?

Yes, that's correct, I already have that changed in my local branch for supporting non-zero off.

Quoted 7 lines
Quoted 5 lines

This is also to the previously discussed question of not enforcing offset (imm=0 in 2nd part of insn) for BPF_PSEUDO_MAP_FD. Seems like verifier *does* enforce that (not that I'm advocating for re-using BPF_PSEUDO_MAP_FD, just stumbled on this bit when going through verifier code).

Not really, lets test:

Ah, sorry, my bad. That code tests .off, not .imm, so yeah, any imm would be accepted.

Quoted 19 lines

[...]

        .insns = {
        BPF_MOV64_IMM(BPF_REG_0, 0),
        BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, BPF_REG_1,
                     BPF_PSEUDO_MAP_FD, 0, 0),
        BPF_RAW_INSN(0, 0, 0, 0, 0xfefefe),
        BPF_EXIT_INSN(),
        },

[...]

#545/p test14 ld_imm64: reject 2nd imm != 0 FAIL
Unexpected success to load!
0: (b7) r0 = 0
1: (18) r1 = 0xffff97e612486400
3: (95) exit
processed 3 insns (limit 131072), stack depth 0
Summary: 0 PASSED, 0 SKIPPED, 2 FAILED

Quoted 2 lines

So I still think it would be worth doing something like the below for bpf:

Yep, lgtm.

Quoted 83 lines

From 290f739ae6bab7b0709d327855a1812f9022beed Mon Sep 17 00:00:00 2001
From: Daniel Borkmann <[email protected]>
Date: Mon, 4 Mar 2019 14:22:41 +0000
Subject: [PATCH bpf] bpf: fix replace_map_fd_with_map_ptr wrt ldimm64 wrt second imm field

Non-zero imm value in the second part of the ldimm64 instruction for BPF_PSEUDO_MAP_FD is invalid, and thus must be rejected. The map fd only ever sits in the first instructions' imm field. None of the BPF loaders known to us are using it, so risk of regression is minimal. For clarity and consistency, the few insn->{src_reg,imm} occurences are rewritten into insn[0].{src_reg,imm}. Add a test case to the BPF selftest suite as well.

Fixes 0246e64d9a5f ("bpf: handle pseudo BPF_LD_IMM64 insn")
---
 kernel/bpf/verifier.c                           | 10 +++++-----
 tools/testing/selftests/bpf/verifier/ld_imm64.c | 17 +++++++++++++++--
 2 files changed, 20 insertions(+), 7 deletions(-)
kernel/bpf/verifier.c +5 -5
index 0e4edd7e3c5f..c8d2a948db37 100644
@@ -6678,17 +6678,17 @@ static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env)
                                /* valid generic load 64-bit imm */
                                goto next_insn;
 
-                       if (insn->src_reg != BPF_PSEUDO_MAP_FD) {
-                               verbose(env,
-                                       "unrecognized bpf_ld_imm64 insn\n");
+                       if (insn[0].src_reg != BPF_PSEUDO_MAP_FD ||
+                           insn[1].imm != 0) {
+                               verbose(env, "unrecognized bpf_ld_imm64 insn\n");
                                return -EINVAL;
                        }
 
-                       f = fdget(insn->imm);
+                       f = fdget(insn[0].imm);
                        map = __bpf_map_get(f);
                        if (IS_ERR(map)) {
                                verbose(env, "fd %d is not pointing to valid bpf_map\n",
-                                       insn->imm);
+                                       insn[0].imm);
                                return PTR_ERR(map);
                        }
 
tools/testing/selftests/bpf/verifier/ld_imm64.c +15 -3
index 28b8c805a293..4a1ff4560a8a 100644
@@ -121,8 +121,8 @@
        "test12 ld_imm64",
        .insns = {
        BPF_MOV64_IMM(BPF_REG_1, 0),
-       BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, BPF_REG_1, 0, 1),
-       BPF_RAW_INSN(0, 0, 0, 0, 1),
+       BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, BPF_REG_1, 0, 999),
+       BPF_RAW_INSN(0, 0, 0, 0, 0),
        BPF_EXIT_INSN(),
        },
        .errstr = "not pointing to valid bpf_map",
@@ -139,3 +139,16 @@
        .errstr = "invalid bpf_ld_imm64 insn",
        .result = REJECT,
 },
+{
+       "test14 ld_imm64: reject 2nd imm != 0",
+       .insns = {
+       BPF_MOV64_IMM(BPF_REG_0, 0),
+       BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, BPF_REG_1,
+                    BPF_PSEUDO_MAP_FD, 0, 0),
+       BPF_RAW_INSN(0, 0, 0, 0, 0xfefefe),
+       BPF_EXIT_INSN(),
+       },
+       .fixup_map_hash_48b = { 1 },
+       .errstr = "unrecognized bpf_ld_imm64 insn",
+       .result = REJECT,
+},
--

2.17.1

author maintainer
#15 lore raw

PATCH v2 2/7 bpf: add program side {rd,wr}only support

In reply to Daniel Borkmann

This work adds two new map creation flags BPF_F_RDONLY_PROG and BPF_F_WRONLY_PROG in order to allow for read-only or write-only BPF maps from a BPF program side.

Today we have BPF_F_RDONLY and BPF_F_WRONLY, but this only applies to system call side, meaning the BPF program has full read/write access to the map as usual while bpf(2) calls with map fd can either only read or write into the map depending on the flags. BPF_F_RDONLY_PROG and BPF_F_WRONLY_PROG allows for the exact opposite such that verifier is going to reject program loads if write into a read-only map or a read into a write-only map is detected.

We've enabled this generic map extension to various non-special maps holding normal user data: array, hash, lru, lpm, local storage, queue and stack. Further map types could be followed up in future depending on use-case. Main use case here is to forbid writes into .rodata map values from verifier side.

---
 include/linux/bpf.h           | 18 ++++++++++++++++++
 include/uapi/linux/bpf.h      | 10 +++++++++-
 kernel/bpf/arraymap.c         |  2 +-
 kernel/bpf/hashtab.c          |  2 +-
 kernel/bpf/local_storage.c    |  2 +-
 kernel/bpf/lpm_trie.c         |  2 +-
 kernel/bpf/queue_stack_maps.c |  3 +--
 kernel/bpf/verifier.c         | 30 +++++++++++++++++++++++++++++-
 8 files changed, 61 insertions(+), 8 deletions(-)
include/linux/bpf.h +18 -0
index bdcc6e2a9977..3f74194dd4f6 100644
@@ -427,6 +427,24 @@ struct bpf_array {
 	};
 };
 
+#define BPF_MAP_CAN_READ	BIT(0)
+#define BPF_MAP_CAN_WRITE	BIT(1)
+
+static inline u32 bpf_map_flags_to_cap(struct bpf_map *map)
+{
+	u32 access_flags = map->map_flags & (BPF_F_RDONLY_PROG | BPF_F_WRONLY_PROG);
+
+	/* Combination of BPF_F_RDONLY_PROG | BPF_F_WRONLY_PROG is
+	 * not possible.
+	 */
+	if (access_flags & BPF_F_RDONLY_PROG)
+		return BPF_MAP_CAN_READ;
+	else if (access_flags & BPF_F_WRONLY_PROG)
+		return BPF_MAP_CAN_WRITE;
+	else
+		return BPF_MAP_CAN_READ | BPF_MAP_CAN_WRITE;
+}
+
 #define MAX_TAIL_CALL_CNT 32
 
 struct bpf_event_entry {
include/uapi/linux/bpf.h +9 -1
index 8884072e1a46..04b26f59b413 100644
@@ -287,7 +287,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)
 
@@ -297,6 +297,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)
 
kernel/bpf/arraymap.c +1 -1
index 3e5969c0c979..076dc3d77faf 100644
@@ -22,7 +22,7 @@
 #include "map_in_map.h"
 
 #define ARRAY_CREATE_FLAG_MASK \
-	(BPF_F_NUMA_NODE | BPF_F_RDONLY | BPF_F_WRONLY)
+	(BPF_F_NUMA_NODE | BPF_F_ACCESS_MASK)
 
 static void bpf_array_free_percpu(struct bpf_array *array)
 {
kernel/bpf/hashtab.c +1 -1
index fed15cf94dca..ab9d51ac80e1 100644
@@ -23,7 +23,7 @@
 
 #define HTAB_CREATE_FLAG_MASK						\
 	(BPF_F_NO_PREALLOC | BPF_F_NO_COMMON_LRU | BPF_F_NUMA_NODE |	\
-	 BPF_F_RDONLY | BPF_F_WRONLY | BPF_F_ZERO_SEED)
+	 BPF_F_ACCESS_MASK | BPF_F_ZERO_SEED)
 
 struct bucket {
 	struct hlist_nulls_head head;
kernel/bpf/local_storage.c +1 -1
index 6b572e2de7fb..3ffe3259da00 100644
@@ -14,7 +14,7 @@ DEFINE_PER_CPU(struct bpf_cgroup_storage*, bpf_cgroup_storage[MAX_BPF_CGROUP_STO
 #ifdef CONFIG_CGROUP_BPF
 
 #define LOCAL_STORAGE_CREATE_FLAG_MASK					\
-	(BPF_F_NUMA_NODE | BPF_F_RDONLY | BPF_F_WRONLY)
+	(BPF_F_NUMA_NODE | BPF_F_ACCESS_MASK)
 
 struct bpf_cgroup_storage_map {
 	struct bpf_map map;
kernel/bpf/lpm_trie.c +1 -1
index abf1002080df..79c75b1626b8 100644
@@ -537,7 +537,7 @@ static int trie_delete_elem(struct bpf_map *map, void *_key)
 #define LPM_KEY_SIZE_MIN	LPM_KEY_SIZE(LPM_DATA_SIZE_MIN)
 
 #define LPM_CREATE_FLAG_MASK	(BPF_F_NO_PREALLOC | BPF_F_NUMA_NODE |	\
-				 BPF_F_RDONLY | BPF_F_WRONLY)
+				 BPF_F_ACCESS_MASK)
 
 static struct bpf_map *trie_alloc(union bpf_attr *attr)
 {
kernel/bpf/queue_stack_maps.c +1 -2
index b384ea9f3254..1eb9ceef075c 100644
@@ -11,8 +11,7 @@
 #include "percpu_freelist.h"
 
 #define QUEUE_STACK_CREATE_FLAG_MASK \
-	(BPF_F_NUMA_NODE | BPF_F_RDONLY | BPF_F_WRONLY)
-
+	(BPF_F_NUMA_NODE | BPF_F_ACCESS_MASK)
 
 struct bpf_queue_stack {
 	struct bpf_map map;
kernel/bpf/verifier.c +29 -1
index 3ad05dda6e9d..cdd2cb01f789 100644
@@ -1429,6 +1429,28 @@ static int check_stack_access(struct bpf_verifier_env *env,
 	return 0;
 }
 
+static int check_map_access_type(struct bpf_verifier_env *env, u32 regno,
+				 int off, int size, enum bpf_access_type type)
+{
+	struct bpf_reg_state *regs = cur_regs(env);
+	struct bpf_map *map = regs[regno].map_ptr;
+	u32 cap = bpf_map_flags_to_cap(map);
+
+	if (type == BPF_WRITE && !(cap & BPF_MAP_CAN_WRITE)) {
+		verbose(env, "write into map forbidden, value_size=%d off=%d size=%d\n",
+			map->value_size, off, size);
+		return -EACCES;
+	}
+
+	if (type == BPF_READ && !(cap & BPF_MAP_CAN_READ)) {
+		verbose(env, "read into map forbidden, value_size=%d off=%d size=%d\n",
+			map->value_size, off, size);
+		return -EACCES;
+	}
+
+	return 0;
+}
+
 /* check read/write into map element returned by bpf_map_lookup_elem() */
 static int __check_map_access(struct bpf_verifier_env *env, u32 regno, int off,
 			      int size, bool zero_size_allowed)
@@ -2014,7 +2036,9 @@ static int check_mem_access(struct bpf_verifier_env *env, int insn_idx, u32 regn
 			verbose(env, "R%d leaks addr into map\n", value_regno);
 			return -EACCES;
 		}
-
+		err = check_map_access_type(env, regno, off, size, t);
+		if (err)
+			return err;
 		err = check_map_access(env, regno, off, size, false);
 		if (!err && t == BPF_READ && value_regno >= 0)
 			mark_reg_unknown(env, regs, value_regno);
@@ -2250,6 +2274,10 @@ static int check_helper_mem_access(struct bpf_verifier_env *env, int regno,
 		return check_packet_access(env, regno, reg->off, access_size,
 					   zero_size_allowed);
 	case PTR_TO_MAP_VALUE:
+		if (check_map_access_type(env, regno, reg->off, access_size,
+					  meta && meta->raw_mode ? BPF_WRITE :
+					  BPF_READ))
+			return -EACCES;
 		return check_map_access(env, regno, reg->off, access_size,
 					zero_size_allowed);
 	default: /* scalar_value|ptr_to_stack or invalid ptr */
Signature · 1 line
2.17.1
#16 lore raw

Re: [PATCH bpf-next v2 2/7] bpf: add program side {rd,wr}only support

Quoted 13 lines · Daniel Borkmann

This work adds two new map creation flags BPF_F_RDONLY_PROG and BPF_F_WRONLY_PROG in order to allow for read-only or write-only BPF maps from a BPF program side.

Today we have BPF_F_RDONLY and BPF_F_WRONLY, but this only applies to system call side, meaning the BPF program has full read/write access to the map as usual while bpf(2) calls with map fd can either only read or write into the map depending on the flags. BPF_F_RDONLY_PROG and BPF_F_WRONLY_PROG allows for the exact opposite such that verifier is going to reject program loads if write into a read-only map or a read into a write-only map is detected.

Quoted 5 lines

We've enabled this generic map extension to various non-special maps holding normal user data: array, hash, lru, lpm, local storage, queue and stack. Further map types could be followed up in future depending on use-case. Main use case here is to forbid writes into .rodata map values from verifier side.

This will also enable optimizing the accesses on system with rich memory architecture :)

Quoted 20 lines
---
 include/linux/bpf.h           | 18 ++++++++++++++++++
 include/uapi/linux/bpf.h      | 10 +++++++++-
 kernel/bpf/arraymap.c         |  2 +-
 kernel/bpf/hashtab.c          |  2 +-
 kernel/bpf/local_storage.c    |  2 +-
 kernel/bpf/lpm_trie.c         |  2 +-
 kernel/bpf/queue_stack_maps.c |  3 +--
 kernel/bpf/verifier.c         | 30 +++++++++++++++++++++++++++++-
 8 files changed, 61 insertions(+), 8 deletions(-)
include/linux/bpf.h +0 -0
index bdcc6e2a9977..3f74194dd4f6 100644
@@ -427,6 +427,24 @@ struct bpf_array {
 	};
 };
 

include/linux/bpf.h struct bpf_array { · line 439

Quoted 10 lines
include/linux/bpf.h +10 -0
+#define BPF_MAP_CAN_READ	BIT(0)
+#define BPF_MAP_CAN_WRITE	BIT(1)
+
+static inline u32 bpf_map_flags_to_cap(struct bpf_map *map)
+{
+	u32 access_flags = map->map_flags & (BPF_F_RDONLY_PROG | BPF_F_WRONLY_PROG);
+
+	/* Combination of BPF_F_RDONLY_PROG | BPF_F_WRONLY_PROG is
+	 * not possible.
+	 */

minor nit: we do check that old RDONLY and WRONLY are not set at the
same time, but here it's not done?

Quoted 7 lines
include/linux/bpf.h +7 -0
+	if (access_flags & BPF_F_RDONLY_PROG)
+		return BPF_MAP_CAN_READ;
+	else if (access_flags & BPF_F_WRONLY_PROG)
+		return BPF_MAP_CAN_WRITE;
+	else
+		return BPF_MAP_CAN_READ | BPF_MAP_CAN_WRITE;
+}
author maintainer
#17 lore raw

Re: [PATCH bpf-next v2 2/7] bpf: add program side {rd,wr}only support

Quoted 14 lines · Jakub Kicinski
Quoted 13 lines · Daniel Borkmann

This work adds two new map creation flags BPF_F_RDONLY_PROG and BPF_F_WRONLY_PROG in order to allow for read-only or write-only BPF maps from a BPF program side.

Today we have BPF_F_RDONLY and BPF_F_WRONLY, but this only applies to system call side, meaning the BPF program has full read/write access to the map as usual while bpf(2) calls with map fd can either only read or write into the map depending on the flags. BPF_F_RDONLY_PROG and BPF_F_WRONLY_PROG allows for the exact opposite such that verifier is going to reject program loads if write into a read-only map or a read into a write-only map is detected.

Quoted 8 lines
Quoted 5 lines

We've enabled this generic map extension to various non-special maps holding normal user data: array, hash, lru, lpm, local storage, queue and stack. Further map types could be followed up in future depending on use-case. Main use case here is to forbid writes into .rodata map values from verifier side.

This will also enable optimizing the accesses on system with rich memory architecture :)

Nice! :)

Quoted 20 lines
Quoted 20 lines
---
 include/linux/bpf.h           | 18 ++++++++++++++++++
 include/uapi/linux/bpf.h      | 10 +++++++++-
 kernel/bpf/arraymap.c         |  2 +-
 kernel/bpf/hashtab.c          |  2 +-
 kernel/bpf/local_storage.c    |  2 +-
 kernel/bpf/lpm_trie.c         |  2 +-
 kernel/bpf/queue_stack_maps.c |  3 +--
 kernel/bpf/verifier.c         | 30 +++++++++++++++++++++++++++++-
 8 files changed, 61 insertions(+), 8 deletions(-)
include/linux/bpf.h +0 -0
index bdcc6e2a9977..3f74194dd4f6 100644
@@ -427,6 +427,24 @@ struct bpf_array {
 	};
 };
 
Quoted 13 lines

include/linux/bpf.h struct bpf_array { · line 439

Quoted 10 lines
include/linux/bpf.h +10 -0
+#define BPF_MAP_CAN_READ	BIT(0)
+#define BPF_MAP_CAN_WRITE	BIT(1)
+
+static inline u32 bpf_map_flags_to_cap(struct bpf_map *map)
+{
+	u32 access_flags = map->map_flags & (BPF_F_RDONLY_PROG | BPF_F_WRONLY_PROG);
+
+	/* Combination of BPF_F_RDONLY_PROG | BPF_F_WRONLY_PROG is
+	 * not possible.
+	 */

minor nit: we do check that old RDONLY and WRONLY are not set at the
same time, but here it's not done?

Good point indeed, I'll fix it in a v3 such that an invalid combination of both, BPF_F_RDONLY_PROG | BPF_F_WRONLY_PROG, is rejected upon map creation.

Quoted 7 lines

include/linux/bpf.h struct bpf_array { · line 446

Quoted 7 lines
include/linux/bpf.h +7 -0
+	if (access_flags & BPF_F_RDONLY_PROG)
+		return BPF_MAP_CAN_READ;
+	else if (access_flags & BPF_F_WRONLY_PROG)
+		return BPF_MAP_CAN_WRITE;
+	else
+		return BPF_MAP_CAN_READ | BPF_MAP_CAN_WRITE;
+}

Thanks,
Daniel

author maintainer
#18 lore raw

PATCH v2 3/7 bpf, obj: allow . char as part of the name

In reply to Daniel Borkmann

Trivial addition to allow '.' aside from '_' as "special" characters in the object name. Used to name maps from loader side as ".bss", ".data", ".rodata".

---
 kernel/bpf/syscall.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/bpf/syscall.c +3 -3
index d3ef45e01d7a..90044da3346e 100644
@@ -440,10 +440,10 @@ static int bpf_obj_name_cpy(char *dst, const char *src)
 	const char *end = src + BPF_OBJ_NAME_LEN;
 
 	memset(dst, 0, BPF_OBJ_NAME_LEN);
-
-	/* Copy all isalnum() and '_' char */
+	/* Copy all isalnum(), '_' and '.' chars. */
 	while (src < end && *src) {
-		if (!isalnum(*src) && *src != '_')
+		if (!isalnum(*src) &&
+		    *src != '_' && *src != '.')
 			return -EINVAL;
 		*dst++ = *src++;
 	}
Signature · 1 line
2.17.1
Acked-by on v2 3/7
#19 lore raw

Re: [PATCH bpf-next v2 3/7] bpf, obj: allow . char as part of the name

Quoted 6 lines · Daniel Borkmann

Trivial addition to allow '.' aside from '_' as "special" characters in the object name. Used to name maps from loader side as ".bss", ".data", ".rodata".

Quoted 9 lines
---
 kernel/bpf/syscall.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/bpf/syscall.c +0 -0
index d3ef45e01d7a..90044da3346e 100644

kernel/bpf/syscall.c static int bpf_obj_name_cpy(char *dst, const char *src) · line 443

Quoted 6 lines
kernel/bpf/syscall.c +1 -2
@@ -440,10 +440,10 @@ static int bpf_obj_name_cpy(char *dst, const char *src)
        const char *end = src + BPF_OBJ_NAME_LEN;
 
        memset(dst, 0, BPF_OBJ_NAME_LEN);
-
-       /* Copy all isalnum() and '_' char */
+       /* Copy all isalnum(), '_' and '.' chars. */

Is there any reason names are so restrictive? Say, why not '-' as well? It's perfectly safe even in filenames. Or even '/' and '\'? Is this name used by anything else in the system, except for introspection?

Quoted 10 lines
kernel/bpf/syscall.c +2 -2
        while (src < end && *src) {
-               if (!isalnum(*src) && *src != '_')
+               if (!isalnum(*src) &&
+                   *src != '_' && *src != '.')
                        return -EINVAL;
                *dst++ = *src++;
        }
--

2.17.1

author maintainer
#20 lore raw

Re: [PATCH bpf-next v2 3/7] bpf, obj: allow . char as part of the name

Quoted 20 lines · Andrii Nakryiko
Quoted 6 lines · Daniel Borkmann

Trivial addition to allow '.' aside from '_' as "special" characters in the object name. Used to name maps from loader side as ".bss", ".data", ".rodata".

Quoted 10 lines
 kernel/bpf/syscall.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/bpf/syscall.c +0 -0
index d3ef45e01d7a..90044da3346e 100644
@@ -440,10 +440,10 @@ static int bpf_obj_name_cpy(char *dst, const char *src)
        const char *end = src + BPF_OBJ_NAME_LEN;
 
Quoted 9 lines

kernel/bpf/syscall.c static int bpf_obj_name_cpy(char *dst, const char *src) · line 443

Quoted 4 lines
kernel/bpf/syscall.c +1 -2
        memset(dst, 0, BPF_OBJ_NAME_LEN);
-
-       /* Copy all isalnum() and '_' char */
+       /* Copy all isalnum(), '_' and '.' chars. */

Is there any reason names are so restrictive? Say, why not '-' as well? It's perfectly safe even in filenames. Or even '/' and '\'? Is this name used by anything else in the system, except for introspection?

Could be done, presumably it was more restrictive in case one might need some reserved names in unforeseeable future, but looks so far noone run into the need to extend it further than this. :)

Quoted 10 lines
Quoted 10 lines
kernel/bpf/syscall.c +2 -2
        while (src < end && *src) {
-               if (!isalnum(*src) && *src != '_')
+               if (!isalnum(*src) &&
+                   *src != '_' && *src != '.')
                        return -EINVAL;
                *dst++ = *src++;
        }
--

2.17.1

author maintainer
#21 lore raw

PATCH v2 4/7 bpf, libbpf: refactor relocation handling

In reply to Daniel Borkmann

From: Joe Stringer <[email protected]>

Adjust the code for relocations slightly with no functional changes, so that upcoming patches that will introduce support for relocations into the .data, .rodata and .bss sections can be added independent of these changes.

---
 tools/lib/bpf/libbpf.c | 62 ++++++++++++++++++++++--------------------
 1 file changed, 32 insertions(+), 30 deletions(-)
tools/lib/bpf/libbpf.c +32 -30
index b38dcbe7460a..8f8f688f3e9b 100644
@@ -851,20 +851,20 @@ static int bpf_object__elf_collect(struct bpf_object *obj, int flags)
 				obj->efile.symbols = data;
 				obj->efile.strtabidx = sh.sh_link;
 			}
-		} else if ((sh.sh_type == SHT_PROGBITS) &&
-			   (sh.sh_flags & SHF_EXECINSTR) &&
-			   (data->d_size > 0)) {
-			if (strcmp(name, ".text") == 0)
-				obj->efile.text_shndx = idx;
-			err = bpf_object__add_program(obj, data->d_buf,
-						      data->d_size, name, idx);
-			if (err) {
-				char errmsg[STRERR_BUFSIZE];
-				char *cp = libbpf_strerror_r(-err, errmsg,
-							     sizeof(errmsg));
-
-				pr_warning("failed to alloc program %s (%s): %s",
-					   name, obj->path, cp);
+		} else if (sh.sh_type == SHT_PROGBITS && data->d_size > 0) {
+			if (sh.sh_flags & SHF_EXECINSTR) {
+				if (strcmp(name, ".text") == 0)
+					obj->efile.text_shndx = idx;
+				err = bpf_object__add_program(obj, data->d_buf,
+							      data->d_size, name, idx);
+				if (err) {
+					char errmsg[STRERR_BUFSIZE];
+					char *cp = libbpf_strerror_r(-err, errmsg,
+								     sizeof(errmsg));
+
+					pr_warning("failed to alloc program %s (%s): %s",
+						   name, obj->path, cp);
+				}
 			}
 		} else if (sh.sh_type == SHT_REL) {
 			void *reloc = obj->efile.reloc;
@@ -1026,24 +1026,26 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
 			return -LIBBPF_ERRNO__RELOC;
 		}
 
-		/* TODO: 'maps' is sorted. We can use bsearch to make it faster. */
-		for (map_idx = 0; map_idx < nr_maps; map_idx++) {
-			if (maps[map_idx].offset == sym.st_value) {
-				pr_debug("relocation: find map %zd (%s) for insn %u\n",
-					 map_idx, maps[map_idx].name, insn_idx);
-				break;
+		if (sym.st_shndx == maps_shndx) {
+			/* TODO: 'maps' is sorted. We can use bsearch to make it faster. */
+			for (map_idx = 0; map_idx < nr_maps; map_idx++) {
+				if (maps[map_idx].offset == sym.st_value) {
+					pr_debug("relocation: find map %zd (%s) for insn %u\n",
+						 map_idx, maps[map_idx].name, insn_idx);
+					break;
+				}
 			}
-		}
 
-		if (map_idx >= nr_maps) {
-			pr_warning("bpf relocation: map_idx %d large than %d\n",
-				   (int)map_idx, (int)nr_maps - 1);
-			return -LIBBPF_ERRNO__RELOC;
-		}
+			if (map_idx >= nr_maps) {
+				pr_warning("bpf relocation: map_idx %d large than %d\n",
+					   (int)map_idx, (int)nr_maps - 1);
+				return -LIBBPF_ERRNO__RELOC;
+			}
 
-		prog->reloc_desc[i].type = RELO_LD64;
-		prog->reloc_desc[i].insn_idx = insn_idx;
-		prog->reloc_desc[i].map_idx = map_idx;
+			prog->reloc_desc[i].type = RELO_LD64;
+			prog->reloc_desc[i].insn_idx = insn_idx;
+			prog->reloc_desc[i].map_idx = map_idx;
+		}
 	}
 	return 0;
 }
@@ -1405,7 +1407,7 @@ bpf_program__relocate(struct bpf_program *prog, struct bpf_object *obj)
 			}
 			insns[insn_idx].src_reg = BPF_PSEUDO_MAP_FD;
 			insns[insn_idx].imm = obj->maps[map_idx].fd;
-		} else {
+		} else if (prog->reloc_desc[i].type == RELO_CALL) {
 			err = bpf_program__reloc_text(prog, obj,
 						      &prog->reloc_desc[i]);
 			if (err)
Signature · 1 line
2.17.1
author maintainer
#22 lore raw

PATCH v2 5/7 bpf, libbpf: support global data/bss/rodata sections

In reply to Daniel Borkmann

This work adds BPF loader support for global data sections to libbpf. This allows to write BPF programs in more natural C-like way by being able to define global variables and const data.

Back at LPC 2018 [0] we presented a first prototype which implemented support for global data sections by extending BPF syscall where union bpf_attr would get additional memory/size pair for each section passed during prog load in order to later add this base address into the ldimm64 instruction along with the user provided offset when accessing a variable. Consensus from LPC was that for proper upstream support, it would be more desirable to use maps instead of bpf_attr extension as this would allow for introspection of these sections as well as potential life updates of their content. This work follows this path by taking the following steps from loader side:

1) In bpf_object__elf_collect() step we pick up ".data", ".rodata", and ".bss" section information.

2) If present, in bpf_object__init_global_maps() we create a map that corresponds to each of the present sections. Given section size and access properties can differ, a single entry array map is created with value size that is corresponding to the ELF section size of .data, .bss or .rodata. In the latter case, the map is created as read-only from program side such that verifier rejects any write attempts into .rodata. In a subsequent step, for .data and .rodata sections, the section content is copied into the map through bpf_map_update_elem(). For .bss this is not necessary since array map is already zero-initialized by default.

3) In bpf_program__collect_reloc() step, we record the corresponding map, insn index, and relocation type for the global data.

4) And last but not least in the actual relocation step in bpf_program__relocate(), we mark the ldimm64 instruction with src_reg = BPF_PSEUDO_MAP_VALUE where in the first imm field the map's file descriptor is stored as similarly done as in BPF_PSEUDO_MAP_FD, and in the second imm field (as ldimm64 is 2-insn wide) we store the access offset into the section.

5) On kernel side, this special marked BPF_PSEUDO_MAP_VALUE load will then store the actual target address in order to have a 'map-lookup'-free access. That is, the actual map value base address + offset. The destination register in the verifier will then be marked as PTR_TO_MAP_VALUE, containing the fixed offset as reg->off and backing BPF map as reg->map_ptr. Meaning, it's treated as any other normal map value from verification side, only with efficient, direct value access instead of actual call to map lookup helper as in the typical case.

Simple example dump of program using globals vars in each section:

  # readelf -a test_global_data.o
  [...]
  [ 6] .bss              NOBITS           0000000000000000  00000328
       0000000000000010  0000000000000000  WA       0     0     8
  [ 7] .data             PROGBITS         0000000000000000  00000328
       0000000000000010  0000000000000000  WA       0     0     8
  [ 8] .rodata           PROGBITS         0000000000000000  00000338
       0000000000000018  0000000000000000   A       0     0     8
  [...]
    95: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    6 static_bss
    96: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    6 static_bss2
    97: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    7 static_data
    98: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    7 static_data2
    99: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    8 static_rodata
   100: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    8 static_rodata2
   101: 0000000000000010     8 OBJECT  LOCAL  DEFAULT    8 static_rodata3
  [...]
  # bpftool prog
  103: sched_cls  name load_static_dat  tag 37a8b6822fc39a29  gpl
       loaded_at 2019-02-28T02:02:35+0000  uid 0
       xlated 712B  jited 426B  memlock 4096B  map_ids 63,64,65,66
  # bpftool map show id 63
  63: array  name .bss  flags 0x0                      <-- .bss area, rw
      key 4B  value 16B  max_entries 1  memlock 4096B
  # bpftool map show id 64
  64: array  name .data  flags 0x0                     <-- .data area, rw
      key 4B  value 16B  max_entries 1  memlock 4096B
  # bpftool map show id 65
  65: array  name .rodata  flags 0x80                  <-- .rodata area, ro
      key 4B  value 24B  max_entries 1  memlock 4096B
  # bpftool prog dump xlated id 103
  int load_static_data(struct __sk_buff * skb):
  ; int load_static_data(struct __sk_buff *skb)
     0: (b7) r1 = 0
  ; key = 0;
     1: (63) *(u32 *)(r10 -4) = r1
     2: (bf) r6 = r10
  ; int load_static_data(struct __sk_buff *skb)
     3: (07) r6 += -4
  ; bpf_map_update_elem(&result, &key, &static_bss, 0);
     4: (18) r1 = map[id:66]
     6: (bf) r2 = r6
     7: (18) r3 = map[id:63][0]+0         <-- direct static_bss addr in .bss area
     9: (b7) r4 = 0
    10: (85) call array_map_update_elem#99888
    11: (b7) r1 = 1
  ; key = 1;
    12: (63) *(u32 *)(r10 -4) = r1
  ; bpf_map_update_elem(&result, &key, &static_data, 0);
    13: (18) r1 = map[id:66]
    15: (bf) r2 = r6
    16: (18) r3 = map[id:64][0]+0         <-- direct static_data addr in .data area
    18: (b7) r4 = 0
    19: (85) call array_map_update_elem#99888
    20: (b7) r1 = 2
  ; key = 2;
    21: (63) *(u32 *)(r10 -4) = r1
  ; bpf_map_update_elem(&result, &key, &static_rodata, 0);
    22: (18) r1 = map[id:66]
    24: (bf) r2 = r6
    25: (18) r3 = map[id:65][0]+0         <-- direct static_rodata addr in .rodata area
    27: (b7) r4 = 0
    28: (85) call array_map_update_elem#99888
    29: (b7) r1 = 3
  ; key = 3;
    30: (63) *(u32 *)(r10 -4) = r1
  ; bpf_map_update_elem(&result, &key, &static_bss2, 0);
    31: (18) r7 = map[id:63][0]+8         <--.
    33: (18) r1 = map[id:66]                 |
    35: (bf) r2 = r6                         |
    36: (18) r3 = map[id:63][0]+8         <-- direct static_bss2 addr in .bss area
    38: (b7) r4 = 0
    39: (85) call array_map_update_elem#99888
  [...]

For now .data/.rodata/.bss maps are not exposed via API to the user, but this could be done in a subsequent step.

Based upon recent fix in LLVM, commit c0db6b6bd444 ("[BPF] Don't fail for static variables").

Joint work with Joe Stringer.

[0] LPC 2018, BPF track, "ELF relocation for static data in BPF",

      http://vger.kernel.org/lpc-bpf2018.html#session-3
---
 tools/include/uapi/linux/bpf.h |  10 +-
 tools/lib/bpf/libbpf.c         | 259 +++++++++++++++++++++++++++------
 2 files changed, 226 insertions(+), 43 deletions(-)
tools/include/uapi/linux/bpf.h +9 -1
index 8884072e1a46..04b26f59b413 100644
@@ -287,7 +287,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)
 
@@ -297,6 +297,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)
 
tools/lib/bpf/libbpf.c +217 -42

386 lines not on this page · raw message

Signature · 1 line
2.17.1
#23 lore raw

Re: [PATCH bpf-next v2 5/7] bpf, libbpf: support global data/bss/rodata sections

Quoted 77 lines · Daniel Borkmann

This work adds BPF loader support for global data sections to libbpf. This allows to write BPF programs in more natural C-like way by being able to define global variables and const data.

Back at LPC 2018 [0] we presented a first prototype which implemented support for global data sections by extending BPF syscall where union bpf_attr would get additional memory/size pair for each section passed during prog load in order to later add this base address into the ldimm64 instruction along with the user provided offset when accessing a variable. Consensus from LPC was that for proper upstream support, it would be more desirable to use maps instead of bpf_attr extension as this would allow for introspection of these sections as well as potential life updates of their content. This work follows this path by taking the following steps from loader side:

1) In bpf_object__elf_collect() step we pick up ".data", ".rodata", and ".bss" section information.

2) If present, in bpf_object__init_global_maps() we create a map that corresponds to each of the present sections. Given section size and access properties can differ, a single entry array map is created with value size that is corresponding to the ELF section size of .data, .bss or .rodata. In the latter case, the map is created as read-only from program side such that verifier rejects any write attempts into .rodata. In a subsequent step, for .data and .rodata sections, the section content is copied into the map through bpf_map_update_elem(). For .bss this is not necessary since array map is already zero-initialized by default.

3) In bpf_program__collect_reloc() step, we record the corresponding map, insn index, and relocation type for the global data.

4) And last but not least in the actual relocation step in bpf_program__relocate(), we mark the ldimm64 instruction with src_reg = BPF_PSEUDO_MAP_VALUE where in the first imm field the map's file descriptor is stored as similarly done as in BPF_PSEUDO_MAP_FD, and in the second imm field (as ldimm64 is 2-insn wide) we store the access offset into the section.

5) On kernel side, this special marked BPF_PSEUDO_MAP_VALUE load will then store the actual target address in order to have a 'map-lookup'-free access. That is, the actual map value base address + offset. The destination register in the verifier will then be marked as PTR_TO_MAP_VALUE, containing the fixed offset as reg->off and backing BPF map as reg->map_ptr. Meaning, it's treated as any other normal map value from verification side, only with efficient, direct value access instead of actual call to map lookup helper as in the typical case.

Simple example dump of program using globals vars in each section:

  # readelf -a test_global_data.o
  [...]
  [ 6] .bss              NOBITS           0000000000000000  00000328
       0000000000000010  0000000000000000  WA       0     0     8
  [ 7] .data             PROGBITS         0000000000000000  00000328
       0000000000000010  0000000000000000  WA       0     0     8
  [ 8] .rodata           PROGBITS         0000000000000000  00000338
       0000000000000018  0000000000000000   A       0     0     8
  [...]
    95: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    6 static_bss
    96: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    6 static_bss2
    97: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    7 static_data
    98: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    7 static_data2
    99: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    8 static_rodata
   100: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    8 static_rodata2
   101: 0000000000000010     8 OBJECT  LOCAL  DEFAULT    8 static_rodata3
  [...]
Quoted 6 lines
  # bpftool prog
  103: sched_cls  name load_static_dat  tag 37a8b6822fc39a29  gpl
       loaded_at 2019-02-28T02:02:35+0000  uid 0
       xlated 712B  jited 426B  memlock 4096B  map_ids 63,64,65,66
  # bpftool map show id 63
  63: array  name .bss  flags 0x0                      <-- .bss area, rw

Can we use <main prog>.bss/data/rodata names? If we load more than one prog with global data that should make it easier to find which one is which.

Quoted 512 lines

key 4B value 16B max_entries 1 memlock 4096B

  # bpftool map show id 64
  64: array  name .data  flags 0x0                     <-- .data area, rw
      key 4B  value 16B  max_entries 1  memlock 4096B
  # bpftool map show id 65
  65: array  name .rodata  flags 0x80                  <-- .rodata area, ro
      key 4B  value 24B  max_entries 1  memlock 4096B
  # bpftool prog dump xlated id 103
  int load_static_data(struct __sk_buff * skb):
  ; int load_static_data(struct __sk_buff *skb)
     0: (b7) r1 = 0
  ; key = 0;
     1: (63) *(u32 *)(r10 -4) = r1
     2: (bf) r6 = r10
  ; int load_static_data(struct __sk_buff *skb)
     3: (07) r6 += -4
  ; bpf_map_update_elem(&result, &key, &static_bss, 0);
     4: (18) r1 = map[id:66]
     6: (bf) r2 = r6
     7: (18) r3 = map[id:63][0]+0         <-- direct static_bss addr in .bss area
     9: (b7) r4 = 0
    10: (85) call array_map_update_elem#99888
    11: (b7) r1 = 1
  ; key = 1;
    12: (63) *(u32 *)(r10 -4) = r1
  ; bpf_map_update_elem(&result, &key, &static_data, 0);
    13: (18) r1 = map[id:66]
    15: (bf) r2 = r6
    16: (18) r3 = map[id:64][0]+0         <-- direct static_data addr in .data area
    18: (b7) r4 = 0
    19: (85) call array_map_update_elem#99888
    20: (b7) r1 = 2
  ; key = 2;
    21: (63) *(u32 *)(r10 -4) = r1
  ; bpf_map_update_elem(&result, &key, &static_rodata, 0);
    22: (18) r1 = map[id:66]
    24: (bf) r2 = r6
    25: (18) r3 = map[id:65][0]+0         <-- direct static_rodata addr in .rodata area
    27: (b7) r4 = 0
    28: (85) call array_map_update_elem#99888
    29: (b7) r1 = 3
  ; key = 3;
    30: (63) *(u32 *)(r10 -4) = r1
  ; bpf_map_update_elem(&result, &key, &static_bss2, 0);
    31: (18) r7 = map[id:63][0]+8         <--.
    33: (18) r1 = map[id:66]                 |
    35: (bf) r2 = r6                         |
    36: (18) r3 = map[id:63][0]+8         <-- direct static_bss2 addr in .bss area
    38: (b7) r4 = 0
    39: (85) call array_map_update_elem#99888
  [...]

For now .data/.rodata/.bss maps are not exposed via API to the user, but this could be done in a subsequent step.

Based upon recent fix in LLVM, commit c0db6b6bd444 ("[BPF] Don't fail for static variables").

Joint work with Joe Stringer.

[0] LPC 2018, BPF track, "ELF relocation for static data in BPF",

      http://vger.kernel.org/lpc-bpf2018.html#session-3
---
 tools/include/uapi/linux/bpf.h |  10 +-
 tools/lib/bpf/libbpf.c         | 259 +++++++++++++++++++++++++++------
 2 files changed, 226 insertions(+), 43 deletions(-)
tools/include/uapi/linux/bpf.h +9 -1
index 8884072e1a46..04b26f59b413 100644
@@ -287,7 +287,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)
 
@@ -297,6 +297,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)
 
tools/lib/bpf/libbpf.c +217 -42
index 8f8f688f3e9b..969bc3d9f02c 100644
@@ -139,6 +139,9 @@ struct bpf_program {
 		enum {
 			RELO_LD64,
 			RELO_CALL,
+			RELO_DATA,
+			RELO_RODATA,
+			RELO_BSS,
 		} type;
 		int insn_idx;
 		union {
@@ -174,7 +177,10 @@ struct bpf_program {
 struct bpf_map {
 	int fd;
 	char *name;
-	size_t offset;
+	union {
+		__u32 global_type;
+		size_t offset;
+	};
 	int map_ifindex;
 	int inner_map_fd;
 	struct bpf_map_def def;
@@ -194,6 +200,8 @@ struct bpf_object {
 	size_t nr_programs;
 	struct bpf_map *maps;
 	size_t nr_maps;
+	struct bpf_map *maps_global;
+	size_t nr_maps_global;
 
 	bool loaded;
 	bool has_pseudo_calls;
@@ -209,6 +217,9 @@ struct bpf_object {
 		Elf *elf;
 		GElf_Ehdr ehdr;
 		Elf_Data *symbols;
+		Elf_Data *global_data;
+		Elf_Data *global_rodata;
+		Elf_Data *global_bss;
 		size_t strtabidx;
 		struct {
 			GElf_Shdr shdr;
@@ -217,6 +228,9 @@ struct bpf_object {
 		int nr_reloc;
 		int maps_shndx;
 		int text_shndx;
+		int data_shndx;
+		int rodata_shndx;
+		int bss_shndx;
 	} efile;
 	/*
 	 * All loaded bpf_object is linked in a list, which is
@@ -457,6 +471,9 @@ static struct bpf_object *bpf_object__new(const char *path,
 	obj->efile.obj_buf = obj_buf;
 	obj->efile.obj_buf_sz = obj_buf_sz;
 	obj->efile.maps_shndx = -1;
+	obj->efile.data_shndx = -1;
+	obj->efile.rodata_shndx = -1;
+	obj->efile.bss_shndx = -1;
 
 	obj->loaded = false;
 
@@ -475,6 +492,9 @@ static void bpf_object__elf_finish(struct bpf_object *obj)
 		obj->efile.elf = NULL;
 	}
 	obj->efile.symbols = NULL;
+	obj->efile.global_data = NULL;
+	obj->efile.global_rodata = NULL;
+	obj->efile.global_bss = NULL;
 
 	zfree(&obj->efile.reloc);
 	obj->efile.nr_reloc = 0;
@@ -757,6 +777,85 @@ bpf_object__init_maps(struct bpf_object *obj, int flags)
 	return 0;
 }
 
+static int
+bpf_object__create_map(struct bpf_object *obj, struct bpf_map *map);
+
+static int
+bpf_object__init_global(struct bpf_object *obj, int i, int type,
+			const char *name, Elf_Data *map_data)
+{
+	struct bpf_map *map = &obj->maps_global[i];
+	struct bpf_map_def *def = &map->def;
+	char *cp, errmsg[STRERR_BUFSIZE];
+	int err, slot0 = 0;
+
+	def->type = BPF_MAP_TYPE_ARRAY;
+	def->key_size = sizeof(int);
+	def->value_size = map_data->d_size;
+	def->max_entries = 1;
+	def->map_flags = type == RELO_RODATA ? BPF_F_RDONLY_PROG : 0;
+
+	map->name = strdup(name);
+	map->global_type = type;
+	map->fd = bpf_object__create_map(obj, map);
+	if (map->fd < 0) {
+		err = map->fd;
+		cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
+		pr_warning("failed to create map (name: '%s'): %s\n",
+			   map->name, cp);
+		goto destroy;
+	}
+
+	pr_debug("create map %s: fd=%d\n", map->name, map->fd);
+
+	if (type != RELO_BSS) {
+		err = bpf_map_update_elem(map->fd, &slot0, map_data->d_buf, 0);
+		if (err < 0) {
+			cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
+			pr_warning("failed to update map (name: '%s'): %s\n",
+				   map->name, cp);
+			goto destroy;
+		}
+
+		pr_debug("updated map %s with elf data: fd=%d\n", map->name,
+			 map->fd);
+	}
+	return 0;
+destroy:
+	for (i = 0; i < obj->nr_maps_global; i++)
+		zclose(obj->maps_global[i].fd);
+	return err;
+}
+
+static int
+bpf_object__init_global_maps(struct bpf_object *obj)
+{
+	int nr_maps_global = (obj->efile.data_shndx >= 0) +
+			     (obj->efile.rodata_shndx >= 0) +
+			     (obj->efile.bss_shndx >= 0), i, err = 0;
+
+	obj->maps_global = calloc(nr_maps_global, sizeof(obj->maps_global[0]));
+	if (!obj->maps_global) {
+		pr_warning("alloc maps for object failed\n");
+		return -ENOMEM;
+	}
+
+	obj->nr_maps_global = nr_maps_global;
+	for (i = 0; i < obj->nr_maps_global; i++)
+		obj->maps[i].fd = -1;
+	i = 0;
+	if (obj->efile.bss_shndx >= 0)
+		err = bpf_object__init_global(obj, i++, RELO_BSS, ".bss",
+					      obj->efile.global_bss);
+	if (obj->efile.data_shndx >= 0 && !err)
+		err = bpf_object__init_global(obj, i++, RELO_DATA, ".data",
+					      obj->efile.global_data);
+	if (obj->efile.rodata_shndx >= 0 && !err)
+		err = bpf_object__init_global(obj, i++, RELO_RODATA, ".rodata",
+					      obj->efile.global_rodata);
+	return err;
+}
+
 static bool section_have_execinstr(struct bpf_object *obj, int idx)
 {
 	Elf_Scn *scn;
@@ -865,6 +964,12 @@ static int bpf_object__elf_collect(struct bpf_object *obj, int flags)
 					pr_warning("failed to alloc program %s (%s): %s",
 						   name, obj->path, cp);
 				}
+			} else if (strcmp(name, ".data") == 0) {
+				obj->efile.global_data = data;
+				obj->efile.data_shndx = idx;
+			} else if (strcmp(name, ".rodata") == 0) {
+				obj->efile.global_rodata = data;
+				obj->efile.rodata_shndx = idx;
 			}
 		} else if (sh.sh_type == SHT_REL) {
 			void *reloc = obj->efile.reloc;
@@ -892,6 +997,9 @@ static int bpf_object__elf_collect(struct bpf_object *obj, int flags)
 				obj->efile.reloc[n].shdr = sh;
 				obj->efile.reloc[n].data = data;
 			}
+		} else if (sh.sh_type == SHT_NOBITS && strcmp(name, ".bss") == 0) {
+			obj->efile.global_bss = data;
+			obj->efile.bss_shndx = idx;
 		} else {
 			pr_debug("skip section(%d) %s\n", idx, name);
 		}
@@ -923,6 +1031,14 @@ static int bpf_object__elf_collect(struct bpf_object *obj, int flags)
 		if (err)
 			goto out;
 	}
+	if (obj->efile.data_shndx >= 0 ||
+	    obj->efile.rodata_shndx >= 0 ||
+	    obj->efile.bss_shndx >= 0) {
+		err = bpf_object__init_global_maps(obj);
+		if (err)
+			goto out;
+	}
+
 	err = bpf_object__init_prog_names(obj);
 out:
 	return err;
@@ -961,6 +1077,11 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
 	Elf_Data *symbols = obj->efile.symbols;
 	int text_shndx = obj->efile.text_shndx;
 	int maps_shndx = obj->efile.maps_shndx;
+	int data_shndx = obj->efile.data_shndx;
+	int rodata_shndx = obj->efile.rodata_shndx;
+	int bss_shndx = obj->efile.bss_shndx;
+	struct bpf_map *maps_global = obj->maps_global;
+	size_t nr_maps_global = obj->nr_maps_global;
 	struct bpf_map *maps = obj->maps;
 	size_t nr_maps = obj->nr_maps;
 	int i, nrels;
@@ -999,8 +1120,10 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
 			 (long long) (rel.r_info >> 32),
 			 (long long) sym.st_value, sym.st_name);
 
-		if (sym.st_shndx != maps_shndx && sym.st_shndx != text_shndx) {
-			pr_warning("Program '%s' contains non-map related relo data pointing to section %u\n",
+		if (sym.st_shndx != maps_shndx && sym.st_shndx != text_shndx &&
+		    sym.st_shndx != data_shndx && sym.st_shndx != rodata_shndx &&
+		    sym.st_shndx != bss_shndx) {
+			pr_warning("Program '%s' contains unrecognized relo data pointing to section %u\n",
 				   prog->section_name, sym.st_shndx);
 			return -LIBBPF_ERRNO__RELOC;
 		}
@@ -1045,6 +1168,30 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
 			prog->reloc_desc[i].type = RELO_LD64;
 			prog->reloc_desc[i].insn_idx = insn_idx;
 			prog->reloc_desc[i].map_idx = map_idx;
+		} else if (sym.st_shndx == data_shndx ||
+			   sym.st_shndx == rodata_shndx ||
+			   sym.st_shndx == bss_shndx) {
+			int type = (sym.st_shndx == data_shndx)   ? RELO_DATA :
+				   (sym.st_shndx == rodata_shndx) ? RELO_RODATA :
+								    RELO_BSS;
+
+			for (map_idx = 0; map_idx < nr_maps_global; map_idx++) {
+				if (maps_global[map_idx].global_type == type) {
+					pr_debug("relocation: find map %zd (%s) for insn %u\n",
+						 map_idx, maps_global[map_idx].name, insn_idx);
+					break;
+				}
+			}
+
+			if (map_idx >= nr_maps_global) {
+				pr_warning("bpf relocation: map_idx %d large than %d\n",
+					   (int)map_idx, (int)nr_maps_global - 1);
+				return -LIBBPF_ERRNO__RELOC;
+			}
+
+			prog->reloc_desc[i].type = type;
+			prog->reloc_desc[i].insn_idx = insn_idx;
+			prog->reloc_desc[i].map_idx = map_idx;
 		}
 	}
 	return 0;
@@ -1176,15 +1323,58 @@ bpf_object__probe_caps(struct bpf_object *obj)
 }
 
 static int
-bpf_object__create_maps(struct bpf_object *obj)
+bpf_object__create_map(struct bpf_object *obj, struct bpf_map *map)
 {
 	struct bpf_create_map_attr create_attr = {};
+	struct bpf_map_def *def = &map->def;
+	char *cp, errmsg[STRERR_BUFSIZE];
+	int fd;
+
+	if (obj->caps.name)
+		create_attr.name = map->name;
+	create_attr.map_ifindex = map->map_ifindex;
+	create_attr.map_type = def->type;
+	create_attr.map_flags = def->map_flags;
+	create_attr.key_size = def->key_size;
+	create_attr.value_size = def->value_size;
+	create_attr.max_entries = def->max_entries;
+	create_attr.btf_fd = 0;
+	create_attr.btf_key_type_id = 0;
+	create_attr.btf_value_type_id = 0;
+	if (bpf_map_type__is_map_in_map(def->type) &&
+	    map->inner_map_fd >= 0)
+		create_attr.inner_map_fd = map->inner_map_fd;
+	if (obj->btf && !bpf_map_find_btf_info(map, obj->btf)) {
+		create_attr.btf_fd = btf__fd(obj->btf);
+		create_attr.btf_key_type_id = map->btf_key_type_id;
+		create_attr.btf_value_type_id = map->btf_value_type_id;
+	}
+
+	fd = bpf_create_map_xattr(&create_attr);
+	if (fd < 0 && create_attr.btf_key_type_id) {
+		cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
+		pr_warning("Error in bpf_create_map_xattr(%s):%s(%d). Retrying without BTF.\n",
+			   map->name, cp, errno);
+
+		create_attr.btf_fd = 0;
+		create_attr.btf_key_type_id = 0;
+		create_attr.btf_value_type_id = 0;
+		map->btf_key_type_id = 0;
+		map->btf_value_type_id = 0;
+		fd = bpf_create_map_xattr(&create_attr);
+	}
+
+	return fd;
+}
+
+static int
+bpf_object__create_maps(struct bpf_object *obj)
+{
 	unsigned int i;
 	int err;
 
 	for (i = 0; i < obj->nr_maps; i++) {
 		struct bpf_map *map = &obj->maps[i];
-		struct bpf_map_def *def = &map->def;
 		char *cp, errmsg[STRERR_BUFSIZE];
 		int *pfd = &map->fd;
 
@@ -1193,41 +1383,7 @@ bpf_object__create_maps(struct bpf_object *obj)
 				 map->name, map->fd);
 			continue;
 		}
-
-		if (obj->caps.name)
-			create_attr.name = map->name;
-		create_attr.map_ifindex = map->map_ifindex;
-		create_attr.map_type = def->type;
-		create_attr.map_flags = def->map_flags;
-		create_attr.key_size = def->key_size;
-		create_attr.value_size = def->value_size;
-		create_attr.max_entries = def->max_entries;
-		create_attr.btf_fd = 0;
-		create_attr.btf_key_type_id = 0;
-		create_attr.btf_value_type_id = 0;
-		if (bpf_map_type__is_map_in_map(def->type) &&
-		    map->inner_map_fd >= 0)
-			create_attr.inner_map_fd = map->inner_map_fd;
-
-		if (obj->btf && !bpf_map_find_btf_info(map, obj->btf)) {
-			create_attr.btf_fd = btf__fd(obj->btf);
-			create_attr.btf_key_type_id = map->btf_key_type_id;
-			create_attr.btf_value_type_id = map->btf_value_type_id;
-		}
-
-		*pfd = bpf_create_map_xattr(&create_attr);
-		if (*pfd < 0 && create_attr.btf_key_type_id) {
-			cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
-			pr_warning("Error in bpf_create_map_xattr(%s):%s(%d). Retrying without BTF.\n",
-				   map->name, cp, errno);
-			create_attr.btf_fd = 0;
-			create_attr.btf_key_type_id = 0;
-			create_attr.btf_value_type_id = 0;
-			map->btf_key_type_id = 0;
-			map->btf_value_type_id = 0;
-			*pfd = bpf_create_map_xattr(&create_attr);
-		}
-
+		*pfd = bpf_object__create_map(obj, map);
 		if (*pfd < 0) {
 			size_t j;
 
@@ -1412,6 +1568,24 @@ bpf_program__relocate(struct bpf_program *prog, struct bpf_object *obj)
 						      &prog->reloc_desc[i]);
 			if (err)
 				return err;
+		} else if (prog->reloc_desc[i].type == RELO_DATA ||
+			   prog->reloc_desc[i].type == RELO_RODATA ||
+			   prog->reloc_desc[i].type == RELO_BSS) {
+			struct bpf_insn *insns = prog->insns;
+			int insn_idx, map_idx, data_off;
+
+			insn_idx = prog->reloc_desc[i].insn_idx;
+			map_idx  = prog->reloc_desc[i].map_idx;
+			data_off = insns[insn_idx].imm;
+
+			if (insn_idx + 1 >= (int)prog->insns_cnt) {
+				pr_warning("relocation out of range: '%s'\n",
+					   prog->section_name);
+				return -LIBBPF_ERRNO__RELOC;
+			}
+			insns[insn_idx].src_reg = BPF_PSEUDO_MAP_VALUE;
+			insns[insn_idx].imm = obj->maps_global[map_idx].fd;
+			insns[insn_idx + 1].imm = data_off;
 		}
 	}
 
@@ -1717,6 +1891,7 @@ __bpf_object__open(const char *path, void *obj_buf, size_t obj_buf_sz,
 
 	CHECK_ERR(bpf_object__elf_init(obj), err, out);
 	CHECK_ERR(bpf_object__check_endianness(obj), err, out);
+	CHECK_ERR(bpf_object__probe_caps(obj), err, out);
 	CHECK_ERR(bpf_object__elf_collect(obj, flags), err, out);
 	CHECK_ERR(bpf_object__collect_reloc(obj), err, out);
 	CHECK_ERR(bpf_object__validate(obj, needs_kver), err, out);
@@ -1789,7 +1964,8 @@ int bpf_object__unload(struct bpf_object *obj)
 
 	for (i = 0; i < obj->nr_maps; i++)
 		zclose(obj->maps[i].fd);
-
+	for (i = 0; i < obj->nr_maps_global; i++)
+		zclose(obj->maps_global[i].fd);
 	for (i = 0; i < obj->nr_programs; i++)
 		bpf_program__unload(&obj->programs[i]);
 
@@ -1810,7 +1986,6 @@ int bpf_object__load(struct bpf_object *obj)
 
 	obj->loaded = true;
 
-	CHECK_ERR(bpf_object__probe_caps(obj), err, out);
 	CHECK_ERR(bpf_object__create_maps(obj), err, out);
 	CHECK_ERR(bpf_object__relocate(obj), err, out);
 	CHECK_ERR(bpf_object__load_progs(obj), err, out);
Signature · 1 line
2.17.1
author maintainer
#24 lore raw

Re: [PATCH bpf-next v2 5/7] bpf, libbpf: support global data/bss/rodata sections

Quoted 78 lines · Stanislav Fomichev
Quoted 77 lines · Daniel Borkmann

This work adds BPF loader support for global data sections to libbpf. This allows to write BPF programs in more natural C-like way by being able to define global variables and const data.

Back at LPC 2018 [0] we presented a first prototype which implemented support for global data sections by extending BPF syscall where union bpf_attr would get additional memory/size pair for each section passed during prog load in order to later add this base address into the ldimm64 instruction along with the user provided offset when accessing a variable. Consensus from LPC was that for proper upstream support, it would be more desirable to use maps instead of bpf_attr extension as this would allow for introspection of these sections as well as potential life updates of their content. This work follows this path by taking the following steps from loader side:

1) In bpf_object__elf_collect() step we pick up ".data", ".rodata", and ".bss" section information.

2) If present, in bpf_object__init_global_maps() we create a map that corresponds to each of the present sections. Given section size and access properties can differ, a single entry array map is created with value size that is corresponding to the ELF section size of .data, .bss or .rodata. In the latter case, the map is created as read-only from program side such that verifier rejects any write attempts into .rodata. In a subsequent step, for .data and .rodata sections, the section content is copied into the map through bpf_map_update_elem(). For .bss this is not necessary since array map is already zero-initialized by default.

3) In bpf_program__collect_reloc() step, we record the corresponding map, insn index, and relocation type for the global data.

4) And last but not least in the actual relocation step in bpf_program__relocate(), we mark the ldimm64 instruction with src_reg = BPF_PSEUDO_MAP_VALUE where in the first imm field the map's file descriptor is stored as similarly done as in BPF_PSEUDO_MAP_FD, and in the second imm field (as ldimm64 is 2-insn wide) we store the access offset into the section.

5) On kernel side, this special marked BPF_PSEUDO_MAP_VALUE load will then store the actual target address in order to have a 'map-lookup'-free access. That is, the actual map value base address + offset. The destination register in the verifier will then be marked as PTR_TO_MAP_VALUE, containing the fixed offset as reg->off and backing BPF map as reg->map_ptr. Meaning, it's treated as any other normal map value from verification side, only with efficient, direct value access instead of actual call to map lookup helper as in the typical case.

Simple example dump of program using globals vars in each section:

  # readelf -a test_global_data.o
  [...]
  [ 6] .bss              NOBITS           0000000000000000  00000328
       0000000000000010  0000000000000000  WA       0     0     8
  [ 7] .data             PROGBITS         0000000000000000  00000328
       0000000000000010  0000000000000000  WA       0     0     8
  [ 8] .rodata           PROGBITS         0000000000000000  00000338
       0000000000000018  0000000000000000   A       0     0     8
  [...]
    95: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    6 static_bss
    96: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    6 static_bss2
    97: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    7 static_data
    98: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    7 static_data2
    99: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    8 static_rodata
   100: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    8 static_rodata2
   101: 0000000000000010     8 OBJECT  LOCAL  DEFAULT    8 static_rodata3
  [...]
Quoted 8 lines
Quoted 6 lines
  # bpftool prog
  103: sched_cls  name load_static_dat  tag 37a8b6822fc39a29  gpl
       loaded_at 2019-02-28T02:02:35+0000  uid 0
       xlated 712B  jited 426B  memlock 4096B  map_ids 63,64,65,66
  # bpftool map show id 63
  63: array  name .bss  flags 0x0                      <-- .bss area, rw

Can we use <main prog>.bss/data/rodata names? If we load more than one prog with global data that should make it easier to find which one is which.

Yeah that's fine, we can change it. They could potentially also be shared, so <main prog>.bss/data/rodata might be misleading, but <obj>.bss/data/rodata could be.

Thanks,
Daniel

#25 lore raw

Re: [PATCH bpf-next v2 5/7] bpf, libbpf: support global data/bss/rodata sections

Quoted 85 lines · Daniel Borkmann
Quoted 84 lines · Stanislav Fomichev
Quoted 83 lines · Daniel Borkmann

This work adds BPF loader support for global data sections to libbpf. This allows to write BPF programs in more natural C-like way by being able to define global variables and const data.

Back at LPC 2018 [0] we presented a first prototype which implemented support for global data sections by extending BPF syscall where union bpf_attr would get additional memory/size pair for each section passed during prog load in order to later add this base address into the ldimm64 instruction along with the user provided offset when accessing a variable. Consensus from LPC was that for proper upstream support, it would be more desirable to use maps instead of bpf_attr extension as this would allow for introspection of these sections as well as potential life updates of their content. This work follows this path by taking the following steps from loader side:

1) In bpf_object__elf_collect() step we pick up ".data", ".rodata", and ".bss" section information.

2) If present, in bpf_object__init_global_maps() we create a map that corresponds to each of the present sections. Given section size and access properties can differ, a single entry array map is created with value size that is corresponding to the ELF section size of .data, .bss or .rodata. In the latter case, the map is created as read-only from program side such that verifier rejects any write attempts into .rodata. In a subsequent step, for .data and .rodata sections, the section content is copied into the map through bpf_map_update_elem(). For .bss this is not necessary since array map is already zero-initialized by default.

3) In bpf_program__collect_reloc() step, we record the corresponding map, insn index, and relocation type for the global data.

4) And last but not least in the actual relocation step in bpf_program__relocate(), we mark the ldimm64 instruction with src_reg = BPF_PSEUDO_MAP_VALUE where in the first imm field the map's file descriptor is stored as similarly done as in BPF_PSEUDO_MAP_FD, and in the second imm field (as ldimm64 is 2-insn wide) we store the access offset into the section.

5) On kernel side, this special marked BPF_PSEUDO_MAP_VALUE load will then store the actual target address in order to have a 'map-lookup'-free access. That is, the actual map value base address + offset. The destination register in the verifier will then be marked as PTR_TO_MAP_VALUE, containing the fixed offset as reg->off and backing BPF map as reg->map_ptr. Meaning, it's treated as any other normal map value from verification side, only with efficient, direct value access instead of actual call to map lookup helper as in the typical case.

Simple example dump of program using globals vars in each section:

   # readelf -a test_global_data.o
   [...]
   [ 6] .bss              NOBITS           0000000000000000  00000328
        0000000000000010  0000000000000000  WA       0     0     8
   [ 7] .data             PROGBITS         0000000000000000  00000328
        0000000000000010  0000000000000000  WA       0     0     8
   [ 8] .rodata           PROGBITS         0000000000000000  00000338
        0000000000000018  0000000000000000   A       0     0     8
   [...]
     95: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    6 static_bss
     96: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    6 static_bss2
     97: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    7 static_data
     98: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    7 static_data2
     99: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    8 static_rodata
    100: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    8 static_rodata2
    101: 0000000000000010     8 OBJECT  LOCAL  DEFAULT    8 static_rodata3
   [...]
   # bpftool prog
   103: sched_cls  name load_static_dat  tag 37a8b6822fc39a29  gpl
        loaded_at 2019-02-28T02:02:35+0000  uid 0
        xlated 712B  jited 426B  memlock 4096B  map_ids 63,64,65,66
   # bpftool map show id 63
   63: array  name .bss  flags 0x0                      <-- .bss area, rw
Quoted 6 lines
Quoted 2 lines

Can we use <main prog>.bss/data/rodata names? If we load more than one prog with global data that should make it easier to find which one is which.

Yeah that's fine, we can change it. They could potentially also be shared, so <main prog>.bss/data/rodata might be misleading, but <obj>.bss/data/rodata could be.

Note the map_name field only 16 bytes (excluding ending '\0', only 15 bytes). If <obj> file has a long name like test_verifier.o, you may have to shorten the <obj> part of the name.

Quoted 4 lines

Thanks,
Daniel

author maintainer
#26 lore raw

Re: [PATCH bpf-next v2 5/7] bpf, libbpf: support global data/bss/rodata sections

Quoted 89 lines · Yonghong Song
Quoted 88 lines · Daniel Borkmann
Quoted 86 lines · Stanislav Fomichev
Quoted 77 lines · Daniel Borkmann

This work adds BPF loader support for global data sections to libbpf. This allows to write BPF programs in more natural C-like way by being able to define global variables and const data.

Back at LPC 2018 [0] we presented a first prototype which implemented support for global data sections by extending BPF syscall where union bpf_attr would get additional memory/size pair for each section passed during prog load in order to later add this base address into the ldimm64 instruction along with the user provided offset when accessing a variable. Consensus from LPC was that for proper upstream support, it would be more desirable to use maps instead of bpf_attr extension as this would allow for introspection of these sections as well as potential life updates of their content. This work follows this path by taking the following steps from loader side:

1) In bpf_object__elf_collect() step we pick up ".data", ".rodata", and ".bss" section information.

2) If present, in bpf_object__init_global_maps() we create a map that corresponds to each of the present sections. Given section size and access properties can differ, a single entry array map is created with value size that is corresponding to the ELF section size of .data, .bss or .rodata. In the latter case, the map is created as read-only from program side such that verifier rejects any write attempts into .rodata. In a subsequent step, for .data and .rodata sections, the section content is copied into the map through bpf_map_update_elem(). For .bss this is not necessary since array map is already zero-initialized by default.

3) In bpf_program__collect_reloc() step, we record the corresponding map, insn index, and relocation type for the global data.

4) And last but not least in the actual relocation step in bpf_program__relocate(), we mark the ldimm64 instruction with src_reg = BPF_PSEUDO_MAP_VALUE where in the first imm field the map's file descriptor is stored as similarly done as in BPF_PSEUDO_MAP_FD, and in the second imm field (as ldimm64 is 2-insn wide) we store the access offset into the section.

5) On kernel side, this special marked BPF_PSEUDO_MAP_VALUE load will then store the actual target address in order to have a 'map-lookup'-free access. That is, the actual map value base address + offset. The destination register in the verifier will then be marked as PTR_TO_MAP_VALUE, containing the fixed offset as reg->off and backing BPF map as reg->map_ptr. Meaning, it's treated as any other normal map value from verification side, only with efficient, direct value access instead of actual call to map lookup helper as in the typical case.

Simple example dump of program using globals vars in each section:

   # readelf -a test_global_data.o
   [...]
   [ 6] .bss              NOBITS           0000000000000000  00000328
        0000000000000010  0000000000000000  WA       0     0     8
   [ 7] .data             PROGBITS         0000000000000000  00000328
        0000000000000010  0000000000000000  WA       0     0     8
   [ 8] .rodata           PROGBITS         0000000000000000  00000338
        0000000000000018  0000000000000000   A       0     0     8
   [...]
     95: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    6 static_bss
     96: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    6 static_bss2
     97: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    7 static_data
     98: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    7 static_data2
     99: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    8 static_rodata
    100: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    8 static_rodata2
    101: 0000000000000010     8 OBJECT  LOCAL  DEFAULT    8 static_rodata3
   [...]
Quoted 6 lines
   # bpftool prog
   103: sched_cls  name load_static_dat  tag 37a8b6822fc39a29  gpl
        loaded_at 2019-02-28T02:02:35+0000  uid 0
        xlated 712B  jited 426B  memlock 4096B  map_ids 63,64,65,66
   # bpftool map show id 63
   63: array  name .bss  flags 0x0                      <-- .bss area, rw

Can we use <main prog>.bss/data/rodata names? If we load more than one prog with global data that should make it easier to find which one is which.

Quoted 7 lines
Quoted 3 lines

Yeah that's fine, we can change it. They could potentially also be shared, so <main prog>.bss/data/rodata might be misleading, but <obj>.bss/data/rodata could be.

Note the map_name field only 16 bytes (excluding ending '\0', only 15 bytes). If <obj> file has a long name like test_verifier.o, you may have to shorten the <obj> part of the name.

Yes, it needs to be ensured that (bss/)data/rodata part is still visible to the user, so <obj> part would need to be truncated accordingly.

#27 lore raw

Re: [PATCH bpf-next v2 5/7] bpf, libbpf: support global data/bss/rodata sections

In reply to Daniel Borkmann
Quoted 18 lines · Daniel Borkmann

This work adds BPF loader support for global data sections to libbpf. This allows to write BPF programs in more natural C-like way by being able to define global variables and const data.

Back at LPC 2018 [0] we presented a first prototype which implemented support for global data sections by extending BPF syscall where union bpf_attr would get additional memory/size pair for each section passed during prog load in order to later add this base address into the ldimm64 instruction along with the user provided offset when accessing a variable. Consensus from LPC was that for proper upstream support, it would be more desirable to use maps instead of bpf_attr extension as this would allow for introspection of these sections as well as potential life updates of their content. This work follows this path by taking the following steps from loader side:

Quoted 5 lines

1) In bpf_object__elf_collect() step we pick up ".data", ".rodata", and ".bss" section information.

2) If present, in bpf_object__init_global_maps() we create a map that corresponds to each of the present sections.

Is there any point in having .data and .bss in separate maps? I can only see for reasons of inspectiion from bpftool, but other than that isn't .bss just an optimization over .data to save space in ELF file, but in other regards is just another part of r/w .data section?

Quoted 10 lines

Given section size and access properties can differ, a single entry array map is created with value size that is corresponding to the ELF section size of .data, .bss or .rodata. In the latter case, the map is created as read-only from program side such that verifier rejects any write attempts into .rodata. In a subsequent step, for .data and .rodata sections, the section content is copied into the map through bpf_map_update_elem(). For .bss this is not necessary since array map is already zero-initialized by default.

For .rodata, ideally it would be nice to make it RDONLY from userland as well, except for first UPDATE. How hard is it to support that?

Quoted 104 lines

3) In bpf_program__collect_reloc() step, we record the corresponding map, insn index, and relocation type for the global data.

4) And last but not least in the actual relocation step in bpf_program__relocate(), we mark the ldimm64 instruction with src_reg = BPF_PSEUDO_MAP_VALUE where in the first imm field the map's file descriptor is stored as similarly done as in BPF_PSEUDO_MAP_FD, and in the second imm field (as ldimm64 is 2-insn wide) we store the access offset into the section.

5) On kernel side, this special marked BPF_PSEUDO_MAP_VALUE load will then store the actual target address in order to have a 'map-lookup'-free access. That is, the actual map value base address + offset. The destination register in the verifier will then be marked as PTR_TO_MAP_VALUE, containing the fixed offset as reg->off and backing BPF map as reg->map_ptr. Meaning, it's treated as any other normal map value from verification side, only with efficient, direct value access instead of actual call to map lookup helper as in the typical case.

Simple example dump of program using globals vars in each section:

  # readelf -a test_global_data.o
  [...]
  [ 6] .bss              NOBITS           0000000000000000  00000328
       0000000000000010  0000000000000000  WA       0     0     8
  [ 7] .data             PROGBITS         0000000000000000  00000328
       0000000000000010  0000000000000000  WA       0     0     8
  [ 8] .rodata           PROGBITS         0000000000000000  00000338
       0000000000000018  0000000000000000   A       0     0     8
  [...]
    95: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    6 static_bss
    96: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    6 static_bss2
    97: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    7 static_data
    98: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    7 static_data2
    99: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    8 static_rodata
   100: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    8 static_rodata2
   101: 0000000000000010     8 OBJECT  LOCAL  DEFAULT    8 static_rodata3
  [...]
  # bpftool prog
  103: sched_cls  name load_static_dat  tag 37a8b6822fc39a29  gpl
       loaded_at 2019-02-28T02:02:35+0000  uid 0
       xlated 712B  jited 426B  memlock 4096B  map_ids 63,64,65,66
  # bpftool map show id 63
  63: array  name .bss  flags 0x0                      <-- .bss area, rw
      key 4B  value 16B  max_entries 1  memlock 4096B
  # bpftool map show id 64
  64: array  name .data  flags 0x0                     <-- .data area, rw
      key 4B  value 16B  max_entries 1  memlock 4096B
  # bpftool map show id 65
  65: array  name .rodata  flags 0x80                  <-- .rodata area, ro
      key 4B  value 24B  max_entries 1  memlock 4096B
  # bpftool prog dump xlated id 103
  int load_static_data(struct __sk_buff * skb):
  ; int load_static_data(struct __sk_buff *skb)
     0: (b7) r1 = 0
  ; key = 0;
     1: (63) *(u32 *)(r10 -4) = r1
     2: (bf) r6 = r10
  ; int load_static_data(struct __sk_buff *skb)
     3: (07) r6 += -4
  ; bpf_map_update_elem(&result, &key, &static_bss, 0);
     4: (18) r1 = map[id:66]
     6: (bf) r2 = r6
     7: (18) r3 = map[id:63][0]+0         <-- direct static_bss addr in .bss area
     9: (b7) r4 = 0
    10: (85) call array_map_update_elem#99888
    11: (b7) r1 = 1
  ; key = 1;
    12: (63) *(u32 *)(r10 -4) = r1
  ; bpf_map_update_elem(&result, &key, &static_data, 0);
    13: (18) r1 = map[id:66]
    15: (bf) r2 = r6
    16: (18) r3 = map[id:64][0]+0         <-- direct static_data addr in .data area
    18: (b7) r4 = 0
    19: (85) call array_map_update_elem#99888
    20: (b7) r1 = 2
  ; key = 2;
    21: (63) *(u32 *)(r10 -4) = r1
  ; bpf_map_update_elem(&result, &key, &static_rodata, 0);
    22: (18) r1 = map[id:66]
    24: (bf) r2 = r6
    25: (18) r3 = map[id:65][0]+0         <-- direct static_rodata addr in .rodata area
    27: (b7) r4 = 0
    28: (85) call array_map_update_elem#99888
    29: (b7) r1 = 3
  ; key = 3;
    30: (63) *(u32 *)(r10 -4) = r1
  ; bpf_map_update_elem(&result, &key, &static_bss2, 0);
    31: (18) r7 = map[id:63][0]+8         <--.
    33: (18) r1 = map[id:66]                 |
    35: (bf) r2 = r6                         |
    36: (18) r3 = map[id:63][0]+8         <-- direct static_bss2 addr in .bss area
    38: (b7) r4 = 0
    39: (85) call array_map_update_elem#99888
  [...]
Quoted 2 lines

For now .data/.rodata/.bss maps are not exposed via API to the user, but this could be done in a subsequent step.

See comment about BPF_MAP_TYPE_HEAP/BLOB map in comments to patch #1, it would probably make more useful API for .data/.rodata/.bss.

Quoted 49 lines

Based upon recent fix in LLVM, commit c0db6b6bd444 ("[BPF] Don't fail for static variables").

Joint work with Joe Stringer.

[0] LPC 2018, BPF track, "ELF relocation for static data in BPF",

      http://vger.kernel.org/lpc-bpf2018.html#session-3
---
 tools/include/uapi/linux/bpf.h |  10 +-
 tools/lib/bpf/libbpf.c         | 259 +++++++++++++++++++++++++++------
 2 files changed, 226 insertions(+), 43 deletions(-)
tools/include/uapi/linux/bpf.h +9 -1
index 8884072e1a46..04b26f59b413 100644
@@ -287,7 +287,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)
 
@@ -297,6 +297,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)
 
tools/lib/bpf/libbpf.c +0 -0
index 8f8f688f3e9b..969bc3d9f02c 100644

tools/lib/bpf/libbpf.c struct bpf_program { · line 144

Quoted 6 lines
tools/lib/bpf/libbpf.c +3 -0
@@ -139,6 +139,9 @@ struct bpf_program {
                enum {
                        RELO_LD64,
                        RELO_CALL,
+                       RELO_DATA,
+                       RELO_RODATA,
+                       RELO_BSS,

All three of those are essentially the same relocations, just applied against different ELF sections.
I think by having just single RELO_GLOBAL_DATA you can actually simplify a bunch of code below, please see corresponding comments.

tools/lib/bpf/libbpf.c struct bpf_program { · line 181

Quoted 10 lines
tools/lib/bpf/libbpf.c +2 -1
                } type;
                int insn_idx;
                union {
@@ -174,7 +177,10 @@ struct bpf_program {
 struct bpf_map {
        int fd;
        char *name;
-       size_t offset;
+       union {
+               __u32 global_type;

This could be an index into common maps array.

tools/lib/bpf/libbpf.c struct bpf_object { · line 204

Quoted 11 lines
tools/lib/bpf/libbpf.c +4 -0
+               size_t offset;
+       };
        int map_ifindex;
        int inner_map_fd;
        struct bpf_map_def def;
@@ -194,6 +200,8 @@ struct bpf_object {
        size_t nr_programs;
        struct bpf_map *maps;
        size_t nr_maps;
+       struct bpf_map *maps_global;
+       size_t nr_maps_global;

Global maps could be stored in maps, along other ones, so that we don't need to keep track of them separately.

Another inconvenience of having a separate array of global maps is that bpf_map__iter won't iterate them. I don't know if that's desirable behavior or not, but it probably would be nice to iterate over global ones as well?

Quoted 44 lines
tools/lib/bpf/libbpf.c +12 -0
        bool loaded;
        bool has_pseudo_calls;
@@ -209,6 +217,9 @@ struct bpf_object {
                Elf *elf;
                GElf_Ehdr ehdr;
                Elf_Data *symbols;
+               Elf_Data *global_data;
+               Elf_Data *global_rodata;
+               Elf_Data *global_bss;
                size_t strtabidx;
                struct {
                        GElf_Shdr shdr;
@@ -217,6 +228,9 @@ struct bpf_object {
                int nr_reloc;
                int maps_shndx;
                int text_shndx;
+               int data_shndx;
+               int rodata_shndx;
+               int bss_shndx;
        } efile;
        /*
         * All loaded bpf_object is linked in a list, which is
@@ -457,6 +471,9 @@ static struct bpf_object *bpf_object__new(const char *path,
        obj->efile.obj_buf = obj_buf;
        obj->efile.obj_buf_sz = obj_buf_sz;
        obj->efile.maps_shndx = -1;
+       obj->efile.data_shndx = -1;
+       obj->efile.rodata_shndx = -1;
+       obj->efile.bss_shndx = -1;
 
        obj->loaded = false;
 
@@ -475,6 +492,9 @@ static void bpf_object__elf_finish(struct bpf_object *obj)
                obj->efile.elf = NULL;
        }
        obj->efile.symbols = NULL;
+       obj->efile.global_data = NULL;
+       obj->efile.global_rodata = NULL;
+       obj->efile.global_bss = NULL;
 
        zfree(&obj->efile.reloc);
        obj->efile.nr_reloc = 0;

tools/lib/bpf/libbpf.c bpf_object__init_maps(struct bpf_object *obj, int flags) · line 785

Quoted 9 lines
tools/lib/bpf/libbpf.c +6 -0
@@ -757,6 +777,85 @@ bpf_object__init_maps(struct bpf_object *obj, int flags)
        return 0;
 }
 
+static int
+bpf_object__create_map(struct bpf_object *obj, struct bpf_map *map);
+
+static int
+bpf_object__init_global(struct bpf_object *obj, int i, int type,
+                       const char *name, Elf_Data *map_data)

Instead of deducing flags and looking up for map by index, you can just pass struct bpf_map * directly instead of int i and provide flags, instead of type.

Quoted 40 lines
tools/lib/bpf/libbpf.c +40 -0
+{
+       struct bpf_map *map = &obj->maps_global[i];
+       struct bpf_map_def *def = &map->def;
+       char *cp, errmsg[STRERR_BUFSIZE];
+       int err, slot0 = 0;
+
+       def->type = BPF_MAP_TYPE_ARRAY;
+       def->key_size = sizeof(int);
+       def->value_size = map_data->d_size;
+       def->max_entries = 1;
+       def->map_flags = type == RELO_RODATA ? BPF_F_RDONLY_PROG : 0;
+
+       map->name = strdup(name);
+       map->global_type = type;
+       map->fd = bpf_object__create_map(obj, map);
+       if (map->fd < 0) {
+               err = map->fd;
+               cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
+               pr_warning("failed to create map (name: '%s'): %s\n",
+                          map->name, cp);
+               goto destroy;
+       }
+
+       pr_debug("create map %s: fd=%d\n", map->name, map->fd);
+
+       if (type != RELO_BSS) {
+               err = bpf_map_update_elem(map->fd, &slot0, map_data->d_buf, 0);
+               if (err < 0) {
+                       cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
+                       pr_warning("failed to update map (name: '%s'): %s\n",
+                                  map->name, cp);
+                       goto destroy;
+               }
+
+               pr_debug("updated map %s with elf data: fd=%d\n", map->name,
+                        map->fd);
+       }
+       return 0;
+destroy:
+       for (i = 0; i < obj->nr_maps_global; i++)

tools/lib/bpf/libbpf.c bpf_object__init_maps(struct bpf_object *obj, int flags) · line 835

Quoted 10 lines
tools/lib/bpf/libbpf.c +10 -0
+               zclose(obj->maps_global[i].fd);
+       return err;
+}
+
+static int
+bpf_object__init_global_maps(struct bpf_object *obj)
+{
+       int nr_maps_global = (obj->efile.data_shndx >= 0) +
+                            (obj->efile.rodata_shndx >= 0) +
+                            (obj->efile.bss_shndx >= 0), i, err = 0;

This looks like a good candidate for separate static function? It can also be reused below to check if there is any global map present.

tools/lib/bpf/libbpf.c bpf_object__init_maps(struct bpf_object *obj, int flags) · line 838

Quoted 3 lines
tools/lib/bpf/libbpf.c +3 -0
+
+       obj->maps_global = calloc(nr_maps_global, sizeof(obj->maps_global[0]));
+       if (!obj->maps_global) {

If nr_maps_global is 0, calloc might or might not return NULL, so this check might erroneously return error.

Quoted 7 lines
tools/lib/bpf/libbpf.c +7 -0
+               pr_warning("alloc maps for object failed\n");
+               return -ENOMEM;
+       }
+
+       obj->nr_maps_global = nr_maps_global;
+       for (i = 0; i < obj->nr_maps_global; i++)
+               obj->maps[i].fd = -1;

tools/lib/bpf/libbpf.c bpf_object__init_maps(struct bpf_object *obj, int flags) · line 855

Quoted 10 lines
tools/lib/bpf/libbpf.c +10 -0
+       i = 0;
+       if (obj->efile.bss_shndx >= 0)
+               err = bpf_object__init_global(obj, i++, RELO_BSS, ".bss",
+                                             obj->efile.global_bss);
+       if (obj->efile.data_shndx >= 0 && !err)
+               err = bpf_object__init_global(obj, i++, RELO_DATA, ".data",
+                                             obj->efile.global_data);
+       if (obj->efile.rodata_shndx >= 0 && !err)
+               err = bpf_object__init_global(obj, i++, RELO_RODATA, ".rodata",
+                                             obj->efile.global_rodata);

Here we know exactly what type of map we are creating, so we can just directly pass all the required structs/flags/data.

Also, to speed up and simplify relocation processing below, I think it's better to store map indexes for each of available .bss, .data and .rodata maps, eliminating another need for having three different types of data relocations.

Quoted 7 lines
tools/lib/bpf/libbpf.c +3 -0
+       return err;
+}
+
 static bool section_have_execinstr(struct bpf_object *obj, int idx)
 {
        Elf_Scn *scn;

tools/lib/bpf/libbpf.c static int bpf_object__elf_collect(struct bpf_object *obj, int flags) · line 973

Quoted 10 lines
tools/lib/bpf/libbpf.c +6 -0
@@ -865,6 +964,12 @@ static int bpf_object__elf_collect(struct bpf_object *obj, int flags)
                                        pr_warning("failed to alloc program %s (%s): %s",
                                                   name, obj->path, cp);
                                }
+                       } else if (strcmp(name, ".data") == 0) {
+                               obj->efile.global_data = data;
+                               obj->efile.data_shndx = idx;
+                       } else if (strcmp(name, ".rodata") == 0) {
+                               obj->efile.global_rodata = data;
+                               obj->efile.rodata_shndx = idx;
                        }

Previously if we encountered unknown PROGBITS section, we'd emit debug message about skipping section, should we add that message here?

Quoted 66 lines
tools/lib/bpf/libbpf.c +30 -2
                } else if (sh.sh_type == SHT_REL) {
                        void *reloc = obj->efile.reloc;
@@ -892,6 +997,9 @@ static int bpf_object__elf_collect(struct bpf_object *obj, int flags)
                                obj->efile.reloc[n].shdr = sh;
                                obj->efile.reloc[n].data = data;
                        }
+               } else if (sh.sh_type == SHT_NOBITS && strcmp(name, ".bss") == 0) {
+                       obj->efile.global_bss = data;
+                       obj->efile.bss_shndx = idx;
                } else {
                        pr_debug("skip section(%d) %s\n", idx, name);
                }
@@ -923,6 +1031,14 @@ static int bpf_object__elf_collect(struct bpf_object *obj, int flags)
                if (err)
                        goto out;
        }
+       if (obj->efile.data_shndx >= 0 ||
+           obj->efile.rodata_shndx >= 0 ||
+           obj->efile.bss_shndx >= 0) {
+               err = bpf_object__init_global_maps(obj);
+               if (err)
+                       goto out;
+       }
+
        err = bpf_object__init_prog_names(obj);
 out:
        return err;
@@ -961,6 +1077,11 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
        Elf_Data *symbols = obj->efile.symbols;
        int text_shndx = obj->efile.text_shndx;
        int maps_shndx = obj->efile.maps_shndx;
+       int data_shndx = obj->efile.data_shndx;
+       int rodata_shndx = obj->efile.rodata_shndx;
+       int bss_shndx = obj->efile.bss_shndx;
+       struct bpf_map *maps_global = obj->maps_global;
+       size_t nr_maps_global = obj->nr_maps_global;
        struct bpf_map *maps = obj->maps;
        size_t nr_maps = obj->nr_maps;
        int i, nrels;
@@ -999,8 +1120,10 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
                         (long long) (rel.r_info >> 32),
                         (long long) sym.st_value, sym.st_name);
 
-               if (sym.st_shndx != maps_shndx && sym.st_shndx != text_shndx) {
-                       pr_warning("Program '%s' contains non-map related relo data pointing to section %u\n",
+               if (sym.st_shndx != maps_shndx && sym.st_shndx != text_shndx &&
+                   sym.st_shndx != data_shndx && sym.st_shndx != rodata_shndx &&
+                   sym.st_shndx != bss_shndx) {
+                       pr_warning("Program '%s' contains unrecognized relo data pointing to section %u\n",
                                   prog->section_name, sym.st_shndx);
                        return -LIBBPF_ERRNO__RELOC;
                }
@@ -1045,6 +1168,30 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
                        prog->reloc_desc[i].type = RELO_LD64;
                        prog->reloc_desc[i].insn_idx = insn_idx;
                        prog->reloc_desc[i].map_idx = map_idx;
+               } else if (sym.st_shndx == data_shndx ||
+                          sym.st_shndx == rodata_shndx ||
+                          sym.st_shndx == bss_shndx) {
+                       int type = (sym.st_shndx == data_shndx)   ? RELO_DATA :
+                                  (sym.st_shndx == rodata_shndx) ? RELO_RODATA :
+                                                                   RELO_BSS;
+
+                       for (map_idx = 0; map_idx < nr_maps_global; map_idx++) {
+                               if (maps_global[map_idx].global_type == type) {
+                                       pr_debug("relocation: find map %zd (%s) for insn %u\n",

tools/lib/bpf/libbpf.c bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr, · line 1190

Quoted 10 lines
tools/lib/bpf/libbpf.c +10 -0
+                                                map_idx, maps_global[map_idx].name, insn_idx);
+                                       break;
+                               }
+                       }
+
+                       if (map_idx >= nr_maps_global) {
+                               pr_warning("bpf relocation: map_idx %d large than %d\n",
+                                          (int)map_idx, (int)nr_maps_global - 1);
+                               return -LIBBPF_ERRNO__RELOC;
+                       }

We don't need to handle all of this if we just remember global map indicies during creation, instead of calculating type, we can just pick correct index (and check it exists). And type can be just generic RELO_DATA.

Quoted 163 lines
tools/lib/bpf/libbpf.c +71 -40
+
+                       prog->reloc_desc[i].type = type;
+                       prog->reloc_desc[i].insn_idx = insn_idx;
+                       prog->reloc_desc[i].map_idx = map_idx;
                }
        }
        return 0;
@@ -1176,15 +1323,58 @@ bpf_object__probe_caps(struct bpf_object *obj)
 }
 
 static int
-bpf_object__create_maps(struct bpf_object *obj)
+bpf_object__create_map(struct bpf_object *obj, struct bpf_map *map)
 {
        struct bpf_create_map_attr create_attr = {};
+       struct bpf_map_def *def = &map->def;
+       char *cp, errmsg[STRERR_BUFSIZE];
+       int fd;
+
+       if (obj->caps.name)
+               create_attr.name = map->name;
+       create_attr.map_ifindex = map->map_ifindex;
+       create_attr.map_type = def->type;
+       create_attr.map_flags = def->map_flags;
+       create_attr.key_size = def->key_size;
+       create_attr.value_size = def->value_size;
+       create_attr.max_entries = def->max_entries;
+       create_attr.btf_fd = 0;
+       create_attr.btf_key_type_id = 0;
+       create_attr.btf_value_type_id = 0;
+       if (bpf_map_type__is_map_in_map(def->type) &&
+           map->inner_map_fd >= 0)
+               create_attr.inner_map_fd = map->inner_map_fd;
+       if (obj->btf && !bpf_map_find_btf_info(map, obj->btf)) {
+               create_attr.btf_fd = btf__fd(obj->btf);
+               create_attr.btf_key_type_id = map->btf_key_type_id;
+               create_attr.btf_value_type_id = map->btf_value_type_id;
+       }
+
+       fd = bpf_create_map_xattr(&create_attr);
+       if (fd < 0 && create_attr.btf_key_type_id) {
+               cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
+               pr_warning("Error in bpf_create_map_xattr(%s):%s(%d). Retrying without BTF.\n",
+                          map->name, cp, errno);
+
+               create_attr.btf_fd = 0;
+               create_attr.btf_key_type_id = 0;
+               create_attr.btf_value_type_id = 0;
+               map->btf_key_type_id = 0;
+               map->btf_value_type_id = 0;
+               fd = bpf_create_map_xattr(&create_attr);
+       }
+
+       return fd;
+}
+
+static int
+bpf_object__create_maps(struct bpf_object *obj)
+{
        unsigned int i;
        int err;
 
        for (i = 0; i < obj->nr_maps; i++) {
                struct bpf_map *map = &obj->maps[i];
-               struct bpf_map_def *def = &map->def;
                char *cp, errmsg[STRERR_BUFSIZE];
                int *pfd = &map->fd;
 
@@ -1193,41 +1383,7 @@ bpf_object__create_maps(struct bpf_object *obj)
                                 map->name, map->fd);
                        continue;
                }
-
-               if (obj->caps.name)
-                       create_attr.name = map->name;
-               create_attr.map_ifindex = map->map_ifindex;
-               create_attr.map_type = def->type;
-               create_attr.map_flags = def->map_flags;
-               create_attr.key_size = def->key_size;
-               create_attr.value_size = def->value_size;
-               create_attr.max_entries = def->max_entries;
-               create_attr.btf_fd = 0;
-               create_attr.btf_key_type_id = 0;
-               create_attr.btf_value_type_id = 0;
-               if (bpf_map_type__is_map_in_map(def->type) &&
-                   map->inner_map_fd >= 0)
-                       create_attr.inner_map_fd = map->inner_map_fd;
-
-               if (obj->btf && !bpf_map_find_btf_info(map, obj->btf)) {
-                       create_attr.btf_fd = btf__fd(obj->btf);
-                       create_attr.btf_key_type_id = map->btf_key_type_id;
-                       create_attr.btf_value_type_id = map->btf_value_type_id;
-               }
-
-               *pfd = bpf_create_map_xattr(&create_attr);
-               if (*pfd < 0 && create_attr.btf_key_type_id) {
-                       cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
-                       pr_warning("Error in bpf_create_map_xattr(%s):%s(%d). Retrying without BTF.\n",
-                                  map->name, cp, errno);
-                       create_attr.btf_fd = 0;
-                       create_attr.btf_key_type_id = 0;
-                       create_attr.btf_value_type_id = 0;
-                       map->btf_key_type_id = 0;
-                       map->btf_value_type_id = 0;
-                       *pfd = bpf_create_map_xattr(&create_attr);
-               }
-
+               *pfd = bpf_object__create_map(obj, map);
                if (*pfd < 0) {
                        size_t j;
 
@@ -1412,6 +1568,24 @@ bpf_program__relocate(struct bpf_program *prog, struct bpf_object *obj)
                                                      &prog->reloc_desc[i]);
                        if (err)
                                return err;
+               } else if (prog->reloc_desc[i].type == RELO_DATA ||
+                          prog->reloc_desc[i].type == RELO_RODATA ||
+                          prog->reloc_desc[i].type == RELO_BSS) {
+                       struct bpf_insn *insns = prog->insns;
+                       int insn_idx, map_idx, data_off;
+
+                       insn_idx = prog->reloc_desc[i].insn_idx;
+                       map_idx  = prog->reloc_desc[i].map_idx;
+                       data_off = insns[insn_idx].imm;
+
+                       if (insn_idx + 1 >= (int)prog->insns_cnt) {
+                               pr_warning("relocation out of range: '%s'\n",
+                                          prog->section_name);
+                               return -LIBBPF_ERRNO__RELOC;
+                       }
+                       insns[insn_idx].src_reg = BPF_PSEUDO_MAP_VALUE;
+                       insns[insn_idx].imm = obj->maps_global[map_idx].fd;
+                       insns[insn_idx + 1].imm = data_off;
                }
        }
 
@@ -1717,6 +1891,7 @@ __bpf_object__open(const char *path, void *obj_buf, size_t obj_buf_sz,
 
        CHECK_ERR(bpf_object__elf_init(obj), err, out);
        CHECK_ERR(bpf_object__check_endianness(obj), err, out);
+       CHECK_ERR(bpf_object__probe_caps(obj), err, out);
        CHECK_ERR(bpf_object__elf_collect(obj, flags), err, out);
        CHECK_ERR(bpf_object__collect_reloc(obj), err, out);
        CHECK_ERR(bpf_object__validate(obj, needs_kver), err, out);
@@ -1789,7 +1964,8 @@ int bpf_object__unload(struct bpf_object *obj)
 
        for (i = 0; i < obj->nr_maps; i++)
                zclose(obj->maps[i].fd);
-
+       for (i = 0; i < obj->nr_maps_global; i++)
+               zclose(obj->maps_global[i].fd);
        for (i = 0; i < obj->nr_programs; i++)
                bpf_program__unload(&obj->programs[i]);
 
@@ -1810,7 +1986,6 @@ int bpf_object__load(struct bpf_object *obj)
 
        obj->loaded = true;
 
-       CHECK_ERR(bpf_object__probe_caps(obj), err, out);
        CHECK_ERR(bpf_object__create_maps(obj), err, out);
        CHECK_ERR(bpf_object__relocate(obj), err, out);
        CHECK_ERR(bpf_object__load_progs(obj), err, out);
--
Quoted 2 lines

2.17.1

I'm sorry if I seem a bit too obsessed with those three new relocation types. I just believe that having one generic and storing global maps along with other maps is cleaner and more uniform.

author maintainer
#28 lore raw

Re: [PATCH bpf-next v2 5/7] bpf, libbpf: support global data/bss/rodata sections

Quoted 22 lines · Andrii Nakryiko
Quoted 21 lines · Daniel Borkmann

This work adds BPF loader support for global data sections to libbpf. This allows to write BPF programs in more natural C-like way by being able to define global variables and const data.

Back at LPC 2018 [0] we presented a first prototype which implemented support for global data sections by extending BPF syscall where union bpf_attr would get additional memory/size pair for each section passed during prog load in order to later add this base address into the ldimm64 instruction along with the user provided offset when accessing a variable. Consensus from LPC was that for proper upstream support, it would be more desirable to use maps instead of bpf_attr extension as this would allow for introspection of these sections as well as potential life updates of their content. This work follows this path by taking the following steps from loader side:

1) In bpf_object__elf_collect() step we pick up ".data", ".rodata", and ".bss" section information.

Quoted 7 lines
Quoted 2 lines

2) If present, in bpf_object__init_global_maps() we create a map that corresponds to each of the present sections.

Is there any point in having .data and .bss in separate maps? I can only see for reasons of inspectiion from bpftool, but other than that isn't .bss just an optimization over .data to save space in ELF file, but in other regards is just another part of r/w .data section?

Hmm, I actually don't mind too much combining both of them. Had the same thought with regards to introspection from bpftool which was why I separated them. But combining the two into a single map is fine actually, saves a bit of resources in kernel, and offsets can easily be fixed up from libbpf side. Will do for v3.

Quoted 11 lines
Quoted 10 lines

Given section size and access properties can differ, a single entry array map is created with value size that is corresponding to the ELF section size of .data, .bss or .rodata. In the latter case, the map is created as read-only from program side such that verifier rejects any write attempts into .rodata. In a subsequent step, for .data and .rodata sections, the section content is copied into the map through bpf_map_update_elem(). For .bss this is not necessary since array map is already zero-initialized by default.

Quoted 2 lines

For .rodata, ideally it would be nice to make it RDONLY from userland as well, except for first UPDATE. How hard is it to support that?

Right now the BPF_F_RDONLY, BPF_F_WRONLY semantics to make the maps read-only or write-only from syscall side are that these permissions are stored into the struct file front end (file->f_mode) for the anon inode we use, meaning it's separated from the actual BPF map, so you can create the map with BPF_F_RDONLY, but root user can do BPF_MAP_GET_FD_BY_ID without the BPF_F_RDONLY and again write into it. This design choice would require that we'd need to add some additional infrastructure on top of this, which would then need to enforce file->f_mode to read-only after the first setup. I think there's simple trick we can apply to make it read-only after setup from syscall side: we'll add a new flag to the map, and then upon map creation libbpf sets everything up, holds the id, closes its fd, and refetches the fd by id. From that point onwards any interface where you would get the fd from the map in user space will enforce BPF_F_RDONLY behavior for file->f_mode. Another, less hacky option could be to extend the struct file ops we currently use for BPF maps and set a map 'immutable' flag from there which is then enforced once all pending operations have completed. I can look a bit into this.

Quoted 153 lines
Quoted 103 lines

3) In bpf_program__collect_reloc() step, we record the corresponding map, insn index, and relocation type for the global data.

4) And last but not least in the actual relocation step in bpf_program__relocate(), we mark the ldimm64 instruction with src_reg = BPF_PSEUDO_MAP_VALUE where in the first imm field the map's file descriptor is stored as similarly done as in BPF_PSEUDO_MAP_FD, and in the second imm field (as ldimm64 is 2-insn wide) we store the access offset into the section.

5) On kernel side, this special marked BPF_PSEUDO_MAP_VALUE load will then store the actual target address in order to have a 'map-lookup'-free access. That is, the actual map value base address + offset. The destination register in the verifier will then be marked as PTR_TO_MAP_VALUE, containing the fixed offset as reg->off and backing BPF map as reg->map_ptr. Meaning, it's treated as any other normal map value from verification side, only with efficient, direct value access instead of actual call to map lookup helper as in the typical case.

Simple example dump of program using globals vars in each section:

  # readelf -a test_global_data.o
  [...]
  [ 6] .bss              NOBITS           0000000000000000  00000328
       0000000000000010  0000000000000000  WA       0     0     8
  [ 7] .data             PROGBITS         0000000000000000  00000328
       0000000000000010  0000000000000000  WA       0     0     8
  [ 8] .rodata           PROGBITS         0000000000000000  00000338
       0000000000000018  0000000000000000   A       0     0     8
  [...]
    95: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    6 static_bss
    96: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    6 static_bss2
    97: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    7 static_data
    98: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    7 static_data2
    99: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    8 static_rodata
   100: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    8 static_rodata2
   101: 0000000000000010     8 OBJECT  LOCAL  DEFAULT    8 static_rodata3
  [...]
  # bpftool prog
  103: sched_cls  name load_static_dat  tag 37a8b6822fc39a29  gpl
       loaded_at 2019-02-28T02:02:35+0000  uid 0
       xlated 712B  jited 426B  memlock 4096B  map_ids 63,64,65,66
  # bpftool map show id 63
  63: array  name .bss  flags 0x0                      <-- .bss area, rw
      key 4B  value 16B  max_entries 1  memlock 4096B
  # bpftool map show id 64
  64: array  name .data  flags 0x0                     <-- .data area, rw
      key 4B  value 16B  max_entries 1  memlock 4096B
  # bpftool map show id 65
  65: array  name .rodata  flags 0x80                  <-- .rodata area, ro
      key 4B  value 24B  max_entries 1  memlock 4096B
  # bpftool prog dump xlated id 103
  int load_static_data(struct __sk_buff * skb):
  ; int load_static_data(struct __sk_buff *skb)
     0: (b7) r1 = 0
  ; key = 0;
     1: (63) *(u32 *)(r10 -4) = r1
     2: (bf) r6 = r10
  ; int load_static_data(struct __sk_buff *skb)
     3: (07) r6 += -4
  ; bpf_map_update_elem(&result, &key, &static_bss, 0);
     4: (18) r1 = map[id:66]
     6: (bf) r2 = r6
     7: (18) r3 = map[id:63][0]+0         <-- direct static_bss addr in .bss area
     9: (b7) r4 = 0
    10: (85) call array_map_update_elem#99888
    11: (b7) r1 = 1
  ; key = 1;
    12: (63) *(u32 *)(r10 -4) = r1
  ; bpf_map_update_elem(&result, &key, &static_data, 0);
    13: (18) r1 = map[id:66]
    15: (bf) r2 = r6
    16: (18) r3 = map[id:64][0]+0         <-- direct static_data addr in .data area
    18: (b7) r4 = 0
    19: (85) call array_map_update_elem#99888
    20: (b7) r1 = 2
  ; key = 2;
    21: (63) *(u32 *)(r10 -4) = r1
  ; bpf_map_update_elem(&result, &key, &static_rodata, 0);
    22: (18) r1 = map[id:66]
    24: (bf) r2 = r6
    25: (18) r3 = map[id:65][0]+0         <-- direct static_rodata addr in .rodata area
    27: (b7) r4 = 0
    28: (85) call array_map_update_elem#99888
    29: (b7) r1 = 3
  ; key = 3;
    30: (63) *(u32 *)(r10 -4) = r1
  ; bpf_map_update_elem(&result, &key, &static_bss2, 0);
    31: (18) r7 = map[id:63][0]+8         <--.
    33: (18) r1 = map[id:66]                 |
    35: (bf) r2 = r6                         |
    36: (18) r3 = map[id:63][0]+8         <-- direct static_bss2 addr in .bss area
    38: (b7) r4 = 0
    39: (85) call array_map_update_elem#99888
  [...]
Quoted 2 lines

For now .data/.rodata/.bss maps are not exposed via API to the user, but this could be done in a subsequent step.

See comment about BPF_MAP_TYPE_HEAP/BLOB map in comments to patch #1, it would probably make more useful API for .data/.rodata/.bss.

Quoted 44 lines

Based upon recent fix in LLVM, commit c0db6b6bd444 ("[BPF] Don't fail for static variables").

Joint work with Joe Stringer.

[0] LPC 2018, BPF track, "ELF relocation for static data in BPF",

      http://vger.kernel.org/lpc-bpf2018.html#session-3
---
 tools/include/uapi/linux/bpf.h |  10 +-
 tools/lib/bpf/libbpf.c         | 259 +++++++++++++++++++++++++++------
 2 files changed, 226 insertions(+), 43 deletions(-)
tools/include/uapi/linux/bpf.h +9 -1
index 8884072e1a46..04b26f59b413 100644
@@ -287,7 +287,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)
 
@@ -297,6 +297,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)
 
Quoted 16 lines

tools/lib/bpf/libbpf.c struct bpf_program { · line 144

Quoted 11 lines
tools/lib/bpf/libbpf.c +3 -0
index 8f8f688f3e9b..969bc3d9f02c 100644
@@ -139,6 +139,9 @@ struct bpf_program {
                enum {
                        RELO_LD64,
                        RELO_CALL,
+                       RELO_DATA,
+                       RELO_RODATA,
+                       RELO_BSS,

All three of those are essentially the same relocations, just applied against different ELF sections.
I think by having just single RELO_GLOBAL_DATA you can actually simplify a bunch of code below, please see corresponding comments.

Ok, sounds like a reasonable simplification, will do all well for v3.

Quoted 28 lines

tools/lib/bpf/libbpf.c struct bpf_program { · line 181

Quoted 10 lines
tools/lib/bpf/libbpf.c +2 -1
                } type;
                int insn_idx;
                union {
@@ -174,7 +177,10 @@ struct bpf_program {
 struct bpf_map {
        int fd;
        char *name;
-       size_t offset;
+       union {
+               __u32 global_type;

This could be an index into common maps array.

tools/lib/bpf/libbpf.c struct bpf_object { · line 204

Quoted 11 lines
tools/lib/bpf/libbpf.c +4 -0
+               size_t offset;
+       };
        int map_ifindex;
        int inner_map_fd;
        struct bpf_map_def def;
@@ -194,6 +200,8 @@ struct bpf_object {
        size_t nr_programs;
        struct bpf_map *maps;
        size_t nr_maps;
+       struct bpf_map *maps_global;
+       size_t nr_maps_global;

Global maps could be stored in maps, along other ones, so that we don't need to keep track of them separately.

Quoted 4 lines

Another inconvenience of having a separate array of global maps is that bpf_map__iter won't iterate them. I don't know if that's desirable behavior or not, but it probably would be nice to iterate over global ones as well?

My thinking was that these maps are not explicitly user specified, so libbpf API would expose them through a different interface than the one we have today in order to not confuse or break application behavior which would otherwise rely on iterating / processing over them. Separate API would retain current behavior and definitely make this unambiguous to apps with regards to what to expect from each of such API call.

Quoted 46 lines
Quoted 46 lines
tools/lib/bpf/libbpf.c +12 -0
        bool loaded;
        bool has_pseudo_calls;
@@ -209,6 +217,9 @@ struct bpf_object {
                Elf *elf;
                GElf_Ehdr ehdr;
                Elf_Data *symbols;
+               Elf_Data *global_data;
+               Elf_Data *global_rodata;
+               Elf_Data *global_bss;
                size_t strtabidx;
                struct {
                        GElf_Shdr shdr;
@@ -217,6 +228,9 @@ struct bpf_object {
                int nr_reloc;
                int maps_shndx;
                int text_shndx;
+               int data_shndx;
+               int rodata_shndx;
+               int bss_shndx;
        } efile;
        /*
         * All loaded bpf_object is linked in a list, which is
@@ -457,6 +471,9 @@ static struct bpf_object *bpf_object__new(const char *path,
        obj->efile.obj_buf = obj_buf;
        obj->efile.obj_buf_sz = obj_buf_sz;
        obj->efile.maps_shndx = -1;
+       obj->efile.data_shndx = -1;
+       obj->efile.rodata_shndx = -1;
+       obj->efile.bss_shndx = -1;
 
        obj->loaded = false;
 
@@ -475,6 +492,9 @@ static void bpf_object__elf_finish(struct bpf_object *obj)
                obj->efile.elf = NULL;
        }
        obj->efile.symbols = NULL;
+       obj->efile.global_data = NULL;
+       obj->efile.global_rodata = NULL;
+       obj->efile.global_bss = NULL;
 
        zfree(&obj->efile.reloc);
        obj->efile.nr_reloc = 0;
@@ -757,6 +777,85 @@ bpf_object__init_maps(struct bpf_object *obj, int flags)
        return 0;
 }
 
Quoted 10 lines

tools/lib/bpf/libbpf.c bpf_object__init_maps(struct bpf_object *obj, int flags) · line 785

Quoted 6 lines
tools/lib/bpf/libbpf.c +6 -0
+static int
+bpf_object__create_map(struct bpf_object *obj, struct bpf_map *map);
+
+static int
+bpf_object__init_global(struct bpf_object *obj, int i, int type,
+                       const char *name, Elf_Data *map_data)

Instead of deducing flags and looking up for map by index, you can just pass struct bpf_map * directly instead of int i and provide flags, instead of type.

Yep, agree.

Quoted 45 lines
Quoted 45 lines
tools/lib/bpf/libbpf.c +45 -0
+{
+       struct bpf_map *map = &obj->maps_global[i];
+       struct bpf_map_def *def = &map->def;
+       char *cp, errmsg[STRERR_BUFSIZE];
+       int err, slot0 = 0;
+
+       def->type = BPF_MAP_TYPE_ARRAY;
+       def->key_size = sizeof(int);
+       def->value_size = map_data->d_size;
+       def->max_entries = 1;
+       def->map_flags = type == RELO_RODATA ? BPF_F_RDONLY_PROG : 0;
+
+       map->name = strdup(name);
+       map->global_type = type;
+       map->fd = bpf_object__create_map(obj, map);
+       if (map->fd < 0) {
+               err = map->fd;
+               cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
+               pr_warning("failed to create map (name: '%s'): %s\n",
+                          map->name, cp);
+               goto destroy;
+       }
+
+       pr_debug("create map %s: fd=%d\n", map->name, map->fd);
+
+       if (type != RELO_BSS) {
+               err = bpf_map_update_elem(map->fd, &slot0, map_data->d_buf, 0);
+               if (err < 0) {
+                       cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
+                       pr_warning("failed to update map (name: '%s'): %s\n",
+                                  map->name, cp);
+                       goto destroy;
+               }
+
+               pr_debug("updated map %s with elf data: fd=%d\n", map->name,
+                        map->fd);
+       }
+       return 0;
+destroy:
+       for (i = 0; i < obj->nr_maps_global; i++)
+               zclose(obj->maps_global[i].fd);
+       return err;
+}
+
+static int
Quoted 8 lines

tools/lib/bpf/libbpf.c bpf_object__init_maps(struct bpf_object *obj, int flags) · line 835

Quoted 5 lines
tools/lib/bpf/libbpf.c +5 -0
+bpf_object__init_global_maps(struct bpf_object *obj)
+{
+       int nr_maps_global = (obj->efile.data_shndx >= 0) +
+                            (obj->efile.rodata_shndx >= 0) +
+                            (obj->efile.bss_shndx >= 0), i, err = 0;

This looks like a good candidate for separate static function? It can also be reused below to check if there is any global map present.

Sounds good.

Quoted 6 lines

tools/lib/bpf/libbpf.c bpf_object__init_maps(struct bpf_object *obj, int flags) · line 838

Quoted 3 lines
tools/lib/bpf/libbpf.c +3 -0
+
+       obj->maps_global = calloc(nr_maps_global, sizeof(obj->maps_global[0]));
+       if (!obj->maps_global) {

If nr_maps_global is 0, calloc might or might not return NULL, so this check might erroneously return error.

Good point, just read it up as well from man page, will fix.

Quoted 18 lines
Quoted 7 lines
tools/lib/bpf/libbpf.c +7 -0
+               pr_warning("alloc maps for object failed\n");
+               return -ENOMEM;
+       }
+
+       obj->nr_maps_global = nr_maps_global;
+       for (i = 0; i < obj->nr_maps_global; i++)
+               obj->maps[i].fd = -1;

tools/lib/bpf/libbpf.c bpf_object__init_maps(struct bpf_object *obj, int flags) · line 855

Quoted 10 lines
tools/lib/bpf/libbpf.c +10 -0
+       i = 0;
+       if (obj->efile.bss_shndx >= 0)
+               err = bpf_object__init_global(obj, i++, RELO_BSS, ".bss",
+                                             obj->efile.global_bss);
+       if (obj->efile.data_shndx >= 0 && !err)
+               err = bpf_object__init_global(obj, i++, RELO_DATA, ".data",
+                                             obj->efile.global_data);
+       if (obj->efile.rodata_shndx >= 0 && !err)
+               err = bpf_object__init_global(obj, i++, RELO_RODATA, ".rodata",
+                                             obj->efile.global_rodata);
Quoted 7 lines

Here we know exactly what type of map we are creating, so we can just directly pass all the required structs/flags/data.

Also, to speed up and simplify relocation processing below, I think it's better to store map indexes for each of available .bss, .data and .rodata maps, eliminating another need for having three different types of data relocations.

Yep, I'll clean this up.

Quoted 12 lines
Quoted 12 lines
tools/lib/bpf/libbpf.c +5 -0
+       return err;
+}
+
 static bool section_have_execinstr(struct bpf_object *obj, int idx)
 {
        Elf_Scn *scn;
@@ -865,6 +964,12 @@ static int bpf_object__elf_collect(struct bpf_object *obj, int flags)
                                        pr_warning("failed to alloc program %s (%s): %s",
                                                   name, obj->path, cp);
                                }
+                       } else if (strcmp(name, ".data") == 0) {
+                               obj->efile.global_data = data;
Quoted 8 lines

tools/lib/bpf/libbpf.c static int bpf_object__elf_collect(struct bpf_object *obj, int flags) · line 973

Quoted 5 lines
tools/lib/bpf/libbpf.c +4 -0
+                               obj->efile.data_shndx = idx;
+                       } else if (strcmp(name, ".rodata") == 0) {
+                               obj->efile.global_rodata = data;
+                               obj->efile.rodata_shndx = idx;
                        }

Previously if we encountered unknown PROGBITS section, we'd emit debug message about skipping section, should we add that message here?

Sounds reasonable, I'll add a similar 'skip section' debug output there.

Quoted 240 lines
Quoted 66 lines
tools/lib/bpf/libbpf.c +30 -2
                } else if (sh.sh_type == SHT_REL) {
                        void *reloc = obj->efile.reloc;
@@ -892,6 +997,9 @@ static int bpf_object__elf_collect(struct bpf_object *obj, int flags)
                                obj->efile.reloc[n].shdr = sh;
                                obj->efile.reloc[n].data = data;
                        }
+               } else if (sh.sh_type == SHT_NOBITS && strcmp(name, ".bss") == 0) {
+                       obj->efile.global_bss = data;
+                       obj->efile.bss_shndx = idx;
                } else {
                        pr_debug("skip section(%d) %s\n", idx, name);
                }
@@ -923,6 +1031,14 @@ static int bpf_object__elf_collect(struct bpf_object *obj, int flags)
                if (err)
                        goto out;
        }
+       if (obj->efile.data_shndx >= 0 ||
+           obj->efile.rodata_shndx >= 0 ||
+           obj->efile.bss_shndx >= 0) {
+               err = bpf_object__init_global_maps(obj);
+               if (err)
+                       goto out;
+       }
+
        err = bpf_object__init_prog_names(obj);
 out:
        return err;
@@ -961,6 +1077,11 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
        Elf_Data *symbols = obj->efile.symbols;
        int text_shndx = obj->efile.text_shndx;
        int maps_shndx = obj->efile.maps_shndx;
+       int data_shndx = obj->efile.data_shndx;
+       int rodata_shndx = obj->efile.rodata_shndx;
+       int bss_shndx = obj->efile.bss_shndx;
+       struct bpf_map *maps_global = obj->maps_global;
+       size_t nr_maps_global = obj->nr_maps_global;
        struct bpf_map *maps = obj->maps;
        size_t nr_maps = obj->nr_maps;
        int i, nrels;
@@ -999,8 +1120,10 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
                         (long long) (rel.r_info >> 32),
                         (long long) sym.st_value, sym.st_name);
 
-               if (sym.st_shndx != maps_shndx && sym.st_shndx != text_shndx) {
-                       pr_warning("Program '%s' contains non-map related relo data pointing to section %u\n",
+               if (sym.st_shndx != maps_shndx && sym.st_shndx != text_shndx &&
+                   sym.st_shndx != data_shndx && sym.st_shndx != rodata_shndx &&
+                   sym.st_shndx != bss_shndx) {
+                       pr_warning("Program '%s' contains unrecognized relo data pointing to section %u\n",
                                   prog->section_name, sym.st_shndx);
                        return -LIBBPF_ERRNO__RELOC;
                }
@@ -1045,6 +1168,30 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
                        prog->reloc_desc[i].type = RELO_LD64;
                        prog->reloc_desc[i].insn_idx = insn_idx;
                        prog->reloc_desc[i].map_idx = map_idx;
+               } else if (sym.st_shndx == data_shndx ||
+                          sym.st_shndx == rodata_shndx ||
+                          sym.st_shndx == bss_shndx) {
+                       int type = (sym.st_shndx == data_shndx)   ? RELO_DATA :
+                                  (sym.st_shndx == rodata_shndx) ? RELO_RODATA :
+                                                                   RELO_BSS;
+
+                       for (map_idx = 0; map_idx < nr_maps_global; map_idx++) {
+                               if (maps_global[map_idx].global_type == type) {
+                                       pr_debug("relocation: find map %zd (%s) for insn %u\n",

tools/lib/bpf/libbpf.c bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr, · line 1190

Quoted 10 lines
tools/lib/bpf/libbpf.c +10 -0
+                                                map_idx, maps_global[map_idx].name, insn_idx);
+                                       break;
+                               }
+                       }
+
+                       if (map_idx >= nr_maps_global) {
+                               pr_warning("bpf relocation: map_idx %d large than %d\n",
+                                          (int)map_idx, (int)nr_maps_global - 1);
+                               return -LIBBPF_ERRNO__RELOC;
+                       }

We don't need to handle all of this if we just remember global map indicies during creation, instead of calculating type, we can just pick correct index (and check it exists). And type can be just generic RELO_DATA.

Quoted 158 lines
tools/lib/bpf/libbpf.c +71 -38
+
+                       prog->reloc_desc[i].type = type;
+                       prog->reloc_desc[i].insn_idx = insn_idx;
+                       prog->reloc_desc[i].map_idx = map_idx;
                }
        }
        return 0;
@@ -1176,15 +1323,58 @@ bpf_object__probe_caps(struct bpf_object *obj)
 }
 
 static int
-bpf_object__create_maps(struct bpf_object *obj)
+bpf_object__create_map(struct bpf_object *obj, struct bpf_map *map)
 {
        struct bpf_create_map_attr create_attr = {};
+       struct bpf_map_def *def = &map->def;
+       char *cp, errmsg[STRERR_BUFSIZE];
+       int fd;
+
+       if (obj->caps.name)
+               create_attr.name = map->name;
+       create_attr.map_ifindex = map->map_ifindex;
+       create_attr.map_type = def->type;
+       create_attr.map_flags = def->map_flags;
+       create_attr.key_size = def->key_size;
+       create_attr.value_size = def->value_size;
+       create_attr.max_entries = def->max_entries;
+       create_attr.btf_fd = 0;
+       create_attr.btf_key_type_id = 0;
+       create_attr.btf_value_type_id = 0;
+       if (bpf_map_type__is_map_in_map(def->type) &&
+           map->inner_map_fd >= 0)
+               create_attr.inner_map_fd = map->inner_map_fd;
+       if (obj->btf && !bpf_map_find_btf_info(map, obj->btf)) {
+               create_attr.btf_fd = btf__fd(obj->btf);
+               create_attr.btf_key_type_id = map->btf_key_type_id;
+               create_attr.btf_value_type_id = map->btf_value_type_id;
+       }
+
+       fd = bpf_create_map_xattr(&create_attr);
+       if (fd < 0 && create_attr.btf_key_type_id) {
+               cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
+               pr_warning("Error in bpf_create_map_xattr(%s):%s(%d). Retrying without BTF.\n",
+                          map->name, cp, errno);
+
+               create_attr.btf_fd = 0;
+               create_attr.btf_key_type_id = 0;
+               create_attr.btf_value_type_id = 0;
+               map->btf_key_type_id = 0;
+               map->btf_value_type_id = 0;
+               fd = bpf_create_map_xattr(&create_attr);
+       }
+
+       return fd;
+}
+
+static int
+bpf_object__create_maps(struct bpf_object *obj)
+{
        unsigned int i;
        int err;
 
        for (i = 0; i < obj->nr_maps; i++) {
                struct bpf_map *map = &obj->maps[i];
-               struct bpf_map_def *def = &map->def;
                char *cp, errmsg[STRERR_BUFSIZE];
                int *pfd = &map->fd;
 
@@ -1193,41 +1383,7 @@ bpf_object__create_maps(struct bpf_object *obj)
                                 map->name, map->fd);
                        continue;
                }
-
-               if (obj->caps.name)
-                       create_attr.name = map->name;
-               create_attr.map_ifindex = map->map_ifindex;
-               create_attr.map_type = def->type;
-               create_attr.map_flags = def->map_flags;
-               create_attr.key_size = def->key_size;
-               create_attr.value_size = def->value_size;
-               create_attr.max_entries = def->max_entries;
-               create_attr.btf_fd = 0;
-               create_attr.btf_key_type_id = 0;
-               create_attr.btf_value_type_id = 0;
-               if (bpf_map_type__is_map_in_map(def->type) &&
-                   map->inner_map_fd >= 0)
-                       create_attr.inner_map_fd = map->inner_map_fd;
-
-               if (obj->btf && !bpf_map_find_btf_info(map, obj->btf)) {
-                       create_attr.btf_fd = btf__fd(obj->btf);
-                       create_attr.btf_key_type_id = map->btf_key_type_id;
-                       create_attr.btf_value_type_id = map->btf_value_type_id;
-               }
-
-               *pfd = bpf_create_map_xattr(&create_attr);
-               if (*pfd < 0 && create_attr.btf_key_type_id) {
-                       cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
-                       pr_warning("Error in bpf_create_map_xattr(%s):%s(%d). Retrying without BTF.\n",
-                                  map->name, cp, errno);
-                       create_attr.btf_fd = 0;
-                       create_attr.btf_key_type_id = 0;
-                       create_attr.btf_value_type_id = 0;
-                       map->btf_key_type_id = 0;
-                       map->btf_value_type_id = 0;
-                       *pfd = bpf_create_map_xattr(&create_attr);
-               }
-
+               *pfd = bpf_object__create_map(obj, map);
                if (*pfd < 0) {
                        size_t j;
 
@@ -1412,6 +1568,24 @@ bpf_program__relocate(struct bpf_program *prog, struct bpf_object *obj)
                                                      &prog->reloc_desc[i]);
                        if (err)
                                return err;
+               } else if (prog->reloc_desc[i].type == RELO_DATA ||
+                          prog->reloc_desc[i].type == RELO_RODATA ||
+                          prog->reloc_desc[i].type == RELO_BSS) {
+                       struct bpf_insn *insns = prog->insns;
+                       int insn_idx, map_idx, data_off;
+
+                       insn_idx = prog->reloc_desc[i].insn_idx;
+                       map_idx  = prog->reloc_desc[i].map_idx;
+                       data_off = insns[insn_idx].imm;
+
+                       if (insn_idx + 1 >= (int)prog->insns_cnt) {
+                               pr_warning("relocation out of range: '%s'\n",
+                                          prog->section_name);
+                               return -LIBBPF_ERRNO__RELOC;
+                       }
+                       insns[insn_idx].src_reg = BPF_PSEUDO_MAP_VALUE;
+                       insns[insn_idx].imm = obj->maps_global[map_idx].fd;
+                       insns[insn_idx + 1].imm = data_off;
                }
        }
 
@@ -1717,6 +1891,7 @@ __bpf_object__open(const char *path, void *obj_buf, size_t obj_buf_sz,
 
        CHECK_ERR(bpf_object__elf_init(obj), err, out);
        CHECK_ERR(bpf_object__check_endianness(obj), err, out);
+       CHECK_ERR(bpf_object__probe_caps(obj), err, out);
        CHECK_ERR(bpf_object__elf_collect(obj, flags), err, out);
        CHECK_ERR(bpf_object__collect_reloc(obj), err, out);
        CHECK_ERR(bpf_object__validate(obj, needs_kver), err, out);
@@ -1789,7 +1964,8 @@ int bpf_object__unload(struct bpf_object *obj)
 
        for (i = 0; i < obj->nr_maps; i++)
                zclose(obj->maps[i].fd);
-
+       for (i = 0; i < obj->nr_maps_global; i++)
+               zclose(obj->maps_global[i].fd);
        for (i = 0; i < obj->nr_programs; i++)
                bpf_program__unload(&obj->programs[i]);
 
@@ -1810,7 +1986,6 @@ int bpf_object__load(struct bpf_object *obj)
 
        obj->loaded = true;
 
Quoted 11 lines
Quoted 7 lines
tools/lib/bpf/libbpf.c +0 -2
-       CHECK_ERR(bpf_object__probe_caps(obj), err, out);
        CHECK_ERR(bpf_object__create_maps(obj), err, out);
        CHECK_ERR(bpf_object__relocate(obj), err, out);
        CHECK_ERR(bpf_object__load_progs(obj), err, out);
--

2.17.1

I'm sorry if I seem a bit too obsessed with those three new relocation types. I just believe that having one generic and storing global maps along with other maps is cleaner and more uniform.

No worries, thanks for all your feedback and review!

Thanks,
Daniel

#29 lore raw

Re: [PATCH bpf-next v2 5/7] bpf, libbpf: support global data/bss/rodata sections

Quoted 31 lines · Daniel Borkmann
Quoted 22 lines · Andrii Nakryiko
Quoted 21 lines · Daniel Borkmann

This work adds BPF loader support for global data sections to libbpf. This allows to write BPF programs in more natural C-like way by being able to define global variables and const data.

Back at LPC 2018 [0] we presented a first prototype which implemented support for global data sections by extending BPF syscall where union bpf_attr would get additional memory/size pair for each section passed during prog load in order to later add this base address into the ldimm64 instruction along with the user provided offset when accessing a variable. Consensus from LPC was that for proper upstream support, it would be more desirable to use maps instead of bpf_attr extension as this would allow for introspection of these sections as well as potential life updates of their content. This work follows this path by taking the following steps from loader side:

1) In bpf_object__elf_collect() step we pick up ".data", ".rodata", and ".bss" section information.

Quoted 7 lines
Quoted 2 lines

2) If present, in bpf_object__init_global_maps() we create a map that corresponds to each of the present sections.

Is there any point in having .data and .bss in separate maps? I can only see for reasons of inspectiion from bpftool, but other than that isn't .bss just an optimization over .data to save space in ELF file, but in other regards is just another part of r/w .data section?

Quoted 5 lines

Hmm, I actually don't mind too much combining both of them. Had the same thought with regards to introspection from bpftool which was why I separated them. But combining the two into a single map is fine actually, saves a bit of resources in kernel, and offsets can easily be fixed up from libbpf side. Will do for v3.

Do we plan to pretty-print data/bss with BTF from the bpftool at some point? Does combining them makes it harder?

Quoted 678 lines
Quoted 11 lines
Quoted 10 lines

Given section size and access properties can differ, a single entry array map is created with value size that is corresponding to the ELF section size of .data, .bss or .rodata. In the latter case, the map is created as read-only from program side such that verifier rejects any write attempts into .rodata. In a subsequent step, for .data and .rodata sections, the section content is copied into the map through bpf_map_update_elem(). For .bss this is not necessary since array map is already zero-initialized by default.

Quoted 2 lines

For .rodata, ideally it would be nice to make it RDONLY from userland as well, except for first UPDATE. How hard is it to support that?

Right now the BPF_F_RDONLY, BPF_F_WRONLY semantics to make the maps read-only or write-only from syscall side are that these permissions are stored into the struct file front end (file->f_mode) for the anon inode we use, meaning it's separated from the actual BPF map, so you can create the map with BPF_F_RDONLY, but root user can do BPF_MAP_GET_FD_BY_ID without the BPF_F_RDONLY and again write into it. This design choice would require that we'd need to add some additional infrastructure on top of this, which would then need to enforce file->f_mode to read-only after the first setup. I think there's simple trick we can apply to make it read-only after setup from syscall side: we'll add a new flag to the map, and then upon map creation libbpf sets everything up, holds the id, closes its fd, and refetches the fd by id. From that point onwards any interface where you would get the fd from the map in user space will enforce BPF_F_RDONLY behavior for file->f_mode. Another, less hacky option could be to extend the struct file ops we currently use for BPF maps and set a map 'immutable' flag from there which is then enforced once all pending operations have completed. I can look a bit into this.

Quoted 153 lines
Quoted 103 lines

3) In bpf_program__collect_reloc() step, we record the corresponding map, insn index, and relocation type for the global data.

4) And last but not least in the actual relocation step in bpf_program__relocate(), we mark the ldimm64 instruction with src_reg = BPF_PSEUDO_MAP_VALUE where in the first imm field the map's file descriptor is stored as similarly done as in BPF_PSEUDO_MAP_FD, and in the second imm field (as ldimm64 is 2-insn wide) we store the access offset into the section.

5) On kernel side, this special marked BPF_PSEUDO_MAP_VALUE load will then store the actual target address in order to have a 'map-lookup'-free access. That is, the actual map value base address + offset. The destination register in the verifier will then be marked as PTR_TO_MAP_VALUE, containing the fixed offset as reg->off and backing BPF map as reg->map_ptr. Meaning, it's treated as any other normal map value from verification side, only with efficient, direct value access instead of actual call to map lookup helper as in the typical case.

Simple example dump of program using globals vars in each section:

  # readelf -a test_global_data.o
  [...]
  [ 6] .bss              NOBITS           0000000000000000  00000328
       0000000000000010  0000000000000000  WA       0     0     8
  [ 7] .data             PROGBITS         0000000000000000  00000328
       0000000000000010  0000000000000000  WA       0     0     8
  [ 8] .rodata           PROGBITS         0000000000000000  00000338
       0000000000000018  0000000000000000   A       0     0     8
  [...]
    95: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    6 static_bss
    96: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    6 static_bss2
    97: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    7 static_data
    98: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    7 static_data2
    99: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    8 static_rodata
   100: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    8 static_rodata2
   101: 0000000000000010     8 OBJECT  LOCAL  DEFAULT    8 static_rodata3
  [...]
  # bpftool prog
  103: sched_cls  name load_static_dat  tag 37a8b6822fc39a29  gpl
       loaded_at 2019-02-28T02:02:35+0000  uid 0
       xlated 712B  jited 426B  memlock 4096B  map_ids 63,64,65,66
  # bpftool map show id 63
  63: array  name .bss  flags 0x0                      <-- .bss area, rw
      key 4B  value 16B  max_entries 1  memlock 4096B
  # bpftool map show id 64
  64: array  name .data  flags 0x0                     <-- .data area, rw
      key 4B  value 16B  max_entries 1  memlock 4096B
  # bpftool map show id 65
  65: array  name .rodata  flags 0x80                  <-- .rodata area, ro
      key 4B  value 24B  max_entries 1  memlock 4096B
  # bpftool prog dump xlated id 103
  int load_static_data(struct __sk_buff * skb):
  ; int load_static_data(struct __sk_buff *skb)
     0: (b7) r1 = 0
  ; key = 0;
     1: (63) *(u32 *)(r10 -4) = r1
     2: (bf) r6 = r10
  ; int load_static_data(struct __sk_buff *skb)
     3: (07) r6 += -4
  ; bpf_map_update_elem(&result, &key, &static_bss, 0);
     4: (18) r1 = map[id:66]
     6: (bf) r2 = r6
     7: (18) r3 = map[id:63][0]+0         <-- direct static_bss addr in .bss area
     9: (b7) r4 = 0
    10: (85) call array_map_update_elem#99888
    11: (b7) r1 = 1
  ; key = 1;
    12: (63) *(u32 *)(r10 -4) = r1
  ; bpf_map_update_elem(&result, &key, &static_data, 0);
    13: (18) r1 = map[id:66]
    15: (bf) r2 = r6
    16: (18) r3 = map[id:64][0]+0         <-- direct static_data addr in .data area
    18: (b7) r4 = 0
    19: (85) call array_map_update_elem#99888
    20: (b7) r1 = 2
  ; key = 2;
    21: (63) *(u32 *)(r10 -4) = r1
  ; bpf_map_update_elem(&result, &key, &static_rodata, 0);
    22: (18) r1 = map[id:66]
    24: (bf) r2 = r6
    25: (18) r3 = map[id:65][0]+0         <-- direct static_rodata addr in .rodata area
    27: (b7) r4 = 0
    28: (85) call array_map_update_elem#99888
    29: (b7) r1 = 3
  ; key = 3;
    30: (63) *(u32 *)(r10 -4) = r1
  ; bpf_map_update_elem(&result, &key, &static_bss2, 0);
    31: (18) r7 = map[id:63][0]+8         <--.
    33: (18) r1 = map[id:66]                 |
    35: (bf) r2 = r6                         |
    36: (18) r3 = map[id:63][0]+8         <-- direct static_bss2 addr in .bss area
    38: (b7) r4 = 0
    39: (85) call array_map_update_elem#99888
  [...]
Quoted 2 lines

For now .data/.rodata/.bss maps are not exposed via API to the user, but this could be done in a subsequent step.

See comment about BPF_MAP_TYPE_HEAP/BLOB map in comments to patch #1, it would probably make more useful API for .data/.rodata/.bss.

Quoted 44 lines

Based upon recent fix in LLVM, commit c0db6b6bd444 ("[BPF] Don't fail for static variables").

Joint work with Joe Stringer.

[0] LPC 2018, BPF track, "ELF relocation for static data in BPF",

      http://vger.kernel.org/lpc-bpf2018.html#session-3
---
 tools/include/uapi/linux/bpf.h |  10 +-
 tools/lib/bpf/libbpf.c         | 259 +++++++++++++++++++++++++++------
 2 files changed, 226 insertions(+), 43 deletions(-)
tools/include/uapi/linux/bpf.h +9 -1
index 8884072e1a46..04b26f59b413 100644
@@ -287,7 +287,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)
 
@@ -297,6 +297,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)
 
Quoted 16 lines

tools/lib/bpf/libbpf.c struct bpf_program { · line 144

Quoted 11 lines
tools/lib/bpf/libbpf.c +3 -0
index 8f8f688f3e9b..969bc3d9f02c 100644
@@ -139,6 +139,9 @@ struct bpf_program {
                enum {
                        RELO_LD64,
                        RELO_CALL,
+                       RELO_DATA,
+                       RELO_RODATA,
+                       RELO_BSS,

All three of those are essentially the same relocations, just applied against different ELF sections.
I think by having just single RELO_GLOBAL_DATA you can actually simplify a bunch of code below, please see corresponding comments.

Ok, sounds like a reasonable simplification, will do all well for v3.

Quoted 28 lines

tools/lib/bpf/libbpf.c struct bpf_program { · line 181

Quoted 10 lines
tools/lib/bpf/libbpf.c +2 -1
                } type;
                int insn_idx;
                union {
@@ -174,7 +177,10 @@ struct bpf_program {
 struct bpf_map {
        int fd;
        char *name;
-       size_t offset;
+       union {
+               __u32 global_type;

This could be an index into common maps array.

tools/lib/bpf/libbpf.c struct bpf_object { · line 204

Quoted 11 lines
tools/lib/bpf/libbpf.c +4 -0
+               size_t offset;
+       };
        int map_ifindex;
        int inner_map_fd;
        struct bpf_map_def def;
@@ -194,6 +200,8 @@ struct bpf_object {
        size_t nr_programs;
        struct bpf_map *maps;
        size_t nr_maps;
+       struct bpf_map *maps_global;
+       size_t nr_maps_global;

Global maps could be stored in maps, along other ones, so that we don't need to keep track of them separately.

Quoted 4 lines

Another inconvenience of having a separate array of global maps is that bpf_map__iter won't iterate them. I don't know if that's desirable behavior or not, but it probably would be nice to iterate over global ones as well?

My thinking was that these maps are not explicitly user specified, so libbpf API would expose them through a different interface than the one we have today in order to not confuse or break application behavior which would otherwise rely on iterating / processing over them. Separate API would retain current behavior and definitely make this unambiguous to apps with regards to what to expect from each of such API call.

Quoted 46 lines
Quoted 46 lines
tools/lib/bpf/libbpf.c +12 -0
        bool loaded;
        bool has_pseudo_calls;
@@ -209,6 +217,9 @@ struct bpf_object {
                Elf *elf;
                GElf_Ehdr ehdr;
                Elf_Data *symbols;
+               Elf_Data *global_data;
+               Elf_Data *global_rodata;
+               Elf_Data *global_bss;
                size_t strtabidx;
                struct {
                        GElf_Shdr shdr;
@@ -217,6 +228,9 @@ struct bpf_object {
                int nr_reloc;
                int maps_shndx;
                int text_shndx;
+               int data_shndx;
+               int rodata_shndx;
+               int bss_shndx;
        } efile;
        /*
         * All loaded bpf_object is linked in a list, which is
@@ -457,6 +471,9 @@ static struct bpf_object *bpf_object__new(const char *path,
        obj->efile.obj_buf = obj_buf;
        obj->efile.obj_buf_sz = obj_buf_sz;
        obj->efile.maps_shndx = -1;
+       obj->efile.data_shndx = -1;
+       obj->efile.rodata_shndx = -1;
+       obj->efile.bss_shndx = -1;
 
        obj->loaded = false;
 
@@ -475,6 +492,9 @@ static void bpf_object__elf_finish(struct bpf_object *obj)
                obj->efile.elf = NULL;
        }
        obj->efile.symbols = NULL;
+       obj->efile.global_data = NULL;
+       obj->efile.global_rodata = NULL;
+       obj->efile.global_bss = NULL;
 
        zfree(&obj->efile.reloc);
        obj->efile.nr_reloc = 0;
@@ -757,6 +777,85 @@ bpf_object__init_maps(struct bpf_object *obj, int flags)
        return 0;
 }
 
Quoted 10 lines

tools/lib/bpf/libbpf.c bpf_object__init_maps(struct bpf_object *obj, int flags) · line 785

Quoted 6 lines
tools/lib/bpf/libbpf.c +6 -0
+static int
+bpf_object__create_map(struct bpf_object *obj, struct bpf_map *map);
+
+static int
+bpf_object__init_global(struct bpf_object *obj, int i, int type,
+                       const char *name, Elf_Data *map_data)

Instead of deducing flags and looking up for map by index, you can just pass struct bpf_map * directly instead of int i and provide flags, instead of type.

Yep, agree.

Quoted 45 lines
Quoted 45 lines
tools/lib/bpf/libbpf.c +45 -0
+{
+       struct bpf_map *map = &obj->maps_global[i];
+       struct bpf_map_def *def = &map->def;
+       char *cp, errmsg[STRERR_BUFSIZE];
+       int err, slot0 = 0;
+
+       def->type = BPF_MAP_TYPE_ARRAY;
+       def->key_size = sizeof(int);
+       def->value_size = map_data->d_size;
+       def->max_entries = 1;
+       def->map_flags = type == RELO_RODATA ? BPF_F_RDONLY_PROG : 0;
+
+       map->name = strdup(name);
+       map->global_type = type;
+       map->fd = bpf_object__create_map(obj, map);
+       if (map->fd < 0) {
+               err = map->fd;
+               cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
+               pr_warning("failed to create map (name: '%s'): %s\n",
+                          map->name, cp);
+               goto destroy;
+       }
+
+       pr_debug("create map %s: fd=%d\n", map->name, map->fd);
+
+       if (type != RELO_BSS) {
+               err = bpf_map_update_elem(map->fd, &slot0, map_data->d_buf, 0);
+               if (err < 0) {
+                       cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
+                       pr_warning("failed to update map (name: '%s'): %s\n",
+                                  map->name, cp);
+                       goto destroy;
+               }
+
+               pr_debug("updated map %s with elf data: fd=%d\n", map->name,
+                        map->fd);
+       }
+       return 0;
+destroy:
+       for (i = 0; i < obj->nr_maps_global; i++)
+               zclose(obj->maps_global[i].fd);
+       return err;
+}
+
+static int
Quoted 8 lines

tools/lib/bpf/libbpf.c bpf_object__init_maps(struct bpf_object *obj, int flags) · line 835

Quoted 5 lines
tools/lib/bpf/libbpf.c +5 -0
+bpf_object__init_global_maps(struct bpf_object *obj)
+{
+       int nr_maps_global = (obj->efile.data_shndx >= 0) +
+                            (obj->efile.rodata_shndx >= 0) +
+                            (obj->efile.bss_shndx >= 0), i, err = 0;

This looks like a good candidate for separate static function? It can also be reused below to check if there is any global map present.

Sounds good.

Quoted 6 lines

tools/lib/bpf/libbpf.c bpf_object__init_maps(struct bpf_object *obj, int flags) · line 838

Quoted 3 lines
tools/lib/bpf/libbpf.c +3 -0
+
+       obj->maps_global = calloc(nr_maps_global, sizeof(obj->maps_global[0]));
+       if (!obj->maps_global) {

If nr_maps_global is 0, calloc might or might not return NULL, so this check might erroneously return error.

Good point, just read it up as well from man page, will fix.

Quoted 18 lines
Quoted 7 lines
tools/lib/bpf/libbpf.c +7 -0
+               pr_warning("alloc maps for object failed\n");
+               return -ENOMEM;
+       }
+
+       obj->nr_maps_global = nr_maps_global;
+       for (i = 0; i < obj->nr_maps_global; i++)
+               obj->maps[i].fd = -1;

tools/lib/bpf/libbpf.c bpf_object__init_maps(struct bpf_object *obj, int flags) · line 855

Quoted 10 lines
tools/lib/bpf/libbpf.c +10 -0
+       i = 0;
+       if (obj->efile.bss_shndx >= 0)
+               err = bpf_object__init_global(obj, i++, RELO_BSS, ".bss",
+                                             obj->efile.global_bss);
+       if (obj->efile.data_shndx >= 0 && !err)
+               err = bpf_object__init_global(obj, i++, RELO_DATA, ".data",
+                                             obj->efile.global_data);
+       if (obj->efile.rodata_shndx >= 0 && !err)
+               err = bpf_object__init_global(obj, i++, RELO_RODATA, ".rodata",
+                                             obj->efile.global_rodata);
Quoted 7 lines

Here we know exactly what type of map we are creating, so we can just directly pass all the required structs/flags/data.

Also, to speed up and simplify relocation processing below, I think it's better to store map indexes for each of available .bss, .data and .rodata maps, eliminating another need for having three different types of data relocations.

Yep, I'll clean this up.

Quoted 12 lines
Quoted 12 lines
tools/lib/bpf/libbpf.c +5 -0
+       return err;
+}
+
 static bool section_have_execinstr(struct bpf_object *obj, int idx)
 {
        Elf_Scn *scn;
@@ -865,6 +964,12 @@ static int bpf_object__elf_collect(struct bpf_object *obj, int flags)
                                        pr_warning("failed to alloc program %s (%s): %s",
                                                   name, obj->path, cp);
                                }
+                       } else if (strcmp(name, ".data") == 0) {
+                               obj->efile.global_data = data;
Quoted 8 lines

tools/lib/bpf/libbpf.c static int bpf_object__elf_collect(struct bpf_object *obj, int flags) · line 973

Quoted 5 lines
tools/lib/bpf/libbpf.c +4 -0
+                               obj->efile.data_shndx = idx;
+                       } else if (strcmp(name, ".rodata") == 0) {
+                               obj->efile.global_rodata = data;
+                               obj->efile.rodata_shndx = idx;
                        }

Previously if we encountered unknown PROGBITS section, we'd emit debug message about skipping section, should we add that message here?

Sounds reasonable, I'll add a similar 'skip section' debug output there.

Quoted 240 lines
Quoted 66 lines
tools/lib/bpf/libbpf.c +30 -2
                } else if (sh.sh_type == SHT_REL) {
                        void *reloc = obj->efile.reloc;
@@ -892,6 +997,9 @@ static int bpf_object__elf_collect(struct bpf_object *obj, int flags)
                                obj->efile.reloc[n].shdr = sh;
                                obj->efile.reloc[n].data = data;
                        }
+               } else if (sh.sh_type == SHT_NOBITS && strcmp(name, ".bss") == 0) {
+                       obj->efile.global_bss = data;
+                       obj->efile.bss_shndx = idx;
                } else {
                        pr_debug("skip section(%d) %s\n", idx, name);
                }
@@ -923,6 +1031,14 @@ static int bpf_object__elf_collect(struct bpf_object *obj, int flags)
                if (err)
                        goto out;
        }
+       if (obj->efile.data_shndx >= 0 ||
+           obj->efile.rodata_shndx >= 0 ||
+           obj->efile.bss_shndx >= 0) {
+               err = bpf_object__init_global_maps(obj);
+               if (err)
+                       goto out;
+       }
+
        err = bpf_object__init_prog_names(obj);
 out:
        return err;
@@ -961,6 +1077,11 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
        Elf_Data *symbols = obj->efile.symbols;
        int text_shndx = obj->efile.text_shndx;
        int maps_shndx = obj->efile.maps_shndx;
+       int data_shndx = obj->efile.data_shndx;
+       int rodata_shndx = obj->efile.rodata_shndx;
+       int bss_shndx = obj->efile.bss_shndx;
+       struct bpf_map *maps_global = obj->maps_global;
+       size_t nr_maps_global = obj->nr_maps_global;
        struct bpf_map *maps = obj->maps;
        size_t nr_maps = obj->nr_maps;
        int i, nrels;
@@ -999,8 +1120,10 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
                         (long long) (rel.r_info >> 32),
                         (long long) sym.st_value, sym.st_name);
 
-               if (sym.st_shndx != maps_shndx && sym.st_shndx != text_shndx) {
-                       pr_warning("Program '%s' contains non-map related relo data pointing to section %u\n",
+               if (sym.st_shndx != maps_shndx && sym.st_shndx != text_shndx &&
+                   sym.st_shndx != data_shndx && sym.st_shndx != rodata_shndx &&
+                   sym.st_shndx != bss_shndx) {
+                       pr_warning("Program '%s' contains unrecognized relo data pointing to section %u\n",
                                   prog->section_name, sym.st_shndx);
                        return -LIBBPF_ERRNO__RELOC;
                }
@@ -1045,6 +1168,30 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
                        prog->reloc_desc[i].type = RELO_LD64;
                        prog->reloc_desc[i].insn_idx = insn_idx;
                        prog->reloc_desc[i].map_idx = map_idx;
+               } else if (sym.st_shndx == data_shndx ||
+                          sym.st_shndx == rodata_shndx ||
+                          sym.st_shndx == bss_shndx) {
+                       int type = (sym.st_shndx == data_shndx)   ? RELO_DATA :
+                                  (sym.st_shndx == rodata_shndx) ? RELO_RODATA :
+                                                                   RELO_BSS;
+
+                       for (map_idx = 0; map_idx < nr_maps_global; map_idx++) {
+                               if (maps_global[map_idx].global_type == type) {
+                                       pr_debug("relocation: find map %zd (%s) for insn %u\n",

tools/lib/bpf/libbpf.c bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr, · line 1190

Quoted 10 lines
tools/lib/bpf/libbpf.c +10 -0
+                                                map_idx, maps_global[map_idx].name, insn_idx);
+                                       break;
+                               }
+                       }
+
+                       if (map_idx >= nr_maps_global) {
+                               pr_warning("bpf relocation: map_idx %d large than %d\n",
+                                          (int)map_idx, (int)nr_maps_global - 1);
+                               return -LIBBPF_ERRNO__RELOC;
+                       }

We don't need to handle all of this if we just remember global map indicies during creation, instead of calculating type, we can just pick correct index (and check it exists). And type can be just generic RELO_DATA.

Quoted 158 lines
tools/lib/bpf/libbpf.c +71 -38
+
+                       prog->reloc_desc[i].type = type;
+                       prog->reloc_desc[i].insn_idx = insn_idx;
+                       prog->reloc_desc[i].map_idx = map_idx;
                }
        }
        return 0;
@@ -1176,15 +1323,58 @@ bpf_object__probe_caps(struct bpf_object *obj)
 }
 
 static int
-bpf_object__create_maps(struct bpf_object *obj)
+bpf_object__create_map(struct bpf_object *obj, struct bpf_map *map)
 {
        struct bpf_create_map_attr create_attr = {};
+       struct bpf_map_def *def = &map->def;
+       char *cp, errmsg[STRERR_BUFSIZE];
+       int fd;
+
+       if (obj->caps.name)
+               create_attr.name = map->name;
+       create_attr.map_ifindex = map->map_ifindex;
+       create_attr.map_type = def->type;
+       create_attr.map_flags = def->map_flags;
+       create_attr.key_size = def->key_size;
+       create_attr.value_size = def->value_size;
+       create_attr.max_entries = def->max_entries;
+       create_attr.btf_fd = 0;
+       create_attr.btf_key_type_id = 0;
+       create_attr.btf_value_type_id = 0;
+       if (bpf_map_type__is_map_in_map(def->type) &&
+           map->inner_map_fd >= 0)
+               create_attr.inner_map_fd = map->inner_map_fd;
+       if (obj->btf && !bpf_map_find_btf_info(map, obj->btf)) {
+               create_attr.btf_fd = btf__fd(obj->btf);
+               create_attr.btf_key_type_id = map->btf_key_type_id;
+               create_attr.btf_value_type_id = map->btf_value_type_id;
+       }
+
+       fd = bpf_create_map_xattr(&create_attr);
+       if (fd < 0 && create_attr.btf_key_type_id) {
+               cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
+               pr_warning("Error in bpf_create_map_xattr(%s):%s(%d). Retrying without BTF.\n",
+                          map->name, cp, errno);
+
+               create_attr.btf_fd = 0;
+               create_attr.btf_key_type_id = 0;
+               create_attr.btf_value_type_id = 0;
+               map->btf_key_type_id = 0;
+               map->btf_value_type_id = 0;
+               fd = bpf_create_map_xattr(&create_attr);
+       }
+
+       return fd;
+}
+
+static int
+bpf_object__create_maps(struct bpf_object *obj)
+{
        unsigned int i;
        int err;
 
        for (i = 0; i < obj->nr_maps; i++) {
                struct bpf_map *map = &obj->maps[i];
-               struct bpf_map_def *def = &map->def;
                char *cp, errmsg[STRERR_BUFSIZE];
                int *pfd = &map->fd;
 
@@ -1193,41 +1383,7 @@ bpf_object__create_maps(struct bpf_object *obj)
                                 map->name, map->fd);
                        continue;
                }
-
-               if (obj->caps.name)
-                       create_attr.name = map->name;
-               create_attr.map_ifindex = map->map_ifindex;
-               create_attr.map_type = def->type;
-               create_attr.map_flags = def->map_flags;
-               create_attr.key_size = def->key_size;
-               create_attr.value_size = def->value_size;
-               create_attr.max_entries = def->max_entries;
-               create_attr.btf_fd = 0;
-               create_attr.btf_key_type_id = 0;
-               create_attr.btf_value_type_id = 0;
-               if (bpf_map_type__is_map_in_map(def->type) &&
-                   map->inner_map_fd >= 0)
-                       create_attr.inner_map_fd = map->inner_map_fd;
-
-               if (obj->btf && !bpf_map_find_btf_info(map, obj->btf)) {
-                       create_attr.btf_fd = btf__fd(obj->btf);
-                       create_attr.btf_key_type_id = map->btf_key_type_id;
-                       create_attr.btf_value_type_id = map->btf_value_type_id;
-               }
-
-               *pfd = bpf_create_map_xattr(&create_attr);
-               if (*pfd < 0 && create_attr.btf_key_type_id) {
-                       cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
-                       pr_warning("Error in bpf_create_map_xattr(%s):%s(%d). Retrying without BTF.\n",
-                                  map->name, cp, errno);
-                       create_attr.btf_fd = 0;
-                       create_attr.btf_key_type_id = 0;
-                       create_attr.btf_value_type_id = 0;
-                       map->btf_key_type_id = 0;
-                       map->btf_value_type_id = 0;
-                       *pfd = bpf_create_map_xattr(&create_attr);
-               }
-
+               *pfd = bpf_object__create_map(obj, map);
                if (*pfd < 0) {
                        size_t j;
 
@@ -1412,6 +1568,24 @@ bpf_program__relocate(struct bpf_program *prog, struct bpf_object *obj)
                                                      &prog->reloc_desc[i]);
                        if (err)
                                return err;
+               } else if (prog->reloc_desc[i].type == RELO_DATA ||
+                          prog->reloc_desc[i].type == RELO_RODATA ||
+                          prog->reloc_desc[i].type == RELO_BSS) {
+                       struct bpf_insn *insns = prog->insns;
+                       int insn_idx, map_idx, data_off;
+
+                       insn_idx = prog->reloc_desc[i].insn_idx;
+                       map_idx  = prog->reloc_desc[i].map_idx;
+                       data_off = insns[insn_idx].imm;
+
+                       if (insn_idx + 1 >= (int)prog->insns_cnt) {
+                               pr_warning("relocation out of range: '%s'\n",
+                                          prog->section_name);
+                               return -LIBBPF_ERRNO__RELOC;
+                       }
+                       insns[insn_idx].src_reg = BPF_PSEUDO_MAP_VALUE;
+                       insns[insn_idx].imm = obj->maps_global[map_idx].fd;
+                       insns[insn_idx + 1].imm = data_off;
                }
        }
 
@@ -1717,6 +1891,7 @@ __bpf_object__open(const char *path, void *obj_buf, size_t obj_buf_sz,
 
        CHECK_ERR(bpf_object__elf_init(obj), err, out);
        CHECK_ERR(bpf_object__check_endianness(obj), err, out);
+       CHECK_ERR(bpf_object__probe_caps(obj), err, out);
        CHECK_ERR(bpf_object__elf_collect(obj, flags), err, out);
        CHECK_ERR(bpf_object__collect_reloc(obj), err, out);
        CHECK_ERR(bpf_object__validate(obj, needs_kver), err, out);
@@ -1789,7 +1964,8 @@ int bpf_object__unload(struct bpf_object *obj)
 
        for (i = 0; i < obj->nr_maps; i++)
                zclose(obj->maps[i].fd);
-
+       for (i = 0; i < obj->nr_maps_global; i++)
+               zclose(obj->maps_global[i].fd);
        for (i = 0; i < obj->nr_programs; i++)
                bpf_program__unload(&obj->programs[i]);
 
@@ -1810,7 +1986,6 @@ int bpf_object__load(struct bpf_object *obj)
 
        obj->loaded = true;
 
Quoted 11 lines
Quoted 7 lines
tools/lib/bpf/libbpf.c +0 -2
-       CHECK_ERR(bpf_object__probe_caps(obj), err, out);
        CHECK_ERR(bpf_object__create_maps(obj), err, out);
        CHECK_ERR(bpf_object__relocate(obj), err, out);
        CHECK_ERR(bpf_object__load_progs(obj), err, out);
--

2.17.1

I'm sorry if I seem a bit too obsessed with those three new relocation types. I just believe that having one generic and storing global maps along with other maps is cleaner and more uniform.

No worries, thanks for all your feedback and review!

Thanks,
Daniel

#30 lore raw

Re: [PATCH bpf-next v2 5/7] bpf, libbpf: support global data/bss/rodata sections

In reply to Daniel Borkmann
Quoted 32 lines · Daniel Borkmann
Quoted 22 lines · Andrii Nakryiko
Quoted 21 lines · Daniel Borkmann

This work adds BPF loader support for global data sections to libbpf. This allows to write BPF programs in more natural C-like way by being able to define global variables and const data.

Back at LPC 2018 [0] we presented a first prototype which implemented support for global data sections by extending BPF syscall where union bpf_attr would get additional memory/size pair for each section passed during prog load in order to later add this base address into the ldimm64 instruction along with the user provided offset when accessing a variable. Consensus from LPC was that for proper upstream support, it would be more desirable to use maps instead of bpf_attr extension as this would allow for introspection of these sections as well as potential life updates of their content. This work follows this path by taking the following steps from loader side:

1) In bpf_object__elf_collect() step we pick up ".data", ".rodata", and ".bss" section information.

Quoted 7 lines
Quoted 2 lines

2) If present, in bpf_object__init_global_maps() we create a map that corresponds to each of the present sections.

Is there any point in having .data and .bss in separate maps? I can only see for reasons of inspectiion from bpftool, but other than that isn't .bss just an optimization over .data to save space in ELF file, but in other regards is just another part of r/w .data section?

Quoted 5 lines

Hmm, I actually don't mind too much combining both of them. Had the same thought with regards to introspection from bpftool which was why I separated them. But combining the two into a single map is fine actually, saves a bit of resources in kernel, and offsets can easily be fixed up from libbpf side. Will do for v3.

I thought a bit more about this and I think there is one good reason (in addition to introspection) to keep them separate.
If total size of .data is not multiple of 8-byte, when appending .bss to it, we'll need to pad few bytes. It probably would be a good thing for verifier to enforce that those bytes are never accessed, which will be impossible to do if we combine .data and .bss.

I'm not sure how important that is, just wanted to bring up one more counter-argument.

Quoted 26 lines
Quoted 12 lines
Quoted 11 lines

Given section size and access properties can differ, a single entry array map is created with value size that is corresponding to the ELF section size of .data, .bss or .rodata. In the latter case, the map is created as read-only from program side such that verifier rejects any write attempts into .rodata. In a subsequent step, for .data and .rodata sections, the section content is copied into the map through bpf_map_update_elem(). For .bss this is not necessary since array map is already zero-initialized by default.

Quoted 2 lines

For .rodata, ideally it would be nice to make it RDONLY from userland as well, except for first UPDATE. How hard is it to support that?

Right now the BPF_F_RDONLY, BPF_F_WRONLY semantics to make the maps read-only or write-only from syscall side are that these permissions are stored into the struct file front end (file->f_mode) for the anon inode we use, meaning it's separated from the actual BPF map, so you can create the map with BPF_F_RDONLY, but root user can do BPF_MAP_GET_FD_BY_ID without the BPF_F_RDONLY and again write into it. This design choice would require that we'd need to add some additional infrastructure on top of this, which would then need to enforce file->f_mode to read-only after the first setup. I think there's simple trick we can apply to make it read-only after setup from syscall side: we'll add a new flag

Quoted 8 lines

to the map, and then upon map creation libbpf sets everything up, holds the id, closes its fd, and refetches the fd by id. From that point onwards any interface where you would get the fd from the map in user space will enforce BPF_F_RDONLY behavior for file->f_mode. Another, less hacky option could be to extend the struct file ops we currently use for BPF maps and set a map 'immutable' flag from there which is then enforced once all pending operations have completed. I can look a bit into this.

Cool, thanks for explaining!

I think that we can start off without this enforcement, but if we had this enforcement, it would open up new possibilities for verifier to optimize/prune code based on values in .rodata, because we'd have guarantee that values can't change.

Quoted 206 lines
Quoted 154 lines
Quoted 104 lines

3) In bpf_program__collect_reloc() step, we record the corresponding map, insn index, and relocation type for the global data.

4) And last but not least in the actual relocation step in bpf_program__relocate(), we mark the ldimm64 instruction with src_reg = BPF_PSEUDO_MAP_VALUE where in the first imm field the map's file descriptor is stored as similarly done as in BPF_PSEUDO_MAP_FD, and in the second imm field (as ldimm64 is 2-insn wide) we store the access offset into the section.

5) On kernel side, this special marked BPF_PSEUDO_MAP_VALUE load will then store the actual target address in order to have a 'map-lookup'-free access. That is, the actual map value base address + offset. The destination register in the verifier will then be marked as PTR_TO_MAP_VALUE, containing the fixed offset as reg->off and backing BPF map as reg->map_ptr. Meaning, it's treated as any other normal map value from verification side, only with efficient, direct value access instead of actual call to map lookup helper as in the typical case.

Simple example dump of program using globals vars in each section:

  # readelf -a test_global_data.o
  [...]
  [ 6] .bss              NOBITS           0000000000000000  00000328
       0000000000000010  0000000000000000  WA       0     0     8
  [ 7] .data             PROGBITS         0000000000000000  00000328
       0000000000000010  0000000000000000  WA       0     0     8
  [ 8] .rodata           PROGBITS         0000000000000000  00000338
       0000000000000018  0000000000000000   A       0     0     8
  [...]
    95: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    6 static_bss
    96: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    6 static_bss2
    97: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    7 static_data
    98: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    7 static_data2
    99: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    8 static_rodata
   100: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    8 static_rodata2
   101: 0000000000000010     8 OBJECT  LOCAL  DEFAULT    8 static_rodata3
  [...]
  # bpftool prog
  103: sched_cls  name load_static_dat  tag 37a8b6822fc39a29  gpl
       loaded_at 2019-02-28T02:02:35+0000  uid 0
       xlated 712B  jited 426B  memlock 4096B  map_ids 63,64,65,66
  # bpftool map show id 63
  63: array  name .bss  flags 0x0                      <-- .bss area, rw
      key 4B  value 16B  max_entries 1  memlock 4096B
  # bpftool map show id 64
  64: array  name .data  flags 0x0                     <-- .data area, rw
      key 4B  value 16B  max_entries 1  memlock 4096B
  # bpftool map show id 65
  65: array  name .rodata  flags 0x80                  <-- .rodata area, ro
      key 4B  value 24B  max_entries 1  memlock 4096B
  # bpftool prog dump xlated id 103
  int load_static_data(struct __sk_buff * skb):
  ; int load_static_data(struct __sk_buff *skb)
     0: (b7) r1 = 0
  ; key = 0;
     1: (63) *(u32 *)(r10 -4) = r1
     2: (bf) r6 = r10
  ; int load_static_data(struct __sk_buff *skb)
     3: (07) r6 += -4
  ; bpf_map_update_elem(&result, &key, &static_bss, 0);
     4: (18) r1 = map[id:66]
     6: (bf) r2 = r6
     7: (18) r3 = map[id:63][0]+0         <-- direct static_bss addr in .bss area
     9: (b7) r4 = 0
    10: (85) call array_map_update_elem#99888
    11: (b7) r1 = 1
  ; key = 1;
    12: (63) *(u32 *)(r10 -4) = r1
  ; bpf_map_update_elem(&result, &key, &static_data, 0);
    13: (18) r1 = map[id:66]
    15: (bf) r2 = r6
    16: (18) r3 = map[id:64][0]+0         <-- direct static_data addr in .data area
    18: (b7) r4 = 0
    19: (85) call array_map_update_elem#99888
    20: (b7) r1 = 2
  ; key = 2;
    21: (63) *(u32 *)(r10 -4) = r1
  ; bpf_map_update_elem(&result, &key, &static_rodata, 0);
    22: (18) r1 = map[id:66]
    24: (bf) r2 = r6
    25: (18) r3 = map[id:65][0]+0         <-- direct static_rodata addr in .rodata area
    27: (b7) r4 = 0
    28: (85) call array_map_update_elem#99888
    29: (b7) r1 = 3
  ; key = 3;
    30: (63) *(u32 *)(r10 -4) = r1
  ; bpf_map_update_elem(&result, &key, &static_bss2, 0);
    31: (18) r7 = map[id:63][0]+8         <--.
    33: (18) r1 = map[id:66]                 |
    35: (bf) r2 = r6                         |
    36: (18) r3 = map[id:63][0]+8         <-- direct static_bss2 addr in .bss area
    38: (b7) r4 = 0
    39: (85) call array_map_update_elem#99888
  [...]
Quoted 2 lines

For now .data/.rodata/.bss maps are not exposed via API to the user, but this could be done in a subsequent step.

See comment about BPF_MAP_TYPE_HEAP/BLOB map in comments to patch #1, it would probably make more useful API for .data/.rodata/.bss.

Quoted 44 lines

Based upon recent fix in LLVM, commit c0db6b6bd444 ("[BPF] Don't fail for static variables").

Joint work with Joe Stringer.

[0] LPC 2018, BPF track, "ELF relocation for static data in BPF",

      http://vger.kernel.org/lpc-bpf2018.html#session-3
---
 tools/include/uapi/linux/bpf.h |  10 +-
 tools/lib/bpf/libbpf.c         | 259 +++++++++++++++++++++++++++------
 2 files changed, 226 insertions(+), 43 deletions(-)
tools/include/uapi/linux/bpf.h +9 -1
index 8884072e1a46..04b26f59b413 100644
@@ -287,7 +287,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)
 
@@ -297,6 +297,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)
 
Quoted 16 lines

tools/lib/bpf/libbpf.c struct bpf_program { · line 144

Quoted 11 lines
tools/lib/bpf/libbpf.c +3 -0
index 8f8f688f3e9b..969bc3d9f02c 100644
@@ -139,6 +139,9 @@ struct bpf_program {
                enum {
                        RELO_LD64,
                        RELO_CALL,
+                       RELO_DATA,
+                       RELO_RODATA,
+                       RELO_BSS,

All three of those are essentially the same relocations, just applied against different ELF sections.
I think by having just single RELO_GLOBAL_DATA you can actually simplify a bunch of code below, please see corresponding comments.

Ok, sounds like a reasonable simplification, will do all well for v3.

Quoted 28 lines

tools/lib/bpf/libbpf.c struct bpf_program { · line 181

Quoted 10 lines
tools/lib/bpf/libbpf.c +2 -1
                } type;
                int insn_idx;
                union {
@@ -174,7 +177,10 @@ struct bpf_program {
 struct bpf_map {
        int fd;
        char *name;
-       size_t offset;
+       union {
+               __u32 global_type;

This could be an index into common maps array.

tools/lib/bpf/libbpf.c struct bpf_object { · line 204

Quoted 11 lines
tools/lib/bpf/libbpf.c +4 -0
+               size_t offset;
+       };
        int map_ifindex;
        int inner_map_fd;
        struct bpf_map_def def;
@@ -194,6 +200,8 @@ struct bpf_object {
        size_t nr_programs;
        struct bpf_map *maps;
        size_t nr_maps;
+       struct bpf_map *maps_global;
+       size_t nr_maps_global;

Global maps could be stored in maps, along other ones, so that we don't need to keep track of them separately.

Quoted 4 lines

Another inconvenience of having a separate array of global maps is that bpf_map__iter won't iterate them. I don't know if that's desirable behavior or not, but it probably would be nice to iterate over global ones as well?

Quoted 7 lines

My thinking was that these maps are not explicitly user specified, so libbpf API would expose them through a different interface than the one we have today in order to not confuse or break application behavior which would otherwise rely on iterating / processing over them. Separate API would retain current behavior and definitely make this unambiguous to apps with regards to what to expect from each of such API call.

Hm... yeah, I guess it's a decision that needs to be made consciously. To me it feels like global maps are sort of compiler sugar, which provides good developer experience, but resolves into lower-level well-known pre-existing abstractions (just another maps). In any case, more generic tools like bpftool will dump all of them, so I'm not certain we should treat them as separate concepts in libbpf? We currently shouldn't be breaking anyone, because applications can't use static/global data, so these new maps will come up only for new use cases. If you think it might be important to differentiate between auto-generated maps and explicitly defined by user maps, then we can add some bpf_map__{global/special/autogen} accessor to differentiate?

My thinking here is that if you want to iterate all maps, it's kind of inconvenient to remember to iterate "normal maps" and remember to generate "automatic maps".

Also, in the future, if libbpf will need to auto-create some other type of map to support some other features, it will require another set of APIs to access/iterate them, so it feels like sticking to single common list is preferrable, imho.

Quoted 432 lines
Quoted 47 lines
Quoted 47 lines
tools/lib/bpf/libbpf.c +12 -0
        bool loaded;
        bool has_pseudo_calls;
@@ -209,6 +217,9 @@ struct bpf_object {
                Elf *elf;
                GElf_Ehdr ehdr;
                Elf_Data *symbols;
+               Elf_Data *global_data;
+               Elf_Data *global_rodata;
+               Elf_Data *global_bss;
                size_t strtabidx;
                struct {
                        GElf_Shdr shdr;
@@ -217,6 +228,9 @@ struct bpf_object {
                int nr_reloc;
                int maps_shndx;
                int text_shndx;
+               int data_shndx;
+               int rodata_shndx;
+               int bss_shndx;
        } efile;
        /*
         * All loaded bpf_object is linked in a list, which is
@@ -457,6 +471,9 @@ static struct bpf_object *bpf_object__new(const char *path,
        obj->efile.obj_buf = obj_buf;
        obj->efile.obj_buf_sz = obj_buf_sz;
        obj->efile.maps_shndx = -1;
+       obj->efile.data_shndx = -1;
+       obj->efile.rodata_shndx = -1;
+       obj->efile.bss_shndx = -1;
 
        obj->loaded = false;
 
@@ -475,6 +492,9 @@ static void bpf_object__elf_finish(struct bpf_object *obj)
                obj->efile.elf = NULL;
        }
        obj->efile.symbols = NULL;
+       obj->efile.global_data = NULL;
+       obj->efile.global_rodata = NULL;
+       obj->efile.global_bss = NULL;
 
        zfree(&obj->efile.reloc);
        obj->efile.nr_reloc = 0;
@@ -757,6 +777,85 @@ bpf_object__init_maps(struct bpf_object *obj, int flags)
        return 0;
 }
 
Quoted 10 lines

tools/lib/bpf/libbpf.c bpf_object__init_maps(struct bpf_object *obj, int flags) · line 785

Quoted 6 lines
tools/lib/bpf/libbpf.c +6 -0
+static int
+bpf_object__create_map(struct bpf_object *obj, struct bpf_map *map);
+
+static int
+bpf_object__init_global(struct bpf_object *obj, int i, int type,
+                       const char *name, Elf_Data *map_data)

Instead of deducing flags and looking up for map by index, you can just pass struct bpf_map * directly instead of int i and provide flags, instead of type.

Yep, agree.

Quoted 45 lines
Quoted 45 lines
tools/lib/bpf/libbpf.c +45 -0
+{
+       struct bpf_map *map = &obj->maps_global[i];
+       struct bpf_map_def *def = &map->def;
+       char *cp, errmsg[STRERR_BUFSIZE];
+       int err, slot0 = 0;
+
+       def->type = BPF_MAP_TYPE_ARRAY;
+       def->key_size = sizeof(int);
+       def->value_size = map_data->d_size;
+       def->max_entries = 1;
+       def->map_flags = type == RELO_RODATA ? BPF_F_RDONLY_PROG : 0;
+
+       map->name = strdup(name);
+       map->global_type = type;
+       map->fd = bpf_object__create_map(obj, map);
+       if (map->fd < 0) {
+               err = map->fd;
+               cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
+               pr_warning("failed to create map (name: '%s'): %s\n",
+                          map->name, cp);
+               goto destroy;
+       }
+
+       pr_debug("create map %s: fd=%d\n", map->name, map->fd);
+
+       if (type != RELO_BSS) {
+               err = bpf_map_update_elem(map->fd, &slot0, map_data->d_buf, 0);
+               if (err < 0) {
+                       cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
+                       pr_warning("failed to update map (name: '%s'): %s\n",
+                                  map->name, cp);
+                       goto destroy;
+               }
+
+               pr_debug("updated map %s with elf data: fd=%d\n", map->name,
+                        map->fd);
+       }
+       return 0;
+destroy:
+       for (i = 0; i < obj->nr_maps_global; i++)
+               zclose(obj->maps_global[i].fd);
+       return err;
+}
+
+static int
Quoted 8 lines

tools/lib/bpf/libbpf.c bpf_object__init_maps(struct bpf_object *obj, int flags) · line 835

Quoted 5 lines
tools/lib/bpf/libbpf.c +5 -0
+bpf_object__init_global_maps(struct bpf_object *obj)
+{
+       int nr_maps_global = (obj->efile.data_shndx >= 0) +
+                            (obj->efile.rodata_shndx >= 0) +
+                            (obj->efile.bss_shndx >= 0), i, err = 0;

This looks like a good candidate for separate static function? It can also be reused below to check if there is any global map present.

Sounds good.

Quoted 6 lines

tools/lib/bpf/libbpf.c bpf_object__init_maps(struct bpf_object *obj, int flags) · line 838

Quoted 3 lines
tools/lib/bpf/libbpf.c +3 -0
+
+       obj->maps_global = calloc(nr_maps_global, sizeof(obj->maps_global[0]));
+       if (!obj->maps_global) {

If nr_maps_global is 0, calloc might or might not return NULL, so this check might erroneously return error.

Good point, just read it up as well from man page, will fix.

Quoted 18 lines
Quoted 7 lines
tools/lib/bpf/libbpf.c +7 -0
+               pr_warning("alloc maps for object failed\n");
+               return -ENOMEM;
+       }
+
+       obj->nr_maps_global = nr_maps_global;
+       for (i = 0; i < obj->nr_maps_global; i++)
+               obj->maps[i].fd = -1;

tools/lib/bpf/libbpf.c bpf_object__init_maps(struct bpf_object *obj, int flags) · line 855

Quoted 10 lines
tools/lib/bpf/libbpf.c +10 -0
+       i = 0;
+       if (obj->efile.bss_shndx >= 0)
+               err = bpf_object__init_global(obj, i++, RELO_BSS, ".bss",
+                                             obj->efile.global_bss);
+       if (obj->efile.data_shndx >= 0 && !err)
+               err = bpf_object__init_global(obj, i++, RELO_DATA, ".data",
+                                             obj->efile.global_data);
+       if (obj->efile.rodata_shndx >= 0 && !err)
+               err = bpf_object__init_global(obj, i++, RELO_RODATA, ".rodata",
+                                             obj->efile.global_rodata);
Quoted 7 lines

Here we know exactly what type of map we are creating, so we can just directly pass all the required structs/flags/data.

Also, to speed up and simplify relocation processing below, I think it's better to store map indexes for each of available .bss, .data and .rodata maps, eliminating another need for having three different types of data relocations.

Yep, I'll clean this up.

Quoted 12 lines
Quoted 12 lines
tools/lib/bpf/libbpf.c +5 -0
+       return err;
+}
+
 static bool section_have_execinstr(struct bpf_object *obj, int idx)
 {
        Elf_Scn *scn;
@@ -865,6 +964,12 @@ static int bpf_object__elf_collect(struct bpf_object *obj, int flags)
                                        pr_warning("failed to alloc program %s (%s): %s",
                                                   name, obj->path, cp);
                                }
+                       } else if (strcmp(name, ".data") == 0) {
+                               obj->efile.global_data = data;
Quoted 8 lines

tools/lib/bpf/libbpf.c static int bpf_object__elf_collect(struct bpf_object *obj, int flags) · line 973

Quoted 5 lines
tools/lib/bpf/libbpf.c +4 -0
+                               obj->efile.data_shndx = idx;
+                       } else if (strcmp(name, ".rodata") == 0) {
+                               obj->efile.global_rodata = data;
+                               obj->efile.rodata_shndx = idx;
                        }

Previously if we encountered unknown PROGBITS section, we'd emit debug message about skipping section, should we add that message here?

Sounds reasonable, I'll add a similar 'skip section' debug output there.

Quoted 240 lines
Quoted 66 lines
tools/lib/bpf/libbpf.c +30 -2
                } else if (sh.sh_type == SHT_REL) {
                        void *reloc = obj->efile.reloc;
@@ -892,6 +997,9 @@ static int bpf_object__elf_collect(struct bpf_object *obj, int flags)
                                obj->efile.reloc[n].shdr = sh;
                                obj->efile.reloc[n].data = data;
                        }
+               } else if (sh.sh_type == SHT_NOBITS && strcmp(name, ".bss") == 0) {
+                       obj->efile.global_bss = data;
+                       obj->efile.bss_shndx = idx;
                } else {
                        pr_debug("skip section(%d) %s\n", idx, name);
                }
@@ -923,6 +1031,14 @@ static int bpf_object__elf_collect(struct bpf_object *obj, int flags)
                if (err)
                        goto out;
        }
+       if (obj->efile.data_shndx >= 0 ||
+           obj->efile.rodata_shndx >= 0 ||
+           obj->efile.bss_shndx >= 0) {
+               err = bpf_object__init_global_maps(obj);
+               if (err)
+                       goto out;
+       }
+
        err = bpf_object__init_prog_names(obj);
 out:
        return err;
@@ -961,6 +1077,11 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
        Elf_Data *symbols = obj->efile.symbols;
        int text_shndx = obj->efile.text_shndx;
        int maps_shndx = obj->efile.maps_shndx;
+       int data_shndx = obj->efile.data_shndx;
+       int rodata_shndx = obj->efile.rodata_shndx;
+       int bss_shndx = obj->efile.bss_shndx;
+       struct bpf_map *maps_global = obj->maps_global;
+       size_t nr_maps_global = obj->nr_maps_global;
        struct bpf_map *maps = obj->maps;
        size_t nr_maps = obj->nr_maps;
        int i, nrels;
@@ -999,8 +1120,10 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
                         (long long) (rel.r_info >> 32),
                         (long long) sym.st_value, sym.st_name);
 
-               if (sym.st_shndx != maps_shndx && sym.st_shndx != text_shndx) {
-                       pr_warning("Program '%s' contains non-map related relo data pointing to section %u\n",
+               if (sym.st_shndx != maps_shndx && sym.st_shndx != text_shndx &&
+                   sym.st_shndx != data_shndx && sym.st_shndx != rodata_shndx &&
+                   sym.st_shndx != bss_shndx) {
+                       pr_warning("Program '%s' contains unrecognized relo data pointing to section %u\n",
                                   prog->section_name, sym.st_shndx);
                        return -LIBBPF_ERRNO__RELOC;
                }
@@ -1045,6 +1168,30 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
                        prog->reloc_desc[i].type = RELO_LD64;
                        prog->reloc_desc[i].insn_idx = insn_idx;
                        prog->reloc_desc[i].map_idx = map_idx;
+               } else if (sym.st_shndx == data_shndx ||
+                          sym.st_shndx == rodata_shndx ||
+                          sym.st_shndx == bss_shndx) {
+                       int type = (sym.st_shndx == data_shndx)   ? RELO_DATA :
+                                  (sym.st_shndx == rodata_shndx) ? RELO_RODATA :
+                                                                   RELO_BSS;
+
+                       for (map_idx = 0; map_idx < nr_maps_global; map_idx++) {
+                               if (maps_global[map_idx].global_type == type) {
+                                       pr_debug("relocation: find map %zd (%s) for insn %u\n",

tools/lib/bpf/libbpf.c bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr, · line 1190

Quoted 10 lines
tools/lib/bpf/libbpf.c +10 -0
+                                                map_idx, maps_global[map_idx].name, insn_idx);
+                                       break;
+                               }
+                       }
+
+                       if (map_idx >= nr_maps_global) {
+                               pr_warning("bpf relocation: map_idx %d large than %d\n",
+                                          (int)map_idx, (int)nr_maps_global - 1);
+                               return -LIBBPF_ERRNO__RELOC;
+                       }

We don't need to handle all of this if we just remember global map indicies during creation, instead of calculating type, we can just pick correct index (and check it exists). And type can be just generic RELO_DATA.

Quoted 158 lines
tools/lib/bpf/libbpf.c +71 -38
+
+                       prog->reloc_desc[i].type = type;
+                       prog->reloc_desc[i].insn_idx = insn_idx;
+                       prog->reloc_desc[i].map_idx = map_idx;
                }
        }
        return 0;
@@ -1176,15 +1323,58 @@ bpf_object__probe_caps(struct bpf_object *obj)
 }
 
 static int
-bpf_object__create_maps(struct bpf_object *obj)
+bpf_object__create_map(struct bpf_object *obj, struct bpf_map *map)
 {
        struct bpf_create_map_attr create_attr = {};
+       struct bpf_map_def *def = &map->def;
+       char *cp, errmsg[STRERR_BUFSIZE];
+       int fd;
+
+       if (obj->caps.name)
+               create_attr.name = map->name;
+       create_attr.map_ifindex = map->map_ifindex;
+       create_attr.map_type = def->type;
+       create_attr.map_flags = def->map_flags;
+       create_attr.key_size = def->key_size;
+       create_attr.value_size = def->value_size;
+       create_attr.max_entries = def->max_entries;
+       create_attr.btf_fd = 0;
+       create_attr.btf_key_type_id = 0;
+       create_attr.btf_value_type_id = 0;
+       if (bpf_map_type__is_map_in_map(def->type) &&
+           map->inner_map_fd >= 0)
+               create_attr.inner_map_fd = map->inner_map_fd;
+       if (obj->btf && !bpf_map_find_btf_info(map, obj->btf)) {
+               create_attr.btf_fd = btf__fd(obj->btf);
+               create_attr.btf_key_type_id = map->btf_key_type_id;
+               create_attr.btf_value_type_id = map->btf_value_type_id;
+       }
+
+       fd = bpf_create_map_xattr(&create_attr);
+       if (fd < 0 && create_attr.btf_key_type_id) {
+               cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
+               pr_warning("Error in bpf_create_map_xattr(%s):%s(%d). Retrying without BTF.\n",
+                          map->name, cp, errno);
+
+               create_attr.btf_fd = 0;
+               create_attr.btf_key_type_id = 0;
+               create_attr.btf_value_type_id = 0;
+               map->btf_key_type_id = 0;
+               map->btf_value_type_id = 0;
+               fd = bpf_create_map_xattr(&create_attr);
+       }
+
+       return fd;
+}
+
+static int
+bpf_object__create_maps(struct bpf_object *obj)
+{
        unsigned int i;
        int err;
 
        for (i = 0; i < obj->nr_maps; i++) {
                struct bpf_map *map = &obj->maps[i];
-               struct bpf_map_def *def = &map->def;
                char *cp, errmsg[STRERR_BUFSIZE];
                int *pfd = &map->fd;
 
@@ -1193,41 +1383,7 @@ bpf_object__create_maps(struct bpf_object *obj)
                                 map->name, map->fd);
                        continue;
                }
-
-               if (obj->caps.name)
-                       create_attr.name = map->name;
-               create_attr.map_ifindex = map->map_ifindex;
-               create_attr.map_type = def->type;
-               create_attr.map_flags = def->map_flags;
-               create_attr.key_size = def->key_size;
-               create_attr.value_size = def->value_size;
-               create_attr.max_entries = def->max_entries;
-               create_attr.btf_fd = 0;
-               create_attr.btf_key_type_id = 0;
-               create_attr.btf_value_type_id = 0;
-               if (bpf_map_type__is_map_in_map(def->type) &&
-                   map->inner_map_fd >= 0)
-                       create_attr.inner_map_fd = map->inner_map_fd;
-
-               if (obj->btf && !bpf_map_find_btf_info(map, obj->btf)) {
-                       create_attr.btf_fd = btf__fd(obj->btf);
-                       create_attr.btf_key_type_id = map->btf_key_type_id;
-                       create_attr.btf_value_type_id = map->btf_value_type_id;
-               }
-
-               *pfd = bpf_create_map_xattr(&create_attr);
-               if (*pfd < 0 && create_attr.btf_key_type_id) {
-                       cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
-                       pr_warning("Error in bpf_create_map_xattr(%s):%s(%d). Retrying without BTF.\n",
-                                  map->name, cp, errno);
-                       create_attr.btf_fd = 0;
-                       create_attr.btf_key_type_id = 0;
-                       create_attr.btf_value_type_id = 0;
-                       map->btf_key_type_id = 0;
-                       map->btf_value_type_id = 0;
-                       *pfd = bpf_create_map_xattr(&create_attr);
-               }
-
+               *pfd = bpf_object__create_map(obj, map);
                if (*pfd < 0) {
                        size_t j;
 
@@ -1412,6 +1568,24 @@ bpf_program__relocate(struct bpf_program *prog, struct bpf_object *obj)
                                                      &prog->reloc_desc[i]);
                        if (err)
                                return err;
+               } else if (prog->reloc_desc[i].type == RELO_DATA ||
+                          prog->reloc_desc[i].type == RELO_RODATA ||
+                          prog->reloc_desc[i].type == RELO_BSS) {
+                       struct bpf_insn *insns = prog->insns;
+                       int insn_idx, map_idx, data_off;
+
+                       insn_idx = prog->reloc_desc[i].insn_idx;
+                       map_idx  = prog->reloc_desc[i].map_idx;
+                       data_off = insns[insn_idx].imm;
+
+                       if (insn_idx + 1 >= (int)prog->insns_cnt) {
+                               pr_warning("relocation out of range: '%s'\n",
+                                          prog->section_name);
+                               return -LIBBPF_ERRNO__RELOC;
+                       }
+                       insns[insn_idx].src_reg = BPF_PSEUDO_MAP_VALUE;
+                       insns[insn_idx].imm = obj->maps_global[map_idx].fd;
+                       insns[insn_idx + 1].imm = data_off;
                }
        }
 
@@ -1717,6 +1891,7 @@ __bpf_object__open(const char *path, void *obj_buf, size_t obj_buf_sz,
 
        CHECK_ERR(bpf_object__elf_init(obj), err, out);
        CHECK_ERR(bpf_object__check_endianness(obj), err, out);
+       CHECK_ERR(bpf_object__probe_caps(obj), err, out);
        CHECK_ERR(bpf_object__elf_collect(obj, flags), err, out);
        CHECK_ERR(bpf_object__collect_reloc(obj), err, out);
        CHECK_ERR(bpf_object__validate(obj, needs_kver), err, out);
@@ -1789,7 +1964,8 @@ int bpf_object__unload(struct bpf_object *obj)
 
        for (i = 0; i < obj->nr_maps; i++)
                zclose(obj->maps[i].fd);
-
+       for (i = 0; i < obj->nr_maps_global; i++)
+               zclose(obj->maps_global[i].fd);
        for (i = 0; i < obj->nr_programs; i++)
                bpf_program__unload(&obj->programs[i]);
 
@@ -1810,7 +1986,6 @@ int bpf_object__load(struct bpf_object *obj)
 
        obj->loaded = true;
 
Quoted 11 lines
Quoted 7 lines
tools/lib/bpf/libbpf.c +0 -2
-       CHECK_ERR(bpf_object__probe_caps(obj), err, out);
        CHECK_ERR(bpf_object__create_maps(obj), err, out);
        CHECK_ERR(bpf_object__relocate(obj), err, out);
        CHECK_ERR(bpf_object__load_progs(obj), err, out);
--

2.17.1

I'm sorry if I seem a bit too obsessed with those three new relocation types. I just believe that having one generic and storing global maps along with other maps is cleaner and more uniform.

No worries, thanks for all your feedback and review!

Thanks,
Daniel

#31 lore raw

Re: [PATCH bpf-next v2 5/7] bpf, libbpf: support global data/bss/rodata sections

In reply to Daniel Borkmann
Quoted 208 lines · Daniel Borkmann

This work adds BPF loader support for global data sections to libbpf. This allows to write BPF programs in more natural C-like way by being able to define global variables and const data.

Back at LPC 2018 [0] we presented a first prototype which implemented support for global data sections by extending BPF syscall where union bpf_attr would get additional memory/size pair for each section passed during prog load in order to later add this base address into the ldimm64 instruction along with the user provided offset when accessing a variable. Consensus from LPC was that for proper upstream support, it would be more desirable to use maps instead of bpf_attr extension as this would allow for introspection of these sections as well as potential life updates of their content. This work follows this path by taking the following steps from loader side:

1) In bpf_object__elf_collect() step we pick up ".data", ".rodata", and ".bss" section information.

2) If present, in bpf_object__init_global_maps() we create a map that corresponds to each of the present sections. Given section size and access properties can differ, a single entry array map is created with value size that is corresponding to the ELF section size of .data, .bss or .rodata. In the latter case, the map is created as read-only from program side such that verifier rejects any write attempts into .rodata. In a subsequent step, for .data and .rodata sections, the section content is copied into the map through bpf_map_update_elem(). For .bss this is not necessary since array map is already zero-initialized by default.

3) In bpf_program__collect_reloc() step, we record the corresponding map, insn index, and relocation type for the global data.

4) And last but not least in the actual relocation step in bpf_program__relocate(), we mark the ldimm64 instruction with src_reg = BPF_PSEUDO_MAP_VALUE where in the first imm field the map's file descriptor is stored as similarly done as in BPF_PSEUDO_MAP_FD, and in the second imm field (as ldimm64 is 2-insn wide) we store the access offset into the section.

5) On kernel side, this special marked BPF_PSEUDO_MAP_VALUE load will then store the actual target address in order to have a 'map-lookup'-free access. That is, the actual map value base address + offset. The destination register in the verifier will then be marked as PTR_TO_MAP_VALUE, containing the fixed offset as reg->off and backing BPF map as reg->map_ptr. Meaning, it's treated as any other normal map value from verification side, only with efficient, direct value access instead of actual call to map lookup helper as in the typical case.

Simple example dump of program using globals vars in each section:

   # readelf -a test_global_data.o
   [...]
   [ 6] .bss              NOBITS           0000000000000000  00000328
        0000000000000010  0000000000000000  WA       0     0     8
   [ 7] .data             PROGBITS         0000000000000000  00000328
        0000000000000010  0000000000000000  WA       0     0     8
   [ 8] .rodata           PROGBITS         0000000000000000  00000338
        0000000000000018  0000000000000000   A       0     0     8
   [...]
     95: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    6 static_bss
     96: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    6 static_bss2
     97: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    7 static_data
     98: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    7 static_data2
     99: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    8 static_rodata
    100: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    8 static_rodata2
    101: 0000000000000010     8 OBJECT  LOCAL  DEFAULT    8 static_rodata3
   [...]
   # bpftool prog
   103: sched_cls  name load_static_dat  tag 37a8b6822fc39a29  gpl
        loaded_at 2019-02-28T02:02:35+0000  uid 0
        xlated 712B  jited 426B  memlock 4096B  map_ids 63,64,65,66
   # bpftool map show id 63
   63: array  name .bss  flags 0x0                      <-- .bss area, rw
       key 4B  value 16B  max_entries 1  memlock 4096B
   # bpftool map show id 64
   64: array  name .data  flags 0x0                     <-- .data area, rw
       key 4B  value 16B  max_entries 1  memlock 4096B
   # bpftool map show id 65
   65: array  name .rodata  flags 0x80                  <-- .rodata area, ro
       key 4B  value 24B  max_entries 1  memlock 4096B
   # bpftool prog dump xlated id 103
   int load_static_data(struct __sk_buff * skb):
   ; int load_static_data(struct __sk_buff *skb)
      0: (b7) r1 = 0
   ; key = 0;
      1: (63) *(u32 *)(r10 -4) = r1
      2: (bf) r6 = r10
   ; int load_static_data(struct __sk_buff *skb)
      3: (07) r6 += -4
   ; bpf_map_update_elem(&result, &key, &static_bss, 0);
      4: (18) r1 = map[id:66]
      6: (bf) r2 = r6
      7: (18) r3 = map[id:63][0]+0         <-- direct static_bss addr in .bss area
      9: (b7) r4 = 0
     10: (85) call array_map_update_elem#99888
     11: (b7) r1 = 1
   ; key = 1;
     12: (63) *(u32 *)(r10 -4) = r1
   ; bpf_map_update_elem(&result, &key, &static_data, 0);
     13: (18) r1 = map[id:66]
     15: (bf) r2 = r6
     16: (18) r3 = map[id:64][0]+0         <-- direct static_data addr in .data area
     18: (b7) r4 = 0
     19: (85) call array_map_update_elem#99888
     20: (b7) r1 = 2
   ; key = 2;
     21: (63) *(u32 *)(r10 -4) = r1
   ; bpf_map_update_elem(&result, &key, &static_rodata, 0);
     22: (18) r1 = map[id:66]
     24: (bf) r2 = r6
     25: (18) r3 = map[id:65][0]+0         <-- direct static_rodata addr in .rodata area
     27: (b7) r4 = 0
     28: (85) call array_map_update_elem#99888
     29: (b7) r1 = 3
   ; key = 3;
     30: (63) *(u32 *)(r10 -4) = r1
   ; bpf_map_update_elem(&result, &key, &static_bss2, 0);
     31: (18) r7 = map[id:63][0]+8         <--.
     33: (18) r1 = map[id:66]                 |
     35: (bf) r2 = r6                         |
     36: (18) r3 = map[id:63][0]+8         <-- direct static_bss2 addr in .bss area
     38: (b7) r4 = 0
     39: (85) call array_map_update_elem#99888
   [...]

For now .data/.rodata/.bss maps are not exposed via API to the user, but this could be done in a subsequent step.

Based upon recent fix in LLVM, commit c0db6b6bd444 ("[BPF] Don't fail for static variables").

Joint work with Joe Stringer.

[0] LPC 2018, BPF track, "ELF relocation for static data in BPF",

       http://vger.kernel.org/lpc-bpf2018.html#session-3
---
  tools/include/uapi/linux/bpf.h |  10 +-
  tools/lib/bpf/libbpf.c         | 259 +++++++++++++++++++++++++++------
  2 files changed, 226 insertions(+), 43 deletions(-)
tools/include/uapi/linux/bpf.h +28 -2
index 8884072e1a46..04b26f59b413 100644
@@ -287,7 +287,7 @@ enum bpf_attach_type {
[...]
@@ -999,8 +1120,10 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
  			 (long long) (rel.r_info >> 32),
  			 (long long) sym.st_value, sym.st_name);
 
-		if (sym.st_shndx != maps_shndx && sym.st_shndx != text_shndx) {
-			pr_warning("Program '%s' contains non-map related relo data pointing to section %u\n",
+		if (sym.st_shndx != maps_shndx && sym.st_shndx != text_shndx &&
+		    sym.st_shndx != data_shndx && sym.st_shndx != rodata_shndx &&
+		    sym.st_shndx != bss_shndx) {
+			pr_warning("Program '%s' contains unrecognized relo data pointing to section %u\n",
  				   prog->section_name, sym.st_shndx);
  			return -LIBBPF_ERRNO__RELOC;
  		}
@@ -1045,6 +1168,30 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
  			prog->reloc_desc[i].type = RELO_LD64;
  			prog->reloc_desc[i].insn_idx = insn_idx;
  			prog->reloc_desc[i].map_idx = map_idx;
+		} else if (sym.st_shndx == data_shndx ||
+			   sym.st_shndx == rodata_shndx ||
+			   sym.st_shndx == bss_shndx) {
+			int type = (sym.st_shndx == data_shndx)   ? RELO_DATA :
+				   (sym.st_shndx == rodata_shndx) ? RELO_RODATA :
+								    RELO_BSS;
+
+			for (map_idx = 0; map_idx < nr_maps_global; map_idx++) {
+				if (maps_global[map_idx].global_type == type) {
+					pr_debug("relocation: find map %zd (%s) for insn %u\n",
+						 map_idx, maps_global[map_idx].name, insn_idx);
+					break;
+				}
+			}
+
+			if (map_idx >= nr_maps_global) {
+				pr_warning("bpf relocation: map_idx %d large than %d\n",
+					   (int)map_idx, (int)nr_maps_global - 1);
+				return -LIBBPF_ERRNO__RELOC;
+			}
+
+			prog->reloc_desc[i].type = type;
+			prog->reloc_desc[i].insn_idx = insn_idx;
+			prog->reloc_desc[i].map_idx = map_idx;
  		}
  	}
  	return 0;
@@ -1176,15 +1323,58 @@ bpf_object__probe_caps(struct bpf_object *obj)
  }
 
  static int

[...]

Quoted 59 lines
tools/include/uapi/linux/bpf.h +5 -36
+
+static int
+bpf_object__create_maps(struct bpf_object *obj)
+{
  	unsigned int i;
  	int err;
 
  	for (i = 0; i < obj->nr_maps; i++) {
  		struct bpf_map *map = &obj->maps[i];
-		struct bpf_map_def *def = &map->def;
  		char *cp, errmsg[STRERR_BUFSIZE];
  		int *pfd = &map->fd;
@@ -1193,41 +1383,7 @@ bpf_object__create_maps(struct bpf_object *obj)
  				 map->name, map->fd);
  			continue;
  		}
-
-		if (obj->caps.name)
-			create_attr.name = map->name;
-		create_attr.map_ifindex = map->map_ifindex;
-		create_attr.map_type = def->type;
-		create_attr.map_flags = def->map_flags;
-		create_attr.key_size = def->key_size;
-		create_attr.value_size = def->value_size;
-		create_attr.max_entries = def->max_entries;
-		create_attr.btf_fd = 0;
-		create_attr.btf_key_type_id = 0;
-		create_attr.btf_value_type_id = 0;
-		if (bpf_map_type__is_map_in_map(def->type) &&
-		    map->inner_map_fd >= 0)
-			create_attr.inner_map_fd = map->inner_map_fd;
-
-		if (obj->btf && !bpf_map_find_btf_info(map, obj->btf)) {
-			create_attr.btf_fd = btf__fd(obj->btf);
-			create_attr.btf_key_type_id = map->btf_key_type_id;
-			create_attr.btf_value_type_id = map->btf_value_type_id;
-		}
-
-		*pfd = bpf_create_map_xattr(&create_attr);
-		if (*pfd < 0 && create_attr.btf_key_type_id) {
-			cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
-			pr_warning("Error in bpf_create_map_xattr(%s):%s(%d). Retrying without BTF.\n",
-				   map->name, cp, errno);
-			create_attr.btf_fd = 0;
-			create_attr.btf_key_type_id = 0;
-			create_attr.btf_value_type_id = 0;
-			map->btf_key_type_id = 0;
-			map->btf_value_type_id = 0;
-			*pfd = bpf_create_map_xattr(&create_attr);
-		}
-
+		*pfd = bpf_object__create_map(obj, map);
  		if (*pfd < 0) {
  			size_t j;
 
@@ -1412,6 +1568,24 @@ bpf_program__relocate(struct bpf_program *prog, struct bpf_object *obj)
  						      &prog->reloc_desc[i]);
  			if (err)

tools/include/uapi/linux/bpf.h bpf_program__relocate(struct bpf_program *prog, struct bpf_object *obj) · line 1579

Quoted 10 lines
tools/include/uapi/linux/bpf.h +9 -0
  				return err;
+		} else if (prog->reloc_desc[i].type == RELO_DATA ||
+			   prog->reloc_desc[i].type == RELO_RODATA ||
+			   prog->reloc_desc[i].type == RELO_BSS) {
+			struct bpf_insn *insns = prog->insns;
+			int insn_idx, map_idx, data_off;
+
+			insn_idx = prog->reloc_desc[i].insn_idx;
+			map_idx  = prog->reloc_desc[i].map_idx;
+			data_off = insns[insn_idx].imm;

I want to point to a subtle difference here between handling pure global variables and static global variables. The "imm" value is only available for static variables. For example,

-bash-4.4$ cat g.c
static volatile long sg = 2;
static volatile int si = 3;
long g = 4;
int i = 5;
int test() { return sg + si + g + i; }
-bash-4.4$
-bash-4.4$ clang -target bpf -O2 -c g.c

-bash-4.4$ readelf -s g.o

Symbol table '.symtab' contains 8 entries:

    Num:    Value          Size Type    Bind   Vis      Ndx Name
      0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
      1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS g.c
      2: 0000000000000010     8 OBJECT  LOCAL  DEFAULT    4 sg
      3: 0000000000000018     4 OBJECT  LOCAL  DEFAULT    4 si
      4: 0000000000000000     0 SECTION LOCAL  DEFAULT    4
      5: 0000000000000000     8 OBJECT  GLOBAL DEFAULT    4 g
      6: 0000000000000008     4 OBJECT  GLOBAL DEFAULT    4 i
      7: 0000000000000000   128 FUNC    GLOBAL DEFAULT    2 test

-bash-4.4$
-bash-4.4$ llvm-readelf -r g.o

Relocation section '.rel.text' at offset 0x1d8 contains 4 entries:
Offset Info Type Symbol's
Value Symbol's Name
0000000000000000 0000000400000001 R_BPF_64_64 0000000000000000 .data
0000000000000018 0000000400000001 R_BPF_64_64 0000000000000000 .data

0000000000000038  0000000500000001 R_BPF_64_64            0000000000000000 g
0000000000000058  0000000600000001 R_BPF_64_64            0000000000000008 i

-bash-4.4$ llvm-objdump -d g.o

g.o: file format ELF64-BPF

Disassembly of section .text:
0000000000000000 test:

        0:       18 01 00 00 10 00 00 00 00 00 00 00 00 00 00 00 
r1 = 16 ll
        2:       79 11 00 00 00 00 00 00         r1 = *(u64 *)(r1 + 0)
        3:       18 02 00 00 18 00 00 00 00 00 00 00 00 00 00 00 
r2 = 24 ll
        5:       61 22 00 00 00 00 00 00         r2 = *(u32 *)(r2 + 0)
        6:       0f 21 00 00 00 00 00 00         r1 += r2
        7:       18 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
r2 = 0 ll
        9:       79 22 00 00 00 00 00 00         r2 = *(u64 *)(r2 + 0)
       10:       0f 21 00 00 00 00 00 00         r1 += r2
       11:       18 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
r2 = 0 ll
       13:       61 20 00 00 00 00 00 00         r0 = *(u32 *)(r2 + 0)
       14:       0f 10 00 00 00 00 00 00         r0 += r1
       15:       95 00 00 00 00 00 00 00         exit

-bash-4.4$

You can see the above, the non-static global access does not have its in-section offset encoded in the insn itself. The difference is due to llvm treating static global and non-static global differently.

To support both cases, during relocation recording stage, you can also record:
. symbol binding (GELF_ST_BIND(sym.st_info)),
non-static global has binding STB_GLOBAL and static global has binding STB_LOCAL
. symbol value (sym.st_value)

During the above relocation resolution, if symbol bind is local, do what you already did here. If symbol bind is global, assign data_off with symbol value.

This applied to both .data and .rodata sections.

The non initialized
global variable will not be in any allocated section in ELF file, it is in a COM section which is to be allocated by loader. So user defines some like

    int g;

and later on uses it. Right now, it will not work. The workaround is "int g = 4", or "static int g". I guess it should be okay, we should encourage users to use "static" variables instead.

Quoted 39 lines
tools/include/uapi/linux/bpf.h +12 -2
+
+			if (insn_idx + 1 >= (int)prog->insns_cnt) {
+				pr_warning("relocation out of range: '%s'\n",
+					   prog->section_name);
+				return -LIBBPF_ERRNO__RELOC;
+			}
+			insns[insn_idx].src_reg = BPF_PSEUDO_MAP_VALUE;
+			insns[insn_idx].imm = obj->maps_global[map_idx].fd;
+			insns[insn_idx + 1].imm = data_off;
  		}
  	}
 
@@ -1717,6 +1891,7 @@ __bpf_object__open(const char *path, void *obj_buf, size_t obj_buf_sz,
 
  	CHECK_ERR(bpf_object__elf_init(obj), err, out);
  	CHECK_ERR(bpf_object__check_endianness(obj), err, out);
+	CHECK_ERR(bpf_object__probe_caps(obj), err, out);
  	CHECK_ERR(bpf_object__elf_collect(obj, flags), err, out);
  	CHECK_ERR(bpf_object__collect_reloc(obj), err, out);
  	CHECK_ERR(bpf_object__validate(obj, needs_kver), err, out);
@@ -1789,7 +1964,8 @@ int bpf_object__unload(struct bpf_object *obj)
 
  	for (i = 0; i < obj->nr_maps; i++)
  		zclose(obj->maps[i].fd);
-
+	for (i = 0; i < obj->nr_maps_global; i++)
+		zclose(obj->maps_global[i].fd);
  	for (i = 0; i < obj->nr_programs; i++)
  		bpf_program__unload(&obj->programs[i]);
 
@@ -1810,7 +1986,6 @@ int bpf_object__load(struct bpf_object *obj)
 
  	obj->loaded = true;
 
-	CHECK_ERR(bpf_object__probe_caps(obj), err, out);
  	CHECK_ERR(bpf_object__create_maps(obj), err, out);
  	CHECK_ERR(bpf_object__relocate(obj), err, out);
  	CHECK_ERR(bpf_object__load_progs(obj), err, out);
#32 lore raw

Re: [PATCH bpf-next v2 5/7] bpf, libbpf: support global data/bss/rodata sections

Quoted 362 lines · Yonghong Song
Quoted 208 lines · Daniel Borkmann

This work adds BPF loader support for global data sections to libbpf. This allows to write BPF programs in more natural C-like way by being able to define global variables and const data.

Back at LPC 2018 [0] we presented a first prototype which implemented support for global data sections by extending BPF syscall where union bpf_attr would get additional memory/size pair for each section passed during prog load in order to later add this base address into the ldimm64 instruction along with the user provided offset when accessing a variable. Consensus from LPC was that for proper upstream support, it would be more desirable to use maps instead of bpf_attr extension as this would allow for introspection of these sections as well as potential life updates of their content. This work follows this path by taking the following steps from loader side:

1) In bpf_object__elf_collect() step we pick up ".data", ".rodata", and ".bss" section information.

2) If present, in bpf_object__init_global_maps() we create a map that corresponds to each of the present sections. Given section size and access properties can differ, a single entry array map is created with value size that is corresponding to the ELF section size of .data, .bss or .rodata. In the latter case, the map is created as read-only from program side such that verifier rejects any write attempts into .rodata. In a subsequent step, for .data and .rodata sections, the section content is copied into the map through bpf_map_update_elem(). For .bss this is not necessary since array map is already zero-initialized by default.

3) In bpf_program__collect_reloc() step, we record the corresponding map, insn index, and relocation type for the global data.

4) And last but not least in the actual relocation step in bpf_program__relocate(), we mark the ldimm64 instruction with src_reg = BPF_PSEUDO_MAP_VALUE where in the first imm field the map's file descriptor is stored as similarly done as in BPF_PSEUDO_MAP_FD, and in the second imm field (as ldimm64 is 2-insn wide) we store the access offset into the section.

5) On kernel side, this special marked BPF_PSEUDO_MAP_VALUE load will then store the actual target address in order to have a 'map-lookup'-free access. That is, the actual map value base address + offset. The destination register in the verifier will then be marked as PTR_TO_MAP_VALUE, containing the fixed offset as reg->off and backing BPF map as reg->map_ptr. Meaning, it's treated as any other normal map value from verification side, only with efficient, direct value access instead of actual call to map lookup helper as in the typical case.

Simple example dump of program using globals vars in each section:

   # readelf -a test_global_data.o
   [...]
   [ 6] .bss              NOBITS           0000000000000000  00000328
        0000000000000010  0000000000000000  WA       0     0     8
   [ 7] .data             PROGBITS         0000000000000000  00000328
        0000000000000010  0000000000000000  WA       0     0     8
   [ 8] .rodata           PROGBITS         0000000000000000  00000338
        0000000000000018  0000000000000000   A       0     0     8
   [...]
     95: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    6 static_bss
     96: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    6 static_bss2
     97: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    7 static_data
     98: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    7 static_data2
     99: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    8 static_rodata
    100: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    8 static_rodata2
    101: 0000000000000010     8 OBJECT  LOCAL  DEFAULT    8 static_rodata3
   [...]
   # bpftool prog
   103: sched_cls  name load_static_dat  tag 37a8b6822fc39a29  gpl
        loaded_at 2019-02-28T02:02:35+0000  uid 0
        xlated 712B  jited 426B  memlock 4096B  map_ids 63,64,65,66
   # bpftool map show id 63
   63: array  name .bss  flags 0x0                      <-- .bss area, rw
       key 4B  value 16B  max_entries 1  memlock 4096B
   # bpftool map show id 64
   64: array  name .data  flags 0x0                     <-- .data area, rw
       key 4B  value 16B  max_entries 1  memlock 4096B
   # bpftool map show id 65
   65: array  name .rodata  flags 0x80                  <-- .rodata area, ro
       key 4B  value 24B  max_entries 1  memlock 4096B
   # bpftool prog dump xlated id 103
   int load_static_data(struct __sk_buff * skb):
   ; int load_static_data(struct __sk_buff *skb)
      0: (b7) r1 = 0
   ; key = 0;
      1: (63) *(u32 *)(r10 -4) = r1
      2: (bf) r6 = r10
   ; int load_static_data(struct __sk_buff *skb)
      3: (07) r6 += -4
   ; bpf_map_update_elem(&result, &key, &static_bss, 0);
      4: (18) r1 = map[id:66]
      6: (bf) r2 = r6
      7: (18) r3 = map[id:63][0]+0         <-- direct static_bss addr in .bss area
      9: (b7) r4 = 0
     10: (85) call array_map_update_elem#99888
     11: (b7) r1 = 1
   ; key = 1;
     12: (63) *(u32 *)(r10 -4) = r1
   ; bpf_map_update_elem(&result, &key, &static_data, 0);
     13: (18) r1 = map[id:66]
     15: (bf) r2 = r6
     16: (18) r3 = map[id:64][0]+0         <-- direct static_data addr in .data area
     18: (b7) r4 = 0
     19: (85) call array_map_update_elem#99888
     20: (b7) r1 = 2
   ; key = 2;
     21: (63) *(u32 *)(r10 -4) = r1
   ; bpf_map_update_elem(&result, &key, &static_rodata, 0);
     22: (18) r1 = map[id:66]
     24: (bf) r2 = r6
     25: (18) r3 = map[id:65][0]+0         <-- direct static_rodata addr in .rodata area
     27: (b7) r4 = 0
     28: (85) call array_map_update_elem#99888
     29: (b7) r1 = 3
   ; key = 3;
     30: (63) *(u32 *)(r10 -4) = r1
   ; bpf_map_update_elem(&result, &key, &static_bss2, 0);
     31: (18) r7 = map[id:63][0]+8         <--.
     33: (18) r1 = map[id:66]                 |
     35: (bf) r2 = r6                         |
     36: (18) r3 = map[id:63][0]+8         <-- direct static_bss2 addr in .bss area
     38: (b7) r4 = 0
     39: (85) call array_map_update_elem#99888
   [...]

For now .data/.rodata/.bss maps are not exposed via API to the user, but this could be done in a subsequent step.

Based upon recent fix in LLVM, commit c0db6b6bd444 ("[BPF] Don't fail for static variables").

Joint work with Joe Stringer.

[0] LPC 2018, BPF track, "ELF relocation for static data in BPF",

       http://vger.kernel.org/lpc-bpf2018.html#session-3
---
  tools/include/uapi/linux/bpf.h |  10 +-
  tools/lib/bpf/libbpf.c         | 259 +++++++++++++++++++++++++++------
  2 files changed, 226 insertions(+), 43 deletions(-)
tools/include/uapi/linux/bpf.h +28 -2
index 8884072e1a46..04b26f59b413 100644
@@ -287,7 +287,7 @@ enum bpf_attach_type {
[...]
@@ -999,8 +1120,10 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
                       (long long) (rel.r_info >> 32),
                       (long long) sym.st_value, sym.st_name);
 
-             if (sym.st_shndx != maps_shndx && sym.st_shndx != text_shndx) {
-                     pr_warning("Program '%s' contains non-map related relo data pointing to section %u\n",
+             if (sym.st_shndx != maps_shndx && sym.st_shndx != text_shndx &&
+                 sym.st_shndx != data_shndx && sym.st_shndx != rodata_shndx &&
+                 sym.st_shndx != bss_shndx) {
+                     pr_warning("Program '%s' contains unrecognized relo data pointing to section %u\n",
                                 prog->section_name, sym.st_shndx);
                      return -LIBBPF_ERRNO__RELOC;
              }
@@ -1045,6 +1168,30 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
                      prog->reloc_desc[i].type = RELO_LD64;
                      prog->reloc_desc[i].insn_idx = insn_idx;
                      prog->reloc_desc[i].map_idx = map_idx;
+             } else if (sym.st_shndx == data_shndx ||
+                        sym.st_shndx == rodata_shndx ||
+                        sym.st_shndx == bss_shndx) {
+                     int type = (sym.st_shndx == data_shndx)   ? RELO_DATA :
+                                (sym.st_shndx == rodata_shndx) ? RELO_RODATA :
+                                                                 RELO_BSS;
+
+                     for (map_idx = 0; map_idx < nr_maps_global; map_idx++) {
+                             if (maps_global[map_idx].global_type == type) {
+                                     pr_debug("relocation: find map %zd (%s) for insn %u\n",
+                                              map_idx, maps_global[map_idx].name, insn_idx);
+                                     break;
+                             }
+                     }
+
+                     if (map_idx >= nr_maps_global) {
+                             pr_warning("bpf relocation: map_idx %d large than %d\n",
+                                        (int)map_idx, (int)nr_maps_global - 1);
+                             return -LIBBPF_ERRNO__RELOC;
+                     }
+
+                     prog->reloc_desc[i].type = type;
+                     prog->reloc_desc[i].insn_idx = insn_idx;
+                     prog->reloc_desc[i].map_idx = map_idx;
              }
      }
      return 0;
@@ -1176,15 +1323,58 @@ bpf_object__probe_caps(struct bpf_object *obj)
  }
 
  static int

[...]

Quoted 59 lines
tools/include/uapi/linux/bpf.h +5 -36
+
+static int
+bpf_object__create_maps(struct bpf_object *obj)
+{
      unsigned int i;
      int err;
 
      for (i = 0; i < obj->nr_maps; i++) {
              struct bpf_map *map = &obj->maps[i];
-             struct bpf_map_def *def = &map->def;
              char *cp, errmsg[STRERR_BUFSIZE];
              int *pfd = &map->fd;
@@ -1193,41 +1383,7 @@ bpf_object__create_maps(struct bpf_object *obj)
                               map->name, map->fd);
                      continue;
              }
-
-             if (obj->caps.name)
-                     create_attr.name = map->name;
-             create_attr.map_ifindex = map->map_ifindex;
-             create_attr.map_type = def->type;
-             create_attr.map_flags = def->map_flags;
-             create_attr.key_size = def->key_size;
-             create_attr.value_size = def->value_size;
-             create_attr.max_entries = def->max_entries;
-             create_attr.btf_fd = 0;
-             create_attr.btf_key_type_id = 0;
-             create_attr.btf_value_type_id = 0;
-             if (bpf_map_type__is_map_in_map(def->type) &&
-                 map->inner_map_fd >= 0)
-                     create_attr.inner_map_fd = map->inner_map_fd;
-
-             if (obj->btf && !bpf_map_find_btf_info(map, obj->btf)) {
-                     create_attr.btf_fd = btf__fd(obj->btf);
-                     create_attr.btf_key_type_id = map->btf_key_type_id;
-                     create_attr.btf_value_type_id = map->btf_value_type_id;
-             }
-
-             *pfd = bpf_create_map_xattr(&create_attr);
-             if (*pfd < 0 && create_attr.btf_key_type_id) {
-                     cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
-                     pr_warning("Error in bpf_create_map_xattr(%s):%s(%d). Retrying without BTF.\n",
-                                map->name, cp, errno);
-                     create_attr.btf_fd = 0;
-                     create_attr.btf_key_type_id = 0;
-                     create_attr.btf_value_type_id = 0;
-                     map->btf_key_type_id = 0;
-                     map->btf_value_type_id = 0;
-                     *pfd = bpf_create_map_xattr(&create_attr);
-             }
-
+             *pfd = bpf_object__create_map(obj, map);
              if (*pfd < 0) {
                      size_t j;
 
@@ -1412,6 +1568,24 @@ bpf_program__relocate(struct bpf_program *prog, struct bpf_object *obj)
                                                    &prog->reloc_desc[i]);
                      if (err)

tools/include/uapi/linux/bpf.h bpf_program__relocate(struct bpf_program *prog, struct bpf_object *obj) · line 1579

Quoted 10 lines
tools/include/uapi/linux/bpf.h +9 -0
                              return err;
+             } else if (prog->reloc_desc[i].type == RELO_DATA ||
+                        prog->reloc_desc[i].type == RELO_RODATA ||
+                        prog->reloc_desc[i].type == RELO_BSS) {
+                     struct bpf_insn *insns = prog->insns;
+                     int insn_idx, map_idx, data_off;
+
+                     insn_idx = prog->reloc_desc[i].insn_idx;
+                     map_idx  = prog->reloc_desc[i].map_idx;
+                     data_off = insns[insn_idx].imm;

I want to point to a subtle difference here between handling pure global variables and static global variables. The "imm" value is only available for static variables. For example,

-bash-4.4$ cat g.c
static volatile long sg = 2;
static volatile int si = 3;
long g = 4;
int i = 5;
int test() { return sg + si + g + i; }

(quoted diff) +0 -3
-bash-4.4$
-bash-4.4$ clang -target bpf -O2 -c g.c
 
-bash-4.4$ readelf -s g.o

Symbol table '.symtab' contains 8 entries:

    Num:    Value          Size Type    Bind   Vis      Ndx Name
      0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
      1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS g.c
      2: 0000000000000010     8 OBJECT  LOCAL  DEFAULT    4 sg
      3: 0000000000000018     4 OBJECT  LOCAL  DEFAULT    4 si
      4: 0000000000000000     0 SECTION LOCAL  DEFAULT    4
      5: 0000000000000000     8 OBJECT  GLOBAL DEFAULT    4 g
      6: 0000000000000008     4 OBJECT  GLOBAL DEFAULT    4 i
      7: 0000000000000000   128 FUNC    GLOBAL DEFAULT    2 test
(quoted diff) +0 -2
-bash-4.4$
-bash-4.4$ llvm-readelf -r g.o

Relocation section '.rel.text' at offset 0x1d8 contains 4 entries:
Offset Info Type Symbol's
Value Symbol's Name
0000000000000000 0000000400000001 R_BPF_64_64 0000000000000000 .data
0000000000000018 0000000400000001 R_BPF_64_64 0000000000000000 .data

0000000000000038  0000000500000001 R_BPF_64_64            0000000000000000 g
0000000000000058  0000000600000001 R_BPF_64_64            0000000000000008 i

-bash-4.4$ llvm-objdump -d g.o

g.o: file format ELF64-BPF

Disassembly of section .text:
0000000000000000 test:

        0:       18 01 00 00 10 00 00 00 00 00 00 00 00 00 00 00
r1 = 16 ll
        2:       79 11 00 00 00 00 00 00         r1 = *(u64 *)(r1 + 0)
        3:       18 02 00 00 18 00 00 00 00 00 00 00 00 00 00 00
r2 = 24 ll
        5:       61 22 00 00 00 00 00 00         r2 = *(u32 *)(r2 + 0)
        6:       0f 21 00 00 00 00 00 00         r1 += r2
        7:       18 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00
r2 = 0 ll
        9:       79 22 00 00 00 00 00 00         r2 = *(u64 *)(r2 + 0)
       10:       0f 21 00 00 00 00 00 00         r1 += r2
       11:       18 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00
r2 = 0 ll
       13:       61 20 00 00 00 00 00 00         r0 = *(u32 *)(r2 + 0)
       14:       0f 10 00 00 00 00 00 00         r0 += r1
       15:       95 00 00 00 00 00 00 00         exit

-bash-4.4$

You can see the above, the non-static global access does not have its in-section offset encoded in the insn itself. The difference is due to llvm treating static global and non-static global differently.

To support both cases, during relocation recording stage, you can also record:
. symbol binding (GELF_ST_BIND(sym.st_info)),
non-static global has binding STB_GLOBAL and static global has binding STB_LOCAL
. symbol value (sym.st_value)

During the above relocation resolution, if symbol bind is local, do what you already did here. If symbol bind is global, assign data_off with symbol value.

This applied to both .data and .rodata sections.

Quoted 8 lines

The non initialized
global variable will not be in any allocated section in ELF file, it is in a COM section which is to be allocated by loader. So user defines some like

    int g;

and later on uses it. Right now, it will not work. The workaround is "int g = 4", or "static int g". I guess it should be okay, we should encourage users to use "static" variables instead.

Would it be reasonable to just plain disable usage of uninitialized global variables, as it kind of goes against BPF's philosophy that everything should be written to, before can be read? So while we can just implicitly zero-out everything beforehand, it might be a good idea to remind and enforce that explictly?

Quoted 40 lines
Quoted 40 lines
tools/include/uapi/linux/bpf.h +12 -2
+
+                     if (insn_idx + 1 >= (int)prog->insns_cnt) {
+                             pr_warning("relocation out of range: '%s'\n",
+                                        prog->section_name);
+                             return -LIBBPF_ERRNO__RELOC;
+                     }
+                     insns[insn_idx].src_reg = BPF_PSEUDO_MAP_VALUE;
+                     insns[insn_idx].imm = obj->maps_global[map_idx].fd;
+                     insns[insn_idx + 1].imm = data_off;
              }
      }
 
@@ -1717,6 +1891,7 @@ __bpf_object__open(const char *path, void *obj_buf, size_t obj_buf_sz,
 
      CHECK_ERR(bpf_object__elf_init(obj), err, out);
      CHECK_ERR(bpf_object__check_endianness(obj), err, out);
+     CHECK_ERR(bpf_object__probe_caps(obj), err, out);
      CHECK_ERR(bpf_object__elf_collect(obj, flags), err, out);
      CHECK_ERR(bpf_object__collect_reloc(obj), err, out);
      CHECK_ERR(bpf_object__validate(obj, needs_kver), err, out);
@@ -1789,7 +1964,8 @@ int bpf_object__unload(struct bpf_object *obj)
 
      for (i = 0; i < obj->nr_maps; i++)
              zclose(obj->maps[i].fd);
-
+     for (i = 0; i < obj->nr_maps_global; i++)
+             zclose(obj->maps_global[i].fd);
      for (i = 0; i < obj->nr_programs; i++)
              bpf_program__unload(&obj->programs[i]);
 
@@ -1810,7 +1986,6 @@ int bpf_object__load(struct bpf_object *obj)
 
      obj->loaded = true;
 
-     CHECK_ERR(bpf_object__probe_caps(obj), err, out);
      CHECK_ERR(bpf_object__create_maps(obj), err, out);
      CHECK_ERR(bpf_object__relocate(obj), err, out);
      CHECK_ERR(bpf_object__load_progs(obj), err, out);
#33 lore raw

Re: [PATCH bpf-next v2 5/7] bpf, libbpf: support global data/bss/rodata sections

Quoted 363 lines · Andrii Nakryiko
Quoted 362 lines · Yonghong Song
Quoted 208 lines · Daniel Borkmann

This work adds BPF loader support for global data sections to libbpf. This allows to write BPF programs in more natural C-like way by being able to define global variables and const data.

Back at LPC 2018 [0] we presented a first prototype which implemented support for global data sections by extending BPF syscall where union bpf_attr would get additional memory/size pair for each section passed during prog load in order to later add this base address into the ldimm64 instruction along with the user provided offset when accessing a variable. Consensus from LPC was that for proper upstream support, it would be more desirable to use maps instead of bpf_attr extension as this would allow for introspection of these sections as well as potential life updates of their content. This work follows this path by taking the following steps from loader side:

1) In bpf_object__elf_collect() step we pick up ".data", ".rodata", and ".bss" section information.

2) If present, in bpf_object__init_global_maps() we create a map that corresponds to each of the present sections. Given section size and access properties can differ, a single entry array map is created with value size that is corresponding to the ELF section size of .data, .bss or .rodata. In the latter case, the map is created as read-only from program side such that verifier rejects any write attempts into .rodata. In a subsequent step, for .data and .rodata sections, the section content is copied into the map through bpf_map_update_elem(). For .bss this is not necessary since array map is already zero-initialized by default.

3) In bpf_program__collect_reloc() step, we record the corresponding map, insn index, and relocation type for the global data.

4) And last but not least in the actual relocation step in bpf_program__relocate(), we mark the ldimm64 instruction with src_reg = BPF_PSEUDO_MAP_VALUE where in the first imm field the map's file descriptor is stored as similarly done as in BPF_PSEUDO_MAP_FD, and in the second imm field (as ldimm64 is 2-insn wide) we store the access offset into the section.

5) On kernel side, this special marked BPF_PSEUDO_MAP_VALUE load will then store the actual target address in order to have a 'map-lookup'-free access. That is, the actual map value base address + offset. The destination register in the verifier will then be marked as PTR_TO_MAP_VALUE, containing the fixed offset as reg->off and backing BPF map as reg->map_ptr. Meaning, it's treated as any other normal map value from verification side, only with efficient, direct value access instead of actual call to map lookup helper as in the typical case.

Simple example dump of program using globals vars in each section:

    # readelf -a test_global_data.o
    [...]
    [ 6] .bss              NOBITS           0000000000000000  00000328
         0000000000000010  0000000000000000  WA       0     0     8
    [ 7] .data             PROGBITS         0000000000000000  00000328
         0000000000000010  0000000000000000  WA       0     0     8
    [ 8] .rodata           PROGBITS         0000000000000000  00000338
         0000000000000018  0000000000000000   A       0     0     8
    [...]
      95: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    6 static_bss
      96: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    6 static_bss2
      97: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    7 static_data
      98: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    7 static_data2
      99: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    8 static_rodata
     100: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    8 static_rodata2
     101: 0000000000000010     8 OBJECT  LOCAL  DEFAULT    8 static_rodata3
    [...]
    # bpftool prog
    103: sched_cls  name load_static_dat  tag 37a8b6822fc39a29  gpl
         loaded_at 2019-02-28T02:02:35+0000  uid 0
         xlated 712B  jited 426B  memlock 4096B  map_ids 63,64,65,66
    # bpftool map show id 63
    63: array  name .bss  flags 0x0                      <-- .bss area, rw
        key 4B  value 16B  max_entries 1  memlock 4096B
    # bpftool map show id 64
    64: array  name .data  flags 0x0                     <-- .data area, rw
        key 4B  value 16B  max_entries 1  memlock 4096B
    # bpftool map show id 65
    65: array  name .rodata  flags 0x80                  <-- .rodata area, ro
        key 4B  value 24B  max_entries 1  memlock 4096B
    # bpftool prog dump xlated id 103
    int load_static_data(struct __sk_buff * skb):
    ; int load_static_data(struct __sk_buff *skb)
       0: (b7) r1 = 0
    ; key = 0;
       1: (63) *(u32 *)(r10 -4) = r1
       2: (bf) r6 = r10
    ; int load_static_data(struct __sk_buff *skb)
       3: (07) r6 += -4
    ; bpf_map_update_elem(&result, &key, &static_bss, 0);
       4: (18) r1 = map[id:66]
       6: (bf) r2 = r6
       7: (18) r3 = map[id:63][0]+0         <-- direct static_bss addr in .bss area
       9: (b7) r4 = 0
      10: (85) call array_map_update_elem#99888
      11: (b7) r1 = 1
    ; key = 1;
      12: (63) *(u32 *)(r10 -4) = r1
    ; bpf_map_update_elem(&result, &key, &static_data, 0);
      13: (18) r1 = map[id:66]
      15: (bf) r2 = r6
      16: (18) r3 = map[id:64][0]+0         <-- direct static_data addr in .data area
      18: (b7) r4 = 0
      19: (85) call array_map_update_elem#99888
      20: (b7) r1 = 2
    ; key = 2;
      21: (63) *(u32 *)(r10 -4) = r1
    ; bpf_map_update_elem(&result, &key, &static_rodata, 0);
      22: (18) r1 = map[id:66]
      24: (bf) r2 = r6
      25: (18) r3 = map[id:65][0]+0         <-- direct static_rodata addr in .rodata area
      27: (b7) r4 = 0
      28: (85) call array_map_update_elem#99888
      29: (b7) r1 = 3
    ; key = 3;
      30: (63) *(u32 *)(r10 -4) = r1
    ; bpf_map_update_elem(&result, &key, &static_bss2, 0);
      31: (18) r7 = map[id:63][0]+8         <--.
      33: (18) r1 = map[id:66]                 |
      35: (bf) r2 = r6                         |
      36: (18) r3 = map[id:63][0]+8         <-- direct static_bss2 addr in .bss area
      38: (b7) r4 = 0
      39: (85) call array_map_update_elem#99888
    [...]

For now .data/.rodata/.bss maps are not exposed via API to the user, but this could be done in a subsequent step.

Based upon recent fix in LLVM, commit c0db6b6bd444 ("[BPF] Don't fail for static variables").

Joint work with Joe Stringer.

[0] LPC 2018, BPF track, "ELF relocation for static data in BPF",
http://vger.kernel.org/lpc-bpf2018.html#session-3

---
   tools/include/uapi/linux/bpf.h |  10 +-
   tools/lib/bpf/libbpf.c         | 259 +++++++++++++++++++++++++++------
   2 files changed, 226 insertions(+), 43 deletions(-)
tools/include/uapi/linux/bpf.h +28 -2
index 8884072e1a46..04b26f59b413 100644
@@ -287,7 +287,7 @@ enum bpf_attach_type {
[...]
@@ -999,8 +1120,10 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
                        (long long) (rel.r_info >> 32),
                        (long long) sym.st_value, sym.st_name);
 
-             if (sym.st_shndx != maps_shndx && sym.st_shndx != text_shndx) {
-                     pr_warning("Program '%s' contains non-map related relo data pointing to section %u\n",
+             if (sym.st_shndx != maps_shndx && sym.st_shndx != text_shndx &&
+                 sym.st_shndx != data_shndx && sym.st_shndx != rodata_shndx &&
+                 sym.st_shndx != bss_shndx) {
+                     pr_warning("Program '%s' contains unrecognized relo data pointing to section %u\n",
                                  prog->section_name, sym.st_shndx);
                       return -LIBBPF_ERRNO__RELOC;
               }
@@ -1045,6 +1168,30 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
                       prog->reloc_desc[i].type = RELO_LD64;
                       prog->reloc_desc[i].insn_idx = insn_idx;
                       prog->reloc_desc[i].map_idx = map_idx;
+             } else if (sym.st_shndx == data_shndx ||
+                        sym.st_shndx == rodata_shndx ||
+                        sym.st_shndx == bss_shndx) {
+                     int type = (sym.st_shndx == data_shndx)   ? RELO_DATA :
+                                (sym.st_shndx == rodata_shndx) ? RELO_RODATA :
+                                                                 RELO_BSS;
+
+                     for (map_idx = 0; map_idx < nr_maps_global; map_idx++) {
+                             if (maps_global[map_idx].global_type == type) {
+                                     pr_debug("relocation: find map %zd (%s) for insn %u\n",
+                                              map_idx, maps_global[map_idx].name, insn_idx);
+                                     break;
+                             }
+                     }
+
+                     if (map_idx >= nr_maps_global) {
+                             pr_warning("bpf relocation: map_idx %d large than %d\n",
+                                        (int)map_idx, (int)nr_maps_global - 1);
+                             return -LIBBPF_ERRNO__RELOC;
+                     }
+
+                     prog->reloc_desc[i].type = type;
+                     prog->reloc_desc[i].insn_idx = insn_idx;
+                     prog->reloc_desc[i].map_idx = map_idx;
               }
       }
       return 0;
@@ -1176,15 +1323,58 @@ bpf_object__probe_caps(struct bpf_object *obj)
   }
 
   static int

[...]

Quoted 59 lines
tools/include/uapi/linux/bpf.h +5 -36
+
+static int
+bpf_object__create_maps(struct bpf_object *obj)
+{
       unsigned int i;
       int err;
 
       for (i = 0; i < obj->nr_maps; i++) {
               struct bpf_map *map = &obj->maps[i];
-             struct bpf_map_def *def = &map->def;
               char *cp, errmsg[STRERR_BUFSIZE];
               int *pfd = &map->fd;
@@ -1193,41 +1383,7 @@ bpf_object__create_maps(struct bpf_object *obj)
                                map->name, map->fd);
                       continue;
               }
-
-             if (obj->caps.name)
-                     create_attr.name = map->name;
-             create_attr.map_ifindex = map->map_ifindex;
-             create_attr.map_type = def->type;
-             create_attr.map_flags = def->map_flags;
-             create_attr.key_size = def->key_size;
-             create_attr.value_size = def->value_size;
-             create_attr.max_entries = def->max_entries;
-             create_attr.btf_fd = 0;
-             create_attr.btf_key_type_id = 0;
-             create_attr.btf_value_type_id = 0;
-             if (bpf_map_type__is_map_in_map(def->type) &&
-                 map->inner_map_fd >= 0)
-                     create_attr.inner_map_fd = map->inner_map_fd;
-
-             if (obj->btf && !bpf_map_find_btf_info(map, obj->btf)) {
-                     create_attr.btf_fd = btf__fd(obj->btf);
-                     create_attr.btf_key_type_id = map->btf_key_type_id;
-                     create_attr.btf_value_type_id = map->btf_value_type_id;
-             }
-
-             *pfd = bpf_create_map_xattr(&create_attr);
-             if (*pfd < 0 && create_attr.btf_key_type_id) {
-                     cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
-                     pr_warning("Error in bpf_create_map_xattr(%s):%s(%d). Retrying without BTF.\n",
-                                map->name, cp, errno);
-                     create_attr.btf_fd = 0;
-                     create_attr.btf_key_type_id = 0;
-                     create_attr.btf_value_type_id = 0;
-                     map->btf_key_type_id = 0;
-                     map->btf_value_type_id = 0;
-                     *pfd = bpf_create_map_xattr(&create_attr);
-             }
-
+             *pfd = bpf_object__create_map(obj, map);
               if (*pfd < 0) {
                       size_t j;
 
@@ -1412,6 +1568,24 @@ bpf_program__relocate(struct bpf_program *prog, struct bpf_object *obj)
                                                     &prog->reloc_desc[i]);
                       if (err)

tools/include/uapi/linux/bpf.h bpf_program__relocate(struct bpf_program *prog, struct bpf_object *obj) · line 1579

Quoted 10 lines
tools/include/uapi/linux/bpf.h +9 -0
                               return err;
+             } else if (prog->reloc_desc[i].type == RELO_DATA ||
+                        prog->reloc_desc[i].type == RELO_RODATA ||
+                        prog->reloc_desc[i].type == RELO_BSS) {
+                     struct bpf_insn *insns = prog->insns;
+                     int insn_idx, map_idx, data_off;
+
+                     insn_idx = prog->reloc_desc[i].insn_idx;
+                     map_idx  = prog->reloc_desc[i].map_idx;
+                     data_off = insns[insn_idx].imm;

I want to point to a subtle difference here between handling pure global variables and static global variables. The "imm" value is only available for static variables. For example,

-bash-4.4$ cat g.c
static volatile long sg = 2;
static volatile int si = 3;
long g = 4;
int i = 5;
int test() { return sg + si + g + i; }

(quoted diff) +0 -3
-bash-4.4$
-bash-4.4$ clang -target bpf -O2 -c g.c
 
-bash-4.4$ readelf -s g.o

Symbol table '.symtab' contains 8 entries:

     Num:    Value          Size Type    Bind   Vis      Ndx Name
       0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
       1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS g.c
       2: 0000000000000010     8 OBJECT  LOCAL  DEFAULT    4 sg
       3: 0000000000000018     4 OBJECT  LOCAL  DEFAULT    4 si
       4: 0000000000000000     0 SECTION LOCAL  DEFAULT    4
       5: 0000000000000000     8 OBJECT  GLOBAL DEFAULT    4 g
       6: 0000000000000008     4 OBJECT  GLOBAL DEFAULT    4 i
       7: 0000000000000000   128 FUNC    GLOBAL DEFAULT    2 test
(quoted diff) +0 -2
-bash-4.4$
-bash-4.4$ llvm-readelf -r g.o

Relocation section '.rel.text' at offset 0x1d8 contains 4 entries:
Offset Info Type Symbol's
Value Symbol's Name
0000000000000000 0000000400000001 R_BPF_64_64 0000000000000000 .data
0000000000000018 0000000400000001 R_BPF_64_64 0000000000000000 .data

0000000000000038  0000000500000001 R_BPF_64_64            0000000000000000 g
0000000000000058  0000000600000001 R_BPF_64_64            0000000000000008 i

-bash-4.4$ llvm-objdump -d g.o

g.o: file format ELF64-BPF

Disassembly of section .text:
0000000000000000 test:

         0:       18 01 00 00 10 00 00 00 00 00 00 00 00 00 00 00
r1 = 16 ll
         2:       79 11 00 00 00 00 00 00         r1 = *(u64 *)(r1 + 0)
         3:       18 02 00 00 18 00 00 00 00 00 00 00 00 00 00 00
r2 = 24 ll
         5:       61 22 00 00 00 00 00 00         r2 = *(u32 *)(r2 + 0)
         6:       0f 21 00 00 00 00 00 00         r1 += r2
         7:       18 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00
r2 = 0 ll
         9:       79 22 00 00 00 00 00 00         r2 = *(u64 *)(r2 + 0)
        10:       0f 21 00 00 00 00 00 00         r1 += r2
        11:       18 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00
r2 = 0 ll
        13:       61 20 00 00 00 00 00 00         r0 = *(u32 *)(r2 + 0)
        14:       0f 10 00 00 00 00 00 00         r0 += r1
        15:       95 00 00 00 00 00 00 00         exit

-bash-4.4$

You can see the above, the non-static global access does not have its in-section offset encoded in the insn itself. The difference is due to llvm treating static global and non-static global differently.

To support both cases, during relocation recording stage, you can also record:
. symbol binding (GELF_ST_BIND(sym.st_info)),
non-static global has binding STB_GLOBAL and static global has binding STB_LOCAL
. symbol value (sym.st_value)

During the above relocation resolution, if symbol bind is local, do what you already did here. If symbol bind is global, assign data_off with symbol value.

This applied to both .data and .rodata sections.

Quoted 14 lines
Quoted 8 lines

The non initialized
global variable will not be in any allocated section in ELF file, it is in a COM section which is to be allocated by loader. So user defines some like

     int g;

and later on uses it. Right now, it will not work. The workaround is "int g = 4", or "static int g". I guess it should be okay, we should encourage users to use "static" variables instead.

Would it be reasonable to just plain disable usage of uninitialized global variables, as it kind of goes against BPF's philosophy that everything should be written to, before can be read? So while we can just implicitly zero-out everything beforehand, it might be a good idea to remind and enforce that explictly?

There will be a verifier error, so the program with "int g" will not run, the same as today.

We could improve by flagging the error at compiler error or libbpf time. But it is not required. I am mentioning just for completeness.

Quoted 41 lines
Quoted 41 lines
Quoted 41 lines
tools/include/uapi/linux/bpf.h +12 -2
+
+                     if (insn_idx + 1 >= (int)prog->insns_cnt) {
+                             pr_warning("relocation out of range: '%s'\n",
+                                        prog->section_name);
+                             return -LIBBPF_ERRNO__RELOC;
+                     }
+                     insns[insn_idx].src_reg = BPF_PSEUDO_MAP_VALUE;
+                     insns[insn_idx].imm = obj->maps_global[map_idx].fd;
+                     insns[insn_idx + 1].imm = data_off;
               }
       }
 
@@ -1717,6 +1891,7 @@ __bpf_object__open(const char *path, void *obj_buf, size_t obj_buf_sz,
 
       CHECK_ERR(bpf_object__elf_init(obj), err, out);
       CHECK_ERR(bpf_object__check_endianness(obj), err, out);
+     CHECK_ERR(bpf_object__probe_caps(obj), err, out);
       CHECK_ERR(bpf_object__elf_collect(obj, flags), err, out);
       CHECK_ERR(bpf_object__collect_reloc(obj), err, out);
       CHECK_ERR(bpf_object__validate(obj, needs_kver), err, out);
@@ -1789,7 +1964,8 @@ int bpf_object__unload(struct bpf_object *obj)
 
       for (i = 0; i < obj->nr_maps; i++)
               zclose(obj->maps[i].fd);
-
+     for (i = 0; i < obj->nr_maps_global; i++)
+             zclose(obj->maps_global[i].fd);
       for (i = 0; i < obj->nr_programs; i++)
               bpf_program__unload(&obj->programs[i]);
 
@@ -1810,7 +1986,6 @@ int bpf_object__load(struct bpf_object *obj)
 
       obj->loaded = true;
 
-     CHECK_ERR(bpf_object__probe_caps(obj), err, out);
       CHECK_ERR(bpf_object__create_maps(obj), err, out);
       CHECK_ERR(bpf_object__relocate(obj), err, out);
       CHECK_ERR(bpf_object__load_progs(obj), err, out);
#34 lore raw

Re: [PATCH bpf-next v2 5/7] bpf, libbpf: support global data/bss/rodata sections

Quoted 382 lines · Yonghong Song
Quoted 363 lines · Andrii Nakryiko
Quoted 362 lines · Yonghong Song
Quoted 208 lines · Daniel Borkmann

This work adds BPF loader support for global data sections to libbpf. This allows to write BPF programs in more natural C-like way by being able to define global variables and const data.

Back at LPC 2018 [0] we presented a first prototype which implemented support for global data sections by extending BPF syscall where union bpf_attr would get additional memory/size pair for each section passed during prog load in order to later add this base address into the ldimm64 instruction along with the user provided offset when accessing a variable. Consensus from LPC was that for proper upstream support, it would be more desirable to use maps instead of bpf_attr extension as this would allow for introspection of these sections as well as potential life updates of their content. This work follows this path by taking the following steps from loader side:

1) In bpf_object__elf_collect() step we pick up ".data", ".rodata", and ".bss" section information.

2) If present, in bpf_object__init_global_maps() we create a map that corresponds to each of the present sections. Given section size and access properties can differ, a single entry array map is created with value size that is corresponding to the ELF section size of .data, .bss or .rodata. In the latter case, the map is created as read-only from program side such that verifier rejects any write attempts into .rodata. In a subsequent step, for .data and .rodata sections, the section content is copied into the map through bpf_map_update_elem(). For .bss this is not necessary since array map is already zero-initialized by default.

3) In bpf_program__collect_reloc() step, we record the corresponding map, insn index, and relocation type for the global data.

4) And last but not least in the actual relocation step in bpf_program__relocate(), we mark the ldimm64 instruction with src_reg = BPF_PSEUDO_MAP_VALUE where in the first imm field the map's file descriptor is stored as similarly done as in BPF_PSEUDO_MAP_FD, and in the second imm field (as ldimm64 is 2-insn wide) we store the access offset into the section.

5) On kernel side, this special marked BPF_PSEUDO_MAP_VALUE load will then store the actual target address in order to have a 'map-lookup'-free access. That is, the actual map value base address + offset. The destination register in the verifier will then be marked as PTR_TO_MAP_VALUE, containing the fixed offset as reg->off and backing BPF map as reg->map_ptr. Meaning, it's treated as any other normal map value from verification side, only with efficient, direct value access instead of actual call to map lookup helper as in the typical case.

Simple example dump of program using globals vars in each section:

    # readelf -a test_global_data.o
    [...]
    [ 6] .bss              NOBITS           0000000000000000  00000328
         0000000000000010  0000000000000000  WA       0     0     8
    [ 7] .data             PROGBITS         0000000000000000  00000328
         0000000000000010  0000000000000000  WA       0     0     8
    [ 8] .rodata           PROGBITS         0000000000000000  00000338
         0000000000000018  0000000000000000   A       0     0     8
    [...]
      95: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    6 static_bss
      96: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    6 static_bss2
      97: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    7 static_data
      98: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    7 static_data2
      99: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    8 static_rodata
     100: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    8 static_rodata2
     101: 0000000000000010     8 OBJECT  LOCAL  DEFAULT    8 static_rodata3
    [...]
    # bpftool prog
    103: sched_cls  name load_static_dat  tag 37a8b6822fc39a29  gpl
         loaded_at 2019-02-28T02:02:35+0000  uid 0
         xlated 712B  jited 426B  memlock 4096B  map_ids 63,64,65,66
    # bpftool map show id 63
    63: array  name .bss  flags 0x0                      <-- .bss area, rw
        key 4B  value 16B  max_entries 1  memlock 4096B
    # bpftool map show id 64
    64: array  name .data  flags 0x0                     <-- .data area, rw
        key 4B  value 16B  max_entries 1  memlock 4096B
    # bpftool map show id 65
    65: array  name .rodata  flags 0x80                  <-- .rodata area, ro
        key 4B  value 24B  max_entries 1  memlock 4096B
    # bpftool prog dump xlated id 103
    int load_static_data(struct __sk_buff * skb):
    ; int load_static_data(struct __sk_buff *skb)
       0: (b7) r1 = 0
    ; key = 0;
       1: (63) *(u32 *)(r10 -4) = r1
       2: (bf) r6 = r10
    ; int load_static_data(struct __sk_buff *skb)
       3: (07) r6 += -4
    ; bpf_map_update_elem(&result, &key, &static_bss, 0);
       4: (18) r1 = map[id:66]
       6: (bf) r2 = r6
       7: (18) r3 = map[id:63][0]+0         <-- direct static_bss addr in .bss area
       9: (b7) r4 = 0
      10: (85) call array_map_update_elem#99888
      11: (b7) r1 = 1
    ; key = 1;
      12: (63) *(u32 *)(r10 -4) = r1
    ; bpf_map_update_elem(&result, &key, &static_data, 0);
      13: (18) r1 = map[id:66]
      15: (bf) r2 = r6
      16: (18) r3 = map[id:64][0]+0         <-- direct static_data addr in .data area
      18: (b7) r4 = 0
      19: (85) call array_map_update_elem#99888
      20: (b7) r1 = 2
    ; key = 2;
      21: (63) *(u32 *)(r10 -4) = r1
    ; bpf_map_update_elem(&result, &key, &static_rodata, 0);
      22: (18) r1 = map[id:66]
      24: (bf) r2 = r6
      25: (18) r3 = map[id:65][0]+0         <-- direct static_rodata addr in .rodata area
      27: (b7) r4 = 0
      28: (85) call array_map_update_elem#99888
      29: (b7) r1 = 3
    ; key = 3;
      30: (63) *(u32 *)(r10 -4) = r1
    ; bpf_map_update_elem(&result, &key, &static_bss2, 0);
      31: (18) r7 = map[id:63][0]+8         <--.
      33: (18) r1 = map[id:66]                 |
      35: (bf) r2 = r6                         |
      36: (18) r3 = map[id:63][0]+8         <-- direct static_bss2 addr in .bss area
      38: (b7) r4 = 0
      39: (85) call array_map_update_elem#99888
    [...]

For now .data/.rodata/.bss maps are not exposed via API to the user, but this could be done in a subsequent step.

Based upon recent fix in LLVM, commit c0db6b6bd444 ("[BPF] Don't fail for static variables").

Joint work with Joe Stringer.

[0] LPC 2018, BPF track, "ELF relocation for static data in BPF",
http://vger.kernel.org/lpc-bpf2018.html#session-3

---
   tools/include/uapi/linux/bpf.h |  10 +-
   tools/lib/bpf/libbpf.c         | 259 +++++++++++++++++++++++++++------
   2 files changed, 226 insertions(+), 43 deletions(-)
tools/include/uapi/linux/bpf.h +28 -2
index 8884072e1a46..04b26f59b413 100644
@@ -287,7 +287,7 @@ enum bpf_attach_type {
[...]
@@ -999,8 +1120,10 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
                        (long long) (rel.r_info >> 32),
                        (long long) sym.st_value, sym.st_name);
 
-             if (sym.st_shndx != maps_shndx && sym.st_shndx != text_shndx) {
-                     pr_warning("Program '%s' contains non-map related relo data pointing to section %u\n",
+             if (sym.st_shndx != maps_shndx && sym.st_shndx != text_shndx &&
+                 sym.st_shndx != data_shndx && sym.st_shndx != rodata_shndx &&
+                 sym.st_shndx != bss_shndx) {
+                     pr_warning("Program '%s' contains unrecognized relo data pointing to section %u\n",
                                  prog->section_name, sym.st_shndx);
                       return -LIBBPF_ERRNO__RELOC;
               }
@@ -1045,6 +1168,30 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
                       prog->reloc_desc[i].type = RELO_LD64;
                       prog->reloc_desc[i].insn_idx = insn_idx;
                       prog->reloc_desc[i].map_idx = map_idx;
+             } else if (sym.st_shndx == data_shndx ||
+                        sym.st_shndx == rodata_shndx ||
+                        sym.st_shndx == bss_shndx) {
+                     int type = (sym.st_shndx == data_shndx)   ? RELO_DATA :
+                                (sym.st_shndx == rodata_shndx) ? RELO_RODATA :
+                                                                 RELO_BSS;
+
+                     for (map_idx = 0; map_idx < nr_maps_global; map_idx++) {
+                             if (maps_global[map_idx].global_type == type) {
+                                     pr_debug("relocation: find map %zd (%s) for insn %u\n",
+                                              map_idx, maps_global[map_idx].name, insn_idx);
+                                     break;
+                             }
+                     }
+
+                     if (map_idx >= nr_maps_global) {
+                             pr_warning("bpf relocation: map_idx %d large than %d\n",
+                                        (int)map_idx, (int)nr_maps_global - 1);
+                             return -LIBBPF_ERRNO__RELOC;
+                     }
+
+                     prog->reloc_desc[i].type = type;
+                     prog->reloc_desc[i].insn_idx = insn_idx;
+                     prog->reloc_desc[i].map_idx = map_idx;
               }
       }
       return 0;
@@ -1176,15 +1323,58 @@ bpf_object__probe_caps(struct bpf_object *obj)
   }
 
   static int

[...]

Quoted 59 lines
tools/include/uapi/linux/bpf.h +5 -36
+
+static int
+bpf_object__create_maps(struct bpf_object *obj)
+{
       unsigned int i;
       int err;
 
       for (i = 0; i < obj->nr_maps; i++) {
               struct bpf_map *map = &obj->maps[i];
-             struct bpf_map_def *def = &map->def;
               char *cp, errmsg[STRERR_BUFSIZE];
               int *pfd = &map->fd;
@@ -1193,41 +1383,7 @@ bpf_object__create_maps(struct bpf_object *obj)
                                map->name, map->fd);
                       continue;
               }
-
-             if (obj->caps.name)
-                     create_attr.name = map->name;
-             create_attr.map_ifindex = map->map_ifindex;
-             create_attr.map_type = def->type;
-             create_attr.map_flags = def->map_flags;
-             create_attr.key_size = def->key_size;
-             create_attr.value_size = def->value_size;
-             create_attr.max_entries = def->max_entries;
-             create_attr.btf_fd = 0;
-             create_attr.btf_key_type_id = 0;
-             create_attr.btf_value_type_id = 0;
-             if (bpf_map_type__is_map_in_map(def->type) &&
-                 map->inner_map_fd >= 0)
-                     create_attr.inner_map_fd = map->inner_map_fd;
-
-             if (obj->btf && !bpf_map_find_btf_info(map, obj->btf)) {
-                     create_attr.btf_fd = btf__fd(obj->btf);
-                     create_attr.btf_key_type_id = map->btf_key_type_id;
-                     create_attr.btf_value_type_id = map->btf_value_type_id;
-             }
-
-             *pfd = bpf_create_map_xattr(&create_attr);
-             if (*pfd < 0 && create_attr.btf_key_type_id) {
-                     cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
-                     pr_warning("Error in bpf_create_map_xattr(%s):%s(%d). Retrying without BTF.\n",
-                                map->name, cp, errno);
-                     create_attr.btf_fd = 0;
-                     create_attr.btf_key_type_id = 0;
-                     create_attr.btf_value_type_id = 0;
-                     map->btf_key_type_id = 0;
-                     map->btf_value_type_id = 0;
-                     *pfd = bpf_create_map_xattr(&create_attr);
-             }
-
+             *pfd = bpf_object__create_map(obj, map);
               if (*pfd < 0) {
                       size_t j;
 
@@ -1412,6 +1568,24 @@ bpf_program__relocate(struct bpf_program *prog, struct bpf_object *obj)
                                                     &prog->reloc_desc[i]);
                       if (err)

tools/include/uapi/linux/bpf.h bpf_program__relocate(struct bpf_program *prog, struct bpf_object *obj) · line 1579

Quoted 10 lines
tools/include/uapi/linux/bpf.h +9 -0
                               return err;
+             } else if (prog->reloc_desc[i].type == RELO_DATA ||
+                        prog->reloc_desc[i].type == RELO_RODATA ||
+                        prog->reloc_desc[i].type == RELO_BSS) {
+                     struct bpf_insn *insns = prog->insns;
+                     int insn_idx, map_idx, data_off;
+
+                     insn_idx = prog->reloc_desc[i].insn_idx;
+                     map_idx  = prog->reloc_desc[i].map_idx;
+                     data_off = insns[insn_idx].imm;

I want to point to a subtle difference here between handling pure global variables and static global variables. The "imm" value is only available for static variables. For example,

-bash-4.4$ cat g.c
static volatile long sg = 2;
static volatile int si = 3;
long g = 4;
int i = 5;
int test() { return sg + si + g + i; }

(quoted diff) +0 -3
-bash-4.4$
-bash-4.4$ clang -target bpf -O2 -c g.c
 
-bash-4.4$ readelf -s g.o

Symbol table '.symtab' contains 8 entries:

     Num:    Value          Size Type    Bind   Vis      Ndx Name
       0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
       1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS g.c
       2: 0000000000000010     8 OBJECT  LOCAL  DEFAULT    4 sg
       3: 0000000000000018     4 OBJECT  LOCAL  DEFAULT    4 si
       4: 0000000000000000     0 SECTION LOCAL  DEFAULT    4
       5: 0000000000000000     8 OBJECT  GLOBAL DEFAULT    4 g
       6: 0000000000000008     4 OBJECT  GLOBAL DEFAULT    4 i
       7: 0000000000000000   128 FUNC    GLOBAL DEFAULT    2 test
(quoted diff) +0 -2
-bash-4.4$
-bash-4.4$ llvm-readelf -r g.o

Relocation section '.rel.text' at offset 0x1d8 contains 4 entries:
Offset Info Type Symbol's
Value Symbol's Name
0000000000000000 0000000400000001 R_BPF_64_64 0000000000000000 .data
0000000000000018 0000000400000001 R_BPF_64_64 0000000000000000 .data

0000000000000038  0000000500000001 R_BPF_64_64            0000000000000000 g
0000000000000058  0000000600000001 R_BPF_64_64            0000000000000008 i

-bash-4.4$ llvm-objdump -d g.o

g.o: file format ELF64-BPF

Disassembly of section .text:
0000000000000000 test:

         0:       18 01 00 00 10 00 00 00 00 00 00 00 00 00 00 00
r1 = 16 ll
         2:       79 11 00 00 00 00 00 00         r1 = *(u64 *)(r1 + 0)
         3:       18 02 00 00 18 00 00 00 00 00 00 00 00 00 00 00
r2 = 24 ll
         5:       61 22 00 00 00 00 00 00         r2 = *(u32 *)(r2 + 0)
         6:       0f 21 00 00 00 00 00 00         r1 += r2
         7:       18 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00
r2 = 0 ll
         9:       79 22 00 00 00 00 00 00         r2 = *(u64 *)(r2 + 0)
        10:       0f 21 00 00 00 00 00 00         r1 += r2
        11:       18 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00
r2 = 0 ll
        13:       61 20 00 00 00 00 00 00         r0 = *(u32 *)(r2 + 0)
        14:       0f 10 00 00 00 00 00 00         r0 += r1
        15:       95 00 00 00 00 00 00 00         exit

-bash-4.4$

You can see the above, the non-static global access does not have its in-section offset encoded in the insn itself. The difference is due to llvm treating static global and non-static global differently.

To support both cases, during relocation recording stage, you can also record:
. symbol binding (GELF_ST_BIND(sym.st_info)),
non-static global has binding STB_GLOBAL and static global has binding STB_LOCAL
. symbol value (sym.st_value)

During the above relocation resolution, if symbol bind is local, do what you already did here. If symbol bind is global, assign data_off with symbol value.

This applied to both .data and .rodata sections.

Quoted 14 lines
Quoted 8 lines

The non initialized
global variable will not be in any allocated section in ELF file, it is in a COM section which is to be allocated by loader. So user defines some like

     int g;

and later on uses it. Right now, it will not work. The workaround is "int g = 4", or "static int g". I guess it should be okay, we should encourage users to use "static" variables instead.

Would it be reasonable to just plain disable usage of uninitialized global variables, as it kind of goes against BPF's philosophy that everything should be written to, before can be read? So while we can just implicitly zero-out everything beforehand, it might be a good idea to remind and enforce that explictly?

Quoted 2 lines

There will be a verifier error, so the program with "int g" will not run, the same as today.

Yeah, I understand, but with pretty obscure error about not supporting relocations and stuff, right?

Quoted 2 lines

We could improve by flagging the error at compiler error or libbpf time.

So that's my point, that having compiler emit nicer error for target=bpf would be nice touch to user experience :)

Quoted 43 lines

But it is not required. I am mentioning just for completeness.

Quoted 41 lines
Quoted 41 lines
Quoted 41 lines
tools/include/uapi/linux/bpf.h +12 -2
+
+                     if (insn_idx + 1 >= (int)prog->insns_cnt) {
+                             pr_warning("relocation out of range: '%s'\n",
+                                        prog->section_name);
+                             return -LIBBPF_ERRNO__RELOC;
+                     }
+                     insns[insn_idx].src_reg = BPF_PSEUDO_MAP_VALUE;
+                     insns[insn_idx].imm = obj->maps_global[map_idx].fd;
+                     insns[insn_idx + 1].imm = data_off;
               }
       }
 
@@ -1717,6 +1891,7 @@ __bpf_object__open(const char *path, void *obj_buf, size_t obj_buf_sz,
 
       CHECK_ERR(bpf_object__elf_init(obj), err, out);
       CHECK_ERR(bpf_object__check_endianness(obj), err, out);
+     CHECK_ERR(bpf_object__probe_caps(obj), err, out);
       CHECK_ERR(bpf_object__elf_collect(obj, flags), err, out);
       CHECK_ERR(bpf_object__collect_reloc(obj), err, out);
       CHECK_ERR(bpf_object__validate(obj, needs_kver), err, out);
@@ -1789,7 +1964,8 @@ int bpf_object__unload(struct bpf_object *obj)
 
       for (i = 0; i < obj->nr_maps; i++)
               zclose(obj->maps[i].fd);
-
+     for (i = 0; i < obj->nr_maps_global; i++)
+             zclose(obj->maps_global[i].fd);
       for (i = 0; i < obj->nr_programs; i++)
               bpf_program__unload(&obj->programs[i]);
 
@@ -1810,7 +1986,6 @@ int bpf_object__load(struct bpf_object *obj)
 
       obj->loaded = true;
 
-     CHECK_ERR(bpf_object__probe_caps(obj), err, out);
       CHECK_ERR(bpf_object__create_maps(obj), err, out);
       CHECK_ERR(bpf_object__relocate(obj), err, out);
       CHECK_ERR(bpf_object__load_progs(obj), err, out);
#35 lore raw

Re: [PATCH bpf-next v2 5/7] bpf, libbpf: support global data/bss/rodata sections

Quoted 386 lines · Andrii Nakryiko
Quoted 382 lines · Yonghong Song
Quoted 363 lines · Andrii Nakryiko
Quoted 362 lines · Yonghong Song
Quoted 208 lines · Daniel Borkmann

This work adds BPF loader support for global data sections to libbpf. This allows to write BPF programs in more natural C-like way by being able to define global variables and const data.

Back at LPC 2018 [0] we presented a first prototype which implemented support for global data sections by extending BPF syscall where union bpf_attr would get additional memory/size pair for each section passed during prog load in order to later add this base address into the ldimm64 instruction along with the user provided offset when accessing a variable. Consensus from LPC was that for proper upstream support, it would be more desirable to use maps instead of bpf_attr extension as this would allow for introspection of these sections as well as potential life updates of their content. This work follows this path by taking the following steps from loader side:

1) In bpf_object__elf_collect() step we pick up ".data", ".rodata", and ".bss" section information.

2) If present, in bpf_object__init_global_maps() we create a map that corresponds to each of the present sections. Given section size and access properties can differ, a single entry array map is created with value size that is corresponding to the ELF section size of .data, .bss or .rodata. In the latter case, the map is created as read-only from program side such that verifier rejects any write attempts into .rodata. In a subsequent step, for .data and .rodata sections, the section content is copied into the map through bpf_map_update_elem(). For .bss this is not necessary since array map is already zero-initialized by default.

3) In bpf_program__collect_reloc() step, we record the corresponding map, insn index, and relocation type for the global data.

4) And last but not least in the actual relocation step in bpf_program__relocate(), we mark the ldimm64 instruction with src_reg = BPF_PSEUDO_MAP_VALUE where in the first imm field the map's file descriptor is stored as similarly done as in BPF_PSEUDO_MAP_FD, and in the second imm field (as ldimm64 is 2-insn wide) we store the access offset into the section.

5) On kernel side, this special marked BPF_PSEUDO_MAP_VALUE load will then store the actual target address in order to have a 'map-lookup'-free access. That is, the actual map value base address + offset. The destination register in the verifier will then be marked as PTR_TO_MAP_VALUE, containing the fixed offset as reg->off and backing BPF map as reg->map_ptr. Meaning, it's treated as any other normal map value from verification side, only with efficient, direct value access instead of actual call to map lookup helper as in the typical case.

Simple example dump of program using globals vars in each section:

     # readelf -a test_global_data.o
     [...]
     [ 6] .bss              NOBITS           0000000000000000  00000328
          0000000000000010  0000000000000000  WA       0     0     8
     [ 7] .data             PROGBITS         0000000000000000  00000328
          0000000000000010  0000000000000000  WA       0     0     8
     [ 8] .rodata           PROGBITS         0000000000000000  00000338
          0000000000000018  0000000000000000   A       0     0     8
     [...]
       95: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    6 static_bss
       96: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    6 static_bss2
       97: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    7 static_data
       98: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    7 static_data2
       99: 0000000000000000     8 OBJECT  LOCAL  DEFAULT    8 static_rodata
      100: 0000000000000008     8 OBJECT  LOCAL  DEFAULT    8 static_rodata2
      101: 0000000000000010     8 OBJECT  LOCAL  DEFAULT    8 static_rodata3
     [...]
     # bpftool prog
     103: sched_cls  name load_static_dat  tag 37a8b6822fc39a29  gpl
          loaded_at 2019-02-28T02:02:35+0000  uid 0
          xlated 712B  jited 426B  memlock 4096B  map_ids 63,64,65,66
     # bpftool map show id 63
     63: array  name .bss  flags 0x0                      <-- .bss area, rw
         key 4B  value 16B  max_entries 1  memlock 4096B
     # bpftool map show id 64
     64: array  name .data  flags 0x0                     <-- .data area, rw
         key 4B  value 16B  max_entries 1  memlock 4096B
     # bpftool map show id 65
     65: array  name .rodata  flags 0x80                  <-- .rodata area, ro
         key 4B  value 24B  max_entries 1  memlock 4096B
     # bpftool prog dump xlated id 103
     int load_static_data(struct __sk_buff * skb):
     ; int load_static_data(struct __sk_buff *skb)
        0: (b7) r1 = 0
     ; key = 0;
        1: (63) *(u32 *)(r10 -4) = r1
        2: (bf) r6 = r10
     ; int load_static_data(struct __sk_buff *skb)
        3: (07) r6 += -4
     ; bpf_map_update_elem(&result, &key, &static_bss, 0);
        4: (18) r1 = map[id:66]
        6: (bf) r2 = r6
        7: (18) r3 = map[id:63][0]+0         <-- direct static_bss addr in .bss area
        9: (b7) r4 = 0
       10: (85) call array_map_update_elem#99888
       11: (b7) r1 = 1
     ; key = 1;
       12: (63) *(u32 *)(r10 -4) = r1
     ; bpf_map_update_elem(&result, &key, &static_data, 0);
       13: (18) r1 = map[id:66]
       15: (bf) r2 = r6
       16: (18) r3 = map[id:64][0]+0         <-- direct static_data addr in .data area
       18: (b7) r4 = 0
       19: (85) call array_map_update_elem#99888
       20: (b7) r1 = 2
     ; key = 2;
       21: (63) *(u32 *)(r10 -4) = r1
     ; bpf_map_update_elem(&result, &key, &static_rodata, 0);
       22: (18) r1 = map[id:66]
       24: (bf) r2 = r6
       25: (18) r3 = map[id:65][0]+0         <-- direct static_rodata addr in .rodata area
       27: (b7) r4 = 0
       28: (85) call array_map_update_elem#99888
       29: (b7) r1 = 3
     ; key = 3;
       30: (63) *(u32 *)(r10 -4) = r1
     ; bpf_map_update_elem(&result, &key, &static_bss2, 0);
       31: (18) r7 = map[id:63][0]+8         <--.
       33: (18) r1 = map[id:66]                 |
       35: (bf) r2 = r6                         |
       36: (18) r3 = map[id:63][0]+8         <-- direct static_bss2 addr in .bss area
       38: (b7) r4 = 0
       39: (85) call array_map_update_elem#99888
     [...]

For now .data/.rodata/.bss maps are not exposed via API to the user, but this could be done in a subsequent step.

Based upon recent fix in LLVM, commit c0db6b6bd444 ("[BPF] Don't fail for static variables").

Joint work with Joe Stringer.

[0] LPC 2018, BPF track, "ELF relocation for static data in BPF",
http://vger.kernel.org/lpc-bpf2018.html#session-3

---
    tools/include/uapi/linux/bpf.h |  10 +-
    tools/lib/bpf/libbpf.c         | 259 +++++++++++++++++++++++++++------
    2 files changed, 226 insertions(+), 43 deletions(-)
tools/include/uapi/linux/bpf.h +28 -2
index 8884072e1a46..04b26f59b413 100644
@@ -287,7 +287,7 @@ enum bpf_attach_type {
[...]
@@ -999,8 +1120,10 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
                         (long long) (rel.r_info >> 32),
                         (long long) sym.st_value, sym.st_name);
 
-             if (sym.st_shndx != maps_shndx && sym.st_shndx != text_shndx) {
-                     pr_warning("Program '%s' contains non-map related relo data pointing to section %u\n",
+             if (sym.st_shndx != maps_shndx && sym.st_shndx != text_shndx &&
+                 sym.st_shndx != data_shndx && sym.st_shndx != rodata_shndx &&
+                 sym.st_shndx != bss_shndx) {
+                     pr_warning("Program '%s' contains unrecognized relo data pointing to section %u\n",
                                   prog->section_name, sym.st_shndx);
                        return -LIBBPF_ERRNO__RELOC;
                }
@@ -1045,6 +1168,30 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
                        prog->reloc_desc[i].type = RELO_LD64;
                        prog->reloc_desc[i].insn_idx = insn_idx;
                        prog->reloc_desc[i].map_idx = map_idx;
+             } else if (sym.st_shndx == data_shndx ||
+                        sym.st_shndx == rodata_shndx ||
+                        sym.st_shndx == bss_shndx) {
+                     int type = (sym.st_shndx == data_shndx)   ? RELO_DATA :
+                                (sym.st_shndx == rodata_shndx) ? RELO_RODATA :
+                                                                 RELO_BSS;
+
+                     for (map_idx = 0; map_idx < nr_maps_global; map_idx++) {
+                             if (maps_global[map_idx].global_type == type) {
+                                     pr_debug("relocation: find map %zd (%s) for insn %u\n",
+                                              map_idx, maps_global[map_idx].name, insn_idx);
+                                     break;
+                             }
+                     }
+
+                     if (map_idx >= nr_maps_global) {
+                             pr_warning("bpf relocation: map_idx %d large than %d\n",
+                                        (int)map_idx, (int)nr_maps_global - 1);
+                             return -LIBBPF_ERRNO__RELOC;
+                     }
+
+                     prog->reloc_desc[i].type = type;
+                     prog->reloc_desc[i].insn_idx = insn_idx;
+                     prog->reloc_desc[i].map_idx = map_idx;
                }
        }
        return 0;
@@ -1176,15 +1323,58 @@ bpf_object__probe_caps(struct bpf_object *obj)
    }
 
    static int

[...]

Quoted 59 lines
tools/include/uapi/linux/bpf.h +5 -36
+
+static int
+bpf_object__create_maps(struct bpf_object *obj)
+{
        unsigned int i;
        int err;
 
        for (i = 0; i < obj->nr_maps; i++) {
                struct bpf_map *map = &obj->maps[i];
-             struct bpf_map_def *def = &map->def;
                char *cp, errmsg[STRERR_BUFSIZE];
                int *pfd = &map->fd;
@@ -1193,41 +1383,7 @@ bpf_object__create_maps(struct bpf_object *obj)
                                 map->name, map->fd);
                        continue;
                }
-
-             if (obj->caps.name)
-                     create_attr.name = map->name;
-             create_attr.map_ifindex = map->map_ifindex;
-             create_attr.map_type = def->type;
-             create_attr.map_flags = def->map_flags;
-             create_attr.key_size = def->key_size;
-             create_attr.value_size = def->value_size;
-             create_attr.max_entries = def->max_entries;
-             create_attr.btf_fd = 0;
-             create_attr.btf_key_type_id = 0;
-             create_attr.btf_value_type_id = 0;
-             if (bpf_map_type__is_map_in_map(def->type) &&
-                 map->inner_map_fd >= 0)
-                     create_attr.inner_map_fd = map->inner_map_fd;
-
-             if (obj->btf && !bpf_map_find_btf_info(map, obj->btf)) {
-                     create_attr.btf_fd = btf__fd(obj->btf);
-                     create_attr.btf_key_type_id = map->btf_key_type_id;
-                     create_attr.btf_value_type_id = map->btf_value_type_id;
-             }
-
-             *pfd = bpf_create_map_xattr(&create_attr);
-             if (*pfd < 0 && create_attr.btf_key_type_id) {
-                     cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
-                     pr_warning("Error in bpf_create_map_xattr(%s):%s(%d). Retrying without BTF.\n",
-                                map->name, cp, errno);
-                     create_attr.btf_fd = 0;
-                     create_attr.btf_key_type_id = 0;
-                     create_attr.btf_value_type_id = 0;
-                     map->btf_key_type_id = 0;
-                     map->btf_value_type_id = 0;
-                     *pfd = bpf_create_map_xattr(&create_attr);
-             }
-
+             *pfd = bpf_object__create_map(obj, map);
                if (*pfd < 0) {
                        size_t j;
 
@@ -1412,6 +1568,24 @@ bpf_program__relocate(struct bpf_program *prog, struct bpf_object *obj)
                                                      &prog->reloc_desc[i]);
                        if (err)

tools/include/uapi/linux/bpf.h bpf_program__relocate(struct bpf_program *prog, struct bpf_object *obj) · line 1579

Quoted 10 lines
tools/include/uapi/linux/bpf.h +9 -0
                                return err;
+             } else if (prog->reloc_desc[i].type == RELO_DATA ||
+                        prog->reloc_desc[i].type == RELO_RODATA ||
+                        prog->reloc_desc[i].type == RELO_BSS) {
+                     struct bpf_insn *insns = prog->insns;
+                     int insn_idx, map_idx, data_off;
+
+                     insn_idx = prog->reloc_desc[i].insn_idx;
+                     map_idx  = prog->reloc_desc[i].map_idx;
+                     data_off = insns[insn_idx].imm;

I want to point to a subtle difference here between handling pure global variables and static global variables. The "imm" value is only available for static variables. For example,

-bash-4.4$ cat g.c
static volatile long sg = 2;
static volatile int si = 3;
long g = 4;
int i = 5;
int test() { return sg + si + g + i; }

(quoted diff) +0 -3
-bash-4.4$
-bash-4.4$ clang -target bpf -O2 -c g.c
 
-bash-4.4$ readelf -s g.o

Symbol table '.symtab' contains 8 entries:

      Num:    Value          Size Type    Bind   Vis      Ndx Name
        0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
        1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS g.c
        2: 0000000000000010     8 OBJECT  LOCAL  DEFAULT    4 sg
        3: 0000000000000018     4 OBJECT  LOCAL  DEFAULT    4 si
        4: 0000000000000000     0 SECTION LOCAL  DEFAULT    4
        5: 0000000000000000     8 OBJECT  GLOBAL DEFAULT    4 g
        6: 0000000000000008     4 OBJECT  GLOBAL DEFAULT    4 i
        7: 0000000000000000   128 FUNC    GLOBAL DEFAULT    2 test
(quoted diff) +0 -2
-bash-4.4$
-bash-4.4$ llvm-readelf -r g.o

Relocation section '.rel.text' at offset 0x1d8 contains 4 entries:
Offset Info Type Symbol's
Value Symbol's Name
0000000000000000 0000000400000001 R_BPF_64_64 0000000000000000 .data
0000000000000018 0000000400000001 R_BPF_64_64 0000000000000000 .data

0000000000000038  0000000500000001 R_BPF_64_64            0000000000000000 g
0000000000000058  0000000600000001 R_BPF_64_64            0000000000000008 i

-bash-4.4$ llvm-objdump -d g.o

g.o: file format ELF64-BPF

Disassembly of section .text:
0000000000000000 test:

          0:       18 01 00 00 10 00 00 00 00 00 00 00 00 00 00 00
r1 = 16 ll
          2:       79 11 00 00 00 00 00 00         r1 = *(u64 *)(r1 + 0)
          3:       18 02 00 00 18 00 00 00 00 00 00 00 00 00 00 00
r2 = 24 ll
          5:       61 22 00 00 00 00 00 00         r2 = *(u32 *)(r2 + 0)
          6:       0f 21 00 00 00 00 00 00         r1 += r2
          7:       18 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00
r2 = 0 ll
          9:       79 22 00 00 00 00 00 00         r2 = *(u64 *)(r2 + 0)
         10:       0f 21 00 00 00 00 00 00         r1 += r2
         11:       18 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00
r2 = 0 ll
         13:       61 20 00 00 00 00 00 00         r0 = *(u32 *)(r2 + 0)
         14:       0f 10 00 00 00 00 00 00         r0 += r1
         15:       95 00 00 00 00 00 00 00         exit

-bash-4.4$

You can see the above, the non-static global access does not have its in-section offset encoded in the insn itself. The difference is due to llvm treating static global and non-static global differently.

To support both cases, during relocation recording stage, you can also record:
. symbol binding (GELF_ST_BIND(sym.st_info)),
non-static global has binding STB_GLOBAL and static global has binding STB_LOCAL
. symbol value (sym.st_value)

During the above relocation resolution, if symbol bind is local, do what you already did here. If symbol bind is global, assign data_off with symbol value.

This applied to both .data and .rodata sections.

Quoted 14 lines
Quoted 8 lines

The non initialized
global variable will not be in any allocated section in ELF file, it is in a COM section which is to be allocated by loader. So user defines some like

      int g;

and later on uses it. Right now, it will not work. The workaround is "int g = 4", or "static int g". I guess it should be okay, we should encourage users to use "static" variables instead.

Would it be reasonable to just plain disable usage of uninitialized global variables, as it kind of goes against BPF's philosophy that everything should be written to, before can be read? So while we can just implicitly zero-out everything beforehand, it might be a good idea to remind and enforce that explictly?

Quoted 2 lines

There will be a verifier error, so the program with "int g" will not run, the same as today.

Quoted 8 lines

Yeah, I understand, but with pretty obscure error about not supporting relocations and stuff, right?

Quoted 2 lines

We could improve by flagging the error at compiler error or libbpf time.

So that's my point, that having compiler emit nicer error for target=bpf would be nice touch to user experience :)

I just removed a compiler error for static variables...

I will wait for this patch lands, hear people complains (either need to support "int g;" or need better error messages, etc.) and then decide what next to do ...

Quoted 44 lines
Quoted 44 lines

But it is not required. I am mentioning just for completeness.

Quoted 41 lines
Quoted 41 lines
Quoted 41 lines
tools/include/uapi/linux/bpf.h +12 -2
+
+                     if (insn_idx + 1 >= (int)prog->insns_cnt) {
+                             pr_warning("relocation out of range: '%s'\n",
+                                        prog->section_name);
+                             return -LIBBPF_ERRNO__RELOC;
+                     }
+                     insns[insn_idx].src_reg = BPF_PSEUDO_MAP_VALUE;
+                     insns[insn_idx].imm = obj->maps_global[map_idx].fd;
+                     insns[insn_idx + 1].imm = data_off;
                }
        }
 
@@ -1717,6 +1891,7 @@ __bpf_object__open(const char *path, void *obj_buf, size_t obj_buf_sz,
 
        CHECK_ERR(bpf_object__elf_init(obj), err, out);
        CHECK_ERR(bpf_object__check_endianness(obj), err, out);
+     CHECK_ERR(bpf_object__probe_caps(obj), err, out);
        CHECK_ERR(bpf_object__elf_collect(obj, flags), err, out);
        CHECK_ERR(bpf_object__collect_reloc(obj), err, out);
        CHECK_ERR(bpf_object__validate(obj, needs_kver), err, out);
@@ -1789,7 +1964,8 @@ int bpf_object__unload(struct bpf_object *obj)
 
        for (i = 0; i < obj->nr_maps; i++)
                zclose(obj->maps[i].fd);
-
+     for (i = 0; i < obj->nr_maps_global; i++)
+             zclose(obj->maps_global[i].fd);
        for (i = 0; i < obj->nr_programs; i++)
                bpf_program__unload(&obj->programs[i]);
 
@@ -1810,7 +1986,6 @@ int bpf_object__load(struct bpf_object *obj)
 
        obj->loaded = true;
 
-     CHECK_ERR(bpf_object__probe_caps(obj), err, out);
        CHECK_ERR(bpf_object__create_maps(obj), err, out);
        CHECK_ERR(bpf_object__relocate(obj), err, out);
        CHECK_ERR(bpf_object__load_progs(obj), err, out);
author maintainer
#36 lore raw

Re: [PATCH bpf-next v2 5/7] bpf, libbpf: support global data/bss/rodata sections

Quoted 5 lines · Yonghong Song
Quoted 4 lines · Andrii Nakryiko
Quoted 3 lines · Yonghong Song
Quoted 2 lines · Andrii Nakryiko
Quoted 1 line · Yonghong Song

On 2/28/19 3:18 PM, Daniel Borkmann wrote:

[...]

Quoted 15 lines
Quoted 15 lines
Quoted 8 lines
Quoted 5 lines

Would it be reasonable to just plain disable usage of uninitialized global variables, as it kind of goes against BPF's philosophy that everything should be written to, before can be read? So while we can just implicitly zero-out everything beforehand, it might be a good idea to remind and enforce that explictly?

There will be a verifier error, so the program with "int g" will not run, the same as today.

Yeah, I understand, but with pretty obscure error about not supporting relocations and stuff, right?

Quoted 2 lines

We could improve by flagging the error at compiler error or libbpf time.

Quoted 8 lines
Quoted 2 lines

So that's my point, that having compiler emit nicer error for target=bpf would be nice touch to user experience :)

I just removed a compiler error for static variables...

I will wait for this patch lands, hear people complains (either need to support "int g;" or need better error messages, etc.) and then decide what next to do ...

By the way, from LLVM side, do you think it makes sense for local vars where you encode the offset into insn->imm to already encode it into (insn+1)->imm of the ldimm64, so that loaders can just pass this offset through instead of fixing it up like I did? I'm fine either way though, just thought might be worth pointing out while we're at it. :)

Thanks,
Daniel

#37 lore raw

Re: [PATCH bpf-next v2 5/7] bpf, libbpf: support global data/bss/rodata sections

Quoted 31 lines · Daniel Borkmann
Quoted 5 lines · Yonghong Song
Quoted 4 lines · Andrii Nakryiko
Quoted 3 lines · Yonghong Song
Quoted 2 lines · Andrii Nakryiko
Quoted 1 line · Yonghong Song

On 2/28/19 3:18 PM, Daniel Borkmann wrote:

[...]

Quoted 15 lines
Quoted 15 lines
Quoted 8 lines
Quoted 5 lines

Would it be reasonable to just plain disable usage of uninitialized global variables, as it kind of goes against BPF's philosophy that everything should be written to, before can be read? So while we can just implicitly zero-out everything beforehand, it might be a good idea to remind and enforce that explictly?

There will be a verifier error, so the program with "int g" will not run, the same as today.

Yeah, I understand, but with pretty obscure error about not supporting relocations and stuff, right?

Quoted 2 lines

We could improve by flagging the error at compiler error or libbpf time.

Quoted 8 lines
Quoted 2 lines

So that's my point, that having compiler emit nicer error for target=bpf would be nice touch to user experience :)

I just removed a compiler error for static variables...

I will wait for this patch lands, hear people complains (either need to support "int g;" or need better error messages, etc.) and then decide what next to do ...

Quoted 5 lines

By the way, from LLVM side, do you think it makes sense for local vars where you encode the offset into insn->imm to already encode it into (insn+1)->imm of the ldimm64, so that loaders can just pass this offset through instead of fixing it up like I did? I'm fine either way though, just thought might be worth pointing out while we're at it. :)

Yes, llvm can do that. Let me prototype it and will let you know if it landed in llvm trunk.

Quoted 4 lines

Thanks,
Daniel

author maintainer
#38 lore raw

Re: [PATCH bpf-next v2 5/7] bpf, libbpf: support global data/bss/rodata sections

Quoted 32 lines · Yonghong Song
Quoted 31 lines · Daniel Borkmann
Quoted 5 lines · Yonghong Song
Quoted 4 lines · Andrii Nakryiko
Quoted 3 lines · Yonghong Song
Quoted 2 lines · Andrii Nakryiko
Quoted 1 line · Yonghong Song

On 2/28/19 3:18 PM, Daniel Borkmann wrote:

[...]

Quoted 23 lines
Quoted 9 lines
Quoted 8 lines
Quoted 5 lines

Would it be reasonable to just plain disable usage of uninitialized global variables, as it kind of goes against BPF's philosophy that everything should be written to, before can be read? So while we can just implicitly zero-out everything beforehand, it might be a good idea to remind and enforce that explictly?

There will be a verifier error, so the program with "int g" will not run, the same as today.

Quoted 8 lines

Yeah, I understand, but with pretty obscure error about not supporting relocations and stuff, right?

Quoted 2 lines

We could improve by flagging the error at compiler error or libbpf time.

So that's my point, that having compiler emit nicer error for target=bpf would be nice touch to user experience :)

I just removed a compiler error for static variables...

I will wait for this patch lands, hear people complains (either need to support "int g;" or need better error messages, etc.) and then decide what next to do ...

Quoted 8 lines
Quoted 5 lines

By the way, from LLVM side, do you think it makes sense for local vars where you encode the offset into insn->imm to already encode it into (insn+1)->imm of the ldimm64, so that loaders can just pass this offset through instead of fixing it up like I did? I'm fine either way though, just thought might be worth pointing out while we're at it. :)

Yes, llvm can do that. Let me prototype it and will let you know if it landed in llvm trunk.

Awesome, thanks!

#39 lore raw

static bpf vars. Was: [PATCH bpf-next v2 5/7] bpf, libbpf: support global data/bss/rodata sections

In reply to Daniel Borkmann
Quoted 1 line · Daniel Borkmann

Overall I think the patches and direction is great. Thanks a lot for working on it.
More thoughts below:

Quoted 5 lines

By the way, from LLVM side, do you think it makes sense for local vars where you encode the offset into insn->imm to already encode it into (insn+1)->imm of the ldimm64, so that loaders can just pass this offset through instead of fixing it up like I did? I'm fine either way though, just thought might be worth pointing out while we're at it. :)

1.
typical ldimm64 carries 64-bit value. upper 32-bits are in insn[1]->imm. I think it's better to stick to this meaning of imm for encoding
the section offset and keep it in insn[0]->imm.
Especially since from disassembler pov it looks like normal ldimm64 with relocation. Later libbpf does PSEUDO trick and can move [0]->imm to [1]->imm.
Or it can use [1]->imm to store FD to pass to kernel?
Another alternative is to use 16-bit of 'off' to encode the offset, but the limit of 32kbyte of static variables is probably too small.

2.
I think it's better to only allow 'static int foo' in libbpf for now. In C 'global' variables suppose to be shareable across multiple elf files. libbpf doesn't have support for it yet. We need to start discussing this multi elf support which will lead into discussion about bpf libraries.
I think we need a bit of freedom to decide the meaning of 'global' modifier. So for now I would support only 'static int foo' in libbpf.
llvm supports both and that's ok, since that's a standard elf markings.

Also were these patches tested with 'static struct {int a; int b;} foo;' and 'static char foo[]="my string";' ?
I suspect it should 'just work' with proposed design, but would be good to have a test.

3.
let's come up with concrete plan for BTF for these static variables. With normal maps the BTF was retrofitted via BPF_ANNOTATE_KV_PAIR macro and no one is proud of this interface choice. We had 'struct bpf_map_def' and the macro was the least evil.
For static variables let's figure out how to integrate BTF into it cleanly. LLVM already knows about the types. It needs another kind to describe the variable names and offsets. I think what we did with BTF_KIND_FUNC should be applicable here. Last time we discussed that we will add BTF_KIND_VAR for this purpose. Shouldn't be too much work to hack it into llvm now? I would even go a step further and make BTF to be mandatory for static vars. Introspection of BPF programs will go long way.

4.
if we make BTF mandatory then the issue of map names will be solved too. The <obj>.bss/data/rodata might not fit into map_name[16], but with BTF we can give it full name.
"<obj>.data" looks great to me especially from introspection angle.

5.
I think it makes sense to keep .bss vs .data vs .rodata separate. I can imagine a program using large zero-inited static array. It's important to save space in elf file, save time to do map create and map populate. With combined .data and .bss it would be much harder.

6.
as the next step would be good to add two new syscall command to read/write individual static variables. Something like:
bpf_map_read/write_bytes(map, key, offset_in_value, buf, size_of_buf) would allow user space to tweak certain variables.
With mandatory BTF we can have an api to read/write variable by name (and not only by offset).
Such bpf_map_read_bytes() would be useful for regular hash maps too. It's convenient to be able to update few bytes in the hash value instead of overwriting the whole thing.

7.
since these 3 maps are created as normal arrays from kernel pov the 'bpftool map show' should not exclude them from the output. Similarly libbpf api bpf_object__for_each_map() and bpf_map__next() should probably include them too. There can be bpf_map__is_pseudo() flag to tell them apart, but since it's a normal map in the kernel other libbpf accessors bpf_map__name(), bpf_map__pin() should work too.

author maintainer
#40 lore raw

Re: static bpf vars. Was: [PATCH bpf-next v2 5/7] bpf, libbpf: support global data/bss/rodata sections

Quoted 5 lines · Alexei Starovoitov

On Fri, Mar 01, 2019 at 09:06:35PM +0100, Daniel Borkmann wrote:

Overall I think the patches and direction is great. Thanks a lot for working on it.
More thoughts below:

Okay, thanks!

Quoted 11 lines
Quoted 5 lines

By the way, from LLVM side, do you think it makes sense for local vars where you encode the offset into insn->imm to already encode it into (insn+1)->imm of the ldimm64, so that loaders can just pass this offset through instead of fixing it up like I did? I'm fine either way though, just thought might be worth pointing out while we're at it. :)

1.
typical ldimm64 carries 64-bit value. upper 32-bits are in insn[1]->imm. I think it's better to stick to this meaning of imm for encoding
the section offset and keep it in insn[0]->imm.
Especially since from disassembler pov it looks like normal ldimm64 with relocation.

Hadn't thought about it from this angle, but yes, from debugging /disasm point of view it makes perfect sense to keep it as-is.

Quoted 2 lines

Later libbpf does PSEUDO trick and can move [0]->imm to [1]->imm. Or it can use [1]->imm to store FD to pass to kernel?

My preference would rather be the former as it's consistent with how we do it for normal map fds as well, so I'd keep loader side having it moved as it currently is; I think it's fine.

Quoted 2 lines

Another alternative is to use 16-bit of 'off' to encode the offset, but the limit of 32kbyte of static variables is probably too small.

Yes agree, and I've also reused both off fields now for optionally allowing to select an index into the array based on Andrii's feedback.

Quoted 8 lines

2.
I think it's better to only allow 'static int foo' in libbpf for now. In C 'global' variables suppose to be shareable across multiple elf files. libbpf doesn't have support for it yet. We need to start discussing this multi elf support which will lead into discussion about bpf libraries.
I think we need a bit of freedom to decide the meaning of 'global' modifier. So for now I would support only 'static int foo' in libbpf.
llvm supports both and that's ok, since that's a standard elf markings.

Makes sense, we first need to have a better understanding on how semantics should look there from BPF pov. I'll restrict libbpf for static vars for the time being, and throw an error message otherwise.

There is one more semantical question: a BPF ELF file can have multiple program entry points in it. Both programs from there could refer to static global variables inside that object file. My thinking which this patch set also implemented is to have both of them refer to the same .bss/.data/.rodata map (and _not_ separate ones) as I think this would also naturally be what the user is expecting when referring to the same global vars in the given object file.

Quoted 3 lines

Also were these patches tested with 'static struct {int a; int b;} foo;' and 'static char foo[]="my string";' ?
I suspect it should 'just work' with proposed design, but would be good to have a test.

+1, I'll add more tests. Iirc, I tested it back with the original prototype from LPC which worked same way from high level point of view, but good to have it explicitly in BPF selftests, agree, will add.

Quoted 4 lines

3.
let's come up with concrete plan for BTF for these static variables. With normal maps the BTF was retrofitted via BPF_ANNOTATE_KV_PAIR macro and no one is proud of this interface choice. We had 'struct bpf_map_def'

Quoted 8 lines

and the macro was the least evil.
For static variables let's figure out how to integrate BTF into it cleanly. LLVM already knows about the types. It needs another kind to describe the variable names and offsets. I think what we did with BTF_KIND_FUNC should be applicable here. Last time we discussed that we will add BTF_KIND_VAR for this purpose. Shouldn't be too much work to hack it into llvm now? I would even go a step further and make BTF to be mandatory for static vars. Introspection of BPF programs will go long way.

We can make that mandatory, nice thing would be that such BPF_ANNOTATE_KV_PAIR macro hack wouldn't be needed at all. From BTF pov, that would be some sort of BTF_KIND_SEC as a section 'container' for all BTF_KIND_VAR variables belonging to it, so map could use its id to describe its map value as such?

Quoted 5 lines

4.
if we make BTF mandatory then the issue of map names will be solved too. The <obj>.bss/data/rodata might not fit into map_name[16], but with BTF we can give it full name.
"<obj>.data" looks great to me especially from introspection angle.

+1

Quoted 5 lines

5.
I think it makes sense to keep .bss vs .data vs .rodata separate. I can imagine a program using large zero-inited static array. It's important to save space in elf file, save time to do map create and map populate. With combined .data and .bss it would be much harder.

I'm fine either way, but yeah, this approach as also taken here means less fixing up from loader pov, and it would probably also make BTF handling easier. So, sticking with separate .bss/.data/.rodata then.

Quoted 10 lines

6.
as the next step would be good to add two new syscall command to read/write individual static variables. Something like:
bpf_map_read/write_bytes(map, key, offset_in_value, buf, size_of_buf) would allow user space to tweak certain variables.
With mandatory BTF we can have an api to read/write variable by name (and not only by offset).
Such bpf_map_read_bytes() would be useful for regular hash maps too. It's convenient to be able to update few bytes in the hash value instead of overwriting the whole thing.

Definitely useful, there was also the suggestion to have an mmap interface which would work at least for array maps, though haven't looked yet into what would be needed from buffer mgmt side to remap for processes that just got the fd by id or via bpf fs for retrieving existing content.

Quoted 7 lines

7.
since these 3 maps are created as normal arrays from kernel pov the 'bpftool map show' should not exclude them from the output. Similarly libbpf api bpf_object__for_each_map() and bpf_map__next() should probably include them too. There can be bpf_map__is_pseudo() flag to tell them apart, but since it's a normal map in the kernel other libbpf accessors bpf_map__name(), bpf_map__pin() should work too.

Yeah, I'll integrate it there in libbpf, as long as we have something to tell them apart from a user pov it should be good.

Thanks,
Daniel

author maintainer
#41 lore raw

Re: [PATCH bpf-next v2 5/7] bpf, libbpf: support global data/bss/rodata sections

In reply to Yonghong Song
Quoted 1 line · Yonghong Song

On 2/28/19 3:18 PM, Daniel Borkmann wrote:

[...]

Quoted 93 lines

tools/lib/bpf/libbpf.c bpf_program__relocate(struct bpf_program *prog, struct bpf_object *obj) · line 1579

Quoted 13 lines
tools/lib/bpf/libbpf.c +9 -0
@@ -1412,6 +1568,24 @@ bpf_program__relocate(struct bpf_program *prog, struct bpf_object *obj)
  						      &prog->reloc_desc[i]);
  			if (err)
  				return err;
+		} else if (prog->reloc_desc[i].type == RELO_DATA ||
+			   prog->reloc_desc[i].type == RELO_RODATA ||
+			   prog->reloc_desc[i].type == RELO_BSS) {
+			struct bpf_insn *insns = prog->insns;
+			int insn_idx, map_idx, data_off;
+
+			insn_idx = prog->reloc_desc[i].insn_idx;
+			map_idx  = prog->reloc_desc[i].map_idx;
+			data_off = insns[insn_idx].imm;

I want to point to a subtle difference here between handling pure global variables and static global variables. The "imm" value is only available for static variables. For example,

-bash-4.4$ cat g.c
static volatile long sg = 2;
static volatile int si = 3;
long g = 4;
int i = 5;
int test() { return sg + si + g + i; }

(quoted diff) +0 -3
-bash-4.4$
-bash-4.4$ clang -target bpf -O2 -c g.c 
 
-bash-4.4$ readelf -s g.o 

Symbol table '.symtab' contains 8 entries:

    Num:    Value          Size Type    Bind   Vis      Ndx Name
      0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
      1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS g.c
      2: 0000000000000010     8 OBJECT  LOCAL  DEFAULT    4 sg
      3: 0000000000000018     4 OBJECT  LOCAL  DEFAULT    4 si
      4: 0000000000000000     0 SECTION LOCAL  DEFAULT    4
      5: 0000000000000000     8 OBJECT  GLOBAL DEFAULT    4 g
      6: 0000000000000008     4 OBJECT  GLOBAL DEFAULT    4 i
      7: 0000000000000000   128 FUNC    GLOBAL DEFAULT    2 test
(quoted diff) +0 -2
-bash-4.4$
-bash-4.4$ llvm-readelf -r g.o

Relocation section '.rel.text' at offset 0x1d8 contains 4 entries:
Offset Info Type Symbol's
Value Symbol's Name
0000000000000000 0000000400000001 R_BPF_64_64 0000000000000000 .data
0000000000000018 0000000400000001 R_BPF_64_64 0000000000000000 .data

0000000000000038  0000000500000001 R_BPF_64_64            0000000000000000 g
0000000000000058  0000000600000001 R_BPF_64_64            0000000000000008 i

-bash-4.4$ llvm-objdump -d g.o

g.o: file format ELF64-BPF

Disassembly of section .text:
0000000000000000 test:

        0:       18 01 00 00 10 00 00 00 00 00 00 00 00 00 00 00 
r1 = 16 ll
        2:       79 11 00 00 00 00 00 00         r1 = *(u64 *)(r1 + 0)
        3:       18 02 00 00 18 00 00 00 00 00 00 00 00 00 00 00 
r2 = 24 ll
        5:       61 22 00 00 00 00 00 00         r2 = *(u32 *)(r2 + 0)
        6:       0f 21 00 00 00 00 00 00         r1 += r2
        7:       18 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
r2 = 0 ll
        9:       79 22 00 00 00 00 00 00         r2 = *(u64 *)(r2 + 0)
       10:       0f 21 00 00 00 00 00 00         r1 += r2
       11:       18 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
r2 = 0 ll
       13:       61 20 00 00 00 00 00 00         r0 = *(u32 *)(r2 + 0)
       14:       0f 10 00 00 00 00 00 00         r0 += r1
       15:       95 00 00 00 00 00 00 00         exit

-bash-4.4$

You can see the above, the non-static global access does not have its in-section offset encoded in the insn itself. The difference is due to llvm treating static global and non-static global differently.

To support both cases, during relocation recording stage, you can also record:
. symbol binding (GELF_ST_BIND(sym.st_info)),
non-static global has binding STB_GLOBAL and static global has binding STB_LOCAL
. symbol value (sym.st_value)

During the above relocation resolution, if symbol bind is local, do what you already did here. If symbol bind is global, assign data_off with symbol value.

This applied to both .data and .rodata sections.

Quoted 8 lines

The non initialized
global variable will not be in any allocated section in ELF file, it is in a COM section which is to be allocated by loader. So user defines some like

    int g;

and later on uses it. Right now, it will not work. The workaround is "int g = 4", or "static int g". I guess it should be okay, we should encourage users to use "static" variables instead.

Agree and noted, and thanks for pointing this out, Yonghong! I'll fix this up accordingly in next round.

Thanks a lot,
Daniel

author maintainer
#42 lore raw

PATCH v2 6/7 bpf, selftest: test global data/bss/rodata sections

In reply to Daniel Borkmann

From: Joe Stringer <[email protected]>

Add tests for libbpf relocation of static variable references into the .data, .rodata and .bss sections of the ELF. Tests with different offsets are all passing:

  # ./test_progs
  [...]
  test_static_data_access:PASS:load program 0 nsec
  test_static_data_access:PASS:pass packet 278 nsec
  test_static_data_access:PASS:relocate .bss reference 1 278 nsec
  test_static_data_access:PASS:relocate .data reference 1 278 nsec
  test_static_data_access:PASS:relocate .rodata reference 1 278 nsec
  test_static_data_access:PASS:relocate .bss reference 2 278 nsec
  test_static_data_access:PASS:relocate .data reference 2 278 nsec
  test_static_data_access:PASS:relocate .rodata reference 2 278 nsec
  test_static_data_access:PASS:relocate .bss reference 3 278 nsec
  test_static_data_access:PASS:relocate .bss reference 4 278 nsec
  Summary: 223 PASSED, 0 FAILED

Joint work with Daniel Borkmann.

---
 tools/testing/selftests/bpf/bpf_helpers.h     |  2 +-
 .../selftests/bpf/progs/test_global_data.c    | 61 +++++++++++++++++++
 tools/testing/selftests/bpf/test_progs.c      | 50 +++++++++++++++
 3 files changed, 112 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/bpf/progs/test_global_data.c
tools/testing/selftests/bpf/bpf_helpers.h +1 -1
index d9999f1ed1d2..0463662935f9 100644
@@ -11,7 +11,7 @@
 /* helper functions called from eBPF programs written in C */
 static void *(*bpf_map_lookup_elem)(void *map, void *key) =
 	(void *) BPF_FUNC_map_lookup_elem;
-static int (*bpf_map_update_elem)(void *map, void *key, void *value,
+static int (*bpf_map_update_elem)(void *map, const void *key, const void *value,
 				  unsigned long long flags) =
 	(void *) BPF_FUNC_map_update_elem;
 static int (*bpf_map_delete_elem)(void *map, void *key) =
tools/testing/selftests/bpf/progs/test_global_data.c new file +61 -0

61 lines not on this page · raw message

tools/testing/selftests/bpf/test_progs.c +50 -0

62 lines not on this page · raw message

Signature · 1 line
2.17.1
#43 lore raw

Re: [PATCH bpf-next v2 6/7] bpf, selftest: test global data/bss/rodata sections

Quoted 64 lines · Daniel Borkmann

From: Joe Stringer <[email protected]>

Add tests for libbpf relocation of static variable references into the .data, .rodata and .bss sections of the ELF. Tests with different offsets are all passing:

  # ./test_progs
  [...]
  test_static_data_access:PASS:load program 0 nsec
  test_static_data_access:PASS:pass packet 278 nsec
  test_static_data_access:PASS:relocate .bss reference 1 278 nsec
  test_static_data_access:PASS:relocate .data reference 1 278 nsec
  test_static_data_access:PASS:relocate .rodata reference 1 278 nsec
  test_static_data_access:PASS:relocate .bss reference 2 278 nsec
  test_static_data_access:PASS:relocate .data reference 2 278 nsec
  test_static_data_access:PASS:relocate .rodata reference 2 278 nsec
  test_static_data_access:PASS:relocate .bss reference 3 278 nsec
  test_static_data_access:PASS:relocate .bss reference 4 278 nsec
  Summary: 223 PASSED, 0 FAILED

Joint work with Daniel Borkmann.

---
 tools/testing/selftests/bpf/bpf_helpers.h     |  2 +-
 .../selftests/bpf/progs/test_global_data.c    | 61 +++++++++++++++++++
 tools/testing/selftests/bpf/test_progs.c      | 50 +++++++++++++++
 3 files changed, 112 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/bpf/progs/test_global_data.c
tools/testing/selftests/bpf/bpf_helpers.h +1 -1
index d9999f1ed1d2..0463662935f9 100644
@@ -11,7 +11,7 @@
 /* helper functions called from eBPF programs written in C */
 static void *(*bpf_map_lookup_elem)(void *map, void *key) =
        (void *) BPF_FUNC_map_lookup_elem;
-static int (*bpf_map_update_elem)(void *map, void *key, void *value,
+static int (*bpf_map_update_elem)(void *map, const void *key, const void *value,
                                  unsigned long long flags) =
        (void *) BPF_FUNC_map_update_elem;
 static int (*bpf_map_delete_elem)(void *map, void *key) =
tools/testing/selftests/bpf/progs/test_global_data.c new file +13 -0
new file mode 100644
index 000000000000..2a7cf40b8efb
@@ -0,0 +1,61 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2019 Isovalent, Inc.
+
+#include <linux/bpf.h>
+#include <linux/pkt_cls.h>
+#include <string.h>
+
+#include "bpf_helpers.h"
+
+struct bpf_map_def SEC("maps") result = {
+       .type           = BPF_MAP_TYPE_ARRAY,
+       .key_size       = sizeof(__u32),
+       .value_size     = sizeof(__u64),

tools/testing/selftests/bpf/progs/test_global_data.c line 23

Quoted 10 lines
tools/testing/selftests/bpf/progs/test_global_data.c new file +10 -0
+       .max_entries    = 9,
+};
+
+static       __u64 static_bss     = 0;         /* Reloc reference to .bss  section   */
+static       __u64 static_data    = 42;                /* Reloc reference to .data section   */
+static const __u64 static_rodata  = 24;                /* Reloc reference to .rodata section */
+static       __u64 static_bss2    = 0;         /* Reloc reference to .bss  section   */
+static       __u64 static_data2   = 0xffeeff;  /* Reloc reference to .data section   */
+static const __u64 static_rodata2 = 0xabab;    /* Reloc reference to .rodata section */
+static const __u64 static_rodata3 = 0xab;      /* Reloc reference to .rodata section */

In the light of Yonghong's explanation about static vs non-static globals, it would be nice to add test for non-static initialized globals here as well?

Quoted 109 lines
tools/testing/selftests/bpf/progs/test_global_data.c new file +38 -0
+
+SEC("static_data_load")
+int load_static_data(struct __sk_buff *skb)
+{
+       __u32 key;
+
+       key = 0;
+       bpf_map_update_elem(&result, &key, &static_bss, 0);
+
+       key = 1;
+       bpf_map_update_elem(&result, &key, &static_data, 0);
+
+       key = 2;
+       bpf_map_update_elem(&result, &key, &static_rodata, 0);
+
+       key = 3;
+       bpf_map_update_elem(&result, &key, &static_bss2, 0);
+
+       key = 4;
+       bpf_map_update_elem(&result, &key, &static_data2, 0);
+
+       key = 5;
+       bpf_map_update_elem(&result, &key, &static_rodata2, 0);
+
+       key = 6;
+       static_bss2 = 1234;
+       bpf_map_update_elem(&result, &key, &static_bss2, 0);
+
+       key = 7;
+       bpf_map_update_elem(&result, &key, &static_bss, 0);
+
+       key = 8;
+       bpf_map_update_elem(&result, &key, &static_rodata3, 0);
+
+       return TC_ACT_OK;
+}
+
+char _license[] SEC("license") = "GPL";
tools/testing/selftests/bpf/test_progs.c +50 -1
index c59d2e015d16..a3e64c054572 100644
@@ -738,6 +738,55 @@ static void test_pkt_md_access(void)
        bpf_object__close(obj);
 }
 
+static void test_static_data_access(void)
+{
+       const char *file = "./test_global_data.o";
+       struct bpf_object *obj;
+       __u32 duration = 0, retval;
+       int i, err, prog_fd, map_fd;
+       uint64_t value;
+
+       err = bpf_prog_load(file, BPF_PROG_TYPE_SCHED_CLS, &obj, &prog_fd);
+       if (CHECK(err, "load program", "error %d loading %s\n", err, file))
+               return;
+
+       map_fd = bpf_find_map(__func__, obj, "result");
+       if (map_fd < 0) {
+               error_cnt++;
+               goto close_prog;
+       }
+
+       err = bpf_prog_test_run(prog_fd, 1, &pkt_v4, sizeof(pkt_v4),
+                               NULL, NULL, &retval, &duration);
+       CHECK(err || retval, "pass packet",
+             "err %d errno %d retval %d duration %d\n",
+             err, errno, retval, duration);
+
+       struct {
+               char *name;
+               uint32_t key;
+               uint64_t value;
+       } tests[] = {
+               { "relocate .bss reference 1",    0, 0 },
+               { "relocate .data reference 1",   1, 42 },
+               { "relocate .rodata reference 1", 2, 24 },
+               { "relocate .bss reference 2",    3, 0 },
+               { "relocate .data reference 2",   4, 0xffeeff },
+               { "relocate .rodata reference 2", 5, 0xabab },
+               { "relocate .bss reference 3",    6, 1234 },
+               { "relocate .bss reference 4",    7, 0 },
+       };
+       for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
+               err = bpf_map_lookup_elem(map_fd, &tests[i].key, &value);
+               CHECK (err || value != tests[i].value, tests[i].name,
+                      "err %d result %lu expected %lu\n",
+                      err, value, tests[i].value);
+       }
+
+close_prog:
+       bpf_object__close(obj);
+}
+
 static void test_obj_name(void)
 {
        struct {
@@ -2182,6 +2231,7 @@ int main(void)
        test_map_lock();
        test_signal_pending(BPF_PROG_TYPE_SOCKET_FILTER);
        test_signal_pending(BPF_PROG_TYPE_FLOW_DISSECTOR);
+       test_static_data_access();
 
        printf("Summary: %d PASSED, %d FAILED\n", pass_cnt, error_cnt);
        return error_cnt ? EXIT_FAILURE : EXIT_SUCCESS;
--

2.17.1

author maintainer
#44 lore raw

Re: [PATCH bpf-next v2 6/7] bpf, selftest: test global data/bss/rodata sections

Quoted 70 lines · Andrii Nakryiko
Quoted 69 lines · Daniel Borkmann

From: Joe Stringer <[email protected]>

Add tests for libbpf relocation of static variable references into the .data, .rodata and .bss sections of the ELF. Tests with different offsets are all passing:

  # ./test_progs
  [...]
  test_static_data_access:PASS:load program 0 nsec
  test_static_data_access:PASS:pass packet 278 nsec
  test_static_data_access:PASS:relocate .bss reference 1 278 nsec
  test_static_data_access:PASS:relocate .data reference 1 278 nsec
  test_static_data_access:PASS:relocate .rodata reference 1 278 nsec
  test_static_data_access:PASS:relocate .bss reference 2 278 nsec
  test_static_data_access:PASS:relocate .data reference 2 278 nsec
  test_static_data_access:PASS:relocate .rodata reference 2 278 nsec
  test_static_data_access:PASS:relocate .bss reference 3 278 nsec
  test_static_data_access:PASS:relocate .bss reference 4 278 nsec
  Summary: 223 PASSED, 0 FAILED

Joint work with Daniel Borkmann.

---
 tools/testing/selftests/bpf/bpf_helpers.h     |  2 +-
 .../selftests/bpf/progs/test_global_data.c    | 61 +++++++++++++++++++
 tools/testing/selftests/bpf/test_progs.c      | 50 +++++++++++++++
 3 files changed, 112 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/bpf/progs/test_global_data.c
tools/testing/selftests/bpf/bpf_helpers.h +1 -1
index d9999f1ed1d2..0463662935f9 100644
@@ -11,7 +11,7 @@
 /* helper functions called from eBPF programs written in C */
 static void *(*bpf_map_lookup_elem)(void *map, void *key) =
        (void *) BPF_FUNC_map_lookup_elem;
-static int (*bpf_map_update_elem)(void *map, void *key, void *value,
+static int (*bpf_map_update_elem)(void *map, const void *key, const void *value,
                                  unsigned long long flags) =
        (void *) BPF_FUNC_map_update_elem;
 static int (*bpf_map_delete_elem)(void *map, void *key) =
tools/testing/selftests/bpf/progs/test_global_data.c new file +19 -0
new file mode 100644
index 000000000000..2a7cf40b8efb
@@ -0,0 +1,61 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2019 Isovalent, Inc.
+
+#include <linux/bpf.h>
+#include <linux/pkt_cls.h>
+#include <string.h>
+
+#include "bpf_helpers.h"
+
+struct bpf_map_def SEC("maps") result = {
+       .type           = BPF_MAP_TYPE_ARRAY,
+       .key_size       = sizeof(__u32),
+       .value_size     = sizeof(__u64),
+       .max_entries    = 9,
+};
+
+static       __u64 static_bss     = 0;         /* Reloc reference to .bss  section   */
+static       __u64 static_data    = 42;                /* Reloc reference to .data section   */
+static const __u64 static_rodata  = 24;                /* Reloc reference to .rodata section */
Quoted 8 lines

tools/testing/selftests/bpf/progs/test_global_data.c line 23

Quoted 4 lines
tools/testing/selftests/bpf/progs/test_global_data.c new file +4 -0
+static       __u64 static_bss2    = 0;         /* Reloc reference to .bss  section   */
+static       __u64 static_data2   = 0xffeeff;  /* Reloc reference to .data section   */
+static const __u64 static_rodata2 = 0xabab;    /* Reloc reference to .rodata section */
+static const __u64 static_rodata3 = 0xab;      /* Reloc reference to .rodata section */

In the light of Yonghong's explanation about static vs non-static globals, it would be nice to add test for non-static initialized globals here as well?

Yes, agree, I'll add them as well and integrate the correct offset for libbpf along with it.

Cheers,
Daniel

#45 lore raw

[LKP] [bpf, selftest] 4beb1a5f45: kernel_selftests.bpf.make_fail

In reply to Daniel Borkmann
FYI, we noticed the following commit (built with gcc-8):

FYI, we noticed the following commit (built with gcc-8):

commit: 4beb1a5f45dc210b1dcccadaf77cfdd454b4b170 ("[PATCH bpf-next v2 6/7] bpf, selftest: test global data/bss/rodata sections")
url: https://github.com/0day-ci/linux/commits/Daniel-Borkmann/BPF-support-for-global-data/20190301-112203
base: https://git.kernel.org/cgit/linux/kernel/git/bpf/bpf-next.git master

in testcase: kernel_selftests
with following parameters:

group: kselftests-00

test-description: The kernel contains a set of "self tests" under the tools/testing/selftests/ directory. These are intended to be small unit tests to exercise individual code paths in the kernel.
test-url: https://www.kernel.org/doc/Documentation/kselftest.txt

on test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 4G

caused below changes (please refer to attached dmesg/kmsg for entire log/backtrace):

KERNEL SELFTESTS: linux_headers_dir is /usr/src/linux-headers-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170

2019-03-03 04:11:07 ln -sf /usr/bin/clang-7 /usr/bin/clang
2019-03-03 04:11:07 ln -sf /usr/bin/llc-7 /usr/bin/llc
2019-03-03 04:11:07 make run_tests -C android
make: Entering directory '/usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/android'
make[1]: Entering directory '/usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/android/ion'
gcc  -I. -I../../../../../drivers/staging/android/uapi/ -I../../../../../usr/include/ -Wall -O2 -g    ionapp_export.c ipcsocket.c ionutils.c   -o ionapp_export
gcc  -I. -I../../../../../drivers/staging/android/uapi/ -I../../../../../usr/include/ -Wall -O2 -g    ionapp_import.c ipcsocket.c ionutils.c   -o ionapp_import
gcc  -I. -I../../../../../drivers/staging/android/uapi/ -I../../../../../usr/include/ -Wall -O2 -g    ionmap_test.c ipcsocket.c ionutils.c   -o ionmap_test
make ARCH=x86 -C ../../../../.. headers_install
make[2]: Entering directory '/usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170'
  HOSTCC  scripts/basic/fixdep
  WRAP    arch/x86/include/generated/uapi/asm/socket.h
  WRAP    arch/x86/include/generated/uapi/asm/bpf_perf_event.h
  WRAP    arch/x86/include/generated/uapi/asm/poll.h
  SYSTBL  arch/x86/include/generated/asm/syscalls_32.h
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_32.h
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_64.h
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_x32.h
  HOSTCC  arch/x86/tools/relocs_32.o
  HOSTCC  arch/x86/tools/relocs_64.o
  HOSTCC  arch/x86/tools/relocs_common.o
  HOSTLD  arch/x86/tools/relocs
  UPD     include/generated/uapi/linux/version.h
  HOSTCC  scripts/unifdef

INSTALL usr/include/asm-generic/ (36 files)
INSTALL usr/include/drm/ (26 files)
INSTALL usr/include/linux/ (505 files)
INSTALL usr/include/linux/android/ (2 files)
INSTALL usr/include/linux/byteorder/ (2 files)
INSTALL usr/include/linux/caif/ (2 files)
INSTALL usr/include/linux/can/ (6 files)
INSTALL usr/include/linux/cifs/ (1 file)
INSTALL usr/include/linux/dvb/ (8 files)
INSTALL usr/include/linux/genwqe/ (1 file)
INSTALL usr/include/linux/hdlc/ (1 file)
INSTALL usr/include/linux/hsi/ (2 files)
INSTALL usr/include/linux/iio/ (2 files)
INSTALL usr/include/linux/isdn/ (1 file)
INSTALL usr/include/linux/mmc/ (1 file)
INSTALL usr/include/linux/netfilter/ (88 files)
INSTALL usr/include/linux/netfilter/ipset/ (4 files)
INSTALL usr/include/linux/netfilter_arp/ (2 files)
INSTALL usr/include/linux/netfilter_bridge/ (17 files)
INSTALL usr/include/linux/netfilter_ipv4/ (9 files)
INSTALL usr/include/linux/netfilter_ipv6/ (13 files)
INSTALL usr/include/linux/nfsd/ (5 files)
INSTALL usr/include/linux/raid/ (2 files)
INSTALL usr/include/linux/sched/ (1 file)
INSTALL usr/include/linux/spi/ (1 file)
INSTALL usr/include/linux/sunrpc/ (1 file)
INSTALL usr/include/linux/tc_act/ (15 files)
INSTALL usr/include/linux/tc_ematch/ (5 files)
INSTALL usr/include/linux/usb/ (13 files)
INSTALL usr/include/linux/wimax/ (1 file)
INSTALL usr/include/misc/ (2 files)
INSTALL usr/include/mtd/ (5 files)
INSTALL usr/include/rdma/ (25 files)
INSTALL usr/include/rdma/hfi/ (2 files)
INSTALL usr/include/scsi/ (5 files)
INSTALL usr/include/scsi/fc/ (4 files)
INSTALL usr/include/sound/ (16 files)
INSTALL usr/include/video/ (3 files)
INSTALL usr/include/xen/ (4 files)
INSTALL usr/include/asm/ (62 files)
make[2]: Leaving directory '/usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170'
make[1]: Leaving directory '/usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/android/ion' TAP version 13
selftests: android: run.sh
========================================
ion_test.sh: No /dev/ion device found
ion_test.sh: May be CONFIG_ION is not set
not ok 1..1 selftests: android: run.sh [SKIP]
make: Leaving directory '/usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/android' ping6 is /bin/ping6
ignored_by_lkp bpf.test_lirc_mode2_user test

2019-03-03 04:13:13 make run_tests -C bpf

make: Entering directory '/usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf' /bin/sh: llvm-readelf: command not found
make -C ../../../lib/bpf OUTPUT=/usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/ make[1]: Entering directory '/usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/lib/bpf'

Auto-detecting system features:
... libelf: [ on ]
... bpf: [ on ]

  HOSTCC   /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/fixdep.o
  HOSTLD   /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/fixdep-in.o
  LINK     /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/fixdep
  CC       /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.o
  CC       /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/bpf.o
  CC       /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/nlattr.o
  CC       /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/btf.o
  CC       /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf_errno.o
  CC       /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/str_error.o
  CC       /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/netlink.o
  CC       /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/bpf_prog_linfo.o
  CC       /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf_probes.o
  CC       /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/xsk.o
  LD       /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf-in.o
  LINK     /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a
  LINK     /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.so
make[1]: Leaving directory '/usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/lib/bpf'
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf -I../../../../include/generated  -I../../../include -I/usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf    test_verifier.c /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/verifier/tests.h -lcap -lelf -lrt -lpthread -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_verifier
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf -I../../../../include/generated  -I../../../include    test_tag.c /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a -lcap -lelf -lrt -lpthread -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_tag
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf -I../../../../include/generated  -I../../../include    test_maps.c /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a -lcap -lelf -lrt -lpthread -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_maps
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf -I../../../../include/generated  -I../../../include    test_lru_map.c /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a -lcap -lelf -lrt -lpthread -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_lru_map
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf -I../../../../include/generated  -I../../../include    test_lpm_map.c /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a -lcap -lelf -lrt -lpthread -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_lpm_map
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf -I../../../../include/generated  -I../../../include    test_progs.c /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a trace_helpers.c -lcap -lelf -lrt -lpthread -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_progs
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf -I../../../../include/generated  -I../../../include    test_align.c /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a -lcap -lelf -lrt -lpthread -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_align
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf -I../../../../include/generated  -I../../../include    test_verifier_log.c /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a -lcap -lelf -lrt -lpthread -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_verifier_log
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf -I../../../../include/generated  -I../../../include    test_dev_cgroup.c /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a cgroup_helpers.c -lcap -lelf -lrt -lpthread -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_dev_cgroup
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf -I../../../../include/generated  -I../../../include    test_tcpbpf_user.c /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a cgroup_helpers.c -lcap -lelf -lrt -lpthread -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_tcpbpf_user
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf -I../../../../include/generated  -I../../../include    test_sock.c /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a cgroup_helpers.c -lcap -lelf -lrt -lpthread -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_sock
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf -I../../../../include/generated  -I../../../include    test_btf.c /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a -lcap -lelf -lrt -lpthread -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_btf
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf -I../../../../include/generated  -I../../../include    test_sockmap.c /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a cgroup_helpers.c -lcap -lelf -lrt -lpthread -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_sockmap
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf -I../../../../include/generated  -I../../../include    get_cgroup_id_user.c /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a cgroup_helpers.c -lcap -lelf -lrt -lpthread -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/get_cgroup_id_user
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf -I../../../../include/generated  -I../../../include    test_socket_cookie.c /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a cgroup_helpers.c -lcap -lelf -lrt -lpthread -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_socket_cookie
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf -I../../../../include/generated  -I../../../include    test_cgroup_storage.c /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a cgroup_helpers.c -lcap -lelf -lrt -lpthread -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_cgroup_storage
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf -I../../../../include/generated  -I../../../include    test_select_reuseport.c /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a -lcap -lelf -lrt -lpthread -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_select_reuseport
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf -I../../../../include/generated  -I../../../include    test_section_names.c /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a -lcap -lelf -lrt -lpthread -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_section_names
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf -I../../../../include/generated  -I../../../include    test_netcnt.c /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a cgroup_helpers.c -lcap -lelf -lrt -lpthread -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_netcnt
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf -I../../../../include/generated  -I../../../include    test_tcpnotify_user.c /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a cgroup_helpers.c trace_helpers.c -lcap -lelf -lrt -lpthread -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_tcpnotify_user
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf -I../../../../include/generated  -I../../../include    test_sock_fields.c /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a cgroup_helpers.c -lcap -lelf -lrt -lpthread -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_sock_fields
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf -I../../../../include/generated  -I../../../include    test_libbpf_open.c /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a -lcap -lelf -lrt -lpthread -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_libbpf_open
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf -I../../../../include/generated  -I../../../include    test_sock_addr.c /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a cgroup_helpers.c -lcap -lelf -lrt -lpthread -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_sock_addr
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf -I../../../../include/generated  -I../../../include    test_skb_cgroup_id_user.c /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a cgroup_helpers.c -lcap -lelf -lrt -lpthread -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_skb_cgroup_id_user
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf -I../../../../include/generated  -I../../../include    flow_dissector_load.c /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a -lcap -lelf -lrt -lpthread -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/flow_dissector_load
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf -I../../../../include/generated  -I../../../include    test_flow_dissector.c /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/libbpf.a -lcap -lelf -lrt -lpthread -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_flow_dissector
clang -I. -I./include/uapi -I../../../include/uapi -idirafter /usr/local/include -idirafter /usr/lib/llvm-7/lib/clang/7.0.1/include -idirafter /usr/include/x86_64-linux-gnu -idirafter /usr/include -Wno-compare-distinct-pointer-types \
	 -O2 -target bpf -emit-llvm -c progs/test_stack_map.c -o - |      \
llc -march=bpf -mcpu=probe  -filetype=obj -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_stack_map.o
clang -I. -I./include/uapi -I../../../include/uapi -idirafter /usr/local/include -idirafter /usr/lib/llvm-7/lib/clang/7.0.1/include -idirafter /usr/include/x86_64-linux-gnu -idirafter /usr/include -Wno-compare-distinct-pointer-types \
	 -O2 -target bpf -emit-llvm -c progs/test_tunnel_kern.c -o - |      \
llc -march=bpf -mcpu=probe  -filetype=obj -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_tunnel_kern.o
clang -I. -I./include/uapi -I../../../include/uapi -idirafter /usr/local/include -idirafter /usr/lib/llvm-7/lib/clang/7.0.1/include -idirafter /usr/include/x86_64-linux-gnu -idirafter /usr/include -Wno-compare-distinct-pointer-types \
	 -O2 -target bpf -emit-llvm -c progs/dev_cgroup.c -o - |      \
llc -march=bpf -mcpu=probe  -filetype=obj -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/dev_cgroup.o
clang -I. -I./include/uapi -I../../../include/uapi -idirafter /usr/local/include -idirafter /usr/lib/llvm-7/lib/clang/7.0.1/include -idirafter /usr/include/x86_64-linux-gnu -idirafter /usr/include -Wno-compare-distinct-pointer-types \
	 -O2 -target bpf -emit-llvm -c progs/test_lwt_ip_encap.c -o - |      \
llc -march=bpf -mcpu=probe  -filetype=obj -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_lwt_ip_encap.o
clang -I. -I./include/uapi -I../../../include/uapi -idirafter /usr/local/include -idirafter /usr/lib/llvm-7/lib/clang/7.0.1/include -idirafter /usr/include/x86_64-linux-gnu -idirafter /usr/include -Wno-compare-distinct-pointer-types \
	 -O2 -target bpf -emit-llvm -c progs/test_obj_id.c -o - |      \
llc -march=bpf -mcpu=probe  -filetype=obj -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_obj_id.o
clang -I. -I./include/uapi -I../../../include/uapi -idirafter /usr/local/include -idirafter /usr/lib/llvm-7/lib/clang/7.0.1/include -idirafter /usr/include/x86_64-linux-gnu -idirafter /usr/include -Wno-compare-distinct-pointer-types \
	 -O2 -target bpf -emit-llvm -c progs/test_global_data.c -o - |      \

llc -march=bpf -mcpu=probe -filetype=obj -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_global_data.o LLVM ERROR: Unsupported relocation: try to compile with -O2 or above, or check your static variable usage
Makefile:192: recipe for target '/usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_global_data.o' failed
make: *** [/usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf/test_global_data.o] Error 1
make: Leaving directory '/usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/bpf' ignored_by_lkp breakpoints.step_after_suspend_test test

2019-03-03 04:15:47 make run_tests -C breakpoints

make: Entering directory '/usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/breakpoints'
gcc breakpoint_test.c -o /usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/breakpoints/breakpoint_test
TAP version 13
selftests: breakpoints: breakpoint_test
========================================
ok 1 Test breakpoint 0 with local: 0 global: 1
ok 2 Test breakpoint 1 with local: 0 global: 1
ok 3 Test breakpoint 2 with local: 0 global: 1
ok 4 Test breakpoint 3 with local: 0 global: 1
ok 5 Test breakpoint 0 with local: 1 global: 0
ok 6 Test breakpoint 1 with local: 1 global: 0
ok 7 Test breakpoint 2 with local: 1 global: 0
ok 8 Test breakpoint 3 with local: 1 global: 0
ok 9 Test breakpoint 0 with local: 1 global: 1
ok 10 Test breakpoint 1 with local: 1 global: 1
ok 11 Test breakpoint 2 with local: 1 global: 1
ok 12 Test breakpoint 3 with local: 1 global: 1
ok 13 Test write watchpoint 0 with len: 1 local: 0 global: 1
ok 14 Test write watchpoint 1 with len: 1 local: 0 global: 1
ok 15 Test write watchpoint 2 with len: 1 local: 0 global: 1
ok 16 Test write watchpoint 3 with len: 1 local: 0 global: 1
ok 17 Test write watchpoint 0 with len: 1 local: 1 global: 0
ok 18 Test write watchpoint 1 with len: 1 local: 1 global: 0
ok 19 Test write watchpoint 2 with len: 1 local: 1 global: 0
ok 20 Test write watchpoint 3 with len: 1 local: 1 global: 0
ok 21 Test write watchpoint 0 with len: 1 local: 1 global: 1
ok 22 Test write watchpoint 1 with len: 1 local: 1 global: 1
ok 23 Test write watchpoint 2 with len: 1 local: 1 global: 1
ok 24 Test write watchpoint 3 with len: 1 local: 1 global: 1
ok 25 Test write watchpoint 0 with len: 2 local: 0 global: 1
ok 26 Test write watchpoint 1 with len: 2 local: 0 global: 1
ok 27 Test write watchpoint 2 with len: 2 local: 0 global: 1
ok 28 Test write watchpoint 3 with len: 2 local: 0 global: 1
ok 29 Test write watchpoint 0 with len: 2 local: 1 global: 0
ok 30 Test write watchpoint 1 with len: 2 local: 1 global: 0
ok 31 Test write watchpoint 2 with len: 2 local: 1 global: 0
ok 32 Test write watchpoint 3 with len: 2 local: 1 global: 0
ok 33 Test write watchpoint 0 with len: 2 local: 1 global: 1
ok 34 Test write watchpoint 1 with len: 2 local: 1 global: 1
ok 35 Test write watchpoint 2 with len: 2 local: 1 global: 1
ok 36 Test write watchpoint 3 with len: 2 local: 1 global: 1
ok 37 Test write watchpoint 0 with len: 4 local: 0 global: 1
ok 38 Test write watchpoint 1 with len: 4 local: 0 global: 1
ok 39 Test write watchpoint 2 with len: 4 local: 0 global: 1
ok 40 Test write watchpoint 3 with len: 4 local: 0 global: 1
ok 41 Test write watchpoint 0 with len: 4 local: 1 global: 0
ok 42 Test write watchpoint 1 with len: 4 local: 1 global: 0
ok 43 Test write watchpoint 2 with len: 4 local: 1 global: 0
ok 44 Test write watchpoint 3 with len: 4 local: 1 global: 0
ok 45 Test write watchpoint 0 with len: 4 local: 1 global: 1
ok 46 Test write watchpoint 1 with len: 4 local: 1 global: 1
ok 47 Test write watchpoint 2 with len: 4 local: 1 global: 1
ok 48 Test write watchpoint 3 with len: 4 local: 1 global: 1
ok 49 Test write watchpoint 0 with len: 8 local: 0 global: 1
ok 50 Test write watchpoint 1 with len: 8 local: 0 global: 1
ok 51 Test write watchpoint 2 with len: 8 local: 0 global: 1
ok 52 Test write watchpoint 3 with len: 8 local: 0 global: 1
ok 53 Test write watchpoint 0 with len: 8 local: 1 global: 0
ok 54 Test write watchpoint 1 with len: 8 local: 1 global: 0
ok 55 Test write watchpoint 2 with len: 8 local: 1 global: 0
ok 56 Test write watchpoint 3 with len: 8 local: 1 global: 0
ok 57 Test write watchpoint 0 with len: 8 local: 1 global: 1
ok 58 Test write watchpoint 1 with len: 8 local: 1 global: 1
ok 59 Test write watchpoint 2 with len: 8 local: 1 global: 1
ok 60 Test write watchpoint 3 with len: 8 local: 1 global: 1
ok 61 Test read watchpoint 0 with len: 1 local: 0 global: 1
ok 62 Test read watchpoint 1 with len: 1 local: 0 global: 1
ok 63 Test read watchpoint 2 with len: 1 local: 0 global: 1
ok 64 Test read watchpoint 3 with len: 1 local: 0 global: 1
ok 65 Test read watchpoint 0 with len: 1 local: 1 global: 0
ok 66 Test read watchpoint 1 with len: 1 local: 1 global: 0
ok 67 Test read watchpoint 2 with len: 1 local: 1 global: 0
ok 68 Test read watchpoint 3 with len: 1 local: 1 global: 0
ok 69 Test read watchpoint 0 with len: 1 local: 1 global: 1
ok 70 Test read watchpoint 1 with len: 1 local: 1 global: 1
ok 71 Test read watchpoint 2 with len: 1 local: 1 global: 1
ok 72 Test read watchpoint 3 with len: 1 local: 1 global: 1
ok 73 Test read watchpoint 0 with len: 2 local: 0 global: 1
ok 74 Test read watchpoint 1 with len: 2 local: 0 global: 1
ok 75 Test read watchpoint 2 with len: 2 local: 0 global: 1
ok 76 Test read watchpoint 3 with len: 2 local: 0 global: 1
ok 77 Test read watchpoint 0 with len: 2 local: 1 global: 0
ok 78 Test read watchpoint 1 with len: 2 local: 1 global: 0
ok 79 Test read watchpoint 2 with len: 2 local: 1 global: 0
ok 80 Test read watchpoint 3 with len: 2 local: 1 global: 0
ok 81 Test read watchpoint 0 with len: 2 local: 1 global: 1
ok 82 Test read watchpoint 1 with len: 2 local: 1 global: 1
ok 83 Test read watchpoint 2 with len: 2 local: 1 global: 1
ok 84 Test read watchpoint 3 with len: 2 local: 1 global: 1
ok 85 Test read watchpoint 0 with len: 4 local: 0 global: 1
ok 86 Test read watchpoint 1 with len: 4 local: 0 global: 1
ok 87 Test read watchpoint 2 with len: 4 local: 0 global: 1
ok 88 Test read watchpoint 3 with len: 4 local: 0 global: 1
ok 89 Test read watchpoint 0 with len: 4 local: 1 global: 0
ok 90 Test read watchpoint 1 with len: 4 local: 1 global: 0
ok 91 Test read watchpoint 2 with len: 4 local: 1 global: 0
ok 92 Test read watchpoint 3 with len: 4 local: 1 global: 0
ok 93 Test read watchpoint 0 with len: 4 local: 1 global: 1
ok 94 Test read watchpoint 1 with len: 4 local: 1 global: 1
ok 95 Test read watchpoint 2 with len: 4 local: 1 global: 1
ok 96 Test read watchpoint 3 with len: 4 local: 1 global: 1
ok 97 Test read watchpoint 0 with len: 8 local: 0 global: 1
ok 98 Test read watchpoint 1 with len: 8 local: 0 global: 1
ok 99 Test read watchpoint 2 with len: 8 local: 0 global: 1
ok 100 Test read watchpoint 3 with len: 8 local: 0 global: 1
ok 101 Test read watchpoint 0 with len: 8 local: 1 global: 0
ok 102 Test read watchpoint 1 with len: 8 local: 1 global: 0
ok 103 Test read watchpoint 2 with len: 8 local: 1 global: 0
ok 104 Test read watchpoint 3 with len: 8 local: 1 global: 0
ok 105 Test read watchpoint 0 with len: 8 local: 1 global: 1
ok 106 Test read watchpoint 1 with len: 8 local: 1 global: 1
ok 107 Test read watchpoint 2 with len: 8 local: 1 global: 1
ok 108 Test read watchpoint 3 with len: 8 local: 1 global: 1
ok 109 Test icebp
ok 110 Test int 3 trap
Pass 110 Fail 0 Xfail 0 Xpass 0 Skip 0 Error 0
1..110
ok 1..1 selftests: breakpoints: breakpoint_test [PASS]
make: Leaving directory '/usr/src/perf_selftests-x86_64-rhel-7.6-4beb1a5f45dc210b1dcccadaf77cfdd454b4b170/tools/testing/selftests/breakpoints'

To reproduce:

git clone https://github.com/intel/lkp-tests.git
cd lkp-tests
bin/lkp qemu -k <bzImage> job-script # job-script is attached in this email

Thanks,
Rong Chen

#
# Automatically generated file; DO NOT EDIT.
# Linux/x86_64 5.0.0-rc6 Kernel Configuration
#

#
# Compiler: gcc-8 (Debian 8.2.0-20) 8.2.0
#
CONFIG_CC_IS_GCC=y
CONFIG_GCC_VERSION=80200
CONFIG_CLANG_VERSION=0
CONFIG_CC_HAS_ASM_GOTO=y
CONFIG_IRQ_WORK=y
CONFIG_BUILDTIME_EXTABLE_SORT=y
CONFIG_THREAD_INFO_IN_TASK=y

#
# General setup
#
CONFIG_INIT_ENV_ARG_LIMIT=32
# CONFIG_COMPILE_TEST is not set
CONFIG_LOCALVERSION=""
CONFIG_LOCALVERSION_AUTO=y
CONFIG_BUILD_SALT=""
CONFIG_HAVE_KERNEL_GZIP=y
CONFIG_HAVE_KERNEL_BZIP2=y
CONFIG_HAVE_KERNEL_LZMA=y
CONFIG_HAVE_KERNEL_XZ=y
CONFIG_HAVE_KERNEL_LZO=y
CONFIG_HAVE_KERNEL_LZ4=y
CONFIG_KERNEL_GZIP=y
# CONFIG_KERNEL_BZIP2 is not set
# CONFIG_KERNEL_LZMA is not set
# CONFIG_KERNEL_XZ is not set
# CONFIG_KERNEL_LZO is not set
# CONFIG_KERNEL_LZ4 is not set
CONFIG_DEFAULT_HOSTNAME="(none)"
CONFIG_SWAP=y
CONFIG_SYSVIPC=y
CONFIG_SYSVIPC_SYSCTL=y
CONFIG_POSIX_MQUEUE=y
CONFIG_POSIX_MQUEUE_SYSCTL=y
CONFIG_CROSS_MEMORY_ATTACH=y
CONFIG_USELIB=y
CONFIG_AUDIT=y
CONFIG_HAVE_ARCH_AUDITSYSCALL=y
CONFIG_AUDITSYSCALL=y

#
# IRQ subsystem
#
CONFIG_GENERIC_IRQ_PROBE=y
CONFIG_GENERIC_IRQ_SHOW=y
CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK=y
CONFIG_GENERIC_PENDING_IRQ=y
CONFIG_GENERIC_IRQ_MIGRATION=y
CONFIG_IRQ_DOMAIN=y
CONFIG_IRQ_SIM=y
CONFIG_IRQ_DOMAIN_HIERARCHY=y
CONFIG_GENERIC_MSI_IRQ=y
CONFIG_GENERIC_MSI_IRQ_DOMAIN=y
CONFIG_GENERIC_IRQ_MATRIX_ALLOCATOR=y
CONFIG_GENERIC_IRQ_RESERVATION_MODE=y
CONFIG_IRQ_FORCED_THREADING=y
CONFIG_SPARSE_IRQ=y
# CONFIG_GENERIC_IRQ_DEBUGFS is not set
CONFIG_CLOCKSOURCE_WATCHDOG=y
CONFIG_ARCH_CLOCKSOURCE_DATA=y
CONFIG_ARCH_CLOCKSOURCE_INIT=y
CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE=y
CONFIG_GENERIC_TIME_VSYSCALL=y
CONFIG_GENERIC_CLOCKEVENTS=y
CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y
CONFIG_GENERIC_CLOCKEVENTS_MIN_ADJUST=y
CONFIG_GENERIC_CMOS_UPDATE=y

#
# Timers subsystem
#
CONFIG_TICK_ONESHOT=y
CONFIG_NO_HZ_COMMON=y
# CONFIG_HZ_PERIODIC is not set
# CONFIG_NO_HZ_IDLE is not set
CONFIG_NO_HZ_FULL=y
CONFIG_NO_HZ=y
CONFIG_HIGH_RES_TIMERS=y
# CONFIG_PREEMPT_NONE is not set
CONFIG_PREEMPT_VOLUNTARY=y
# CONFIG_PREEMPT is not set
CONFIG_PREEMPT_COUNT=y

#
# CPU/Task time and stats accounting
#
CONFIG_VIRT_CPU_ACCOUNTING=y
CONFIG_VIRT_CPU_ACCOUNTING_GEN=y
# CONFIG_IRQ_TIME_ACCOUNTING is not set
CONFIG_HAVE_SCHED_AVG_IRQ=y
CONFIG_BSD_PROCESS_ACCT=y
CONFIG_BSD_PROCESS_ACCT_V3=y
CONFIG_TASKSTATS=y
CONFIG_TASK_DELAY_ACCT=y
CONFIG_TASK_XACCT=y
CONFIG_TASK_IO_ACCOUNTING=y
# CONFIG_PSI is not set
CONFIG_CPU_ISOLATION=y

#
# RCU Subsystem
#
CONFIG_TREE_RCU=y
# CONFIG_RCU_EXPERT is not set
CONFIG_SRCU=y
CONFIG_TREE_SRCU=y
CONFIG_TASKS_RCU=y
CONFIG_RCU_STALL_COMMON=y
CONFIG_RCU_NEED_SEGCBLIST=y
CONFIG_CONTEXT_TRACKING=y
# CONFIG_CONTEXT_TRACKING_FORCE is not set
CONFIG_RCU_NOCB_CPU=y
CONFIG_BUILD_BIN2C=y
CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y
CONFIG_LOG_BUF_SHIFT=20
CONFIG_LOG_CPU_MAX_BUF_SHIFT=12
CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT=13
CONFIG_HAVE_UNSTABLE_SCHED_CLOCK=y
CONFIG_ARCH_SUPPORTS_NUMA_BALANCING=y
CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH=y
CONFIG_ARCH_SUPPORTS_INT128=y
CONFIG_NUMA_BALANCING=y
CONFIG_NUMA_BALANCING_DEFAULT_ENABLED=y
CONFIG_CGROUPS=y
CONFIG_PAGE_COUNTER=y
CONFIG_MEMCG=y
CONFIG_MEMCG_SWAP=y
CONFIG_MEMCG_SWAP_ENABLED=y
CONFIG_MEMCG_KMEM=y
CONFIG_BLK_CGROUP=y
# CONFIG_DEBUG_BLK_CGROUP is not set
CONFIG_CGROUP_WRITEBACK=y
CONFIG_CGROUP_SCHED=y
CONFIG_FAIR_GROUP_SCHED=y
CONFIG_CFS_BANDWIDTH=y
CONFIG_RT_GROUP_SCHED=y
CONFIG_CGROUP_PIDS=y
CONFIG_CGROUP_RDMA=y
CONFIG_CGROUP_FREEZER=y
CONFIG_CGROUP_HUGETLB=y
CONFIG_CPUSETS=y
CONFIG_PROC_PID_CPUSET=y
CONFIG_CGROUP_DEVICE=y
# CONFIG_CGROUP_CPUACCT is not set
CONFIG_CGROUP_PERF=y
CONFIG_CGROUP_BPF=y
# CONFIG_CGROUP_DEBUG is not set
CONFIG_SOCK_CGROUP_DATA=y
CONFIG_NAMESPACES=y
CONFIG_UTS_NS=y
CONFIG_IPC_NS=y
CONFIG_USER_NS=y
CONFIG_PID_NS=y
CONFIG_NET_NS=y
CONFIG_CHECKPOINT_RESTORE=y
CONFIG_SCHED_AUTOGROUP=y
# CONFIG_SYSFS_DEPRECATED is not set
CONFIG_RELAY=y
CONFIG_BLK_DEV_INITRD=y
CONFIG_INITRAMFS_SOURCE=""
CONFIG_RD_GZIP=y
CONFIG_RD_BZIP2=y
CONFIG_RD_LZMA=y
CONFIG_RD_XZ=y
CONFIG_RD_LZO=y
CONFIG_RD_LZ4=y
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y
# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
CONFIG_SYSCTL=y
CONFIG_ANON_INODES=y
CONFIG_HAVE_UID16=y
CONFIG_SYSCTL_EXCEPTION_TRACE=y
CONFIG_HAVE_PCSPKR_PLATFORM=y
CONFIG_BPF=y
CONFIG_EXPERT=y
CONFIG_UID16=y
CONFIG_MULTIUSER=y
CONFIG_SGETMASK_SYSCALL=y
CONFIG_SYSFS_SYSCALL=y
# CONFIG_SYSCTL_SYSCALL is not set
CONFIG_FHANDLE=y
CONFIG_POSIX_TIMERS=y
CONFIG_PRINTK=y
CONFIG_PRINTK_NMI=y
CONFIG_BUG=y
CONFIG_ELF_CORE=y
CONFIG_PCSPKR_PLATFORM=y
CONFIG_BASE_FULL=y
CONFIG_FUTEX=y
CONFIG_FUTEX_PI=y
CONFIG_EPOLL=y
CONFIG_SIGNALFD=y
CONFIG_TIMERFD=y
CONFIG_EVENTFD=y
CONFIG_SHMEM=y
CONFIG_AIO=y
CONFIG_ADVISE_SYSCALLS=y
CONFIG_MEMBARRIER=y
CONFIG_KALLSYMS=y
CONFIG_KALLSYMS_ALL=y
CONFIG_KALLSYMS_ABSOLUTE_PERCPU=y
CONFIG_KALLSYMS_BASE_RELATIVE=y
CONFIG_BPF_SYSCALL=y
CONFIG_BPF_JIT_ALWAYS_ON=y
CONFIG_USERFAULTFD=y
CONFIG_ARCH_HAS_MEMBARRIER_SYNC_CORE=y
CONFIG_RSEQ=y
# CONFIG_DEBUG_RSEQ is not set
CONFIG_EMBEDDED=y
CONFIG_HAVE_PERF_EVENTS=y
# CONFIG_PC104 is not set

#
# Kernel Performance Events And Counters
#
CONFIG_PERF_EVENTS=y
# CONFIG_DEBUG_PERF_USE_VMALLOC is not set CONFIG_VM_EVENT_COUNTERS=y
CONFIG_SLUB_DEBUG=y
# CONFIG_SLUB_MEMCG_SYSFS_ON is not set
# CONFIG_COMPAT_BRK is not set
# CONFIG_SLAB is not set
CONFIG_SLUB=y
# CONFIG_SLOB is not set CONFIG_SLAB_MERGE_DEFAULT=y
# CONFIG_SLAB_FREELIST_RANDOM is not set
# CONFIG_SLAB_FREELIST_HARDENED is not set CONFIG_SLUB_CPU_PARTIAL=y CONFIG_SYSTEM_DATA_VERIFICATION=y CONFIG_PROFILING=y
CONFIG_TRACEPOINTS=y
CONFIG_64BIT=y
CONFIG_X86_64=y
CONFIG_X86=y
CONFIG_INSTRUCTION_DECODER=y CONFIG_OUTPUT_FORMAT="elf64-x86-64" CONFIG_ARCH_DEFCONFIG="arch/x86/configs/x86_64_defconfig" CONFIG_LOCKDEP_SUPPORT=y CONFIG_STACKTRACE_SUPPORT=y
CONFIG_MMU=y
CONFIG_ARCH_MMAP_RND_BITS_MIN=28 CONFIG_ARCH_MMAP_RND_BITS_MAX=32 CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MIN=8 CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX=16 CONFIG_GENERIC_ISA_DMA=y
CONFIG_GENERIC_BUG=y CONFIG_GENERIC_BUG_RELATIVE_POINTERS=y CONFIG_GENERIC_HWEIGHT=y CONFIG_ARCH_MAY_HAVE_PC_FDC=y CONFIG_RWSEM_XCHGADD_ALGORITHM=y CONFIG_GENERIC_CALIBRATE_DELAY=y CONFIG_ARCH_HAS_CPU_RELAX=y CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y CONFIG_ARCH_HAS_FILTER_PGPROT=y CONFIG_HAVE_SETUP_PER_CPU_AREA=y CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK=y CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK=y CONFIG_ARCH_HIBERNATION_POSSIBLE=y CONFIG_ARCH_SUSPEND_POSSIBLE=y CONFIG_ARCH_WANT_HUGE_PMD_SHARE=y CONFIG_ARCH_WANT_GENERAL_HUGETLB=y CONFIG_ZONE_DMA32=y
CONFIG_AUDIT_ARCH=y CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING=y CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y CONFIG_HAVE_INTEL_TXT=y
CONFIG_X86_64_SMP=y CONFIG_ARCH_SUPPORTS_UPROBES=y CONFIG_FIX_EARLYCON_MEM=y CONFIG_DYNAMIC_PHYSICAL_MASK=y CONFIG_PGTABLE_LEVELS=5 CONFIG_CC_HAS_SANE_STACKPROTECTOR=y

#
# Processor type and features
#
CONFIG_ZONE_DMA=y
CONFIG_SMP=y
CONFIG_X86_FEATURE_NAMES=y
CONFIG_X86_X2APIC=y
CONFIG_X86_MPPARSE=y
# CONFIG_GOLDFISH is not set
CONFIG_RETPOLINE=y
# CONFIG_X86_CPU_RESCTRL is not set
CONFIG_X86_EXTENDED_PLATFORM=y
# CONFIG_X86_NUMACHIP is not set
# CONFIG_X86_VSMP is not set
CONFIG_X86_UV=y
# CONFIG_X86_GOLDFISH is not set
# CONFIG_X86_INTEL_MID is not set
CONFIG_X86_INTEL_LPSS=y
CONFIG_X86_AMD_PLATFORM_DEVICE=y
CONFIG_IOSF_MBI=y
# CONFIG_IOSF_MBI_DEBUG is not set
CONFIG_X86_SUPPORTS_MEMORY_FAILURE=y
# CONFIG_SCHED_OMIT_FRAME_POINTER is not set
CONFIG_HYPERVISOR_GUEST=y
CONFIG_PARAVIRT=y
CONFIG_PARAVIRT_XXL=y
# CONFIG_PARAVIRT_DEBUG is not set
CONFIG_PARAVIRT_SPINLOCKS=y
# CONFIG_QUEUED_LOCK_STAT is not set
CONFIG_XEN=y
CONFIG_XEN_PV=y
CONFIG_XEN_PV_SMP=y
# CONFIG_XEN_DOM0 is not set
CONFIG_XEN_PVHVM=y
CONFIG_XEN_PVHVM_SMP=y
CONFIG_XEN_512GB=y
CONFIG_XEN_SAVE_RESTORE=y
# CONFIG_XEN_DEBUG_FS is not set
# CONFIG_XEN_PVH is not set
CONFIG_KVM_GUEST=y
# CONFIG_PVH is not set
# CONFIG_KVM_DEBUG_FS is not set
CONFIG_PARAVIRT_TIME_ACCOUNTING=y
CONFIG_PARAVIRT_CLOCK=y
# CONFIG_JAILHOUSE_GUEST is not set
# CONFIG_MK8 is not set
# CONFIG_MPSC is not set
# CONFIG_MCORE2 is not set
# CONFIG_MATOM is not set
CONFIG_GENERIC_CPU=y
CONFIG_X86_INTERNODE_CACHE_SHIFT=6
CONFIG_X86_L1_CACHE_SHIFT=6
CONFIG_X86_TSC=y
CONFIG_X86_CMPXCHG64=y
CONFIG_X86_CMOV=y
CONFIG_X86_MINIMUM_CPU_FAMILY=64
CONFIG_X86_DEBUGCTLMSR=y
# CONFIG_PROCESSOR_SELECT is not set
CONFIG_CPU_SUP_INTEL=y
CONFIG_CPU_SUP_AMD=y
CONFIG_CPU_SUP_HYGON=y
CONFIG_CPU_SUP_CENTAUR=y
CONFIG_HPET_TIMER=y
CONFIG_HPET_EMULATE_RTC=y
CONFIG_DMI=y
CONFIG_GART_IOMMU=y
# CONFIG_CALGARY_IOMMU is not set
CONFIG_MAXSMP=y
CONFIG_NR_CPUS_RANGE_BEGIN=8192
CONFIG_NR_CPUS_RANGE_END=8192
CONFIG_NR_CPUS_DEFAULT=8192
CONFIG_NR_CPUS=8192
CONFIG_SCHED_SMT=y
CONFIG_SCHED_MC=y
CONFIG_SCHED_MC_PRIO=y
CONFIG_X86_LOCAL_APIC=y
CONFIG_X86_IO_APIC=y
CONFIG_X86_REROUTE_FOR_BROKEN_BOOT_IRQS=y
CONFIG_X86_MCE=y
CONFIG_X86_MCELOG_LEGACY=y
CONFIG_X86_MCE_INTEL=y
CONFIG_X86_MCE_AMD=y
CONFIG_X86_MCE_THRESHOLD=y
CONFIG_X86_MCE_INJECT=m
CONFIG_X86_THERMAL_VECTOR=y

#
# Performance monitoring
#
CONFIG_PERF_EVENTS_INTEL_UNCORE=y CONFIG_PERF_EVENTS_INTEL_RAPL=y CONFIG_PERF_EVENTS_INTEL_CSTATE=y
# CONFIG_PERF_EVENTS_AMD_POWER is not set CONFIG_X86_16BIT=y
CONFIG_X86_ESPFIX64=y CONFIG_X86_VSYSCALL_EMULATION=y
CONFIG_I8K=m
CONFIG_MICROCODE=y
CONFIG_MICROCODE_INTEL=y
CONFIG_MICROCODE_AMD=y CONFIG_MICROCODE_OLD_INTERFACE=y CONFIG_X86_MSR=y
CONFIG_X86_CPUID=y
CONFIG_X86_5LEVEL=y
CONFIG_X86_DIRECT_GBPAGES=y
# CONFIG_X86_CPA_STATISTICS is not set CONFIG_ARCH_HAS_MEM_ENCRYPT=y CONFIG_AMD_MEM_ENCRYPT=y
# CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT is not set CONFIG_ARCH_USE_MEMREMAP_PROT=y
CONFIG_NUMA=y
CONFIG_AMD_NUMA=y
CONFIG_X86_64_ACPI_NUMA=y CONFIG_NODES_SPAN_OTHER_NODES=y
# CONFIG_NUMA_EMU is not set CONFIG_NODES_SHIFT=10 CONFIG_ARCH_SPARSEMEM_ENABLE=y CONFIG_ARCH_SPARSEMEM_DEFAULT=y CONFIG_ARCH_SELECT_MEMORY_MODEL=y CONFIG_ARCH_MEMORY_PROBE=y CONFIG_ARCH_PROC_KCORE_TEXT=y CONFIG_ILLEGAL_POINTER_VALUE=0xdead000000000000 CONFIG_X86_PMEM_LEGACY_DEVICE=y CONFIG_X86_PMEM_LEGACY=m CONFIG_X86_CHECK_BIOS_CORRUPTION=y
# CONFIG_X86_BOOTPARAM_MEMORY_CORRUPTION_CHECK is not set CONFIG_X86_RESERVE_LOW=64
CONFIG_MTRR=y
CONFIG_MTRR_SANITIZER=y CONFIG_MTRR_SANITIZER_ENABLE_DEFAULT=1 CONFIG_MTRR_SANITIZER_SPARE_REG_NR_DEFAULT=1 CONFIG_X86_PAT=y
CONFIG_ARCH_USES_PG_UNCACHED=y CONFIG_ARCH_RANDOM=y
CONFIG_X86_SMAP=y
CONFIG_X86_INTEL_UMIP=y
CONFIG_X86_INTEL_MPX=y CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS=y CONFIG_EFI=y
CONFIG_EFI_STUB=y
CONFIG_EFI_MIXED=y
CONFIG_SECCOMP=y
# CONFIG_HZ_100 is not set
# CONFIG_HZ_250 is not set
# CONFIG_HZ_300 is not set
CONFIG_HZ_1000=y
CONFIG_HZ=1000
CONFIG_SCHED_HRTICK=y
CONFIG_KEXEC=y
CONFIG_KEXEC_FILE=y CONFIG_ARCH_HAS_KEXEC_PURGATORY=y CONFIG_KEXEC_VERIFY_SIG=y CONFIG_KEXEC_BZIMAGE_VERIFY_SIG=y CONFIG_CRASH_DUMP=y
CONFIG_KEXEC_JUMP=y CONFIG_PHYSICAL_START=0x1000000 CONFIG_RELOCATABLE=y
CONFIG_RANDOMIZE_BASE=y
CONFIG_X86_NEED_RELOCS=y CONFIG_PHYSICAL_ALIGN=0x200000 CONFIG_DYNAMIC_MEMORY_LAYOUT=y CONFIG_RANDOMIZE_MEMORY=y CONFIG_RANDOMIZE_MEMORY_PHYSICAL_PADDING=0xa CONFIG_HOTPLUG_CPU=y CONFIG_BOOTPARAM_HOTPLUG_CPU0=y
# CONFIG_DEBUG_HOTPLUG_CPU0 is not set
# CONFIG_COMPAT_VDSO is not set CONFIG_LEGACY_VSYSCALL_EMULATE=y
# CONFIG_LEGACY_VSYSCALL_NONE is not set
# CONFIG_CMDLINE_BOOL is not set CONFIG_MODIFY_LDT_SYSCALL=y CONFIG_HAVE_LIVEPATCH=y
CONFIG_LIVEPATCH=y
CONFIG_ARCH_HAS_ADD_PAGES=y CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y CONFIG_ARCH_ENABLE_MEMORY_HOTREMOVE=y CONFIG_USE_PERCPU_NUMA_NODE_ID=y CONFIG_ARCH_ENABLE_SPLIT_PMD_PTLOCK=y CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION=y CONFIG_ARCH_ENABLE_THP_MIGRATION=y

#
# Power management and ACPI options
#
CONFIG_ARCH_HIBERNATION_HEADER=y
CONFIG_SUSPEND=y
CONFIG_SUSPEND_FREEZER=y
# CONFIG_SUSPEND_SKIP_SYNC is not set
CONFIG_HIBERNATE_CALLBACKS=y
CONFIG_HIBERNATION=y
CONFIG_PM_STD_PARTITION=""
CONFIG_PM_SLEEP=y
CONFIG_PM_SLEEP_SMP=y
# CONFIG_PM_AUTOSLEEP is not set
# CONFIG_PM_WAKELOCKS is not set
CONFIG_PM=y
CONFIG_PM_DEBUG=y
CONFIG_PM_ADVANCED_DEBUG=y
# CONFIG_PM_TEST_SUSPEND is not set
CONFIG_PM_SLEEP_DEBUG=y
# CONFIG_DPM_WATCHDOG is not set
CONFIG_PM_TRACE=y
CONFIG_PM_TRACE_RTC=y
CONFIG_PM_CLK=y
# CONFIG_WQ_POWER_EFFICIENT_DEFAULT is not set
# CONFIG_ENERGY_MODEL is not set
CONFIG_ARCH_SUPPORTS_ACPI=y
CONFIG_ACPI=y
CONFIG_ACPI_LEGACY_TABLES_LOOKUP=y
CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC=y
CONFIG_ACPI_SYSTEM_POWER_STATES_SUPPORT=y
# CONFIG_ACPI_DEBUGGER is not set
CONFIG_ACPI_SPCR_TABLE=y
CONFIG_ACPI_LPIT=y
CONFIG_ACPI_SLEEP=y
# CONFIG_ACPI_PROCFS_POWER is not set
CONFIG_ACPI_REV_OVERRIDE_POSSIBLE=y
CONFIG_ACPI_EC_DEBUGFS=m
CONFIG_ACPI_AC=y
CONFIG_ACPI_BATTERY=y
CONFIG_ACPI_BUTTON=y
CONFIG_ACPI_VIDEO=m
CONFIG_ACPI_FAN=y
# CONFIG_ACPI_TAD is not set
CONFIG_ACPI_DOCK=y
CONFIG_ACPI_CPU_FREQ_PSS=y
CONFIG_ACPI_PROCESSOR_CSTATE=y
CONFIG_ACPI_PROCESSOR_IDLE=y
CONFIG_ACPI_CPPC_LIB=y
CONFIG_ACPI_PROCESSOR=y
CONFIG_ACPI_IPMI=m
CONFIG_ACPI_HOTPLUG_CPU=y
CONFIG_ACPI_PROCESSOR_AGGREGATOR=m
CONFIG_ACPI_THERMAL=y
CONFIG_ACPI_NUMA=y
CONFIG_ARCH_HAS_ACPI_TABLE_UPGRADE=y
CONFIG_ACPI_TABLE_UPGRADE=y
# CONFIG_ACPI_DEBUG is not set
CONFIG_ACPI_PCI_SLOT=y
CONFIG_ACPI_CONTAINER=y
CONFIG_ACPI_HOTPLUG_MEMORY=y
CONFIG_ACPI_HOTPLUG_IOAPIC=y
CONFIG_ACPI_SBS=m
CONFIG_ACPI_HED=y
CONFIG_ACPI_CUSTOM_METHOD=m
CONFIG_ACPI_BGRT=y
# CONFIG_ACPI_REDUCED_HARDWARE_ONLY is not set
CONFIG_ACPI_NFIT=m
# CONFIG_NFIT_SECURITY_DEBUG is not set
CONFIG_HAVE_ACPI_APEI=y
CONFIG_HAVE_ACPI_APEI_NMI=y
CONFIG_ACPI_APEI=y
CONFIG_ACPI_APEI_GHES=y
CONFIG_ACPI_APEI_PCIEAER=y
CONFIG_ACPI_APEI_MEMORY_FAILURE=y
CONFIG_ACPI_APEI_EINJ=m
CONFIG_ACPI_APEI_ERST_DEBUG=y
# CONFIG_DPTF_POWER is not set
CONFIG_ACPI_WATCHDOG=y
CONFIG_ACPI_EXTLOG=m
CONFIG_ACPI_ADXL=y
# CONFIG_PMIC_OPREGION is not set
# CONFIG_ACPI_CONFIGFS is not set
CONFIG_X86_PM_TIMER=y
CONFIG_SFI=y

#
# CPU Frequency scaling
#
CONFIG_CPU_FREQ=y CONFIG_CPU_FREQ_GOV_ATTR_SET=y CONFIG_CPU_FREQ_GOV_COMMON=y
# CONFIG_CPU_FREQ_STAT is not set
# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set # CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set # CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set # CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL is not set CONFIG_CPU_FREQ_GOV_PERFORMANCE=y CONFIG_CPU_FREQ_GOV_POWERSAVE=y CONFIG_CPU_FREQ_GOV_USERSPACE=y CONFIG_CPU_FREQ_GOV_ONDEMAND=y CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
# CONFIG_CPU_FREQ_GOV_SCHEDUTIL is not set

#
# CPU frequency scaling drivers
#
CONFIG_X86_INTEL_PSTATE=y
CONFIG_X86_PCC_CPUFREQ=m
CONFIG_X86_ACPI_CPUFREQ=m
CONFIG_X86_ACPI_CPUFREQ_CPB=y
CONFIG_X86_POWERNOW_K8=m
CONFIG_X86_AMD_FREQ_SENSITIVITY=m
# CONFIG_X86_SPEEDSTEP_CENTRINO is not set
CONFIG_X86_P4_CLOCKMOD=m

#

# shared options
#
CONFIG_X86_SPEEDSTEP_LIB=m

#
# CPU Idle
#
CONFIG_CPU_IDLE=y
# CONFIG_CPU_IDLE_GOV_LADDER is not set
CONFIG_CPU_IDLE_GOV_MENU=y
CONFIG_INTEL_IDLE=y

#
# Bus options (PCI etc.)
#
CONFIG_PCI_DIRECT=y
CONFIG_PCI_MMCONFIG=y
CONFIG_PCI_XEN=y
CONFIG_MMCONF_FAM10H=y
# CONFIG_PCI_CNB20LE_QUIRK is not set
# CONFIG_ISA_BUS is not set
CONFIG_ISA_DMA_API=y
CONFIG_AMD_NB=y
# CONFIG_X86_SYSFB is not set

#
# Binary Emulations
#
CONFIG_IA32_EMULATION=y
# CONFIG_IA32_AOUT is not set
# CONFIG_X86_X32 is not set
CONFIG_COMPAT_32=y
CONFIG_COMPAT=y
CONFIG_COMPAT_FOR_U64_ALIGNMENT=y
CONFIG_SYSVIPC_COMPAT=y
CONFIG_X86_DEV_DMA_OPS=y
CONFIG_HAVE_GENERIC_GUP=y

#
# Firmware Drivers
#
CONFIG_EDD=m
# CONFIG_EDD_OFF is not set
CONFIG_FIRMWARE_MEMMAP=y
CONFIG_DMIID=y
CONFIG_DMI_SYSFS=y
CONFIG_DMI_SCAN_MACHINE_NON_EFI_FALLBACK=y
CONFIG_ISCSI_IBFT_FIND=y
CONFIG_ISCSI_IBFT=m
CONFIG_FW_CFG_SYSFS=y
# CONFIG_FW_CFG_SYSFS_CMDLINE is not set
# CONFIG_GOOGLE_FIRMWARE is not set

#
# EFI (Extensible Firmware Interface) Support
#
CONFIG_EFI_VARS=y
CONFIG_EFI_ESRT=y
CONFIG_EFI_VARS_PSTORE=y
CONFIG_EFI_VARS_PSTORE_DEFAULT_DISABLE=y
CONFIG_EFI_RUNTIME_MAP=y
# CONFIG_EFI_FAKE_MEMMAP is not set
CONFIG_EFI_RUNTIME_WRAPPERS=y
# CONFIG_EFI_BOOTLOADER_CONTROL is not set
# CONFIG_EFI_CAPSULE_LOADER is not set
# CONFIG_EFI_TEST is not set
CONFIG_APPLE_PROPERTIES=y
# CONFIG_RESET_ATTACK_MITIGATION is not set
CONFIG_UEFI_CPER=y
CONFIG_UEFI_CPER_X86=y
CONFIG_EFI_DEV_PATH_PARSER=y

#
# Tegra firmware driver
#
CONFIG_HAVE_KVM=y
CONFIG_HAVE_KVM_IRQCHIP=y
CONFIG_HAVE_KVM_IRQFD=y
CONFIG_HAVE_KVM_IRQ_ROUTING=y
CONFIG_HAVE_KVM_EVENTFD=y
CONFIG_KVM_MMIO=y
CONFIG_KVM_ASYNC_PF=y
CONFIG_HAVE_KVM_MSI=y
CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT=y
CONFIG_KVM_VFIO=y
CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT=y
CONFIG_KVM_COMPAT=y
CONFIG_HAVE_KVM_IRQ_BYPASS=y
CONFIG_VIRTUALIZATION=y
CONFIG_KVM=m
CONFIG_KVM_INTEL=m
CONFIG_KVM_AMD=m
CONFIG_KVM_AMD_SEV=y
CONFIG_KVM_MMU_AUDIT=y
CONFIG_VHOST_NET=m
# CONFIG_VHOST_SCSI is not set
CONFIG_VHOST_VSOCK=m
CONFIG_VHOST=m
# CONFIG_VHOST_CROSS_ENDIAN_LEGACY is not set

#
# General architecture-dependent options
#
CONFIG_CRASH_CORE=y
CONFIG_KEXEC_CORE=y
CONFIG_HOTPLUG_SMT=y
CONFIG_OPROFILE=m
CONFIG_OPROFILE_EVENT_MULTIPLEX=y
CONFIG_HAVE_OPROFILE=y
CONFIG_OPROFILE_NMI_TIMER=y
CONFIG_KPROBES=y
CONFIG_JUMP_LABEL=y
# CONFIG_STATIC_KEYS_SELFTEST is not set
CONFIG_OPTPROBES=y
CONFIG_KPROBES_ON_FTRACE=y
CONFIG_UPROBES=y
CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y
CONFIG_ARCH_USE_BUILTIN_BSWAP=y
CONFIG_KRETPROBES=y
CONFIG_USER_RETURN_NOTIFIER=y
CONFIG_HAVE_IOREMAP_PROT=y
CONFIG_HAVE_KPROBES=y
CONFIG_HAVE_KRETPROBES=y
CONFIG_HAVE_OPTPROBES=y
CONFIG_HAVE_KPROBES_ON_FTRACE=y
CONFIG_HAVE_FUNCTION_ERROR_INJECTION=y
CONFIG_HAVE_NMI=y
CONFIG_HAVE_ARCH_TRACEHOOK=y
CONFIG_HAVE_DMA_CONTIGUOUS=y
CONFIG_GENERIC_SMP_IDLE_THREAD=y
CONFIG_ARCH_HAS_FORTIFY_SOURCE=y
CONFIG_ARCH_HAS_SET_MEMORY=y
CONFIG_HAVE_ARCH_THREAD_STRUCT_WHITELIST=y
CONFIG_ARCH_WANTS_DYNAMIC_TASK_STRUCT=y
CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y
CONFIG_HAVE_RSEQ=y
CONFIG_HAVE_FUNCTION_ARG_ACCESS_API=y
CONFIG_HAVE_CLK=y
CONFIG_HAVE_HW_BREAKPOINT=y
CONFIG_HAVE_MIXED_BREAKPOINTS_REGS=y
CONFIG_HAVE_USER_RETURN_NOTIFIER=y
CONFIG_HAVE_PERF_EVENTS_NMI=y
CONFIG_HAVE_HARDLOCKUP_DETECTOR_PERF=y
CONFIG_HAVE_PERF_REGS=y
CONFIG_HAVE_PERF_USER_STACK_DUMP=y
CONFIG_HAVE_ARCH_JUMP_LABEL=y
CONFIG_HAVE_ARCH_JUMP_LABEL_RELATIVE=y
CONFIG_HAVE_RCU_TABLE_FREE=y
CONFIG_HAVE_RCU_TABLE_INVALIDATE=y
CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG=y
CONFIG_HAVE_ALIGNED_STRUCT_PAGE=y
CONFIG_HAVE_CMPXCHG_LOCAL=y
CONFIG_HAVE_CMPXCHG_DOUBLE=y
CONFIG_ARCH_WANT_COMPAT_IPC_PARSE_VERSION=y
CONFIG_ARCH_WANT_OLD_COMPAT_IPC=y
CONFIG_HAVE_ARCH_SECCOMP_FILTER=y
CONFIG_SECCOMP_FILTER=y
CONFIG_HAVE_ARCH_STACKLEAK=y
CONFIG_HAVE_STACKPROTECTOR=y
CONFIG_CC_HAS_STACKPROTECTOR_NONE=y
CONFIG_STACKPROTECTOR=y
CONFIG_STACKPROTECTOR_STRONG=y
CONFIG_HAVE_ARCH_WITHIN_STACK_FRAMES=y
CONFIG_HAVE_CONTEXT_TRACKING=y
CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y
CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y
CONFIG_HAVE_MOVE_PMD=y
CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE=y
CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD=y
CONFIG_HAVE_ARCH_HUGE_VMAP=y
CONFIG_HAVE_ARCH_SOFT_DIRTY=y
CONFIG_HAVE_MOD_ARCH_SPECIFIC=y
CONFIG_MODULES_USE_ELF_RELA=y
CONFIG_HAVE_IRQ_EXIT_ON_IRQ_STACK=y
CONFIG_ARCH_HAS_ELF_RANDOMIZE=y
CONFIG_HAVE_ARCH_MMAP_RND_BITS=y
CONFIG_HAVE_EXIT_THREAD=y
CONFIG_ARCH_MMAP_RND_BITS=28
CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS=y
CONFIG_ARCH_MMAP_RND_COMPAT_BITS=8
CONFIG_HAVE_ARCH_COMPAT_MMAP_BASES=y
CONFIG_HAVE_COPY_THREAD_TLS=y
CONFIG_HAVE_STACK_VALIDATION=y
CONFIG_HAVE_RELIABLE_STACKTRACE=y
CONFIG_OLD_SIGSUSPEND3=y
CONFIG_COMPAT_OLD_SIGACTION=y
CONFIG_COMPAT_32BIT_TIME=y
CONFIG_HAVE_ARCH_VMAP_STACK=y
CONFIG_VMAP_STACK=y
CONFIG_ARCH_HAS_STRICT_KERNEL_RWX=y
CONFIG_STRICT_KERNEL_RWX=y
CONFIG_ARCH_HAS_STRICT_MODULE_RWX=y
CONFIG_STRICT_MODULE_RWX=y
CONFIG_ARCH_HAS_REFCOUNT=y
# CONFIG_REFCOUNT_FULL is not set
CONFIG_HAVE_ARCH_PREL32_RELOCATIONS=y

#
# GCOV-based kernel profiling
#
# CONFIG_GCOV_KERNEL is not set
CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y
CONFIG_PLUGIN_HOSTCC="g++"
CONFIG_HAVE_GCC_PLUGINS=y
# CONFIG_GCC_PLUGINS is not set
CONFIG_RT_MUTEXES=y
CONFIG_BASE_SMALL=0
CONFIG_MODULES=y
CONFIG_MODULE_FORCE_LOAD=y
CONFIG_MODULE_UNLOAD=y
# CONFIG_MODULE_FORCE_UNLOAD is not set
# CONFIG_MODVERSIONS is not set
# CONFIG_MODULE_SRCVERSION_ALL is not set
CONFIG_MODULE_SIG=y
# CONFIG_MODULE_SIG_FORCE is not set
CONFIG_MODULE_SIG_ALL=y
# CONFIG_MODULE_SIG_SHA1 is not set
# CONFIG_MODULE_SIG_SHA224 is not set
CONFIG_MODULE_SIG_SHA256=y
# CONFIG_MODULE_SIG_SHA384 is not set
# CONFIG_MODULE_SIG_SHA512 is not set
CONFIG_MODULE_SIG_HASH="sha256"
# CONFIG_MODULE_COMPRESS is not set
# CONFIG_TRIM_UNUSED_KSYMS is not set
CONFIG_MODULES_TREE_LOOKUP=y
CONFIG_BLOCK=y
CONFIG_BLK_SCSI_REQUEST=y
CONFIG_BLK_DEV_BSG=y
CONFIG_BLK_DEV_BSGLIB=y
CONFIG_BLK_DEV_INTEGRITY=y
CONFIG_BLK_DEV_ZONED=y
CONFIG_BLK_DEV_THROTTLING=y
# CONFIG_BLK_DEV_THROTTLING_LOW is not set
# CONFIG_BLK_CMDLINE_PARSER is not set
# CONFIG_BLK_WBT is not set
# CONFIG_BLK_CGROUP_IOLATENCY is not set
CONFIG_BLK_DEBUG_FS=y
CONFIG_BLK_DEBUG_FS_ZONED=y
# CONFIG_BLK_SED_OPAL is not set

#
# Partition Types
#
CONFIG_PARTITION_ADVANCED=y
# CONFIG_ACORN_PARTITION is not set
# CONFIG_AIX_PARTITION is not set
CONFIG_OSF_PARTITION=y
CONFIG_AMIGA_PARTITION=y
# CONFIG_ATARI_PARTITION is not set
CONFIG_MAC_PARTITION=y
CONFIG_MSDOS_PARTITION=y
CONFIG_BSD_DISKLABEL=y
CONFIG_MINIX_SUBPARTITION=y
CONFIG_SOLARIS_X86_PARTITION=y
CONFIG_UNIXWARE_DISKLABEL=y
# CONFIG_LDM_PARTITION is not set
CONFIG_SGI_PARTITION=y
# CONFIG_ULTRIX_PARTITION is not set
CONFIG_SUN_PARTITION=y
CONFIG_KARMA_PARTITION=y
CONFIG_EFI_PARTITION=y
# CONFIG_SYSV68_PARTITION is not set
# CONFIG_CMDLINE_PARTITION is not set
CONFIG_BLOCK_COMPAT=y
CONFIG_BLK_MQ_PCI=y
CONFIG_BLK_MQ_VIRTIO=y
CONFIG_BLK_MQ_RDMA=y
CONFIG_BLK_PM=y

#
# IO Schedulers
#
CONFIG_MQ_IOSCHED_DEADLINE=y
CONFIG_MQ_IOSCHED_KYBER=y
# CONFIG_IOSCHED_BFQ is not set
CONFIG_PREEMPT_NOTIFIERS=y
CONFIG_PADATA=y
CONFIG_ASN1=y
CONFIG_INLINE_SPIN_UNLOCK_IRQ=y
CONFIG_INLINE_READ_UNLOCK=y
CONFIG_INLINE_READ_UNLOCK_IRQ=y
CONFIG_INLINE_WRITE_UNLOCK=y
CONFIG_INLINE_WRITE_UNLOCK_IRQ=y
CONFIG_ARCH_SUPPORTS_ATOMIC_RMW=y
CONFIG_MUTEX_SPIN_ON_OWNER=y
CONFIG_RWSEM_SPIN_ON_OWNER=y
CONFIG_LOCK_SPIN_ON_OWNER=y
CONFIG_ARCH_USE_QUEUED_SPINLOCKS=y
CONFIG_QUEUED_SPINLOCKS=y
CONFIG_ARCH_USE_QUEUED_RWLOCKS=y
CONFIG_QUEUED_RWLOCKS=y
CONFIG_ARCH_HAS_SYNC_CORE_BEFORE_USERMODE=y
CONFIG_ARCH_HAS_SYSCALL_WRAPPER=y
CONFIG_FREEZER=y

#
# Executable file formats
#
CONFIG_BINFMT_ELF=y
CONFIG_COMPAT_BINFMT_ELF=y
CONFIG_ELFCORE=y
CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y
CONFIG_BINFMT_SCRIPT=y
CONFIG_BINFMT_MISC=m
CONFIG_COREDUMP=y

#
# Memory Management options
#
CONFIG_SELECT_MEMORY_MODEL=y CONFIG_SPARSEMEM_MANUAL=y
CONFIG_SPARSEMEM=y
CONFIG_NEED_MULTIPLE_NODES=y CONFIG_HAVE_MEMORY_PRESENT=y CONFIG_SPARSEMEM_EXTREME=y CONFIG_SPARSEMEM_VMEMMAP_ENABLE=y CONFIG_SPARSEMEM_VMEMMAP=y CONFIG_HAVE_MEMBLOCK_NODE_MAP=y CONFIG_ARCH_DISCARD_MEMBLOCK=y CONFIG_MEMORY_ISOLATION=y CONFIG_HAVE_BOOTMEM_INFO_NODE=y CONFIG_MEMORY_HOTPLUG=y CONFIG_MEMORY_HOTPLUG_SPARSE=y
# CONFIG_MEMORY_HOTPLUG_DEFAULT_ONLINE is not set CONFIG_MEMORY_HOTREMOVE=y CONFIG_SPLIT_PTLOCK_CPUS=4
CONFIG_MEMORY_BALLOON=y CONFIG_BALLOON_COMPACTION=y
CONFIG_COMPACTION=y
CONFIG_MIGRATION=y
CONFIG_PHYS_ADDR_T_64BIT=y
CONFIG_BOUNCE=y
CONFIG_VIRT_TO_BUS=y
CONFIG_MMU_NOTIFIER=y
CONFIG_KSM=y
CONFIG_DEFAULT_MMAP_MIN_ADDR=4096 CONFIG_ARCH_SUPPORTS_MEMORY_FAILURE=y CONFIG_MEMORY_FAILURE=y
CONFIG_HWPOISON_INJECT=m CONFIG_TRANSPARENT_HUGEPAGE=y CONFIG_TRANSPARENT_HUGEPAGE_ALWAYS=y
# CONFIG_TRANSPARENT_HUGEPAGE_MADVISE is not set CONFIG_ARCH_WANTS_THP_SWAP=y
CONFIG_THP_SWAP=y CONFIG_TRANSPARENT_HUGE_PAGECACHE=y CONFIG_CLEANCACHE=y
CONFIG_FRONTSWAP=y
CONFIG_CMA=y
# CONFIG_CMA_DEBUG is not set
# CONFIG_CMA_DEBUGFS is not set
CONFIG_CMA_AREAS=7
CONFIG_MEM_SOFT_DIRTY=y
CONFIG_ZSWAP=y
CONFIG_ZPOOL=y
CONFIG_ZBUD=y
# CONFIG_Z3FOLD is not set
CONFIG_ZSMALLOC=y
# CONFIG_PGTABLE_MAPPING is not set
# CONFIG_ZSMALLOC_STAT is not set CONFIG_GENERIC_EARLY_IOREMAP=y CONFIG_DEFERRED_STRUCT_PAGE_INIT=y
# CONFIG_IDLE_PAGE_TRACKING is not set CONFIG_ARCH_HAS_ZONE_DEVICE=y
CONFIG_ZONE_DEVICE=y
CONFIG_ARCH_HAS_HMM=y
CONFIG_MIGRATE_VMA_HELPER=y CONFIG_DEV_PAGEMAP_OPS=y
CONFIG_HMM=y
CONFIG_HMM_MIRROR=y
# CONFIG_DEVICE_PRIVATE is not set
# CONFIG_DEVICE_PUBLIC is not set CONFIG_FRAME_VECTOR=y CONFIG_ARCH_USES_HIGH_VMA_FLAGS=y CONFIG_ARCH_HAS_PKEYS=y
# CONFIG_PERCPU_STATS is not set
# CONFIG_GUP_BENCHMARK is not set CONFIG_ARCH_HAS_PTE_SPECIAL=y
CONFIG_NET=y
CONFIG_COMPAT_NETLINK_MESSAGES=y CONFIG_NET_INGRESS=y
CONFIG_NET_EGRESS=y
CONFIG_SKB_EXTENSIONS=y

#
# Networking options
#
CONFIG_PACKET=y
CONFIG_PACKET_DIAG=m
CONFIG_UNIX=y
CONFIG_UNIX_DIAG=m
# CONFIG_TLS is not set
CONFIG_XFRM=y
CONFIG_XFRM_ALGO=y
CONFIG_XFRM_USER=y
# CONFIG_XFRM_INTERFACE is not set
CONFIG_XFRM_SUB_POLICY=y
CONFIG_XFRM_MIGRATE=y
CONFIG_XFRM_STATISTICS=y
CONFIG_XFRM_IPCOMP=m
CONFIG_NET_KEY=m
CONFIG_NET_KEY_MIGRATE=y
# CONFIG_SMC is not set
# CONFIG_XDP_SOCKETS is not set
CONFIG_INET=y
CONFIG_IP_MULTICAST=y
CONFIG_IP_ADVANCED_ROUTER=y
CONFIG_IP_FIB_TRIE_STATS=y
CONFIG_IP_MULTIPLE_TABLES=y
CONFIG_IP_ROUTE_MULTIPATH=y
CONFIG_IP_ROUTE_VERBOSE=y
CONFIG_IP_ROUTE_CLASSID=y
CONFIG_IP_PNP=y
CONFIG_IP_PNP_DHCP=y
# CONFIG_IP_PNP_BOOTP is not set
# CONFIG_IP_PNP_RARP is not set
CONFIG_NET_IPIP=m
CONFIG_NET_IPGRE_DEMUX=m
CONFIG_NET_IP_TUNNEL=m
CONFIG_NET_IPGRE=m
CONFIG_NET_IPGRE_BROADCAST=y
CONFIG_IP_MROUTE_COMMON=y
CONFIG_IP_MROUTE=y
CONFIG_IP_MROUTE_MULTIPLE_TABLES=y
CONFIG_IP_PIMSM_V1=y
CONFIG_IP_PIMSM_V2=y
CONFIG_SYN_COOKIES=y
CONFIG_NET_IPVTI=m
CONFIG_NET_UDP_TUNNEL=m
CONFIG_NET_FOU=m
CONFIG_NET_FOU_IP_TUNNELS=y
CONFIG_INET_AH=m
CONFIG_INET_ESP=m
# CONFIG_INET_ESP_OFFLOAD is not set
CONFIG_INET_IPCOMP=m
CONFIG_INET_XFRM_TUNNEL=m
CONFIG_INET_TUNNEL=m
CONFIG_INET_XFRM_MODE_TRANSPORT=m
CONFIG_INET_XFRM_MODE_TUNNEL=m
CONFIG_INET_XFRM_MODE_BEET=m
CONFIG_INET_DIAG=m
CONFIG_INET_TCP_DIAG=m
CONFIG_INET_UDP_DIAG=m
# CONFIG_INET_RAW_DIAG is not set
# CONFIG_INET_DIAG_DESTROY is not set
CONFIG_TCP_CONG_ADVANCED=y
CONFIG_TCP_CONG_BIC=m
CONFIG_TCP_CONG_CUBIC=y
CONFIG_TCP_CONG_WESTWOOD=m
CONFIG_TCP_CONG_HTCP=m
CONFIG_TCP_CONG_HSTCP=m
CONFIG_TCP_CONG_HYBLA=m
CONFIG_TCP_CONG_VEGAS=m
# CONFIG_TCP_CONG_NV is not set
CONFIG_TCP_CONG_SCALABLE=m
CONFIG_TCP_CONG_LP=m
CONFIG_TCP_CONG_VENO=m
CONFIG_TCP_CONG_YEAH=m
CONFIG_TCP_CONG_ILLINOIS=m
CONFIG_TCP_CONG_DCTCP=m
# CONFIG_TCP_CONG_CDG is not set
# CONFIG_TCP_CONG_BBR is not set
CONFIG_DEFAULT_CUBIC=y
# CONFIG_DEFAULT_RENO is not set
CONFIG_DEFAULT_TCP_CONG="cubic"
CONFIG_TCP_MD5SIG=y
CONFIG_IPV6=y
CONFIG_IPV6_ROUTER_PREF=y
CONFIG_IPV6_ROUTE_INFO=y
CONFIG_IPV6_OPTIMISTIC_DAD=y
CONFIG_INET6_AH=m
CONFIG_INET6_ESP=m
# CONFIG_INET6_ESP_OFFLOAD is not set
CONFIG_INET6_IPCOMP=m
CONFIG_IPV6_MIP6=m
# CONFIG_IPV6_ILA is not set
CONFIG_INET6_XFRM_TUNNEL=m
CONFIG_INET6_TUNNEL=m
CONFIG_INET6_XFRM_MODE_TRANSPORT=m
CONFIG_INET6_XFRM_MODE_TUNNEL=m
CONFIG_INET6_XFRM_MODE_BEET=m
CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION=m
CONFIG_IPV6_VTI=m
CONFIG_IPV6_SIT=m
CONFIG_IPV6_SIT_6RD=y
CONFIG_IPV6_NDISC_NODETYPE=y
CONFIG_IPV6_TUNNEL=m
CONFIG_IPV6_GRE=m
CONFIG_IPV6_FOU=m
CONFIG_IPV6_FOU_TUNNEL=m
CONFIG_IPV6_MULTIPLE_TABLES=y
# CONFIG_IPV6_SUBTREES is not set
CONFIG_IPV6_MROUTE=y
CONFIG_IPV6_MROUTE_MULTIPLE_TABLES=y
CONFIG_IPV6_PIMSM_V2=y
CONFIG_IPV6_SEG6_LWTUNNEL=y
# CONFIG_IPV6_SEG6_HMAC is not set
CONFIG_IPV6_SEG6_BPF=y
CONFIG_NETLABEL=y
CONFIG_NETWORK_SECMARK=y
CONFIG_NET_PTP_CLASSIFY=y
CONFIG_NETWORK_PHY_TIMESTAMPING=y
CONFIG_NETFILTER=y
CONFIG_NETFILTER_ADVANCED=y
CONFIG_BRIDGE_NETFILTER=m

#
# Core Netfilter Configuration
#
CONFIG_NETFILTER_INGRESS=y
CONFIG_NETFILTER_NETLINK=m
CONFIG_NETFILTER_FAMILY_BRIDGE=y
CONFIG_NETFILTER_FAMILY_ARP=y
CONFIG_NETFILTER_NETLINK_ACCT=m
CONFIG_NETFILTER_NETLINK_QUEUE=m
CONFIG_NETFILTER_NETLINK_LOG=m
CONFIG_NETFILTER_NETLINK_OSF=m
CONFIG_NF_CONNTRACK=m
CONFIG_NF_LOG_COMMON=m
# CONFIG_NF_LOG_NETDEV is not set
CONFIG_NETFILTER_CONNCOUNT=m
CONFIG_NF_CONNTRACK_MARK=y
CONFIG_NF_CONNTRACK_SECMARK=y
CONFIG_NF_CONNTRACK_ZONES=y
CONFIG_NF_CONNTRACK_PROCFS=y
CONFIG_NF_CONNTRACK_EVENTS=y
CONFIG_NF_CONNTRACK_TIMEOUT=y
CONFIG_NF_CONNTRACK_TIMESTAMP=y
CONFIG_NF_CONNTRACK_LABELS=y
CONFIG_NF_CT_PROTO_DCCP=y
CONFIG_NF_CT_PROTO_GRE=y
CONFIG_NF_CT_PROTO_SCTP=y
CONFIG_NF_CT_PROTO_UDPLITE=y
CONFIG_NF_CONNTRACK_AMANDA=m
CONFIG_NF_CONNTRACK_FTP=m
CONFIG_NF_CONNTRACK_H323=m
CONFIG_NF_CONNTRACK_IRC=m
CONFIG_NF_CONNTRACK_BROADCAST=m
CONFIG_NF_CONNTRACK_NETBIOS_NS=m
CONFIG_NF_CONNTRACK_SNMP=m
CONFIG_NF_CONNTRACK_PPTP=m
CONFIG_NF_CONNTRACK_SANE=m
CONFIG_NF_CONNTRACK_SIP=m
CONFIG_NF_CONNTRACK_TFTP=m
CONFIG_NF_CT_NETLINK=m
CONFIG_NF_CT_NETLINK_TIMEOUT=m
# CONFIG_NETFILTER_NETLINK_GLUE_CT is not set
CONFIG_NF_NAT=m
CONFIG_NF_NAT_NEEDED=y
CONFIG_NF_NAT_AMANDA=m
CONFIG_NF_NAT_FTP=m
CONFIG_NF_NAT_IRC=m
CONFIG_NF_NAT_SIP=m
CONFIG_NF_NAT_TFTP=m
CONFIG_NF_NAT_REDIRECT=y
CONFIG_NETFILTER_SYNPROXY=m
CONFIG_NF_TABLES=m
# CONFIG_NF_TABLES_SET is not set
# CONFIG_NF_TABLES_INET is not set
# CONFIG_NF_TABLES_NETDEV is not set
# CONFIG_NFT_NUMGEN is not set
CONFIG_NFT_CT=m
CONFIG_NFT_COUNTER=m
# CONFIG_NFT_CONNLIMIT is not set
CONFIG_NFT_LOG=m
CONFIG_NFT_LIMIT=m
CONFIG_NFT_MASQ=m
CONFIG_NFT_REDIR=m
CONFIG_NFT_NAT=m
# CONFIG_NFT_TUNNEL is not set
# CONFIG_NFT_OBJREF is not set
CONFIG_NFT_QUEUE=m
# CONFIG_NFT_QUOTA is not set
CONFIG_NFT_REJECT=m
CONFIG_NFT_COMPAT=m
CONFIG_NFT_HASH=m
# CONFIG_NFT_XFRM is not set
# CONFIG_NFT_SOCKET is not set
# CONFIG_NFT_OSF is not set
# CONFIG_NFT_TPROXY is not set
# CONFIG_NF_FLOW_TABLE is not set
CONFIG_NETFILTER_XTABLES=y

#
# Xtables combined modules
#
CONFIG_NETFILTER_XT_MARK=m
CONFIG_NETFILTER_XT_CONNMARK=m
CONFIG_NETFILTER_XT_SET=m

#
# Xtables targets
#
CONFIG_NETFILTER_XT_TARGET_AUDIT=m
CONFIG_NETFILTER_XT_TARGET_CHECKSUM=m
CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
CONFIG_NETFILTER_XT_TARGET_CONNMARK=m
CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=m
CONFIG_NETFILTER_XT_TARGET_CT=m
CONFIG_NETFILTER_XT_TARGET_DSCP=m
CONFIG_NETFILTER_XT_TARGET_HL=m
CONFIG_NETFILTER_XT_TARGET_HMARK=m
CONFIG_NETFILTER_XT_TARGET_IDLETIMER=m
CONFIG_NETFILTER_XT_TARGET_LED=m
CONFIG_NETFILTER_XT_TARGET_LOG=m
CONFIG_NETFILTER_XT_TARGET_MARK=m
CONFIG_NETFILTER_XT_NAT=m
CONFIG_NETFILTER_XT_TARGET_NETMAP=m
CONFIG_NETFILTER_XT_TARGET_NFLOG=m
CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m
CONFIG_NETFILTER_XT_TARGET_NOTRACK=m
CONFIG_NETFILTER_XT_TARGET_RATEEST=m
CONFIG_NETFILTER_XT_TARGET_REDIRECT=m
CONFIG_NETFILTER_XT_TARGET_TEE=m
CONFIG_NETFILTER_XT_TARGET_TPROXY=m
CONFIG_NETFILTER_XT_TARGET_TRACE=m
CONFIG_NETFILTER_XT_TARGET_SECMARK=m
CONFIG_NETFILTER_XT_TARGET_TCPMSS=m
CONFIG_NETFILTER_XT_TARGET_TCPOPTSTRIP=m

#
# Xtables matches
#
CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=m
CONFIG_NETFILTER_XT_MATCH_BPF=m
CONFIG_NETFILTER_XT_MATCH_CGROUP=m
CONFIG_NETFILTER_XT_MATCH_CLUSTER=m
CONFIG_NETFILTER_XT_MATCH_COMMENT=m
CONFIG_NETFILTER_XT_MATCH_CONNBYTES=m
CONFIG_NETFILTER_XT_MATCH_CONNLABEL=m
CONFIG_NETFILTER_XT_MATCH_CONNLIMIT=m
CONFIG_NETFILTER_XT_MATCH_CONNMARK=m
CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
CONFIG_NETFILTER_XT_MATCH_CPU=m
CONFIG_NETFILTER_XT_MATCH_DCCP=m
CONFIG_NETFILTER_XT_MATCH_DEVGROUP=m
CONFIG_NETFILTER_XT_MATCH_DSCP=m
CONFIG_NETFILTER_XT_MATCH_ECN=m
CONFIG_NETFILTER_XT_MATCH_ESP=m
CONFIG_NETFILTER_XT_MATCH_HASHLIMIT=m
CONFIG_NETFILTER_XT_MATCH_HELPER=m
CONFIG_NETFILTER_XT_MATCH_HL=m
# CONFIG_NETFILTER_XT_MATCH_IPCOMP is not set
CONFIG_NETFILTER_XT_MATCH_IPRANGE=m
CONFIG_NETFILTER_XT_MATCH_IPVS=m
CONFIG_NETFILTER_XT_MATCH_L2TP=m
CONFIG_NETFILTER_XT_MATCH_LENGTH=m
CONFIG_NETFILTER_XT_MATCH_LIMIT=m
CONFIG_NETFILTER_XT_MATCH_MAC=m
CONFIG_NETFILTER_XT_MATCH_MARK=m
CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
CONFIG_NETFILTER_XT_MATCH_NFACCT=m
CONFIG_NETFILTER_XT_MATCH_OSF=m
CONFIG_NETFILTER_XT_MATCH_OWNER=m
CONFIG_NETFILTER_XT_MATCH_POLICY=m
CONFIG_NETFILTER_XT_MATCH_PHYSDEV=m
CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m
CONFIG_NETFILTER_XT_MATCH_QUOTA=m
CONFIG_NETFILTER_XT_MATCH_RATEEST=m
CONFIG_NETFILTER_XT_MATCH_REALM=m
CONFIG_NETFILTER_XT_MATCH_RECENT=m
CONFIG_NETFILTER_XT_MATCH_SCTP=m
CONFIG_NETFILTER_XT_MATCH_SOCKET=m
CONFIG_NETFILTER_XT_MATCH_STATE=m
CONFIG_NETFILTER_XT_MATCH_STATISTIC=m
CONFIG_NETFILTER_XT_MATCH_STRING=m
CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
CONFIG_NETFILTER_XT_MATCH_TIME=m
CONFIG_NETFILTER_XT_MATCH_U32=m
CONFIG_IP_SET=m
CONFIG_IP_SET_MAX=256
CONFIG_IP_SET_BITMAP_IP=m
CONFIG_IP_SET_BITMAP_IPMAC=m
CONFIG_IP_SET_BITMAP_PORT=m
CONFIG_IP_SET_HASH_IP=m
CONFIG_IP_SET_HASH_IPMARK=m
CONFIG_IP_SET_HASH_IPPORT=m
CONFIG_IP_SET_HASH_IPPORTIP=m
CONFIG_IP_SET_HASH_IPPORTNET=m
CONFIG_IP_SET_HASH_IPMAC=m
CONFIG_IP_SET_HASH_MAC=m
CONFIG_IP_SET_HASH_NETPORTNET=m
CONFIG_IP_SET_HASH_NET=m
CONFIG_IP_SET_HASH_NETNET=m
CONFIG_IP_SET_HASH_NETPORT=m
CONFIG_IP_SET_HASH_NETIFACE=m
CONFIG_IP_SET_LIST_SET=m
CONFIG_IP_VS=m
CONFIG_IP_VS_IPV6=y
# CONFIG_IP_VS_DEBUG is not set
CONFIG_IP_VS_TAB_BITS=12

#
# IPVS transport protocol load balancing support
#
CONFIG_IP_VS_PROTO_TCP=y
CONFIG_IP_VS_PROTO_UDP=y CONFIG_IP_VS_PROTO_AH_ESP=y CONFIG_IP_VS_PROTO_ESP=y
CONFIG_IP_VS_PROTO_AH=y
CONFIG_IP_VS_PROTO_SCTP=y

#
# IPVS scheduler
#
CONFIG_IP_VS_RR=m
CONFIG_IP_VS_WRR=m
CONFIG_IP_VS_LC=m
CONFIG_IP_VS_WLC=m
# CONFIG_IP_VS_FO is not set
# CONFIG_IP_VS_OVF is not set
CONFIG_IP_VS_LBLC=m
CONFIG_IP_VS_LBLCR=m
CONFIG_IP_VS_DH=m
CONFIG_IP_VS_SH=m
# CONFIG_IP_VS_MH is not set
CONFIG_IP_VS_SED=m
CONFIG_IP_VS_NQ=m

#
# IPVS SH scheduler
#
CONFIG_IP_VS_SH_TAB_BITS=8

#
# IPVS MH scheduler
#
CONFIG_IP_VS_MH_TAB_INDEX=12

#
# IPVS application helper
#
CONFIG_IP_VS_FTP=m
CONFIG_IP_VS_NFCT=y
CONFIG_IP_VS_PE_SIP=m

#
# IP: Netfilter Configuration
#
CONFIG_NF_DEFRAG_IPV4=m
CONFIG_NF_SOCKET_IPV4=m
CONFIG_NF_TPROXY_IPV4=m
# CONFIG_NF_TABLES_IPV4 is not set
# CONFIG_NF_TABLES_ARP is not set
CONFIG_NF_DUP_IPV4=m
# CONFIG_NF_LOG_ARP is not set
CONFIG_NF_LOG_IPV4=m
CONFIG_NF_REJECT_IPV4=m
CONFIG_NF_NAT_IPV4=m
CONFIG_NF_NAT_MASQUERADE_IPV4=y
CONFIG_NF_NAT_SNMP_BASIC=m
CONFIG_NF_NAT_PPTP=m
CONFIG_NF_NAT_H323=m
CONFIG_IP_NF_IPTABLES=m
CONFIG_IP_NF_MATCH_AH=m
CONFIG_IP_NF_MATCH_ECN=m
CONFIG_IP_NF_MATCH_RPFILTER=m
CONFIG_IP_NF_MATCH_TTL=m
CONFIG_IP_NF_FILTER=m
CONFIG_IP_NF_TARGET_REJECT=m
CONFIG_IP_NF_TARGET_SYNPROXY=m
CONFIG_IP_NF_NAT=m
CONFIG_IP_NF_TARGET_MASQUERADE=m
CONFIG_IP_NF_TARGET_NETMAP=m
CONFIG_IP_NF_TARGET_REDIRECT=m
CONFIG_IP_NF_MANGLE=m
CONFIG_IP_NF_TARGET_CLUSTERIP=m
CONFIG_IP_NF_TARGET_ECN=m
CONFIG_IP_NF_TARGET_TTL=m
CONFIG_IP_NF_RAW=m
CONFIG_IP_NF_SECURITY=m
CONFIG_IP_NF_ARPTABLES=m
CONFIG_IP_NF_ARPFILTER=m
CONFIG_IP_NF_ARP_MANGLE=m

#
# IPv6: Netfilter Configuration
#
CONFIG_NF_SOCKET_IPV6=m
CONFIG_NF_TPROXY_IPV6=m
# CONFIG_NF_TABLES_IPV6 is not set
CONFIG_NF_DUP_IPV6=m
CONFIG_NF_REJECT_IPV6=m
CONFIG_NF_LOG_IPV6=m
CONFIG_NF_NAT_IPV6=m
CONFIG_NF_NAT_MASQUERADE_IPV6=y
CONFIG_IP6_NF_IPTABLES=m
CONFIG_IP6_NF_MATCH_AH=m
CONFIG_IP6_NF_MATCH_EUI64=m
CONFIG_IP6_NF_MATCH_FRAG=m
CONFIG_IP6_NF_MATCH_OPTS=m
CONFIG_IP6_NF_MATCH_HL=m
CONFIG_IP6_NF_MATCH_IPV6HEADER=m
CONFIG_IP6_NF_MATCH_MH=m
CONFIG_IP6_NF_MATCH_RPFILTER=m
CONFIG_IP6_NF_MATCH_RT=m
# CONFIG_IP6_NF_MATCH_SRH is not set
CONFIG_IP6_NF_TARGET_HL=m
CONFIG_IP6_NF_FILTER=m
CONFIG_IP6_NF_TARGET_REJECT=m
CONFIG_IP6_NF_TARGET_SYNPROXY=m
CONFIG_IP6_NF_MANGLE=m
CONFIG_IP6_NF_RAW=m
CONFIG_IP6_NF_SECURITY=m
CONFIG_IP6_NF_NAT=m
CONFIG_IP6_NF_TARGET_MASQUERADE=m
CONFIG_IP6_NF_TARGET_NPT=m
CONFIG_NF_DEFRAG_IPV6=m
# CONFIG_NF_TABLES_BRIDGE is not set
CONFIG_BRIDGE_NF_EBTABLES=m
CONFIG_BRIDGE_EBT_BROUTE=m
CONFIG_BRIDGE_EBT_T_FILTER=m
CONFIG_BRIDGE_EBT_T_NAT=m
CONFIG_BRIDGE_EBT_802_3=m
CONFIG_BRIDGE_EBT_AMONG=m
CONFIG_BRIDGE_EBT_ARP=m
CONFIG_BRIDGE_EBT_IP=m
CONFIG_BRIDGE_EBT_IP6=m
CONFIG_BRIDGE_EBT_LIMIT=m
CONFIG_BRIDGE_EBT_MARK=m
CONFIG_BRIDGE_EBT_PKTTYPE=m
CONFIG_BRIDGE_EBT_STP=m
CONFIG_BRIDGE_EBT_VLAN=m
CONFIG_BRIDGE_EBT_ARPREPLY=m
CONFIG_BRIDGE_EBT_DNAT=m
CONFIG_BRIDGE_EBT_MARK_T=m
CONFIG_BRIDGE_EBT_REDIRECT=m
CONFIG_BRIDGE_EBT_SNAT=m
CONFIG_BRIDGE_EBT_LOG=m
CONFIG_BRIDGE_EBT_NFLOG=m
# CONFIG_BPFILTER is not set
CONFIG_IP_DCCP=m
CONFIG_INET_DCCP_DIAG=m

#
# DCCP CCIDs Configuration
#
# CONFIG_IP_DCCP_CCID2_DEBUG is not set
CONFIG_IP_DCCP_CCID3=y
# CONFIG_IP_DCCP_CCID3_DEBUG is not set
CONFIG_IP_DCCP_TFRC_LIB=y

#
# DCCP Kernel Hacking
#
# CONFIG_IP_DCCP_DEBUG is not set CONFIG_IP_SCTP=m
# CONFIG_SCTP_DBG_OBJCNT is not set
# CONFIG_SCTP_DEFAULT_COOKIE_HMAC_MD5 is not set CONFIG_SCTP_DEFAULT_COOKIE_HMAC_SHA1=y
# CONFIG_SCTP_DEFAULT_COOKIE_HMAC_NONE is not set CONFIG_SCTP_COOKIE_HMAC_MD5=y CONFIG_SCTP_COOKIE_HMAC_SHA1=y CONFIG_INET_SCTP_DIAG=m
# CONFIG_RDS is not set
# CONFIG_TIPC is not set
CONFIG_ATM=m
CONFIG_ATM_CLIP=m
# CONFIG_ATM_CLIP_NO_ICMP is not set CONFIG_ATM_LANE=m
# CONFIG_ATM_MPOA is not set CONFIG_ATM_BR2684=m
# CONFIG_ATM_BR2684_IPFILTER is not set CONFIG_L2TP=m
CONFIG_L2TP_DEBUGFS=m
CONFIG_L2TP_V3=y
CONFIG_L2TP_IP=m
CONFIG_L2TP_ETH=m
CONFIG_STP=m
CONFIG_GARP=m
CONFIG_MRP=m
CONFIG_BRIDGE=m CONFIG_BRIDGE_IGMP_SNOOPING=y CONFIG_BRIDGE_VLAN_FILTERING=y CONFIG_HAVE_NET_DSA=y
# CONFIG_NET_DSA is not set CONFIG_VLAN_8021Q=m
CONFIG_VLAN_8021Q_GVRP=y CONFIG_VLAN_8021Q_MVRP=y
# CONFIG_DECNET is not set
CONFIG_LLC=m
# CONFIG_LLC2 is not set
# CONFIG_ATALK is not set
# CONFIG_X25 is not set
# CONFIG_LAPB is not set
# CONFIG_PHONET is not set
CONFIG_6LOWPAN=m
# CONFIG_6LOWPAN_DEBUGFS is not set CONFIG_6LOWPAN_NHC=m CONFIG_6LOWPAN_NHC_DEST=m CONFIG_6LOWPAN_NHC_FRAGMENT=m CONFIG_6LOWPAN_NHC_HOP=m CONFIG_6LOWPAN_NHC_IPV6=m CONFIG_6LOWPAN_NHC_MOBILITY=m CONFIG_6LOWPAN_NHC_ROUTING=m CONFIG_6LOWPAN_NHC_UDP=m
# CONFIG_6LOWPAN_GHC_EXT_HDR_HOP is not set # CONFIG_6LOWPAN_GHC_UDP is not set
# CONFIG_6LOWPAN_GHC_ICMPV6 is not set
# CONFIG_6LOWPAN_GHC_EXT_HDR_DEST is not set # CONFIG_6LOWPAN_GHC_EXT_HDR_FRAG is not set # CONFIG_6LOWPAN_GHC_EXT_HDR_ROUTE is not set CONFIG_IEEE802154=m
# CONFIG_IEEE802154_NL802154_EXPERIMENTAL is not set CONFIG_IEEE802154_SOCKET=m CONFIG_IEEE802154_6LOWPAN=m CONFIG_MAC802154=m
CONFIG_NET_SCHED=y

#
# Queueing/Scheduling
#
CONFIG_NET_SCH_CBQ=m
CONFIG_NET_SCH_HTB=m
CONFIG_NET_SCH_HFSC=m
CONFIG_NET_SCH_ATM=m
CONFIG_NET_SCH_PRIO=m
CONFIG_NET_SCH_MULTIQ=m
CONFIG_NET_SCH_RED=m
CONFIG_NET_SCH_SFB=m
CONFIG_NET_SCH_SFQ=m
CONFIG_NET_SCH_TEQL=m
CONFIG_NET_SCH_TBF=m
# CONFIG_NET_SCH_CBS is not set
# CONFIG_NET_SCH_ETF is not set
# CONFIG_NET_SCH_TAPRIO is not set
CONFIG_NET_SCH_GRED=m
CONFIG_NET_SCH_DSMARK=m
CONFIG_NET_SCH_NETEM=m
CONFIG_NET_SCH_DRR=m
CONFIG_NET_SCH_MQPRIO=m
# CONFIG_NET_SCH_SKBPRIO is not set
CONFIG_NET_SCH_CHOKE=m
CONFIG_NET_SCH_QFQ=m
CONFIG_NET_SCH_CODEL=m
CONFIG_NET_SCH_FQ_CODEL=m
# CONFIG_NET_SCH_CAKE is not set
CONFIG_NET_SCH_FQ=m
# CONFIG_NET_SCH_HHF is not set
# CONFIG_NET_SCH_PIE is not set
CONFIG_NET_SCH_INGRESS=m
CONFIG_NET_SCH_PLUG=m
# CONFIG_NET_SCH_DEFAULT is not set

#
# Classification
#
CONFIG_NET_CLS=y
CONFIG_NET_CLS_BASIC=m
CONFIG_NET_CLS_TCINDEX=m
CONFIG_NET_CLS_ROUTE4=m
CONFIG_NET_CLS_FW=m
CONFIG_NET_CLS_U32=m
CONFIG_CLS_U32_PERF=y
CONFIG_CLS_U32_MARK=y
CONFIG_NET_CLS_RSVP=m
CONFIG_NET_CLS_RSVP6=m
CONFIG_NET_CLS_FLOW=m
CONFIG_NET_CLS_CGROUP=y
CONFIG_NET_CLS_BPF=m
CONFIG_NET_CLS_FLOWER=m
CONFIG_NET_CLS_MATCHALL=m
CONFIG_NET_EMATCH=y
CONFIG_NET_EMATCH_STACK=32
CONFIG_NET_EMATCH_CMP=m
CONFIG_NET_EMATCH_NBYTE=m
CONFIG_NET_EMATCH_U32=m
CONFIG_NET_EMATCH_META=m
CONFIG_NET_EMATCH_TEXT=m
# CONFIG_NET_EMATCH_CANID is not set
CONFIG_NET_EMATCH_IPSET=m
# CONFIG_NET_EMATCH_IPT is not set
CONFIG_NET_CLS_ACT=y
CONFIG_NET_ACT_POLICE=m
CONFIG_NET_ACT_GACT=m
CONFIG_GACT_PROB=y
CONFIG_NET_ACT_MIRRED=m
CONFIG_NET_ACT_SAMPLE=m
CONFIG_NET_ACT_IPT=m
CONFIG_NET_ACT_NAT=m
CONFIG_NET_ACT_PEDIT=m
CONFIG_NET_ACT_SIMP=m
CONFIG_NET_ACT_SKBEDIT=m
CONFIG_NET_ACT_CSUM=m
CONFIG_NET_ACT_VLAN=m
# CONFIG_NET_ACT_BPF is not set
CONFIG_NET_ACT_CONNMARK=m
CONFIG_NET_ACT_SKBMOD=m
# CONFIG_NET_ACT_IFE is not set
CONFIG_NET_ACT_TUNNEL_KEY=m
CONFIG_NET_CLS_IND=y
CONFIG_NET_SCH_FIFO=y
CONFIG_DCB=y
CONFIG_DNS_RESOLVER=m
# CONFIG_BATMAN_ADV is not set
CONFIG_OPENVSWITCH=m
CONFIG_OPENVSWITCH_GRE=m
CONFIG_OPENVSWITCH_VXLAN=m
CONFIG_OPENVSWITCH_GENEVE=m
CONFIG_VSOCKETS=m
CONFIG_VSOCKETS_DIAG=m
CONFIG_VMWARE_VMCI_VSOCKETS=m
CONFIG_VIRTIO_VSOCKETS=m
CONFIG_VIRTIO_VSOCKETS_COMMON=m
CONFIG_HYPERV_VSOCKETS=m
CONFIG_NETLINK_DIAG=m
CONFIG_MPLS=y
CONFIG_NET_MPLS_GSO=y
# CONFIG_MPLS_ROUTING is not set
CONFIG_NET_NSH=m
# CONFIG_HSR is not set
CONFIG_NET_SWITCHDEV=y
CONFIG_NET_L3_MASTER_DEV=y
# CONFIG_NET_NCSI is not set
CONFIG_RPS=y
CONFIG_RFS_ACCEL=y
CONFIG_XPS=y
# CONFIG_CGROUP_NET_PRIO is not set
CONFIG_CGROUP_NET_CLASSID=y
CONFIG_NET_RX_BUSY_POLL=y
CONFIG_BQL=y
CONFIG_BPF_JIT=y
CONFIG_BPF_STREAM_PARSER=y
CONFIG_NET_FLOW_LIMIT=y

#
# Network testing
#
CONFIG_NET_PKTGEN=m
CONFIG_NET_DROP_MONITOR=y
# CONFIG_HAMRADIO is not set
CONFIG_CAN=m
CONFIG_CAN_RAW=m
CONFIG_CAN_BCM=m
CONFIG_CAN_GW=m

#
# CAN Device Drivers
#
CONFIG_CAN_VCAN=m
# CONFIG_CAN_VXCAN is not set
CONFIG_CAN_SLCAN=m
CONFIG_CAN_DEV=m
CONFIG_CAN_CALC_BITTIMING=y
CONFIG_CAN_C_CAN=m
CONFIG_CAN_C_CAN_PLATFORM=m
CONFIG_CAN_C_CAN_PCI=m
CONFIG_CAN_CC770=m
# CONFIG_CAN_CC770_ISA is not set
CONFIG_CAN_CC770_PLATFORM=m
# CONFIG_CAN_IFI_CANFD is not set
# CONFIG_CAN_M_CAN is not set
# CONFIG_CAN_PEAK_PCIEFD is not set
CONFIG_CAN_SJA1000=m
# CONFIG_CAN_SJA1000_ISA is not set
CONFIG_CAN_SJA1000_PLATFORM=m
CONFIG_CAN_EMS_PCI=m
CONFIG_CAN_PEAK_PCI=m
CONFIG_CAN_PEAK_PCIEC=y
CONFIG_CAN_KVASER_PCI=m
CONFIG_CAN_PLX_PCI=m
CONFIG_CAN_SOFTING=m

#
# CAN SPI interfaces
#
# CONFIG_CAN_HI311X is not set
# CONFIG_CAN_MCP251X is not set

#
# CAN USB interfaces
#
CONFIG_CAN_8DEV_USB=m
CONFIG_CAN_EMS_USB=m
CONFIG_CAN_ESD_USB2=m
# CONFIG_CAN_GS_USB is not set
CONFIG_CAN_KVASER_USB=m
# CONFIG_CAN_MCBA_USB is not set
CONFIG_CAN_PEAK_USB=m
# CONFIG_CAN_UCAN is not set
# CONFIG_CAN_DEBUG_DEVICES is not set
CONFIG_BT=m
CONFIG_BT_BREDR=y
CONFIG_BT_RFCOMM=m
CONFIG_BT_RFCOMM_TTY=y
CONFIG_BT_BNEP=m
CONFIG_BT_BNEP_MC_FILTER=y
CONFIG_BT_BNEP_PROTO_FILTER=y
CONFIG_BT_CMTP=m
CONFIG_BT_HIDP=m
CONFIG_BT_HS=y
CONFIG_BT_LE=y
# CONFIG_BT_6LOWPAN is not set
# CONFIG_BT_LEDS is not set
# CONFIG_BT_SELFTEST is not set
CONFIG_BT_DEBUGFS=y

#
# Bluetooth device drivers
#
CONFIG_BT_INTEL=m
CONFIG_BT_BCM=m
CONFIG_BT_RTL=m
CONFIG_BT_HCIBTUSB=m
# CONFIG_BT_HCIBTUSB_AUTOSUSPEND is not set
CONFIG_BT_HCIBTUSB_BCM=y
CONFIG_BT_HCIBTUSB_RTL=y
CONFIG_BT_HCIBTSDIO=m
CONFIG_BT_HCIUART=m
CONFIG_BT_HCIUART_H4=y
CONFIG_BT_HCIUART_BCSP=y
CONFIG_BT_HCIUART_ATH3K=y
# CONFIG_BT_HCIUART_INTEL is not set
# CONFIG_BT_HCIUART_AG6XX is not set
# CONFIG_BT_HCIUART_MRVL is not set
CONFIG_BT_HCIBCM203X=m
CONFIG_BT_HCIBPA10X=m
CONFIG_BT_HCIBFUSB=m
CONFIG_BT_HCIVHCI=m
CONFIG_BT_MRVL=m
CONFIG_BT_MRVL_SDIO=m
CONFIG_BT_ATH3K=m
# CONFIG_AF_RXRPC is not set
# CONFIG_AF_KCM is not set
CONFIG_STREAM_PARSER=y
CONFIG_FIB_RULES=y
CONFIG_WIRELESS=y
CONFIG_WIRELESS_EXT=y
CONFIG_WEXT_CORE=y
CONFIG_WEXT_PROC=y
CONFIG_WEXT_PRIV=y
CONFIG_CFG80211=m
# CONFIG_NL80211_TESTMODE is not set
# CONFIG_CFG80211_DEVELOPER_WARNINGS is not set
# CONFIG_CFG80211_CERTIFICATION_ONUS is not set
CONFIG_CFG80211_REQUIRE_SIGNED_REGDB=y
CONFIG_CFG80211_USE_KERNEL_REGDB_KEYS=y
CONFIG_CFG80211_DEFAULT_PS=y
# CONFIG_CFG80211_DEBUGFS is not set
CONFIG_CFG80211_CRDA_SUPPORT=y
CONFIG_CFG80211_WEXT=y
CONFIG_LIB80211=m
# CONFIG_LIB80211_DEBUG is not set
CONFIG_MAC80211=m
CONFIG_MAC80211_HAS_RC=y
CONFIG_MAC80211_RC_MINSTREL=y
CONFIG_MAC80211_RC_DEFAULT_MINSTREL=y
CONFIG_MAC80211_RC_DEFAULT="minstrel_ht"
CONFIG_MAC80211_MESH=y
CONFIG_MAC80211_LEDS=y
CONFIG_MAC80211_DEBUGFS=y
# CONFIG_MAC80211_MESSAGE_TRACING is not set
# CONFIG_MAC80211_DEBUG_MENU is not set
CONFIG_MAC80211_STA_HASH_MAX_SIZE=0
# CONFIG_WIMAX is not set
CONFIG_RFKILL=m
CONFIG_RFKILL_LEDS=y
CONFIG_RFKILL_INPUT=y
# CONFIG_RFKILL_GPIO is not set
CONFIG_NET_9P=y
CONFIG_NET_9P_VIRTIO=m
# CONFIG_NET_9P_XEN is not set
# CONFIG_NET_9P_RDMA is not set
# CONFIG_NET_9P_DEBUG is not set
# CONFIG_CAIF is not set
CONFIG_CEPH_LIB=m
# CONFIG_CEPH_LIB_PRETTYDEBUG is not set
CONFIG_CEPH_LIB_USE_DNS_RESOLVER=y
# CONFIG_NFC is not set
CONFIG_PSAMPLE=m
# CONFIG_NET_IFE is not set
CONFIG_LWTUNNEL=y
CONFIG_LWTUNNEL_BPF=y
CONFIG_DST_CACHE=y
CONFIG_GRO_CELLS=y
CONFIG_NET_SOCK_MSG=y
CONFIG_NET_DEVLINK=m
CONFIG_MAY_USE_DEVLINK=m
CONFIG_PAGE_POOL=y
CONFIG_FAILOVER=m
CONFIG_HAVE_EBPF_JIT=y

#
# Device Drivers
#
CONFIG_HAVE_EISA=y
# CONFIG_EISA is not set
CONFIG_HAVE_PCI=y
CONFIG_PCI=y
CONFIG_PCI_DOMAINS=y
CONFIG_PCIEPORTBUS=y
CONFIG_HOTPLUG_PCI_PCIE=y
CONFIG_PCIEAER=y
CONFIG_PCIEAER_INJECT=m
CONFIG_PCIE_ECRC=y
CONFIG_PCIEASPM=y
# CONFIG_PCIEASPM_DEBUG is not set
CONFIG_PCIEASPM_DEFAULT=y
# CONFIG_PCIEASPM_POWERSAVE is not set
# CONFIG_PCIEASPM_POWER_SUPERSAVE is not set
# CONFIG_PCIEASPM_PERFORMANCE is not set
CONFIG_PCIE_PME=y
# CONFIG_PCIE_DPC is not set
# CONFIG_PCIE_PTM is not set
CONFIG_PCI_MSI=y
CONFIG_PCI_MSI_IRQ_DOMAIN=y
CONFIG_PCI_QUIRKS=y
# CONFIG_PCI_DEBUG is not set
# CONFIG_PCI_REALLOC_ENABLE_AUTO is not set
CONFIG_PCI_STUB=y
# CONFIG_PCI_PF_STUB is not set
# CONFIG_XEN_PCIDEV_FRONTEND is not set
CONFIG_PCI_ATS=y
CONFIG_PCI_LOCKLESS_CONFIG=y
CONFIG_PCI_IOV=y
CONFIG_PCI_PRI=y
CONFIG_PCI_PASID=y
# CONFIG_PCI_P2PDMA is not set
CONFIG_PCI_LABEL=y
CONFIG_PCI_HYPERV=m
CONFIG_HOTPLUG_PCI=y
CONFIG_HOTPLUG_PCI_ACPI=y
CONFIG_HOTPLUG_PCI_ACPI_IBM=m
# CONFIG_HOTPLUG_PCI_CPCI is not set
CONFIG_HOTPLUG_PCI_SHPC=y

#
# PCI controller drivers
#

#
# Cadence PCIe controllers support
#
CONFIG_VMD=y

#
# DesignWare PCI Core Support
#
# CONFIG_PCIE_DW_PLAT_HOST is not set
# CONFIG_PCI_MESON is not set

#
# PCI Endpoint
#
# CONFIG_PCI_ENDPOINT is not set

#
# PCI switch controller drivers
#
# CONFIG_PCI_SW_SWITCHTEC is not set
CONFIG_PCCARD=y
# CONFIG_PCMCIA is not set
CONFIG_CARDBUS=y

#
# PC-card bridges
#
CONFIG_YENTA=m
CONFIG_YENTA_O2=y
CONFIG_YENTA_RICOH=y
CONFIG_YENTA_TI=y
CONFIG_YENTA_ENE_TUNE=y
CONFIG_YENTA_TOSHIBA=y
# CONFIG_RAPIDIO is not set

#
# Generic Driver Options
#
CONFIG_UEVENT_HELPER=y
CONFIG_UEVENT_HELPER_PATH=""
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
CONFIG_STANDALONE=y
CONFIG_PREVENT_FIRMWARE_BUILD=y

#
# Firmware loader
#
CONFIG_FW_LOADER=y
CONFIG_EXTRA_FIRMWARE=""
CONFIG_FW_LOADER_USER_HELPER=y
CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y
CONFIG_WANT_DEV_COREDUMP=y
CONFIG_ALLOW_DEV_COREDUMP=y
CONFIG_DEV_COREDUMP=y
# CONFIG_DEBUG_DRIVER is not set
# CONFIG_DEBUG_DEVRES is not set
# CONFIG_DEBUG_TEST_DRIVER_REMOVE is not set
# CONFIG_TEST_ASYNC_DRIVER_PROBE is not set
CONFIG_SYS_HYPERVISOR=y
CONFIG_GENERIC_CPU_AUTOPROBE=y
CONFIG_GENERIC_CPU_VULNERABILITIES=y
CONFIG_REGMAP=y
CONFIG_REGMAP_I2C=y
CONFIG_REGMAP_SPI=y
CONFIG_REGMAP_IRQ=y
CONFIG_DMA_SHARED_BUFFER=y
# CONFIG_DMA_FENCE_TRACE is not set
CONFIG_DMA_CMA=y

#
# Default contiguous memory area size:
#
CONFIG_CMA_SIZE_MBYTES=200
CONFIG_CMA_SIZE_SEL_MBYTES=y
# CONFIG_CMA_SIZE_SEL_PERCENTAGE is not set
# CONFIG_CMA_SIZE_SEL_MIN is not set
# CONFIG_CMA_SIZE_SEL_MAX is not set
CONFIG_CMA_ALIGNMENT=8

#
# Bus devices
#
CONFIG_CONNECTOR=y
CONFIG_PROC_EVENTS=y
# CONFIG_GNSS is not set
CONFIG_MTD=m
# CONFIG_MTD_TESTS is not set
# CONFIG_MTD_CMDLINE_PARTS is not set
# CONFIG_MTD_AR7_PARTS is not set

#
# Partition parsers
#
# CONFIG_MTD_REDBOOT_PARTS is not set

#
# User Modules And Translation Layers
#
CONFIG_MTD_BLKDEVS=m
CONFIG_MTD_BLOCK=m
# CONFIG_MTD_BLOCK_RO is not set
# CONFIG_FTL is not set
# CONFIG_NFTL is not set
# CONFIG_INFTL is not set
# CONFIG_RFD_FTL is not set
# CONFIG_SSFDC is not set
# CONFIG_SM_FTL is not set
# CONFIG_MTD_OOPS is not set
# CONFIG_MTD_SWAP is not set
# CONFIG_MTD_PARTITIONED_MASTER is not set

#
# RAM/ROM/Flash chip drivers
#
# CONFIG_MTD_CFI is not set
# CONFIG_MTD_JEDECPROBE is not set
CONFIG_MTD_MAP_BANK_WIDTH_1=y
CONFIG_MTD_MAP_BANK_WIDTH_2=y
CONFIG_MTD_MAP_BANK_WIDTH_4=y
CONFIG_MTD_CFI_I1=y
CONFIG_MTD_CFI_I2=y
# CONFIG_MTD_RAM is not set
# CONFIG_MTD_ROM is not set
# CONFIG_MTD_ABSENT is not set

#
# Mapping drivers for chip access
#
# CONFIG_MTD_COMPLEX_MAPPINGS is not set
# CONFIG_MTD_INTEL_VR_NOR is not set
# CONFIG_MTD_PLATRAM is not set

#
# Self-contained MTD device drivers
#
# CONFIG_MTD_PMC551 is not set
# CONFIG_MTD_DATAFLASH is not set
# CONFIG_MTD_MCHP23K256 is not set
# CONFIG_MTD_SST25L is not set
# CONFIG_MTD_SLRAM is not set
# CONFIG_MTD_PHRAM is not set
# CONFIG_MTD_MTDRAM is not set
# CONFIG_MTD_BLOCK2MTD is not set

#
# Disk-On-Chip Device Drivers
#
# CONFIG_MTD_DOCG3 is not set
# CONFIG_MTD_ONENAND is not set
# CONFIG_MTD_NAND is not set
# CONFIG_MTD_SPI_NAND is not set

#
# LPDDR & LPDDR2 PCM memory drivers
#
# CONFIG_MTD_LPDDR is not set
# CONFIG_MTD_SPI_NOR is not set
CONFIG_MTD_UBI=m
CONFIG_MTD_UBI_WL_THRESHOLD=4096
CONFIG_MTD_UBI_BEB_LIMIT=20
# CONFIG_MTD_UBI_FASTMAP is not set
# CONFIG_MTD_UBI_GLUEBI is not set
# CONFIG_MTD_UBI_BLOCK is not set
# CONFIG_OF is not set
CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y
CONFIG_PARPORT=m
CONFIG_PARPORT_PC=m
CONFIG_PARPORT_SERIAL=m
# CONFIG_PARPORT_PC_FIFO is not set
# CONFIG_PARPORT_PC_SUPERIO is not set
# CONFIG_PARPORT_AX88796 is not set
CONFIG_PARPORT_1284=y
CONFIG_PARPORT_NOT_PC=y
CONFIG_PNP=y
# CONFIG_PNP_DEBUG_MESSAGES is not set

#
# Protocols
#
CONFIG_PNPACPI=y
CONFIG_BLK_DEV=y
CONFIG_BLK_DEV_NULL_BLK=m
CONFIG_BLK_DEV_NULL_BLK_FAULT_INJECTION=y
CONFIG_BLK_DEV_FD=m
CONFIG_CDROM=m
# CONFIG_PARIDE is not set
CONFIG_BLK_DEV_PCIESSD_MTIP32XX=m
# CONFIG_ZRAM is not set
# CONFIG_BLK_DEV_UMEM is not set
CONFIG_BLK_DEV_LOOP=m
CONFIG_BLK_DEV_LOOP_MIN_COUNT=0
# CONFIG_BLK_DEV_CRYPTOLOOP is not set
# CONFIG_BLK_DEV_DRBD is not set
CONFIG_BLK_DEV_NBD=m
# CONFIG_BLK_DEV_SKD is not set
CONFIG_BLK_DEV_SX8=m
CONFIG_BLK_DEV_RAM=m
CONFIG_BLK_DEV_RAM_COUNT=16
CONFIG_BLK_DEV_RAM_SIZE=16384
CONFIG_CDROM_PKTCDVD=m
CONFIG_CDROM_PKTCDVD_BUFFERS=8
# CONFIG_CDROM_PKTCDVD_WCACHE is not set
CONFIG_ATA_OVER_ETH=m
CONFIG_XEN_BLKDEV_FRONTEND=m
CONFIG_VIRTIO_BLK=m
# CONFIG_VIRTIO_BLK_SCSI is not set
CONFIG_BLK_DEV_RBD=m
# CONFIG_BLK_DEV_RSXX is not set

#
# NVME Support
#
CONFIG_NVME_CORE=m
CONFIG_BLK_DEV_NVME=m
CONFIG_NVME_MULTIPATH=y
CONFIG_NVME_FABRICS=m
CONFIG_NVME_RDMA=m
CONFIG_NVME_FC=m
# CONFIG_NVME_TCP is not set
CONFIG_NVME_TARGET=m
CONFIG_NVME_TARGET_LOOP=m
CONFIG_NVME_TARGET_RDMA=m
CONFIG_NVME_TARGET_FC=m
CONFIG_NVME_TARGET_FCLOOP=m
# CONFIG_NVME_TARGET_TCP is not set

#
# Misc devices
#
CONFIG_SENSORS_LIS3LV02D=m
# CONFIG_AD525X_DPOT is not set
# CONFIG_DUMMY_IRQ is not set
# CONFIG_IBM_ASM is not set
# CONFIG_PHANTOM is not set
CONFIG_SGI_IOC4=m
CONFIG_TIFM_CORE=m
CONFIG_TIFM_7XX1=m
# CONFIG_ICS932S401 is not set
CONFIG_ENCLOSURE_SERVICES=m
CONFIG_SGI_XP=m
CONFIG_HP_ILO=m
CONFIG_SGI_GRU=m
# CONFIG_SGI_GRU_DEBUG is not set
CONFIG_APDS9802ALS=m
CONFIG_ISL29003=m
CONFIG_ISL29020=m
CONFIG_SENSORS_TSL2550=m
CONFIG_SENSORS_BH1770=m
CONFIG_SENSORS_APDS990X=m
# CONFIG_HMC6352 is not set
# CONFIG_DS1682 is not set
CONFIG_VMWARE_BALLOON=m
# CONFIG_USB_SWITCH_FSA9480 is not set
# CONFIG_LATTICE_ECP3_CONFIG is not set
# CONFIG_SRAM is not set
# CONFIG_PCI_ENDPOINT_TEST is not set
CONFIG_PVPANIC=y
# CONFIG_C2PORT is not set

#
# EEPROM support
#
CONFIG_EEPROM_AT24=m
# CONFIG_EEPROM_AT25 is not set
CONFIG_EEPROM_LEGACY=m
CONFIG_EEPROM_MAX6875=m
CONFIG_EEPROM_93CX6=m
# CONFIG_EEPROM_93XX46 is not set
# CONFIG_EEPROM_IDT_89HPESX is not set
# CONFIG_EEPROM_EE1004 is not set
CONFIG_CB710_CORE=m
# CONFIG_CB710_DEBUG is not set
CONFIG_CB710_DEBUG_ASSUMPTIONS=y

#
# Texas Instruments shared transport line discipline #
# CONFIG_TI_ST is not set CONFIG_SENSORS_LIS3_I2C=m CONFIG_ALTERA_STAPL=m
CONFIG_INTEL_MEI=m
CONFIG_INTEL_MEI_ME=m
# CONFIG_INTEL_MEI_TXE is not set CONFIG_VMWARE_VMCI=m

#
# Intel MIC & related support
#

#
# Intel MIC Bus Driver
#
# CONFIG_INTEL_MIC_BUS is not set

#
# SCIF Bus Driver
#
# CONFIG_SCIF_BUS is not set

#
# VOP Bus Driver
#
# CONFIG_VOP_BUS is not set

#
# Intel MIC Host Driver
#

#
# Intel MIC Card Driver
#

#
# SCIF Driver
#

#
# Intel MIC Coprocessor State Management (COSM) Drivers #

#
# VOP Driver
#
# CONFIG_GENWQE is not set
# CONFIG_ECHO is not set
# CONFIG_MISC_ALCOR_PCI is not set
# CONFIG_MISC_RTSX_PCI is not set
# CONFIG_MISC_RTSX_USB is not set
CONFIG_HAVE_IDE=y
# CONFIG_IDE is not set

#
# SCSI device support
#
CONFIG_SCSI_MOD=y
CONFIG_RAID_ATTRS=m
CONFIG_SCSI=y
CONFIG_SCSI_DMA=y
CONFIG_SCSI_NETLINK=y
CONFIG_SCSI_PROC_FS=y

#
# SCSI support type (disk, tape, CD-ROM)
#
CONFIG_BLK_DEV_SD=m
CONFIG_CHR_DEV_ST=m
CONFIG_CHR_DEV_OSST=m
CONFIG_BLK_DEV_SR=m
CONFIG_BLK_DEV_SR_VENDOR=y
CONFIG_CHR_DEV_SG=m
CONFIG_CHR_DEV_SCH=m
CONFIG_SCSI_ENCLOSURE=m
CONFIG_SCSI_CONSTANTS=y
CONFIG_SCSI_LOGGING=y
CONFIG_SCSI_SCAN_ASYNC=y

#
# SCSI Transports
#
CONFIG_SCSI_SPI_ATTRS=m
CONFIG_SCSI_FC_ATTRS=m
CONFIG_SCSI_ISCSI_ATTRS=m
CONFIG_SCSI_SAS_ATTRS=m
CONFIG_SCSI_SAS_LIBSAS=m
CONFIG_SCSI_SAS_ATA=y
CONFIG_SCSI_SAS_HOST_SMP=y
CONFIG_SCSI_SRP_ATTRS=m
CONFIG_SCSI_LOWLEVEL=y
CONFIG_ISCSI_TCP=m
CONFIG_ISCSI_BOOT_SYSFS=m
CONFIG_SCSI_CXGB3_ISCSI=m
CONFIG_SCSI_CXGB4_ISCSI=m
CONFIG_SCSI_BNX2_ISCSI=m
CONFIG_SCSI_BNX2X_FCOE=m
CONFIG_BE2ISCSI=m
# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
CONFIG_SCSI_HPSA=m
CONFIG_SCSI_3W_9XXX=m
CONFIG_SCSI_3W_SAS=m
# CONFIG_SCSI_ACARD is not set
CONFIG_SCSI_AACRAID=m
# CONFIG_SCSI_AIC7XXX is not set
CONFIG_SCSI_AIC79XX=m
CONFIG_AIC79XX_CMDS_PER_DEVICE=4
CONFIG_AIC79XX_RESET_DELAY_MS=15000
# CONFIG_AIC79XX_DEBUG_ENABLE is not set
CONFIG_AIC79XX_DEBUG_MASK=0
# CONFIG_AIC79XX_REG_PRETTY_PRINT is not set
# CONFIG_SCSI_AIC94XX is not set
CONFIG_SCSI_MVSAS=m
# CONFIG_SCSI_MVSAS_DEBUG is not set
CONFIG_SCSI_MVSAS_TASKLET=y
CONFIG_SCSI_MVUMI=m
# CONFIG_SCSI_DPT_I2O is not set
# CONFIG_SCSI_ADVANSYS is not set
CONFIG_SCSI_ARCMSR=m
# CONFIG_SCSI_ESAS2R is not set
# CONFIG_MEGARAID_NEWGEN is not set
# CONFIG_MEGARAID_LEGACY is not set
CONFIG_MEGARAID_SAS=m
CONFIG_SCSI_MPT3SAS=m
CONFIG_SCSI_MPT2SAS_MAX_SGE=128
CONFIG_SCSI_MPT3SAS_MAX_SGE=128
CONFIG_SCSI_MPT2SAS=m
CONFIG_SCSI_SMARTPQI=m
CONFIG_SCSI_UFSHCD=m
CONFIG_SCSI_UFSHCD_PCI=m
# CONFIG_SCSI_UFS_DWC_TC_PCI is not set
# CONFIG_SCSI_UFSHCD_PLATFORM is not set
# CONFIG_SCSI_UFS_BSG is not set
CONFIG_SCSI_HPTIOP=m
# CONFIG_SCSI_BUSLOGIC is not set
# CONFIG_SCSI_MYRB is not set
# CONFIG_SCSI_MYRS is not set
CONFIG_VMWARE_PVSCSI=m
# CONFIG_XEN_SCSI_FRONTEND is not set
CONFIG_HYPERV_STORAGE=m
CONFIG_LIBFC=m
CONFIG_LIBFCOE=m
CONFIG_FCOE=m
CONFIG_FCOE_FNIC=m
# CONFIG_SCSI_SNIC is not set
# CONFIG_SCSI_DMX3191D is not set
# CONFIG_SCSI_GDTH is not set
CONFIG_SCSI_ISCI=m
# CONFIG_SCSI_IPS is not set
CONFIG_SCSI_INITIO=m
# CONFIG_SCSI_INIA100 is not set
# CONFIG_SCSI_PPA is not set
# CONFIG_SCSI_IMM is not set
CONFIG_SCSI_STEX=m
# CONFIG_SCSI_SYM53C8XX_2 is not set
# CONFIG_SCSI_IPR is not set
# CONFIG_SCSI_QLOGIC_1280 is not set
CONFIG_SCSI_QLA_FC=m
CONFIG_TCM_QLA2XXX=m
# CONFIG_TCM_QLA2XXX_DEBUG is not set
CONFIG_SCSI_QLA_ISCSI=m
CONFIG_QEDI=m
CONFIG_QEDF=m
# CONFIG_SCSI_LPFC is not set
# CONFIG_SCSI_DC395x is not set
# CONFIG_SCSI_AM53C974 is not set
# CONFIG_SCSI_WD719X is not set
CONFIG_SCSI_DEBUG=m
CONFIG_SCSI_PMCRAID=m
CONFIG_SCSI_PM8001=m
CONFIG_SCSI_BFA_FC=m
CONFIG_SCSI_VIRTIO=m
CONFIG_SCSI_CHELSIO_FCOE=m
CONFIG_SCSI_DH=y
CONFIG_SCSI_DH_RDAC=y
CONFIG_SCSI_DH_HP_SW=y
CONFIG_SCSI_DH_EMC=y
CONFIG_SCSI_DH_ALUA=y
CONFIG_SCSI_OSD_INITIATOR=m
CONFIG_SCSI_OSD_ULD=m
CONFIG_SCSI_OSD_DPRINT_SENSE=1
# CONFIG_SCSI_OSD_DEBUG is not set
CONFIG_ATA=m
CONFIG_ATA_VERBOSE_ERROR=y
CONFIG_ATA_ACPI=y
# CONFIG_SATA_ZPODD is not set
CONFIG_SATA_PMP=y

#
# Controllers with non-SFF native interface
#
CONFIG_SATA_AHCI=m
CONFIG_SATA_MOBILE_LPM_POLICY=0
CONFIG_SATA_AHCI_PLATFORM=m
# CONFIG_SATA_INIC162X is not set
CONFIG_SATA_ACARD_AHCI=m
CONFIG_SATA_SIL24=m
CONFIG_ATA_SFF=y

#
# SFF controllers with custom DMA interface
#
CONFIG_PDC_ADMA=m
CONFIG_SATA_QSTOR=m
CONFIG_SATA_SX4=m
CONFIG_ATA_BMDMA=y

#
# SATA SFF controllers with BMDMA
#
CONFIG_ATA_PIIX=m
# CONFIG_SATA_DWC is not set
CONFIG_SATA_MV=m
CONFIG_SATA_NV=m
CONFIG_SATA_PROMISE=m
CONFIG_SATA_SIL=m
CONFIG_SATA_SIS=m
CONFIG_SATA_SVW=m
CONFIG_SATA_ULI=m
CONFIG_SATA_VIA=m
CONFIG_SATA_VITESSE=m

#
# PATA SFF controllers with BMDMA
#
CONFIG_PATA_ALI=m
CONFIG_PATA_AMD=m
CONFIG_PATA_ARTOP=m
CONFIG_PATA_ATIIXP=m
CONFIG_PATA_ATP867X=m
CONFIG_PATA_CMD64X=m
# CONFIG_PATA_CYPRESS is not set
# CONFIG_PATA_EFAR is not set
CONFIG_PATA_HPT366=m
CONFIG_PATA_HPT37X=m
CONFIG_PATA_HPT3X2N=m
CONFIG_PATA_HPT3X3=m
# CONFIG_PATA_HPT3X3_DMA is not set
CONFIG_PATA_IT8213=m
CONFIG_PATA_IT821X=m
CONFIG_PATA_JMICRON=m
CONFIG_PATA_MARVELL=m
CONFIG_PATA_NETCELL=m
CONFIG_PATA_NINJA32=m
# CONFIG_PATA_NS87415 is not set
CONFIG_PATA_OLDPIIX=m
# CONFIG_PATA_OPTIDMA is not set
CONFIG_PATA_PDC2027X=m
CONFIG_PATA_PDC_OLD=m
# CONFIG_PATA_RADISYS is not set
CONFIG_PATA_RDC=m
CONFIG_PATA_SCH=m
CONFIG_PATA_SERVERWORKS=m
CONFIG_PATA_SIL680=m
CONFIG_PATA_SIS=m
CONFIG_PATA_TOSHIBA=m
# CONFIG_PATA_TRIFLEX is not set
CONFIG_PATA_VIA=m
# CONFIG_PATA_WINBOND is not set

#
# PIO-only SFF controllers
#
# CONFIG_PATA_CMD640_PCI is not set
# CONFIG_PATA_MPIIX is not set
# CONFIG_PATA_NS87410 is not set
# CONFIG_PATA_OPTI is not set
# CONFIG_PATA_PLATFORM is not set
# CONFIG_PATA_RZ1000 is not set

#
# Generic fallback / legacy drivers
#
CONFIG_PATA_ACPI=m
CONFIG_ATA_GENERIC=m
# CONFIG_PATA_LEGACY is not set CONFIG_MD=y
CONFIG_BLK_DEV_MD=y
CONFIG_MD_AUTODETECT=y
CONFIG_MD_LINEAR=m
CONFIG_MD_RAID0=m
CONFIG_MD_RAID1=m
CONFIG_MD_RAID10=m
CONFIG_MD_RAID456=m
CONFIG_MD_MULTIPATH=m
CONFIG_MD_FAULTY=m
# CONFIG_MD_CLUSTER is not set
# CONFIG_BCACHE is not set CONFIG_BLK_DEV_DM_BUILTIN=y CONFIG_BLK_DEV_DM=m
CONFIG_DM_DEBUG=y
CONFIG_DM_BUFIO=m
# CONFIG_DM_DEBUG_BLOCK_MANAGER_LOCKING is not set CONFIG_DM_BIO_PRISON=m CONFIG_DM_PERSISTENT_DATA=m
# CONFIG_DM_UNSTRIPED is not set CONFIG_DM_CRYPT=m
CONFIG_DM_SNAPSHOT=m CONFIG_DM_THIN_PROVISIONING=m CONFIG_DM_CACHE=m
CONFIG_DM_CACHE_SMQ=m
# CONFIG_DM_WRITECACHE is not set CONFIG_DM_ERA=m
CONFIG_DM_MIRROR=m CONFIG_DM_LOG_USERSPACE=m
CONFIG_DM_RAID=m
CONFIG_DM_ZERO=m
CONFIG_DM_MULTIPATH=m CONFIG_DM_MULTIPATH_QL=m CONFIG_DM_MULTIPATH_ST=m
CONFIG_DM_DELAY=m
CONFIG_DM_UEVENT=y
CONFIG_DM_FLAKEY=m
CONFIG_DM_VERITY=m
# CONFIG_DM_VERITY_FEC is not set CONFIG_DM_SWITCH=m
CONFIG_DM_LOG_WRITES=m
# CONFIG_DM_INTEGRITY is not set
# CONFIG_DM_ZONED is not set CONFIG_TARGET_CORE=m
CONFIG_TCM_IBLOCK=m
CONFIG_TCM_FILEIO=m
CONFIG_TCM_PSCSI=m
CONFIG_TCM_USER2=m CONFIG_LOOPBACK_TARGET=m
CONFIG_TCM_FC=m
CONFIG_ISCSI_TARGET=m CONFIG_ISCSI_TARGET_CXGB4=m
# CONFIG_SBP_TARGET is not set CONFIG_FUSION=y
CONFIG_FUSION_SPI=m
# CONFIG_FUSION_FC is not set CONFIG_FUSION_SAS=m CONFIG_FUSION_MAX_SGE=128 CONFIG_FUSION_CTL=m CONFIG_FUSION_LOGGING=y

#
# IEEE 1394 (FireWire) support
#
CONFIG_FIREWIRE=m
CONFIG_FIREWIRE_OHCI=m
CONFIG_FIREWIRE_SBP2=m
CONFIG_FIREWIRE_NET=m
# CONFIG_FIREWIRE_NOSY is not set
CONFIG_MACINTOSH_DRIVERS=y
CONFIG_MAC_EMUMOUSEBTN=y
CONFIG_NETDEVICES=y
CONFIG_MII=m
CONFIG_NET_CORE=y
CONFIG_BONDING=m
CONFIG_DUMMY=m
# CONFIG_EQUALIZER is not set
CONFIG_NET_FC=y
CONFIG_IFB=m
CONFIG_NET_TEAM=m
CONFIG_NET_TEAM_MODE_BROADCAST=m
CONFIG_NET_TEAM_MODE_ROUNDROBIN=m
CONFIG_NET_TEAM_MODE_RANDOM=m
CONFIG_NET_TEAM_MODE_ACTIVEBACKUP=m
CONFIG_NET_TEAM_MODE_LOADBALANCE=m
CONFIG_MACVLAN=m
CONFIG_MACVTAP=m
# CONFIG_IPVLAN is not set
CONFIG_VXLAN=m
CONFIG_GENEVE=m
# CONFIG_GTP is not set
CONFIG_MACSEC=y
CONFIG_NETCONSOLE=m
CONFIG_NETCONSOLE_DYNAMIC=y
CONFIG_NETPOLL=y
CONFIG_NET_POLL_CONTROLLER=y
CONFIG_NTB_NETDEV=m
CONFIG_TUN=m
CONFIG_TAP=m
# CONFIG_TUN_VNET_CROSS_LE is not set
CONFIG_VETH=m
CONFIG_VIRTIO_NET=m
CONFIG_NLMON=m
CONFIG_NET_VRF=y
CONFIG_VSOCKMON=m
# CONFIG_ARCNET is not set
# CONFIG_ATM_DRIVERS is not set

#
# CAIF transport drivers
#

#
# Distributed Switch Architecture drivers
#
CONFIG_ETHERNET=y
CONFIG_MDIO=m
# CONFIG_NET_VENDOR_3COM is not set
# CONFIG_NET_VENDOR_ADAPTEC is not set
CONFIG_NET_VENDOR_AGERE=y
# CONFIG_ET131X is not set
CONFIG_NET_VENDOR_ALACRITECH=y
# CONFIG_SLICOSS is not set
# CONFIG_NET_VENDOR_ALTEON is not set
# CONFIG_ALTERA_TSE is not set
CONFIG_NET_VENDOR_AMAZON=y
CONFIG_ENA_ETHERNET=m
CONFIG_NET_VENDOR_AMD=y
CONFIG_AMD8111_ETH=m
CONFIG_PCNET32=m
CONFIG_AMD_XGBE=m
# CONFIG_AMD_XGBE_DCB is not set
CONFIG_AMD_XGBE_HAVE_ECC=y
CONFIG_NET_VENDOR_AQUANTIA=y
CONFIG_AQTION=m
CONFIG_NET_VENDOR_ARC=y
CONFIG_NET_VENDOR_ATHEROS=y
CONFIG_ATL2=m
CONFIG_ATL1=m
CONFIG_ATL1E=m
CONFIG_ATL1C=m
CONFIG_ALX=m
CONFIG_NET_VENDOR_AURORA=y
# CONFIG_AURORA_NB8800 is not set
CONFIG_NET_VENDOR_BROADCOM=y
CONFIG_B44=m
CONFIG_B44_PCI_AUTOSELECT=y
CONFIG_B44_PCICORE_AUTOSELECT=y
CONFIG_B44_PCI=y
# CONFIG_BCMGENET is not set
CONFIG_BNX2=m
CONFIG_CNIC=m
CONFIG_TIGON3=m
CONFIG_TIGON3_HWMON=y
CONFIG_BNX2X=m
CONFIG_BNX2X_SRIOV=y
# CONFIG_SYSTEMPORT is not set
CONFIG_BNXT=m
CONFIG_BNXT_SRIOV=y
CONFIG_BNXT_FLOWER_OFFLOAD=y
CONFIG_BNXT_DCB=y
CONFIG_BNXT_HWMON=y
CONFIG_NET_VENDOR_BROCADE=y
CONFIG_BNA=m
CONFIG_NET_VENDOR_CADENCE=y
CONFIG_MACB=m
CONFIG_MACB_USE_HWSTAMP=y
# CONFIG_MACB_PCI is not set
CONFIG_NET_VENDOR_CAVIUM=y
# CONFIG_THUNDER_NIC_PF is not set
# CONFIG_THUNDER_NIC_VF is not set
# CONFIG_THUNDER_NIC_BGX is not set
# CONFIG_THUNDER_NIC_RGX is not set
CONFIG_CAVIUM_PTP=y
CONFIG_LIQUIDIO=m
CONFIG_LIQUIDIO_VF=m
CONFIG_NET_VENDOR_CHELSIO=y
# CONFIG_CHELSIO_T1 is not set
CONFIG_CHELSIO_T3=m
CONFIG_CHELSIO_T4=m
# CONFIG_CHELSIO_T4_DCB is not set
CONFIG_CHELSIO_T4VF=m
CONFIG_CHELSIO_LIB=m
CONFIG_NET_VENDOR_CISCO=y
CONFIG_ENIC=m
CONFIG_NET_VENDOR_CORTINA=y
# CONFIG_CX_ECAT is not set
CONFIG_DNET=m
CONFIG_NET_VENDOR_DEC=y
CONFIG_NET_TULIP=y
CONFIG_DE2104X=m
CONFIG_DE2104X_DSL=0
CONFIG_TULIP=m
# CONFIG_TULIP_MWI is not set
CONFIG_TULIP_MMIO=y
# CONFIG_TULIP_NAPI is not set
CONFIG_DE4X5=m
CONFIG_WINBOND_840=m
CONFIG_DM9102=m
CONFIG_ULI526X=m
CONFIG_PCMCIA_XIRCOM=m
# CONFIG_NET_VENDOR_DLINK is not set
CONFIG_NET_VENDOR_EMULEX=y
CONFIG_BE2NET=m
CONFIG_BE2NET_HWMON=y
CONFIG_BE2NET_BE2=y
CONFIG_BE2NET_BE3=y
CONFIG_BE2NET_LANCER=y
CONFIG_BE2NET_SKYHAWK=y
CONFIG_NET_VENDOR_EZCHIP=y
# CONFIG_NET_VENDOR_HP is not set
CONFIG_NET_VENDOR_HUAWEI=y
# CONFIG_HINIC is not set
# CONFIG_NET_VENDOR_I825XX is not set
CONFIG_NET_VENDOR_INTEL=y
# CONFIG_E100 is not set
CONFIG_E1000=y
CONFIG_E1000E=m
CONFIG_E1000E_HWTS=y
CONFIG_IGB=m
CONFIG_IGB_HWMON=y
CONFIG_IGB_DCA=y
CONFIG_IGBVF=m
# CONFIG_IXGB is not set
CONFIG_IXGBE=m
CONFIG_IXGBE_HWMON=y
CONFIG_IXGBE_DCA=y
CONFIG_IXGBE_DCB=y
CONFIG_IXGBEVF=m
CONFIG_I40E=m
CONFIG_I40E_DCB=y
CONFIG_IAVF=m
CONFIG_I40EVF=m
# CONFIG_ICE is not set
CONFIG_FM10K=m
# CONFIG_IGC is not set
CONFIG_JME=m
CONFIG_NET_VENDOR_MARVELL=y
CONFIG_MVMDIO=m
CONFIG_SKGE=m
# CONFIG_SKGE_DEBUG is not set
CONFIG_SKGE_GENESIS=y
CONFIG_SKY2=m
# CONFIG_SKY2_DEBUG is not set
CONFIG_NET_VENDOR_MELLANOX=y
CONFIG_MLX4_EN=m
CONFIG_MLX4_EN_DCB=y
CONFIG_MLX4_CORE=m
CONFIG_MLX4_DEBUG=y
CONFIG_MLX4_CORE_GEN2=y
CONFIG_MLX5_CORE=m
# CONFIG_MLX5_FPGA is not set
CONFIG_MLX5_CORE_EN=y
CONFIG_MLX5_EN_ARFS=y
CONFIG_MLX5_EN_RXNFC=y
CONFIG_MLX5_MPFS=y
CONFIG_MLX5_ESWITCH=y
CONFIG_MLX5_CORE_EN_DCB=y
CONFIG_MLX5_CORE_IPOIB=y
CONFIG_MLXSW_CORE=m
CONFIG_MLXSW_CORE_HWMON=y
CONFIG_MLXSW_CORE_THERMAL=y
CONFIG_MLXSW_PCI=m
CONFIG_MLXSW_I2C=m
CONFIG_MLXSW_SWITCHIB=m
CONFIG_MLXSW_SWITCHX2=m
CONFIG_MLXSW_SPECTRUM=m
CONFIG_MLXSW_SPECTRUM_DCB=y
CONFIG_MLXSW_MINIMAL=m
CONFIG_MLXFW=m
# CONFIG_NET_VENDOR_MICREL is not set
# CONFIG_NET_VENDOR_MICROCHIP is not set
CONFIG_NET_VENDOR_MICROSEMI=y
# CONFIG_MSCC_OCELOT_SWITCH is not set
CONFIG_NET_VENDOR_MYRI=y
CONFIG_MYRI10GE=m
CONFIG_MYRI10GE_DCA=y
# CONFIG_FEALNX is not set
# CONFIG_NET_VENDOR_NATSEMI is not set
CONFIG_NET_VENDOR_NETERION=y
# CONFIG_S2IO is not set
# CONFIG_VXGE is not set
CONFIG_NET_VENDOR_NETRONOME=y
CONFIG_NFP=m
CONFIG_NFP_APP_FLOWER=y
CONFIG_NFP_APP_ABM_NIC=y
# CONFIG_NFP_DEBUG is not set
CONFIG_NET_VENDOR_NI=y
# CONFIG_NI_XGE_MANAGEMENT_ENET is not set
# CONFIG_NET_VENDOR_NVIDIA is not set
CONFIG_NET_VENDOR_OKI=y
CONFIG_ETHOC=m
CONFIG_NET_VENDOR_PACKET_ENGINES=y
# CONFIG_HAMACHI is not set
# CONFIG_YELLOWFIN is not set
CONFIG_NET_VENDOR_QLOGIC=y
CONFIG_QLA3XXX=m
CONFIG_QLCNIC=m
CONFIG_QLCNIC_SRIOV=y
CONFIG_QLCNIC_DCB=y
CONFIG_QLCNIC_HWMON=y
CONFIG_QLGE=m
CONFIG_NETXEN_NIC=m
CONFIG_QED=m
CONFIG_QED_LL2=y
CONFIG_QED_SRIOV=y
CONFIG_QEDE=m
CONFIG_QED_RDMA=y
CONFIG_QED_ISCSI=y
CONFIG_QED_FCOE=y
CONFIG_QED_OOO=y
CONFIG_NET_VENDOR_QUALCOMM=y
# CONFIG_QCOM_EMAC is not set
# CONFIG_RMNET is not set
# CONFIG_NET_VENDOR_RDC is not set
CONFIG_NET_VENDOR_REALTEK=y
# CONFIG_ATP is not set
CONFIG_8139CP=m
CONFIG_8139TOO=m
# CONFIG_8139TOO_PIO is not set
# CONFIG_8139TOO_TUNE_TWISTER is not set
CONFIG_8139TOO_8129=y
# CONFIG_8139_OLD_RX_RESET is not set
CONFIG_R8169=m
CONFIG_NET_VENDOR_RENESAS=y
CONFIG_NET_VENDOR_ROCKER=y
CONFIG_ROCKER=m
CONFIG_NET_VENDOR_SAMSUNG=y
# CONFIG_SXGBE_ETH is not set
# CONFIG_NET_VENDOR_SEEQ is not set
CONFIG_NET_VENDOR_SOLARFLARE=y
CONFIG_SFC=m
CONFIG_SFC_MTD=y
CONFIG_SFC_MCDI_MON=y
CONFIG_SFC_SRIOV=y
CONFIG_SFC_MCDI_LOGGING=y
CONFIG_SFC_FALCON=m
CONFIG_SFC_FALCON_MTD=y
# CONFIG_NET_VENDOR_SILAN is not set
# CONFIG_NET_VENDOR_SIS is not set
CONFIG_NET_VENDOR_SMSC=y
CONFIG_EPIC100=m
# CONFIG_SMSC911X is not set
CONFIG_SMSC9420=m
CONFIG_NET_VENDOR_SOCIONEXT=y
# CONFIG_NET_VENDOR_STMICRO is not set
# CONFIG_NET_VENDOR_SUN is not set
CONFIG_NET_VENDOR_SYNOPSYS=y
# CONFIG_DWC_XLGMAC is not set
# CONFIG_NET_VENDOR_TEHUTI is not set
CONFIG_NET_VENDOR_TI=y
# CONFIG_TI_CPSW_ALE is not set
CONFIG_TLAN=m
# CONFIG_NET_VENDOR_VIA is not set
# CONFIG_NET_VENDOR_WIZNET is not set
# CONFIG_FDDI is not set
# CONFIG_HIPPI is not set
# CONFIG_NET_SB1000 is not set
CONFIG_MDIO_DEVICE=y
CONFIG_MDIO_BUS=y
# CONFIG_MDIO_BCM_UNIMAC is not set
CONFIG_MDIO_BITBANG=m
# CONFIG_MDIO_GPIO is not set
# CONFIG_MDIO_MSCC_MIIM is not set
# CONFIG_MDIO_THUNDER is not set
CONFIG_PHYLIB=y
CONFIG_SWPHY=y
# CONFIG_LED_TRIGGER_PHY is not set

#
# MII PHY device drivers
#
CONFIG_AMD_PHY=m
# CONFIG_AQUANTIA_PHY is not set
# CONFIG_ASIX_PHY is not set
CONFIG_AT803X_PHY=m
# CONFIG_BCM7XXX_PHY is not set
CONFIG_BCM87XX_PHY=m
CONFIG_BCM_NET_PHYLIB=m
CONFIG_BROADCOM_PHY=m
CONFIG_CICADA_PHY=m
# CONFIG_CORTINA_PHY is not set
CONFIG_DAVICOM_PHY=m
# CONFIG_DP83822_PHY is not set
# CONFIG_DP83TC811_PHY is not set
# CONFIG_DP83848_PHY is not set
# CONFIG_DP83867_PHY is not set
CONFIG_FIXED_PHY=y
CONFIG_ICPLUS_PHY=m
# CONFIG_INTEL_XWAY_PHY is not set
CONFIG_LSI_ET1011C_PHY=m
CONFIG_LXT_PHY=m
CONFIG_MARVELL_PHY=m
# CONFIG_MARVELL_10G_PHY is not set
CONFIG_MICREL_PHY=m
# CONFIG_MICROCHIP_PHY is not set
# CONFIG_MICROCHIP_T1_PHY is not set
# CONFIG_MICROSEMI_PHY is not set
CONFIG_NATIONAL_PHY=m
CONFIG_QSEMI_PHY=m
CONFIG_REALTEK_PHY=m
# CONFIG_RENESAS_PHY is not set
# CONFIG_ROCKCHIP_PHY is not set
CONFIG_SMSC_PHY=m
CONFIG_STE10XP=m
# CONFIG_TERANETICS_PHY is not set
CONFIG_VITESSE_PHY=m
# CONFIG_XILINX_GMII2RGMII is not set
# CONFIG_MICREL_KS8995MA is not set
# CONFIG_PLIP is not set
CONFIG_PPP=m
CONFIG_PPP_BSDCOMP=m
CONFIG_PPP_DEFLATE=m
CONFIG_PPP_FILTER=y
CONFIG_PPP_MPPE=m
CONFIG_PPP_MULTILINK=y
CONFIG_PPPOATM=m
CONFIG_PPPOE=m
CONFIG_PPTP=m
CONFIG_PPPOL2TP=m
CONFIG_PPP_ASYNC=m
CONFIG_PPP_SYNC_TTY=m
CONFIG_SLIP=m
CONFIG_SLHC=m
CONFIG_SLIP_COMPRESSED=y
CONFIG_SLIP_SMART=y
# CONFIG_SLIP_MODE_SLIP6 is not set
CONFIG_USB_NET_DRIVERS=y
CONFIG_USB_CATC=m
CONFIG_USB_KAWETH=m
CONFIG_USB_PEGASUS=m
CONFIG_USB_RTL8150=m
CONFIG_USB_RTL8152=m
# CONFIG_USB_LAN78XX is not set
CONFIG_USB_USBNET=m
CONFIG_USB_NET_AX8817X=m
CONFIG_USB_NET_AX88179_178A=m
CONFIG_USB_NET_CDCETHER=m
CONFIG_USB_NET_CDC_EEM=m
CONFIG_USB_NET_CDC_NCM=m
CONFIG_USB_NET_HUAWEI_CDC_NCM=m
CONFIG_USB_NET_CDC_MBIM=m
CONFIG_USB_NET_DM9601=m
# CONFIG_USB_NET_SR9700 is not set
# CONFIG_USB_NET_SR9800 is not set
CONFIG_USB_NET_SMSC75XX=m
CONFIG_USB_NET_SMSC95XX=m
CONFIG_USB_NET_GL620A=m
CONFIG_USB_NET_NET1080=m
CONFIG_USB_NET_PLUSB=m
CONFIG_USB_NET_MCS7830=m
CONFIG_USB_NET_RNDIS_HOST=m
CONFIG_USB_NET_CDC_SUBSET_ENABLE=m
CONFIG_USB_NET_CDC_SUBSET=m
CONFIG_USB_ALI_M5632=y
CONFIG_USB_AN2720=y
CONFIG_USB_BELKIN=y
CONFIG_USB_ARMLINUX=y
CONFIG_USB_EPSON2888=y
CONFIG_USB_KC2190=y
CONFIG_USB_NET_ZAURUS=m
CONFIG_USB_NET_CX82310_ETH=m
CONFIG_USB_NET_KALMIA=m
CONFIG_USB_NET_QMI_WWAN=m
CONFIG_USB_HSO=m
CONFIG_USB_NET_INT51X1=m
CONFIG_USB_IPHETH=m
CONFIG_USB_SIERRA_NET=m
CONFIG_USB_VL600=m
# CONFIG_USB_NET_CH9200 is not set
# CONFIG_USB_NET_AQC111 is not set
CONFIG_WLAN=y
# CONFIG_WIRELESS_WDS is not set
CONFIG_WLAN_VENDOR_ADMTEK=y
# CONFIG_ADM8211 is not set
CONFIG_ATH_COMMON=m
CONFIG_WLAN_VENDOR_ATH=y
# CONFIG_ATH_DEBUG is not set
# CONFIG_ATH5K is not set
# CONFIG_ATH5K_PCI is not set
CONFIG_ATH9K_HW=m
CONFIG_ATH9K_COMMON=m
CONFIG_ATH9K_COMMON_DEBUG=y
CONFIG_ATH9K_BTCOEX_SUPPORT=y
CONFIG_ATH9K=m
CONFIG_ATH9K_PCI=y
CONFIG_ATH9K_AHB=y
CONFIG_ATH9K_DEBUGFS=y
# CONFIG_ATH9K_STATION_STATISTICS is not set
# CONFIG_ATH9K_DYNACK is not set
CONFIG_ATH9K_WOW=y
CONFIG_ATH9K_RFKILL=y
# CONFIG_ATH9K_CHANNEL_CONTEXT is not set
CONFIG_ATH9K_PCOEM=y
CONFIG_ATH9K_HTC=m
# CONFIG_ATH9K_HTC_DEBUGFS is not set
# CONFIG_ATH9K_HWRNG is not set
# CONFIG_ATH9K_COMMON_SPECTRAL is not set
CONFIG_CARL9170=m
CONFIG_CARL9170_LEDS=y
# CONFIG_CARL9170_DEBUGFS is not set
CONFIG_CARL9170_WPC=y
# CONFIG_CARL9170_HWRNG is not set
# CONFIG_ATH6KL is not set
# CONFIG_AR5523 is not set
CONFIG_WIL6210=m
CONFIG_WIL6210_ISR_COR=y
CONFIG_WIL6210_TRACING=y
CONFIG_WIL6210_DEBUGFS=y
CONFIG_ATH10K=m
CONFIG_ATH10K_CE=y
CONFIG_ATH10K_PCI=m
# CONFIG_ATH10K_SDIO is not set
# CONFIG_ATH10K_USB is not set
# CONFIG_ATH10K_DEBUG is not set
CONFIG_ATH10K_DEBUGFS=y
# CONFIG_ATH10K_SPECTRAL is not set
# CONFIG_ATH10K_TRACING is not set
# CONFIG_WCN36XX is not set
CONFIG_WLAN_VENDOR_ATMEL=y
# CONFIG_ATMEL is not set
# CONFIG_AT76C50X_USB is not set
CONFIG_WLAN_VENDOR_BROADCOM=y
# CONFIG_B43 is not set
# CONFIG_B43LEGACY is not set
CONFIG_BRCMUTIL=m
CONFIG_BRCMSMAC=m
CONFIG_BRCMFMAC=m
CONFIG_BRCMFMAC_PROTO_BCDC=y
CONFIG_BRCMFMAC_PROTO_MSGBUF=y
CONFIG_BRCMFMAC_SDIO=y
CONFIG_BRCMFMAC_USB=y
CONFIG_BRCMFMAC_PCIE=y
# CONFIG_BRCM_TRACING is not set
# CONFIG_BRCMDBG is not set
CONFIG_WLAN_VENDOR_CISCO=y
# CONFIG_AIRO is not set
CONFIG_WLAN_VENDOR_INTEL=y
# CONFIG_IPW2100 is not set
# CONFIG_IPW2200 is not set
CONFIG_IWLEGACY=m
CONFIG_IWL4965=m
CONFIG_IWL3945=m

#

# iwl3945 / iwl4965 Debugging Options
#
CONFIG_IWLEGACY_DEBUG=y
CONFIG_IWLEGACY_DEBUGFS=y
CONFIG_IWLWIFI=m
CONFIG_IWLWIFI_LEDS=y
CONFIG_IWLDVM=m
CONFIG_IWLMVM=m
CONFIG_IWLWIFI_OPMODE_MODULAR=y
# CONFIG_IWLWIFI_BCAST_FILTERING is not set
# CONFIG_IWLWIFI_PCIE_RTPM is not set

#
# Debugging Options
#
# CONFIG_IWLWIFI_DEBUG is not set
CONFIG_IWLWIFI_DEBUGFS=y
# CONFIG_IWLWIFI_DEVICE_TRACING is not set
CONFIG_WLAN_VENDOR_INTERSIL=y
# CONFIG_HOSTAP is not set
# CONFIG_HERMES is not set
# CONFIG_P54_COMMON is not set
# CONFIG_PRISM54 is not set
CONFIG_WLAN_VENDOR_MARVELL=y
# CONFIG_LIBERTAS is not set
# CONFIG_LIBERTAS_THINFIRM is not set
CONFIG_MWIFIEX=m
CONFIG_MWIFIEX_SDIO=m
CONFIG_MWIFIEX_PCIE=m
CONFIG_MWIFIEX_USB=m
CONFIG_MWL8K=m
CONFIG_WLAN_VENDOR_MEDIATEK=y
# CONFIG_MT7601U is not set
# CONFIG_MT76x0U is not set
# CONFIG_MT76x0E is not set
# CONFIG_MT76x2E is not set
# CONFIG_MT76x2U is not set
CONFIG_WLAN_VENDOR_RALINK=y
CONFIG_RT2X00=m
# CONFIG_RT2400PCI is not set
# CONFIG_RT2500PCI is not set
CONFIG_RT61PCI=m
CONFIG_RT2800PCI=m
CONFIG_RT2800PCI_RT33XX=y
CONFIG_RT2800PCI_RT35XX=y
CONFIG_RT2800PCI_RT53XX=y
CONFIG_RT2800PCI_RT3290=y
# CONFIG_RT2500USB is not set
CONFIG_RT73USB=m
CONFIG_RT2800USB=m
CONFIG_RT2800USB_RT33XX=y
CONFIG_RT2800USB_RT35XX=y
CONFIG_RT2800USB_RT3573=y
CONFIG_RT2800USB_RT53XX=y
CONFIG_RT2800USB_RT55XX=y
CONFIG_RT2800USB_UNKNOWN=y
CONFIG_RT2800_LIB=m
CONFIG_RT2800_LIB_MMIO=m
CONFIG_RT2X00_LIB_MMIO=m
CONFIG_RT2X00_LIB_PCI=m
CONFIG_RT2X00_LIB_USB=m
CONFIG_RT2X00_LIB=m
CONFIG_RT2X00_LIB_FIRMWARE=y
CONFIG_RT2X00_LIB_CRYPTO=y
CONFIG_RT2X00_LIB_LEDS=y
CONFIG_RT2X00_LIB_DEBUGFS=y
# CONFIG_RT2X00_DEBUG is not set
CONFIG_WLAN_VENDOR_REALTEK=y
# CONFIG_RTL8180 is not set
CONFIG_RTL8187=m
CONFIG_RTL8187_LEDS=y
CONFIG_RTL_CARDS=m
CONFIG_RTL8192CE=m
CONFIG_RTL8192SE=m
CONFIG_RTL8192DE=m
CONFIG_RTL8723AE=m
CONFIG_RTL8723BE=m
CONFIG_RTL8188EE=m
CONFIG_RTL8192EE=m
CONFIG_RTL8821AE=m
CONFIG_RTL8192CU=m
CONFIG_RTLWIFI=m
CONFIG_RTLWIFI_PCI=m
CONFIG_RTLWIFI_USB=m
# CONFIG_RTLWIFI_DEBUG is not set
CONFIG_RTL8192C_COMMON=m
CONFIG_RTL8723_COMMON=m
CONFIG_RTLBTCOEXIST=m
# CONFIG_RTL8XXXU is not set
CONFIG_WLAN_VENDOR_RSI=y
# CONFIG_RSI_91X is not set
CONFIG_WLAN_VENDOR_ST=y
# CONFIG_CW1200 is not set
CONFIG_WLAN_VENDOR_TI=y
# CONFIG_WL1251 is not set
# CONFIG_WL12XX is not set
# CONFIG_WL18XX is not set
# CONFIG_WLCORE is not set
CONFIG_WLAN_VENDOR_ZYDAS=y
# CONFIG_USB_ZD1201 is not set
# CONFIG_ZD1211RW is not set
CONFIG_WLAN_VENDOR_QUANTENNA=y
# CONFIG_QTNFMAC_PCIE is not set
CONFIG_MAC80211_HWSIM=m
# CONFIG_USB_NET_RNDIS_WLAN is not set
# CONFIG_VIRT_WIFI is not set

#
# Enable WiMAX (Networking options) to see the WiMAX drivers #
CONFIG_WAN=y
# CONFIG_LANMEDIA is not set
CONFIG_HDLC=m
CONFIG_HDLC_RAW=m
# CONFIG_HDLC_RAW_ETH is not set CONFIG_HDLC_CISCO=m
CONFIG_HDLC_FR=m
CONFIG_HDLC_PPP=m

#
# X.25/LAPB support is disabled
#
# CONFIG_PCI200SYN is not set
# CONFIG_WANXL is not set
# CONFIG_PC300TOO is not set
# CONFIG_FARSYNC is not set
# CONFIG_DSCC4 is not set
CONFIG_DLCI=m
CONFIG_DLCI_MAX=8
# CONFIG_SBNI is not set
CONFIG_IEEE802154_DRIVERS=m
CONFIG_IEEE802154_FAKELB=m
# CONFIG_IEEE802154_AT86RF230 is not set
# CONFIG_IEEE802154_MRF24J40 is not set
# CONFIG_IEEE802154_CC2520 is not set
# CONFIG_IEEE802154_ATUSB is not set
# CONFIG_IEEE802154_ADF7242 is not set
# CONFIG_IEEE802154_CA8210 is not set
# CONFIG_IEEE802154_MCR20A is not set
# CONFIG_IEEE802154_HWSIM is not set
CONFIG_XEN_NETDEV_FRONTEND=m
CONFIG_VMXNET3=m
CONFIG_FUJITSU_ES=m
CONFIG_THUNDERBOLT_NET=m
CONFIG_HYPERV_NET=m
CONFIG_NETDEVSIM=m
CONFIG_NET_FAILOVER=m
CONFIG_ISDN=y
CONFIG_ISDN_I4L=m
CONFIG_ISDN_PPP=y
CONFIG_ISDN_PPP_VJ=y
CONFIG_ISDN_MPP=y
CONFIG_IPPP_FILTER=y
# CONFIG_ISDN_PPP_BSDCOMP is not set
CONFIG_ISDN_AUDIO=y
CONFIG_ISDN_TTY_FAX=y

#
# ISDN feature submodules
#
CONFIG_ISDN_DIVERSION=m

#
# ISDN4Linux hardware drivers
#

#
# Passive cards
#
CONFIG_ISDN_DRV_HISAX=m

#
# D-channel protocol features
#
CONFIG_HISAX_EURO=y
CONFIG_DE_AOC=y
CONFIG_HISAX_NO_SENDCOMPLETE=y
CONFIG_HISAX_NO_LLC=y
CONFIG_HISAX_NO_KEYPAD=y
CONFIG_HISAX_1TR6=y
CONFIG_HISAX_NI1=y
CONFIG_HISAX_MAX_CARDS=8

#
# HiSax supported cards
#
CONFIG_HISAX_16_3=y
CONFIG_HISAX_TELESPCI=y
CONFIG_HISAX_S0BOX=y
CONFIG_HISAX_FRITZPCI=y
CONFIG_HISAX_AVM_A1_PCMCIA=y
CONFIG_HISAX_ELSA=y
CONFIG_HISAX_DIEHLDIVA=y
CONFIG_HISAX_SEDLBAUER=y
CONFIG_HISAX_NETJET=y
CONFIG_HISAX_NETJET_U=y
CONFIG_HISAX_NICCY=y
CONFIG_HISAX_BKM_A4T=y
CONFIG_HISAX_SCT_QUADRO=y
CONFIG_HISAX_GAZEL=y
CONFIG_HISAX_HFC_PCI=y
CONFIG_HISAX_W6692=y
CONFIG_HISAX_HFC_SX=y
CONFIG_HISAX_ENTERNOW_PCI=y
# CONFIG_HISAX_DEBUG is not set

#
# HiSax PCMCIA card service modules
#

#
# HiSax sub driver modules
#
CONFIG_HISAX_ST5481=m
# CONFIG_HISAX_HFCUSB is not set
CONFIG_HISAX_HFC4S8S=m
CONFIG_HISAX_FRITZ_PCIPNP=m
CONFIG_ISDN_CAPI=m
# CONFIG_CAPI_TRACE is not set
CONFIG_ISDN_CAPI_CAPI20=m
CONFIG_ISDN_CAPI_MIDDLEWARE=y
CONFIG_ISDN_CAPI_CAPIDRV=m
# CONFIG_ISDN_CAPI_CAPIDRV_VERBOSE is not set

#
# CAPI hardware drivers
#
CONFIG_CAPI_AVM=y
CONFIG_ISDN_DRV_AVMB1_B1PCI=m
CONFIG_ISDN_DRV_AVMB1_B1PCIV4=y
CONFIG_ISDN_DRV_AVMB1_T1PCI=m
CONFIG_ISDN_DRV_AVMB1_C4=m
CONFIG_ISDN_DRV_GIGASET=m
CONFIG_GIGASET_CAPI=y
CONFIG_GIGASET_BASE=m
CONFIG_GIGASET_M105=m
CONFIG_GIGASET_M101=m
# CONFIG_GIGASET_DEBUG is not set
CONFIG_HYSDN=m
CONFIG_HYSDN_CAPI=y
CONFIG_MISDN=m
CONFIG_MISDN_DSP=m
CONFIG_MISDN_L1OIP=m

#
# mISDN hardware drivers
#
CONFIG_MISDN_HFCPCI=m
CONFIG_MISDN_HFCMULTI=m
CONFIG_MISDN_HFCUSB=m
CONFIG_MISDN_AVMFRITZ=m
CONFIG_MISDN_SPEEDFAX=m
CONFIG_MISDN_INFINEON=m
CONFIG_MISDN_W6692=m
CONFIG_MISDN_NETJET=m
CONFIG_MISDN_IPAC=m
CONFIG_MISDN_ISAR=m
CONFIG_ISDN_HDLC=m
# CONFIG_NVM is not set

#
# Input device support
#
CONFIG_INPUT=y
CONFIG_INPUT_LEDS=y
CONFIG_INPUT_FF_MEMLESS=y
CONFIG_INPUT_POLLDEV=m
CONFIG_INPUT_SPARSEKMAP=m
# CONFIG_INPUT_MATRIXKMAP is not set

#
# Userland interfaces
#
CONFIG_INPUT_MOUSEDEV=y
# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
CONFIG_INPUT_JOYDEV=m
CONFIG_INPUT_EVDEV=y
# CONFIG_INPUT_EVBUG is not set

#
# Input Device Drivers
#
CONFIG_INPUT_KEYBOARD=y
# CONFIG_KEYBOARD_ADC is not set
# CONFIG_KEYBOARD_ADP5588 is not set
# CONFIG_KEYBOARD_ADP5589 is not set
CONFIG_KEYBOARD_ATKBD=y
# CONFIG_KEYBOARD_QT1070 is not set
# CONFIG_KEYBOARD_QT2160 is not set
# CONFIG_KEYBOARD_DLINK_DIR685 is not set
# CONFIG_KEYBOARD_LKKBD is not set
# CONFIG_KEYBOARD_GPIO is not set
# CONFIG_KEYBOARD_GPIO_POLLED is not set
# CONFIG_KEYBOARD_TCA6416 is not set
# CONFIG_KEYBOARD_TCA8418 is not set
# CONFIG_KEYBOARD_MATRIX is not set
# CONFIG_KEYBOARD_LM8323 is not set
# CONFIG_KEYBOARD_LM8333 is not set
# CONFIG_KEYBOARD_MAX7359 is not set
# CONFIG_KEYBOARD_MCS is not set
# CONFIG_KEYBOARD_MPR121 is not set
# CONFIG_KEYBOARD_NEWTON is not set
# CONFIG_KEYBOARD_OPENCORES is not set
# CONFIG_KEYBOARD_SAMSUNG is not set
# CONFIG_KEYBOARD_STOWAWAY is not set
# CONFIG_KEYBOARD_SUNKBD is not set
# CONFIG_KEYBOARD_TM2_TOUCHKEY is not set
# CONFIG_KEYBOARD_XTKBD is not set
CONFIG_INPUT_MOUSE=y
CONFIG_MOUSE_PS2=y
CONFIG_MOUSE_PS2_ALPS=y
CONFIG_MOUSE_PS2_BYD=y
CONFIG_MOUSE_PS2_LOGIPS2PP=y
CONFIG_MOUSE_PS2_SYNAPTICS=y
CONFIG_MOUSE_PS2_SYNAPTICS_SMBUS=y
CONFIG_MOUSE_PS2_CYPRESS=y
CONFIG_MOUSE_PS2_LIFEBOOK=y
CONFIG_MOUSE_PS2_TRACKPOINT=y
CONFIG_MOUSE_PS2_ELANTECH=y
CONFIG_MOUSE_PS2_ELANTECH_SMBUS=y
CONFIG_MOUSE_PS2_SENTELIC=y
# CONFIG_MOUSE_PS2_TOUCHKIT is not set
CONFIG_MOUSE_PS2_FOCALTECH=y
CONFIG_MOUSE_PS2_VMMOUSE=y
CONFIG_MOUSE_PS2_SMBUS=y
CONFIG_MOUSE_SERIAL=m
CONFIG_MOUSE_APPLETOUCH=m
CONFIG_MOUSE_BCM5974=m
CONFIG_MOUSE_CYAPA=m
# CONFIG_MOUSE_ELAN_I2C is not set
CONFIG_MOUSE_VSXXXAA=m
# CONFIG_MOUSE_GPIO is not set
CONFIG_MOUSE_SYNAPTICS_I2C=m
CONFIG_MOUSE_SYNAPTICS_USB=m
# CONFIG_INPUT_JOYSTICK is not set
CONFIG_INPUT_TABLET=y
CONFIG_TABLET_USB_ACECAD=m
CONFIG_TABLET_USB_AIPTEK=m
CONFIG_TABLET_USB_GTCO=m
# CONFIG_TABLET_USB_HANWANG is not set
CONFIG_TABLET_USB_KBTAB=m
# CONFIG_TABLET_USB_PEGASUS is not set
# CONFIG_TABLET_SERIAL_WACOM4 is not set
CONFIG_INPUT_TOUCHSCREEN=y
CONFIG_TOUCHSCREEN_PROPERTIES=y
# CONFIG_TOUCHSCREEN_ADS7846 is not set
# CONFIG_TOUCHSCREEN_AD7877 is not set
# CONFIG_TOUCHSCREEN_AD7879 is not set
# CONFIG_TOUCHSCREEN_ADC is not set
# CONFIG_TOUCHSCREEN_ATMEL_MXT is not set
# CONFIG_TOUCHSCREEN_AUO_PIXCIR is not set
# CONFIG_TOUCHSCREEN_BU21013 is not set
# CONFIG_TOUCHSCREEN_BU21029 is not set
# CONFIG_TOUCHSCREEN_CHIPONE_ICN8505 is not set
# CONFIG_TOUCHSCREEN_CY8CTMG110 is not set
# CONFIG_TOUCHSCREEN_CYTTSP_CORE is not set
# CONFIG_TOUCHSCREEN_CYTTSP4_CORE is not set
# CONFIG_TOUCHSCREEN_DYNAPRO is not set
# CONFIG_TOUCHSCREEN_HAMPSHIRE is not set
# CONFIG_TOUCHSCREEN_EETI is not set
# CONFIG_TOUCHSCREEN_EGALAX_SERIAL is not set
# CONFIG_TOUCHSCREEN_EXC3000 is not set
# CONFIG_TOUCHSCREEN_FUJITSU is not set
# CONFIG_TOUCHSCREEN_GOODIX is not set
# CONFIG_TOUCHSCREEN_HIDEEP is not set
# CONFIG_TOUCHSCREEN_ILI210X is not set
# CONFIG_TOUCHSCREEN_S6SY761 is not set
# CONFIG_TOUCHSCREEN_GUNZE is not set
# CONFIG_TOUCHSCREEN_EKTF2127 is not set
# CONFIG_TOUCHSCREEN_ELAN is not set
CONFIG_TOUCHSCREEN_ELO=m
CONFIG_TOUCHSCREEN_WACOM_W8001=m
CONFIG_TOUCHSCREEN_WACOM_I2C=m
# CONFIG_TOUCHSCREEN_MAX11801 is not set
# CONFIG_TOUCHSCREEN_MCS5000 is not set
# CONFIG_TOUCHSCREEN_MMS114 is not set
# CONFIG_TOUCHSCREEN_MELFAS_MIP4 is not set
# CONFIG_TOUCHSCREEN_MTOUCH is not set
# CONFIG_TOUCHSCREEN_INEXIO is not set
# CONFIG_TOUCHSCREEN_MK712 is not set
# CONFIG_TOUCHSCREEN_PENMOUNT is not set
# CONFIG_TOUCHSCREEN_EDT_FT5X06 is not set
# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set
# CONFIG_TOUCHSCREEN_TOUCHWIN is not set
# CONFIG_TOUCHSCREEN_PIXCIR is not set
# CONFIG_TOUCHSCREEN_WDT87XX_I2C is not set
# CONFIG_TOUCHSCREEN_WM97XX is not set
# CONFIG_TOUCHSCREEN_USB_COMPOSITE is not set
# CONFIG_TOUCHSCREEN_TOUCHIT213 is not set
# CONFIG_TOUCHSCREEN_TSC_SERIO is not set
# CONFIG_TOUCHSCREEN_TSC2004 is not set
# CONFIG_TOUCHSCREEN_TSC2005 is not set
# CONFIG_TOUCHSCREEN_TSC2007 is not set
# CONFIG_TOUCHSCREEN_RM_TS is not set
# CONFIG_TOUCHSCREEN_SILEAD is not set
# CONFIG_TOUCHSCREEN_SIS_I2C is not set
# CONFIG_TOUCHSCREEN_ST1232 is not set
# CONFIG_TOUCHSCREEN_STMFTS is not set
# CONFIG_TOUCHSCREEN_SUR40 is not set
# CONFIG_TOUCHSCREEN_SURFACE3_SPI is not set
# CONFIG_TOUCHSCREEN_SX8654 is not set
# CONFIG_TOUCHSCREEN_TPS6507X is not set
# CONFIG_TOUCHSCREEN_ZET6223 is not set
# CONFIG_TOUCHSCREEN_ZFORCE is not set
# CONFIG_TOUCHSCREEN_ROHM_BU21023 is not set
CONFIG_INPUT_MISC=y
# CONFIG_INPUT_AD714X is not set
# CONFIG_INPUT_BMA150 is not set
# CONFIG_INPUT_E3X0_BUTTON is not set
CONFIG_INPUT_PCSPKR=m
# CONFIG_INPUT_MMA8450 is not set
CONFIG_INPUT_APANEL=m
CONFIG_INPUT_GP2A=m
# CONFIG_INPUT_GPIO_BEEPER is not set
# CONFIG_INPUT_GPIO_DECODER is not set
CONFIG_INPUT_ATLAS_BTNS=m
CONFIG_INPUT_ATI_REMOTE2=m
CONFIG_INPUT_KEYSPAN_REMOTE=m
# CONFIG_INPUT_KXTJ9 is not set
CONFIG_INPUT_POWERMATE=m
CONFIG_INPUT_YEALINK=m
CONFIG_INPUT_CM109=m
CONFIG_INPUT_UINPUT=m
# CONFIG_INPUT_PCF8574 is not set
# CONFIG_INPUT_PWM_BEEPER is not set
# CONFIG_INPUT_PWM_VIBRA is not set
CONFIG_INPUT_GPIO_ROTARY_ENCODER=m
# CONFIG_INPUT_ADXL34X is not set
# CONFIG_INPUT_IMS_PCU is not set
# CONFIG_INPUT_CMA3000 is not set
CONFIG_INPUT_XEN_KBDDEV_FRONTEND=m
# CONFIG_INPUT_IDEAPAD_SLIDEBAR is not set
# CONFIG_INPUT_DRV260X_HAPTICS is not set
# CONFIG_INPUT_DRV2665_HAPTICS is not set
# CONFIG_INPUT_DRV2667_HAPTICS is not set
CONFIG_RMI4_CORE=m
# CONFIG_RMI4_I2C is not set
# CONFIG_RMI4_SPI is not set
CONFIG_RMI4_SMB=m
CONFIG_RMI4_F03=y
CONFIG_RMI4_F03_SERIO=m
CONFIG_RMI4_2D_SENSOR=y
CONFIG_RMI4_F11=y
CONFIG_RMI4_F12=y
CONFIG_RMI4_F30=y
# CONFIG_RMI4_F34 is not set
# CONFIG_RMI4_F54 is not set
# CONFIG_RMI4_F55 is not set

#
# Hardware I/O ports
#
CONFIG_SERIO=y
CONFIG_ARCH_MIGHT_HAVE_PC_SERIO=y
CONFIG_SERIO_I8042=y
CONFIG_SERIO_SERPORT=y
# CONFIG_SERIO_CT82C710 is not set
# CONFIG_SERIO_PARKBD is not set
# CONFIG_SERIO_PCIPS2 is not set
CONFIG_SERIO_LIBPS2=y
CONFIG_SERIO_RAW=m
CONFIG_SERIO_ALTERA_PS2=m
# CONFIG_SERIO_PS2MULT is not set
CONFIG_SERIO_ARC_PS2=m
# CONFIG_SERIO_OLPC_APSP is not set
CONFIG_HYPERV_KEYBOARD=m
# CONFIG_SERIO_GPIO_PS2 is not set
# CONFIG_USERIO is not set
# CONFIG_GAMEPORT is not set

#
# Character devices
#
CONFIG_TTY=y
CONFIG_VT=y
CONFIG_CONSOLE_TRANSLATIONS=y
CONFIG_VT_CONSOLE=y
CONFIG_VT_CONSOLE_SLEEP=y
CONFIG_HW_CONSOLE=y
CONFIG_VT_HW_CONSOLE_BINDING=y
CONFIG_UNIX98_PTYS=y
# CONFIG_LEGACY_PTYS is not set
CONFIG_SERIAL_NONSTANDARD=y
# CONFIG_ROCKETPORT is not set
CONFIG_CYCLADES=m
# CONFIG_CYZ_INTR is not set
# CONFIG_MOXA_INTELLIO is not set
# CONFIG_MOXA_SMARTIO is not set
CONFIG_SYNCLINK=m
CONFIG_SYNCLINKMP=m
CONFIG_SYNCLINK_GT=m
CONFIG_NOZOMI=m
# CONFIG_ISI is not set
CONFIG_N_HDLC=m
CONFIG_N_GSM=m
# CONFIG_TRACE_SINK is not set
CONFIG_DEVMEM=y
# CONFIG_DEVKMEM is not set

#
# Serial drivers
#
CONFIG_SERIAL_EARLYCON=y CONFIG_SERIAL_8250=y
# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set CONFIG_SERIAL_8250_PNP=y
# CONFIG_SERIAL_8250_FINTEK is not set CONFIG_SERIAL_8250_CONSOLE=y CONFIG_SERIAL_8250_DMA=y CONFIG_SERIAL_8250_PCI=y CONFIG_SERIAL_8250_EXAR=y CONFIG_SERIAL_8250_NR_UARTS=32 CONFIG_SERIAL_8250_RUNTIME_UARTS=4 CONFIG_SERIAL_8250_EXTENDED=y CONFIG_SERIAL_8250_MANY_PORTS=y CONFIG_SERIAL_8250_SHARE_IRQ=y
# CONFIG_SERIAL_8250_DETECT_IRQ is not set CONFIG_SERIAL_8250_RSA=y CONFIG_SERIAL_8250_DW=y
# CONFIG_SERIAL_8250_RT288X is not set CONFIG_SERIAL_8250_LPSS=y CONFIG_SERIAL_8250_MID=y
# CONFIG_SERIAL_8250_MOXA is not set

#
# Non-8250 serial port support
#
# CONFIG_SERIAL_MAX3100 is not set
# CONFIG_SERIAL_MAX310X is not set
# CONFIG_SERIAL_UARTLITE is not set
CONFIG_SERIAL_CORE=y
CONFIG_SERIAL_CORE_CONSOLE=y
CONFIG_SERIAL_JSM=m
# CONFIG_SERIAL_SCCNXP is not set
# CONFIG_SERIAL_SC16IS7XX is not set
# CONFIG_SERIAL_ALTERA_JTAGUART is not set
# CONFIG_SERIAL_ALTERA_UART is not set
# CONFIG_SERIAL_IFX6X60 is not set
CONFIG_SERIAL_ARC=m
CONFIG_SERIAL_ARC_NR_PORTS=1
# CONFIG_SERIAL_RP2 is not set
# CONFIG_SERIAL_FSL_LPUART is not set
# CONFIG_SERIAL_DEV_BUS is not set
# CONFIG_TTY_PRINTK is not set
CONFIG_PRINTER=m
# CONFIG_LP_CONSOLE is not set
CONFIG_PPDEV=m
CONFIG_HVC_DRIVER=y
CONFIG_HVC_IRQ=y
CONFIG_HVC_XEN=y
CONFIG_HVC_XEN_FRONTEND=y
CONFIG_VIRTIO_CONSOLE=m
CONFIG_IPMI_HANDLER=m
CONFIG_IPMI_DMI_DECODE=y
# CONFIG_IPMI_PANIC_EVENT is not set
CONFIG_IPMI_DEVICE_INTERFACE=m
CONFIG_IPMI_SI=m
CONFIG_IPMI_SSIF=m
CONFIG_IPMI_WATCHDOG=m
CONFIG_IPMI_POWEROFF=m
CONFIG_HW_RANDOM=y
CONFIG_HW_RANDOM_TIMERIOMEM=m
CONFIG_HW_RANDOM_INTEL=m
CONFIG_HW_RANDOM_AMD=m
CONFIG_HW_RANDOM_VIA=m
CONFIG_HW_RANDOM_VIRTIO=m
CONFIG_NVRAM=y
# CONFIG_R3964 is not set
# CONFIG_APPLICOM is not set
# CONFIG_MWAVE is not set
CONFIG_RAW_DRIVER=y
CONFIG_MAX_RAW_DEVS=8192
CONFIG_HPET=y
CONFIG_HPET_MMAP=y
# CONFIG_HPET_MMAP_DEFAULT is not set
CONFIG_HANGCHECK_TIMER=m
CONFIG_UV_MMTIMER=m
CONFIG_TCG_TPM=y
CONFIG_HW_RANDOM_TPM=y
CONFIG_TCG_TIS_CORE=y
CONFIG_TCG_TIS=y
# CONFIG_TCG_TIS_SPI is not set
CONFIG_TCG_TIS_I2C_ATMEL=m
CONFIG_TCG_TIS_I2C_INFINEON=m
CONFIG_TCG_TIS_I2C_NUVOTON=m
CONFIG_TCG_NSC=m
CONFIG_TCG_ATMEL=m
CONFIG_TCG_INFINEON=m
# CONFIG_TCG_XEN is not set
CONFIG_TCG_CRB=y
# CONFIG_TCG_VTPM_PROXY is not set
CONFIG_TCG_TIS_ST33ZP24=m
CONFIG_TCG_TIS_ST33ZP24_I2C=m
# CONFIG_TCG_TIS_ST33ZP24_SPI is not set
CONFIG_TELCLOCK=m
CONFIG_DEVPORT=y
# CONFIG_XILLYBUS is not set
# CONFIG_RANDOM_TRUST_CPU is not set

#
# I2C support
#
CONFIG_I2C=y
CONFIG_ACPI_I2C_OPREGION=y
CONFIG_I2C_BOARDINFO=y
CONFIG_I2C_COMPAT=y
CONFIG_I2C_CHARDEV=m
CONFIG_I2C_MUX=m

#
# Multiplexer I2C Chip support
#
# CONFIG_I2C_MUX_GPIO is not set
# CONFIG_I2C_MUX_LTC4306 is not set
# CONFIG_I2C_MUX_PCA9541 is not set
# CONFIG_I2C_MUX_PCA954x is not set
# CONFIG_I2C_MUX_REG is not set
# CONFIG_I2C_MUX_MLXCPLD is not set
CONFIG_I2C_HELPER_AUTO=y
CONFIG_I2C_SMBUS=m
CONFIG_I2C_ALGOBIT=m
CONFIG_I2C_ALGOPCA=m

#
# I2C Hardware Bus support
#

#
# PC SMBus host controller drivers
#
# CONFIG_I2C_ALI1535 is not set
# CONFIG_I2C_ALI1563 is not set
# CONFIG_I2C_ALI15X3 is not set
CONFIG_I2C_AMD756=m
CONFIG_I2C_AMD756_S4882=m
CONFIG_I2C_AMD8111=m
CONFIG_I2C_I801=m
CONFIG_I2C_ISCH=m
CONFIG_I2C_ISMT=m
CONFIG_I2C_PIIX4=m
CONFIG_I2C_NFORCE2=m
CONFIG_I2C_NFORCE2_S4985=m
# CONFIG_I2C_NVIDIA_GPU is not set
# CONFIG_I2C_SIS5595 is not set
# CONFIG_I2C_SIS630 is not set
CONFIG_I2C_SIS96X=m
CONFIG_I2C_VIA=m
CONFIG_I2C_VIAPRO=m

#
# ACPI drivers
#
CONFIG_I2C_SCMI=m

#
# I2C system bus drivers (mostly embedded / system-on-chip) #
# CONFIG_I2C_CBUS_GPIO is not set CONFIG_I2C_DESIGNWARE_CORE=m CONFIG_I2C_DESIGNWARE_PLATFORM=m
# CONFIG_I2C_DESIGNWARE_SLAVE is not set
# CONFIG_I2C_DESIGNWARE_PCI is not set
# CONFIG_I2C_DESIGNWARE_BAYTRAIL is not set
# CONFIG_I2C_EMEV2 is not set
# CONFIG_I2C_GPIO is not set
# CONFIG_I2C_OCORES is not set CONFIG_I2C_PCA_PLATFORM=m
CONFIG_I2C_SIMTEC=m
# CONFIG_I2C_XILINX is not set

#
# External I2C/SMBus adapter drivers
#
CONFIG_I2C_DIOLAN_U2C=m
CONFIG_I2C_PARPORT=m
CONFIG_I2C_PARPORT_LIGHT=m
# CONFIG_I2C_ROBOTFUZZ_OSIF is not set
# CONFIG_I2C_TAOS_EVM is not set
CONFIG_I2C_TINY_USB=m
CONFIG_I2C_VIPERBOARD=m

#
# Other I2C/SMBus bus drivers
#
# CONFIG_I2C_MLXCPLD is not set
CONFIG_I2C_STUB=m
# CONFIG_I2C_SLAVE is not set
# CONFIG_I2C_DEBUG_CORE is not set
# CONFIG_I2C_DEBUG_ALGO is not set
# CONFIG_I2C_DEBUG_BUS is not set
# CONFIG_I3C is not set
CONFIG_SPI=y
# CONFIG_SPI_DEBUG is not set
CONFIG_SPI_MASTER=y
# CONFIG_SPI_MEM is not set

#
# SPI Master Controller Drivers
#
# CONFIG_SPI_ALTERA is not set
# CONFIG_SPI_AXI_SPI_ENGINE is not set
# CONFIG_SPI_BITBANG is not set
# CONFIG_SPI_BUTTERFLY is not set
# CONFIG_SPI_CADENCE is not set
# CONFIG_SPI_DESIGNWARE is not set
# CONFIG_SPI_GPIO is not set
# CONFIG_SPI_LM70_LLP is not set
# CONFIG_SPI_OC_TINY is not set
# CONFIG_SPI_PXA2XX is not set
# CONFIG_SPI_ROCKCHIP is not set
# CONFIG_SPI_SC18IS602 is not set
# CONFIG_SPI_MXIC is not set
# CONFIG_SPI_XCOMM is not set
# CONFIG_SPI_XILINX is not set
# CONFIG_SPI_ZYNQMP_GQSPI is not set

#
# SPI Protocol Masters
#
# CONFIG_SPI_SPIDEV is not set
# CONFIG_SPI_LOOPBACK_TEST is not set
# CONFIG_SPI_TLE62X0 is not set
# CONFIG_SPI_SLAVE is not set
# CONFIG_SPMI is not set
# CONFIG_HSI is not set
CONFIG_PPS=y
# CONFIG_PPS_DEBUG is not set

#
# PPS clients support
#
# CONFIG_PPS_CLIENT_KTIMER is not set
CONFIG_PPS_CLIENT_LDISC=m
CONFIG_PPS_CLIENT_PARPORT=m
CONFIG_PPS_CLIENT_GPIO=m

#
# PPS generators support
#

#
# PTP clock support
#
CONFIG_PTP_1588_CLOCK=y
CONFIG_DP83640_PHY=m
CONFIG_PTP_1588_CLOCK_KVM=m
CONFIG_PINCTRL=y
CONFIG_PINMUX=y
CONFIG_PINCONF=y
CONFIG_GENERIC_PINCONF=y
# CONFIG_DEBUG_PINCTRL is not set
CONFIG_PINCTRL_AMD=m
# CONFIG_PINCTRL_MCP23S08 is not set
# CONFIG_PINCTRL_SX150X is not set
CONFIG_PINCTRL_BAYTRAIL=y
# CONFIG_PINCTRL_CHERRYVIEW is not set
CONFIG_PINCTRL_INTEL=m
# CONFIG_PINCTRL_BROXTON is not set
CONFIG_PINCTRL_CANNONLAKE=m
# CONFIG_PINCTRL_CEDARFORK is not set
CONFIG_PINCTRL_DENVERTON=m
CONFIG_PINCTRL_GEMINILAKE=m
# CONFIG_PINCTRL_ICELAKE is not set
CONFIG_PINCTRL_LEWISBURG=m
CONFIG_PINCTRL_SUNRISEPOINT=m
CONFIG_GPIOLIB=y
CONFIG_GPIOLIB_FASTPATH_LIMIT=512
CONFIG_GPIO_ACPI=y
CONFIG_GPIOLIB_IRQCHIP=y
# CONFIG_DEBUG_GPIO is not set
CONFIG_GPIO_SYSFS=y
CONFIG_GPIO_GENERIC=m

#
# Memory mapped GPIO drivers
#
CONFIG_GPIO_AMDPT=m
# CONFIG_GPIO_DWAPB is not set
# CONFIG_GPIO_EXAR is not set
# CONFIG_GPIO_GENERIC_PLATFORM is not set
CONFIG_GPIO_ICH=m
# CONFIG_GPIO_LYNXPOINT is not set
# CONFIG_GPIO_MB86S7X is not set
CONFIG_GPIO_MOCKUP=y
# CONFIG_GPIO_VX855 is not set

#
# Port-mapped I/O GPIO drivers
#
# CONFIG_GPIO_F7188X is not set
# CONFIG_GPIO_IT87 is not set
# CONFIG_GPIO_SCH is not set
# CONFIG_GPIO_SCH311X is not set
# CONFIG_GPIO_WINBOND is not set
# CONFIG_GPIO_WS16C48 is not set

#
# I2C GPIO expanders
#
# CONFIG_GPIO_ADP5588 is not set
# CONFIG_GPIO_MAX7300 is not set
# CONFIG_GPIO_MAX732X is not set
# CONFIG_GPIO_PCA953X is not set
# CONFIG_GPIO_PCF857X is not set
# CONFIG_GPIO_TPIC2810 is not set

#
# MFD GPIO expanders
#

#
# PCI GPIO expanders
#
# CONFIG_GPIO_AMD8111 is not set
# CONFIG_GPIO_ML_IOH is not set
# CONFIG_GPIO_PCI_IDIO_16 is not set
# CONFIG_GPIO_PCIE_IDIO_24 is not set
# CONFIG_GPIO_RDC321X is not set

#
# SPI GPIO expanders
#
# CONFIG_GPIO_MAX3191X is not set
# CONFIG_GPIO_MAX7301 is not set
# CONFIG_GPIO_MC33880 is not set
# CONFIG_GPIO_PISOSR is not set
# CONFIG_GPIO_XRA1403 is not set

#
# USB GPIO expanders
#
CONFIG_GPIO_VIPERBOARD=m
# CONFIG_W1 is not set
# CONFIG_POWER_AVS is not set
CONFIG_POWER_RESET=y
# CONFIG_POWER_RESET_RESTART is not set
CONFIG_POWER_SUPPLY=y
# CONFIG_POWER_SUPPLY_DEBUG is not set
# CONFIG_PDA_POWER is not set
# CONFIG_GENERIC_ADC_BATTERY is not set
# CONFIG_TEST_POWER is not set
# CONFIG_CHARGER_ADP5061 is not set
# CONFIG_BATTERY_DS2780 is not set
# CONFIG_BATTERY_DS2781 is not set
# CONFIG_BATTERY_DS2782 is not set
# CONFIG_BATTERY_SBS is not set
# CONFIG_CHARGER_SBS is not set
# CONFIG_MANAGER_SBS is not set
# CONFIG_BATTERY_BQ27XXX is not set
# CONFIG_BATTERY_MAX17040 is not set
# CONFIG_BATTERY_MAX17042 is not set
# CONFIG_CHARGER_MAX8903 is not set
# CONFIG_CHARGER_LP8727 is not set
# CONFIG_CHARGER_GPIO is not set
# CONFIG_CHARGER_LTC3651 is not set
# CONFIG_CHARGER_BQ2415X is not set
# CONFIG_CHARGER_BQ24257 is not set
# CONFIG_CHARGER_BQ24735 is not set
# CONFIG_CHARGER_BQ25890 is not set
CONFIG_CHARGER_SMB347=m
# CONFIG_BATTERY_GAUGE_LTC2941 is not set
# CONFIG_CHARGER_RT9455 is not set
CONFIG_HWMON=y
CONFIG_HWMON_VID=m
# CONFIG_HWMON_DEBUG_CHIP is not set

#
# Native drivers
#
CONFIG_SENSORS_ABITUGURU=m
CONFIG_SENSORS_ABITUGURU3=m
# CONFIG_SENSORS_AD7314 is not set
CONFIG_SENSORS_AD7414=m
CONFIG_SENSORS_AD7418=m
CONFIG_SENSORS_ADM1021=m
CONFIG_SENSORS_ADM1025=m
CONFIG_SENSORS_ADM1026=m
CONFIG_SENSORS_ADM1029=m
CONFIG_SENSORS_ADM1031=m
CONFIG_SENSORS_ADM9240=m
CONFIG_SENSORS_ADT7X10=m
# CONFIG_SENSORS_ADT7310 is not set
CONFIG_SENSORS_ADT7410=m
CONFIG_SENSORS_ADT7411=m
CONFIG_SENSORS_ADT7462=m
CONFIG_SENSORS_ADT7470=m
CONFIG_SENSORS_ADT7475=m
CONFIG_SENSORS_ASC7621=m
CONFIG_SENSORS_K8TEMP=m
CONFIG_SENSORS_K10TEMP=m
CONFIG_SENSORS_FAM15H_POWER=m
CONFIG_SENSORS_APPLESMC=m
CONFIG_SENSORS_ASB100=m
# CONFIG_SENSORS_ASPEED is not set
CONFIG_SENSORS_ATXP1=m
CONFIG_SENSORS_DS620=m
CONFIG_SENSORS_DS1621=m
CONFIG_SENSORS_DELL_SMM=m
CONFIG_SENSORS_I5K_AMB=m
CONFIG_SENSORS_F71805F=m
CONFIG_SENSORS_F71882FG=m
CONFIG_SENSORS_F75375S=m
CONFIG_SENSORS_FSCHMD=m
# CONFIG_SENSORS_FTSTEUTATES is not set
CONFIG_SENSORS_GL518SM=m
CONFIG_SENSORS_GL520SM=m
CONFIG_SENSORS_G760A=m
# CONFIG_SENSORS_G762 is not set
# CONFIG_SENSORS_HIH6130 is not set
CONFIG_SENSORS_IBMAEM=m
CONFIG_SENSORS_IBMPEX=m
# CONFIG_SENSORS_IIO_HWMON is not set
# CONFIG_SENSORS_I5500 is not set
CONFIG_SENSORS_CORETEMP=m
CONFIG_SENSORS_IT87=m
CONFIG_SENSORS_JC42=m
# CONFIG_SENSORS_POWR1220 is not set
CONFIG_SENSORS_LINEAGE=m
# CONFIG_SENSORS_LTC2945 is not set
# CONFIG_SENSORS_LTC2990 is not set
CONFIG_SENSORS_LTC4151=m
CONFIG_SENSORS_LTC4215=m
# CONFIG_SENSORS_LTC4222 is not set
CONFIG_SENSORS_LTC4245=m
# CONFIG_SENSORS_LTC4260 is not set
CONFIG_SENSORS_LTC4261=m
# CONFIG_SENSORS_MAX1111 is not set
CONFIG_SENSORS_MAX16065=m
CONFIG_SENSORS_MAX1619=m
CONFIG_SENSORS_MAX1668=m
CONFIG_SENSORS_MAX197=m
# CONFIG_SENSORS_MAX31722 is not set
# CONFIG_SENSORS_MAX6621 is not set
CONFIG_SENSORS_MAX6639=m
CONFIG_SENSORS_MAX6642=m
CONFIG_SENSORS_MAX6650=m
CONFIG_SENSORS_MAX6697=m
# CONFIG_SENSORS_MAX31790 is not set
CONFIG_SENSORS_MCP3021=m
# CONFIG_SENSORS_TC654 is not set
# CONFIG_SENSORS_ADCXX is not set
CONFIG_SENSORS_LM63=m
# CONFIG_SENSORS_LM70 is not set
CONFIG_SENSORS_LM73=m
CONFIG_SENSORS_LM75=m
CONFIG_SENSORS_LM77=m
CONFIG_SENSORS_LM78=m
CONFIG_SENSORS_LM80=m
CONFIG_SENSORS_LM83=m
CONFIG_SENSORS_LM85=m
CONFIG_SENSORS_LM87=m
CONFIG_SENSORS_LM90=m
CONFIG_SENSORS_LM92=m
CONFIG_SENSORS_LM93=m
CONFIG_SENSORS_LM95234=m
CONFIG_SENSORS_LM95241=m
CONFIG_SENSORS_LM95245=m
CONFIG_SENSORS_PC87360=m
CONFIG_SENSORS_PC87427=m
CONFIG_SENSORS_NTC_THERMISTOR=m
# CONFIG_SENSORS_NCT6683 is not set
CONFIG_SENSORS_NCT6775=m
# CONFIG_SENSORS_NCT7802 is not set
# CONFIG_SENSORS_NCT7904 is not set
# CONFIG_SENSORS_NPCM7XX is not set
# CONFIG_SENSORS_OCC_P8_I2C is not set
CONFIG_SENSORS_PCF8591=m
CONFIG_PMBUS=m
CONFIG_SENSORS_PMBUS=m
CONFIG_SENSORS_ADM1275=m
# CONFIG_SENSORS_IBM_CFFPS is not set
# CONFIG_SENSORS_IR35221 is not set
CONFIG_SENSORS_LM25066=m
CONFIG_SENSORS_LTC2978=m
# CONFIG_SENSORS_LTC3815 is not set
CONFIG_SENSORS_MAX16064=m
# CONFIG_SENSORS_MAX20751 is not set
# CONFIG_SENSORS_MAX31785 is not set
CONFIG_SENSORS_MAX34440=m
CONFIG_SENSORS_MAX8688=m
# CONFIG_SENSORS_TPS40422 is not set
# CONFIG_SENSORS_TPS53679 is not set
CONFIG_SENSORS_UCD9000=m
CONFIG_SENSORS_UCD9200=m
CONFIG_SENSORS_ZL6100=m
CONFIG_SENSORS_SHT15=m
CONFIG_SENSORS_SHT21=m
# CONFIG_SENSORS_SHT3x is not set
# CONFIG_SENSORS_SHTC1 is not set
CONFIG_SENSORS_SIS5595=m
CONFIG_SENSORS_DME1737=m
CONFIG_SENSORS_EMC1403=m
# CONFIG_SENSORS_EMC2103 is not set
CONFIG_SENSORS_EMC6W201=m
CONFIG_SENSORS_SMSC47M1=m
CONFIG_SENSORS_SMSC47M192=m
CONFIG_SENSORS_SMSC47B397=m
CONFIG_SENSORS_SCH56XX_COMMON=m
CONFIG_SENSORS_SCH5627=m
CONFIG_SENSORS_SCH5636=m
# CONFIG_SENSORS_STTS751 is not set
# CONFIG_SENSORS_SMM665 is not set
# CONFIG_SENSORS_ADC128D818 is not set
CONFIG_SENSORS_ADS1015=m
CONFIG_SENSORS_ADS7828=m
# CONFIG_SENSORS_ADS7871 is not set
CONFIG_SENSORS_AMC6821=m
CONFIG_SENSORS_INA209=m
CONFIG_SENSORS_INA2XX=m
# CONFIG_SENSORS_INA3221 is not set
# CONFIG_SENSORS_TC74 is not set
CONFIG_SENSORS_THMC50=m
CONFIG_SENSORS_TMP102=m
# CONFIG_SENSORS_TMP103 is not set
# CONFIG_SENSORS_TMP108 is not set
CONFIG_SENSORS_TMP401=m
CONFIG_SENSORS_TMP421=m
CONFIG_SENSORS_VIA_CPUTEMP=m
CONFIG_SENSORS_VIA686A=m
CONFIG_SENSORS_VT1211=m
CONFIG_SENSORS_VT8231=m
# CONFIG_SENSORS_W83773G is not set
CONFIG_SENSORS_W83781D=m
CONFIG_SENSORS_W83791D=m
CONFIG_SENSORS_W83792D=m
CONFIG_SENSORS_W83793=m
CONFIG_SENSORS_W83795=m
# CONFIG_SENSORS_W83795_FANCTRL is not set
CONFIG_SENSORS_W83L785TS=m
CONFIG_SENSORS_W83L786NG=m
CONFIG_SENSORS_W83627HF=m
CONFIG_SENSORS_W83627EHF=m
# CONFIG_SENSORS_XGENE is not set

#
# ACPI drivers
#
CONFIG_SENSORS_ACPI_POWER=m CONFIG_SENSORS_ATK0110=m
CONFIG_THERMAL=y
# CONFIG_THERMAL_STATISTICS is not set CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0 CONFIG_THERMAL_HWMON=y CONFIG_THERMAL_WRITABLE_TRIPS=y CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y
# CONFIG_THERMAL_DEFAULT_GOV_FAIR_SHARE is not set # CONFIG_THERMAL_DEFAULT_GOV_USER_SPACE is not set # CONFIG_THERMAL_DEFAULT_GOV_POWER_ALLOCATOR is not set CONFIG_THERMAL_GOV_FAIR_SHARE=y CONFIG_THERMAL_GOV_STEP_WISE=y CONFIG_THERMAL_GOV_BANG_BANG=y CONFIG_THERMAL_GOV_USER_SPACE=y
# CONFIG_THERMAL_GOV_POWER_ALLOCATOR is not set # CONFIG_CLOCK_THERMAL is not set
# CONFIG_DEVFREQ_THERMAL is not set
# CONFIG_THERMAL_EMULATION is not set

#
# Intel thermal drivers
#
CONFIG_INTEL_POWERCLAMP=m
CONFIG_X86_PKG_TEMP_THERMAL=m
CONFIG_INTEL_SOC_DTS_IOSF_CORE=m
# CONFIG_INTEL_SOC_DTS_THERMAL is not set

#
# ACPI INT340X thermal drivers
#
CONFIG_INT340X_THERMAL=m
CONFIG_ACPI_THERMAL_REL=m
# CONFIG_INT3406_THERMAL is not set
# CONFIG_INTEL_PCH_THERMAL is not set
# CONFIG_GENERIC_ADC_THERMAL is not set
CONFIG_WATCHDOG=y
CONFIG_WATCHDOG_CORE=y
# CONFIG_WATCHDOG_NOWAYOUT is not set
CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED=y
CONFIG_WATCHDOG_SYSFS=y

#
# Watchdog Device Drivers
#
CONFIG_SOFT_WATCHDOG=m
CONFIG_WDAT_WDT=m
# CONFIG_XILINX_WATCHDOG is not set
# CONFIG_ZIIRAVE_WATCHDOG is not set
# CONFIG_CADENCE_WATCHDOG is not set
# CONFIG_DW_WATCHDOG is not set
# CONFIG_MAX63XX_WATCHDOG is not set
# CONFIG_ACQUIRE_WDT is not set
# CONFIG_ADVANTECH_WDT is not set
CONFIG_ALIM1535_WDT=m
CONFIG_ALIM7101_WDT=m
# CONFIG_EBC_C384_WDT is not set
CONFIG_F71808E_WDT=m
CONFIG_SP5100_TCO=m
CONFIG_SBC_FITPC2_WATCHDOG=m
# CONFIG_EUROTECH_WDT is not set
CONFIG_IB700_WDT=m
CONFIG_IBMASR=m
# CONFIG_WAFER_WDT is not set
CONFIG_I6300ESB_WDT=m
CONFIG_IE6XX_WDT=m
CONFIG_ITCO_WDT=m
CONFIG_ITCO_VENDOR_SUPPORT=y
CONFIG_IT8712F_WDT=m
CONFIG_IT87_WDT=m
CONFIG_HP_WATCHDOG=m
CONFIG_HPWDT_NMI_DECODING=y
# CONFIG_SC1200_WDT is not set
# CONFIG_PC87413_WDT is not set
CONFIG_NV_TCO=m
# CONFIG_60XX_WDT is not set
# CONFIG_CPU5_WDT is not set
CONFIG_SMSC_SCH311X_WDT=m
# CONFIG_SMSC37B787_WDT is not set
# CONFIG_TQMX86_WDT is not set
CONFIG_VIA_WDT=m
CONFIG_W83627HF_WDT=m
CONFIG_W83877F_WDT=m
CONFIG_W83977F_WDT=m
CONFIG_MACHZ_WDT=m
# CONFIG_SBC_EPX_C3_WATCHDOG is not set
CONFIG_INTEL_MEI_WDT=m
# CONFIG_NI903X_WDT is not set
# CONFIG_NIC7018_WDT is not set
# CONFIG_MEN_A21_WDT is not set
CONFIG_XEN_WDT=m

#
# PCI-based Watchdog Cards
#
CONFIG_PCIPCWATCHDOG=m
CONFIG_WDTPCI=m

#
# USB-based Watchdog Cards
#
CONFIG_USBPCWATCHDOG=m

#
# Watchdog Pretimeout Governors
#
# CONFIG_WATCHDOG_PRETIMEOUT_GOV is not set
CONFIG_SSB_POSSIBLE=y
CONFIG_SSB=m
CONFIG_SSB_SPROM=y
CONFIG_SSB_PCIHOST_POSSIBLE=y
CONFIG_SSB_PCIHOST=y
CONFIG_SSB_SDIOHOST_POSSIBLE=y
CONFIG_SSB_SDIOHOST=y
CONFIG_SSB_DRIVER_PCICORE_POSSIBLE=y
CONFIG_SSB_DRIVER_PCICORE=y
CONFIG_SSB_DRIVER_GPIO=y
CONFIG_BCMA_POSSIBLE=y
CONFIG_BCMA=m
CONFIG_BCMA_HOST_PCI_POSSIBLE=y
CONFIG_BCMA_HOST_PCI=y
# CONFIG_BCMA_HOST_SOC is not set
CONFIG_BCMA_DRIVER_PCI=y
CONFIG_BCMA_DRIVER_GMAC_CMN=y
CONFIG_BCMA_DRIVER_GPIO=y
# CONFIG_BCMA_DEBUG is not set

#
# Multifunction device drivers
#
CONFIG_MFD_CORE=y
# CONFIG_MFD_AS3711 is not set
# CONFIG_PMIC_ADP5520 is not set
# CONFIG_MFD_AAT2870_CORE is not set
# CONFIG_MFD_BCM590XX is not set
# CONFIG_MFD_BD9571MWV is not set
# CONFIG_MFD_AXP20X_I2C is not set
# CONFIG_MFD_CROS_EC is not set
# CONFIG_MFD_MADERA is not set
# CONFIG_PMIC_DA903X is not set
# CONFIG_MFD_DA9052_SPI is not set
# CONFIG_MFD_DA9052_I2C is not set
# CONFIG_MFD_DA9055 is not set
# CONFIG_MFD_DA9062 is not set
# CONFIG_MFD_DA9063 is not set
# CONFIG_MFD_DA9150 is not set
# CONFIG_MFD_DLN2 is not set
# CONFIG_MFD_MC13XXX_SPI is not set
# CONFIG_MFD_MC13XXX_I2C is not set
# CONFIG_HTC_PASIC3 is not set
# CONFIG_HTC_I2CPLD is not set
# CONFIG_MFD_INTEL_QUARK_I2C_GPIO is not set
CONFIG_LPC_ICH=m
CONFIG_LPC_SCH=m
# CONFIG_INTEL_SOC_PMIC is not set
# CONFIG_INTEL_SOC_PMIC_CHTWC is not set
# CONFIG_INTEL_SOC_PMIC_CHTDC_TI is not set
CONFIG_MFD_INTEL_LPSS=y
CONFIG_MFD_INTEL_LPSS_ACPI=y
CONFIG_MFD_INTEL_LPSS_PCI=y
# CONFIG_MFD_JANZ_CMODIO is not set
# CONFIG_MFD_KEMPLD is not set
# CONFIG_MFD_88PM800 is not set
# CONFIG_MFD_88PM805 is not set
# CONFIG_MFD_88PM860X is not set
# CONFIG_MFD_MAX14577 is not set
# CONFIG_MFD_MAX77693 is not set
# CONFIG_MFD_MAX77843 is not set
# CONFIG_MFD_MAX8907 is not set
# CONFIG_MFD_MAX8925 is not set
# CONFIG_MFD_MAX8997 is not set
# CONFIG_MFD_MAX8998 is not set
# CONFIG_MFD_MT6397 is not set
# CONFIG_MFD_MENF21BMC is not set
# CONFIG_EZX_PCAP is not set
CONFIG_MFD_VIPERBOARD=m
# CONFIG_MFD_RETU is not set
# CONFIG_MFD_PCF50633 is not set
# CONFIG_UCB1400_CORE is not set
# CONFIG_MFD_RDC321X is not set
# CONFIG_MFD_RT5033 is not set
# CONFIG_MFD_RC5T583 is not set
# CONFIG_MFD_SEC_CORE is not set
# CONFIG_MFD_SI476X_CORE is not set
CONFIG_MFD_SM501=m
CONFIG_MFD_SM501_GPIO=y
# CONFIG_MFD_SKY81452 is not set
# CONFIG_MFD_SMSC is not set
# CONFIG_ABX500_CORE is not set
# CONFIG_MFD_SYSCON is not set
# CONFIG_MFD_TI_AM335X_TSCADC is not set
# CONFIG_MFD_LP3943 is not set
# CONFIG_MFD_LP8788 is not set
# CONFIG_MFD_TI_LMU is not set
# CONFIG_MFD_PALMAS is not set
# CONFIG_TPS6105X is not set
# CONFIG_TPS65010 is not set
# CONFIG_TPS6507X is not set
# CONFIG_MFD_TPS65086 is not set
# CONFIG_MFD_TPS65090 is not set
# CONFIG_MFD_TPS68470 is not set
# CONFIG_MFD_TI_LP873X is not set
# CONFIG_MFD_TPS6586X is not set
# CONFIG_MFD_TPS65910 is not set
# CONFIG_MFD_TPS65912_I2C is not set
# CONFIG_MFD_TPS65912_SPI is not set
# CONFIG_MFD_TPS80031 is not set
# CONFIG_TWL4030_CORE is not set
# CONFIG_TWL6040_CORE is not set
# CONFIG_MFD_WL1273_CORE is not set
# CONFIG_MFD_LM3533 is not set
CONFIG_MFD_VX855=m
# CONFIG_MFD_ARIZONA_I2C is not set
# CONFIG_MFD_ARIZONA_SPI is not set
# CONFIG_MFD_WM8400 is not set
# CONFIG_MFD_WM831X_I2C is not set
# CONFIG_MFD_WM831X_SPI is not set
# CONFIG_MFD_WM8350_I2C is not set
# CONFIG_MFD_WM8994 is not set
# CONFIG_REGULATOR is not set
CONFIG_RC_CORE=m
CONFIG_RC_MAP=m
# CONFIG_LIRC is not set
CONFIG_RC_DECODERS=y
CONFIG_IR_NEC_DECODER=m
CONFIG_IR_RC5_DECODER=m
CONFIG_IR_RC6_DECODER=m
CONFIG_IR_JVC_DECODER=m
CONFIG_IR_SONY_DECODER=m
CONFIG_IR_SANYO_DECODER=m
# CONFIG_IR_SHARP_DECODER is not set
CONFIG_IR_MCE_KBD_DECODER=m
# CONFIG_IR_XMP_DECODER is not set
# CONFIG_IR_IMON_DECODER is not set
CONFIG_RC_DEVICES=y
CONFIG_RC_ATI_REMOTE=m
CONFIG_IR_ENE=m
CONFIG_IR_IMON=m
# CONFIG_IR_IMON_RAW is not set
CONFIG_IR_MCEUSB=m
CONFIG_IR_ITE_CIR=m
CONFIG_IR_FINTEK=m
CONFIG_IR_NUVOTON=m
CONFIG_IR_REDRAT3=m
CONFIG_IR_STREAMZAP=m
CONFIG_IR_WINBOND_CIR=m
# CONFIG_IR_IGORPLUGUSB is not set
CONFIG_IR_IGUANA=m
CONFIG_IR_TTUSBIR=m
CONFIG_RC_LOOPBACK=m
# CONFIG_IR_SERIAL is not set
# CONFIG_IR_SIR is not set
# CONFIG_RC_XBOX_DVD is not set
CONFIG_MEDIA_SUPPORT=m

#
# Multimedia core support
#
CONFIG_MEDIA_CAMERA_SUPPORT=y
CONFIG_MEDIA_ANALOG_TV_SUPPORT=y
CONFIG_MEDIA_DIGITAL_TV_SUPPORT=y
CONFIG_MEDIA_RADIO_SUPPORT=y
# CONFIG_MEDIA_SDR_SUPPORT is not set
# CONFIG_MEDIA_CEC_SUPPORT is not set
# CONFIG_MEDIA_CONTROLLER is not set
CONFIG_VIDEO_DEV=m
CONFIG_VIDEO_V4L2=m
# CONFIG_VIDEO_ADV_DEBUG is not set
# CONFIG_VIDEO_FIXED_MINOR_RANGES is not set
CONFIG_VIDEO_TUNER=m
CONFIG_VIDEOBUF_GEN=m
CONFIG_VIDEOBUF_DMA_SG=m
CONFIG_VIDEOBUF_VMALLOC=m
CONFIG_DVB_CORE=m
# CONFIG_DVB_MMAP is not set
CONFIG_DVB_NET=y
CONFIG_TTPCI_EEPROM=m
CONFIG_DVB_MAX_ADAPTERS=8
CONFIG_DVB_DYNAMIC_MINORS=y
# CONFIG_DVB_DEMUX_SECTION_LOSS_LOG is not set
# CONFIG_DVB_ULE_DEBUG is not set

#
# Media drivers
#
CONFIG_MEDIA_USB_SUPPORT=y

#
# Webcam devices
#
CONFIG_USB_VIDEO_CLASS=m
CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV=y
CONFIG_USB_GSPCA=m
CONFIG_USB_M5602=m
CONFIG_USB_STV06XX=m
CONFIG_USB_GL860=m
CONFIG_USB_GSPCA_BENQ=m
CONFIG_USB_GSPCA_CONEX=m
CONFIG_USB_GSPCA_CPIA1=m
# CONFIG_USB_GSPCA_DTCS033 is not set
CONFIG_USB_GSPCA_ETOMS=m
CONFIG_USB_GSPCA_FINEPIX=m
CONFIG_USB_GSPCA_JEILINJ=m
CONFIG_USB_GSPCA_JL2005BCD=m
# CONFIG_USB_GSPCA_KINECT is not set
CONFIG_USB_GSPCA_KONICA=m
CONFIG_USB_GSPCA_MARS=m
CONFIG_USB_GSPCA_MR97310A=m
CONFIG_USB_GSPCA_NW80X=m
CONFIG_USB_GSPCA_OV519=m
CONFIG_USB_GSPCA_OV534=m
CONFIG_USB_GSPCA_OV534_9=m
CONFIG_USB_GSPCA_PAC207=m
CONFIG_USB_GSPCA_PAC7302=m
CONFIG_USB_GSPCA_PAC7311=m
CONFIG_USB_GSPCA_SE401=m
CONFIG_USB_GSPCA_SN9C2028=m
CONFIG_USB_GSPCA_SN9C20X=m
CONFIG_USB_GSPCA_SONIXB=m
CONFIG_USB_GSPCA_SONIXJ=m
CONFIG_USB_GSPCA_SPCA500=m
CONFIG_USB_GSPCA_SPCA501=m
CONFIG_USB_GSPCA_SPCA505=m
CONFIG_USB_GSPCA_SPCA506=m
CONFIG_USB_GSPCA_SPCA508=m
CONFIG_USB_GSPCA_SPCA561=m
CONFIG_USB_GSPCA_SPCA1528=m
CONFIG_USB_GSPCA_SQ905=m
CONFIG_USB_GSPCA_SQ905C=m
CONFIG_USB_GSPCA_SQ930X=m
CONFIG_USB_GSPCA_STK014=m
# CONFIG_USB_GSPCA_STK1135 is not set
CONFIG_USB_GSPCA_STV0680=m
CONFIG_USB_GSPCA_SUNPLUS=m
CONFIG_USB_GSPCA_T613=m
CONFIG_USB_GSPCA_TOPRO=m
# CONFIG_USB_GSPCA_TOUPTEK is not set
CONFIG_USB_GSPCA_TV8532=m
CONFIG_USB_GSPCA_VC032X=m
CONFIG_USB_GSPCA_VICAM=m
CONFIG_USB_GSPCA_XIRLINK_CIT=m
CONFIG_USB_GSPCA_ZC3XX=m
CONFIG_USB_PWC=m
# CONFIG_USB_PWC_DEBUG is not set
CONFIG_USB_PWC_INPUT_EVDEV=y
# CONFIG_VIDEO_CPIA2 is not set
CONFIG_USB_ZR364XX=m
CONFIG_USB_STKWEBCAM=m
CONFIG_USB_S2255=m
# CONFIG_VIDEO_USBTV is not set

#
# Analog TV USB devices
#
CONFIG_VIDEO_PVRUSB2=m
CONFIG_VIDEO_PVRUSB2_SYSFS=y
CONFIG_VIDEO_PVRUSB2_DVB=y
# CONFIG_VIDEO_PVRUSB2_DEBUGIFC is not set
CONFIG_VIDEO_HDPVR=m
CONFIG_VIDEO_USBVISION=m
# CONFIG_VIDEO_STK1160_COMMON is not set
# CONFIG_VIDEO_GO7007 is not set

#
# Analog/digital TV USB devices
#
CONFIG_VIDEO_AU0828=m
CONFIG_VIDEO_AU0828_V4L2=y
# CONFIG_VIDEO_AU0828_RC is not set
CONFIG_VIDEO_CX231XX=m
CONFIG_VIDEO_CX231XX_RC=y
CONFIG_VIDEO_CX231XX_ALSA=m
CONFIG_VIDEO_CX231XX_DVB=m
CONFIG_VIDEO_TM6000=m
CONFIG_VIDEO_TM6000_ALSA=m
CONFIG_VIDEO_TM6000_DVB=m

#
# Digital TV USB devices
#
CONFIG_DVB_USB=m
# CONFIG_DVB_USB_DEBUG is not set
CONFIG_DVB_USB_DIB3000MC=m
CONFIG_DVB_USB_A800=m
CONFIG_DVB_USB_DIBUSB_MB=m
# CONFIG_DVB_USB_DIBUSB_MB_FAULTY is not set
CONFIG_DVB_USB_DIBUSB_MC=m
CONFIG_DVB_USB_DIB0700=m
CONFIG_DVB_USB_UMT_010=m
CONFIG_DVB_USB_CXUSB=m
CONFIG_DVB_USB_M920X=m
CONFIG_DVB_USB_DIGITV=m
CONFIG_DVB_USB_VP7045=m
CONFIG_DVB_USB_VP702X=m
CONFIG_DVB_USB_GP8PSK=m
CONFIG_DVB_USB_NOVA_T_USB2=m
CONFIG_DVB_USB_TTUSB2=m
CONFIG_DVB_USB_DTT200U=m
CONFIG_DVB_USB_OPERA1=m
CONFIG_DVB_USB_AF9005=m
CONFIG_DVB_USB_AF9005_REMOTE=m
CONFIG_DVB_USB_PCTV452E=m
CONFIG_DVB_USB_DW2102=m
CONFIG_DVB_USB_CINERGY_T2=m
CONFIG_DVB_USB_DTV5100=m
CONFIG_DVB_USB_AZ6027=m
CONFIG_DVB_USB_TECHNISAT_USB2=m
CONFIG_DVB_USB_V2=m
CONFIG_DVB_USB_AF9015=m
CONFIG_DVB_USB_AF9035=m
CONFIG_DVB_USB_ANYSEE=m
CONFIG_DVB_USB_AU6610=m
CONFIG_DVB_USB_AZ6007=m
CONFIG_DVB_USB_CE6230=m
CONFIG_DVB_USB_EC168=m
CONFIG_DVB_USB_GL861=m
CONFIG_DVB_USB_LME2510=m
CONFIG_DVB_USB_MXL111SF=m
CONFIG_DVB_USB_RTL28XXU=m
# CONFIG_DVB_USB_DVBSKY is not set
# CONFIG_DVB_USB_ZD1301 is not set
CONFIG_DVB_TTUSB_BUDGET=m
CONFIG_DVB_TTUSB_DEC=m
CONFIG_SMS_USB_DRV=m
CONFIG_DVB_B2C2_FLEXCOP_USB=m
# CONFIG_DVB_B2C2_FLEXCOP_USB_DEBUG is not set
# CONFIG_DVB_AS102 is not set

#
# Webcam, TV (analog/digital) USB devices
#
CONFIG_VIDEO_EM28XX=m
# CONFIG_VIDEO_EM28XX_V4L2 is not set
CONFIG_VIDEO_EM28XX_ALSA=m
CONFIG_VIDEO_EM28XX_DVB=m
CONFIG_VIDEO_EM28XX_RC=m
CONFIG_MEDIA_PCI_SUPPORT=y

#
# Media capture support
#
# CONFIG_VIDEO_MEYE is not set
# CONFIG_VIDEO_SOLO6X10 is not set
# CONFIG_VIDEO_TW5864 is not set
# CONFIG_VIDEO_TW68 is not set
# CONFIG_VIDEO_TW686X is not set

#
# Media capture/analog TV support
#
CONFIG_VIDEO_IVTV=m
# CONFIG_VIDEO_IVTV_DEPRECATED_IOCTLS is not set
# CONFIG_VIDEO_IVTV_ALSA is not set CONFIG_VIDEO_FB_IVTV=m
# CONFIG_VIDEO_HEXIUM_GEMINI is not set
# CONFIG_VIDEO_HEXIUM_ORION is not set
# CONFIG_VIDEO_MXB is not set
# CONFIG_VIDEO_DT3155 is not set

#
# Media capture/analog/hybrid TV support
#
CONFIG_VIDEO_CX18=m
CONFIG_VIDEO_CX18_ALSA=m
CONFIG_VIDEO_CX23885=m
CONFIG_MEDIA_ALTERA_CI=m
# CONFIG_VIDEO_CX25821 is not set
CONFIG_VIDEO_CX88=m
CONFIG_VIDEO_CX88_ALSA=m
CONFIG_VIDEO_CX88_BLACKBIRD=m
CONFIG_VIDEO_CX88_DVB=m
CONFIG_VIDEO_CX88_ENABLE_VP3054=y
CONFIG_VIDEO_CX88_VP3054=m
CONFIG_VIDEO_CX88_MPEG=m
CONFIG_VIDEO_BT848=m
CONFIG_DVB_BT8XX=m
CONFIG_VIDEO_SAA7134=m
CONFIG_VIDEO_SAA7134_ALSA=m
CONFIG_VIDEO_SAA7134_RC=y
CONFIG_VIDEO_SAA7134_DVB=m
CONFIG_VIDEO_SAA7164=m

#
# Media digital TV PCI Adapters
#
CONFIG_DVB_AV7110_IR=y
CONFIG_DVB_AV7110=m
CONFIG_DVB_AV7110_OSD=y
CONFIG_DVB_BUDGET_CORE=m
CONFIG_DVB_BUDGET=m
CONFIG_DVB_BUDGET_CI=m
CONFIG_DVB_BUDGET_AV=m
CONFIG_DVB_BUDGET_PATCH=m
CONFIG_DVB_B2C2_FLEXCOP_PCI=m
# CONFIG_DVB_B2C2_FLEXCOP_PCI_DEBUG is not set
CONFIG_DVB_PLUTO2=m
CONFIG_DVB_DM1105=m
CONFIG_DVB_PT1=m
# CONFIG_DVB_PT3 is not set
CONFIG_MANTIS_CORE=m
CONFIG_DVB_MANTIS=m
CONFIG_DVB_HOPPER=m
CONFIG_DVB_NGENE=m
CONFIG_DVB_DDBRIDGE=m
# CONFIG_DVB_DDBRIDGE_MSIENABLE is not set
# CONFIG_DVB_SMIPCIE is not set
# CONFIG_DVB_NETUP_UNIDVB is not set
# CONFIG_V4L_PLATFORM_DRIVERS is not set
# CONFIG_V4L_MEM2MEM_DRIVERS is not set
# CONFIG_V4L_TEST_DRIVERS is not set
# CONFIG_DVB_PLATFORM_DRIVERS is not set

#
# Supported MMC/SDIO adapters
#
CONFIG_SMS_SDIO_DRV=m
CONFIG_RADIO_ADAPTERS=y
CONFIG_RADIO_TEA575X=m
# CONFIG_RADIO_SI470X is not set
# CONFIG_RADIO_SI4713 is not set
# CONFIG_USB_MR800 is not set
# CONFIG_USB_DSBR is not set
# CONFIG_RADIO_MAXIRADIO is not set
# CONFIG_RADIO_SHARK is not set
# CONFIG_RADIO_SHARK2 is not set
# CONFIG_USB_KEENE is not set
# CONFIG_USB_RAREMONO is not set
# CONFIG_USB_MA901 is not set
# CONFIG_RADIO_TEA5764 is not set
# CONFIG_RADIO_SAA7706H is not set
# CONFIG_RADIO_TEF6862 is not set
# CONFIG_RADIO_WL1273 is not set

#
# Texas Instruments WL128x FM driver (ST based)
#

#
# Supported FireWire (IEEE 1394) Adapters
#
CONFIG_DVB_FIREDTV=m
CONFIG_DVB_FIREDTV_INPUT=y
CONFIG_MEDIA_COMMON_OPTIONS=y

#

# common driver options
#
CONFIG_VIDEO_CX2341X=m
CONFIG_VIDEO_TVEEPROM=m
CONFIG_CYPRESS_FIRMWARE=m
CONFIG_VIDEOBUF2_CORE=m
CONFIG_VIDEOBUF2_V4L2=m
CONFIG_VIDEOBUF2_MEMOPS=m
CONFIG_VIDEOBUF2_VMALLOC=m
CONFIG_VIDEOBUF2_DMA_SG=m
CONFIG_VIDEOBUF2_DVB=m
CONFIG_DVB_B2C2_FLEXCOP=m
CONFIG_VIDEO_SAA7146=m
CONFIG_VIDEO_SAA7146_VV=m
CONFIG_SMS_SIANO_MDTV=m
CONFIG_SMS_SIANO_RC=y
# CONFIG_SMS_SIANO_DEBUGFS is not set

#
# Media ancillary drivers (tuners, sensors, i2c, spi, frontends) #
CONFIG_MEDIA_SUBDRV_AUTOSELECT=y
CONFIG_MEDIA_ATTACH=y
CONFIG_VIDEO_IR_I2C=m

#
# Audio decoders, processors and mixers
#
CONFIG_VIDEO_TVAUDIO=m
CONFIG_VIDEO_TDA7432=m
CONFIG_VIDEO_MSP3400=m
CONFIG_VIDEO_CS3308=m
CONFIG_VIDEO_CS5345=m
CONFIG_VIDEO_CS53L32A=m
CONFIG_VIDEO_WM8775=m
CONFIG_VIDEO_WM8739=m
CONFIG_VIDEO_VP27SMPX=m

#
# RDS decoders
#
CONFIG_VIDEO_SAA6588=m

#
# Video decoders
#
CONFIG_VIDEO_SAA711X=m

#
# Video and audio decoders
#
CONFIG_VIDEO_SAA717X=m
CONFIG_VIDEO_CX25840=m

#
# Video encoders
#
CONFIG_VIDEO_SAA7127=m

#
# Camera sensor devices
#

#
# Flash devices
#

#
# Video improvement chips
#
CONFIG_VIDEO_UPD64031A=m
CONFIG_VIDEO_UPD64083=m

#
# Audio/Video compression chips
#
CONFIG_VIDEO_SAA6752HS=m

#
# SDR tuner chips
#

#
# Miscellaneous helper chips
#
CONFIG_VIDEO_M52790=m

#
# Sensors used on soc_camera driver
#

#
# Media SPI Adapters
#
# CONFIG_CXD2880_SPI_DRV is not set
CONFIG_MEDIA_TUNER=m
CONFIG_MEDIA_TUNER_SIMPLE=m
CONFIG_MEDIA_TUNER_TDA18250=m
CONFIG_MEDIA_TUNER_TDA8290=m
CONFIG_MEDIA_TUNER_TDA827X=m
CONFIG_MEDIA_TUNER_TDA18271=m
CONFIG_MEDIA_TUNER_TDA9887=m
CONFIG_MEDIA_TUNER_TEA5761=m
CONFIG_MEDIA_TUNER_TEA5767=m
CONFIG_MEDIA_TUNER_MT20XX=m
CONFIG_MEDIA_TUNER_MT2060=m
CONFIG_MEDIA_TUNER_MT2063=m
CONFIG_MEDIA_TUNER_MT2266=m
CONFIG_MEDIA_TUNER_MT2131=m
CONFIG_MEDIA_TUNER_QT1010=m
CONFIG_MEDIA_TUNER_XC2028=m
CONFIG_MEDIA_TUNER_XC5000=m
CONFIG_MEDIA_TUNER_XC4000=m
CONFIG_MEDIA_TUNER_MXL5005S=m
CONFIG_MEDIA_TUNER_MXL5007T=m
CONFIG_MEDIA_TUNER_MC44S803=m
CONFIG_MEDIA_TUNER_MAX2165=m
CONFIG_MEDIA_TUNER_TDA18218=m
CONFIG_MEDIA_TUNER_FC0011=m
CONFIG_MEDIA_TUNER_FC0012=m
CONFIG_MEDIA_TUNER_FC0013=m
CONFIG_MEDIA_TUNER_TDA18212=m
CONFIG_MEDIA_TUNER_E4000=m
CONFIG_MEDIA_TUNER_FC2580=m
CONFIG_MEDIA_TUNER_M88RS6000T=m
CONFIG_MEDIA_TUNER_TUA9001=m
CONFIG_MEDIA_TUNER_SI2157=m
CONFIG_MEDIA_TUNER_IT913X=m
CONFIG_MEDIA_TUNER_R820T=m
CONFIG_MEDIA_TUNER_QM1D1C0042=m
CONFIG_MEDIA_TUNER_QM1D1B0004=m

#
# Multistandard (satellite) frontends
#
CONFIG_DVB_STB0899=m
CONFIG_DVB_STB6100=m
CONFIG_DVB_STV090x=m
CONFIG_DVB_STV0910=m
CONFIG_DVB_STV6110x=m
CONFIG_DVB_STV6111=m
CONFIG_DVB_MXL5XX=m
CONFIG_DVB_M88DS3103=m

#
# Multistandard (cable + terrestrial) frontends
#
CONFIG_DVB_DRXK=m
CONFIG_DVB_TDA18271C2DD=m
CONFIG_DVB_SI2165=m
CONFIG_DVB_MN88472=m
CONFIG_DVB_MN88473=m

#
# DVB-S (satellite) frontends
#
CONFIG_DVB_CX24110=m
CONFIG_DVB_CX24123=m
CONFIG_DVB_MT312=m
CONFIG_DVB_ZL10036=m
CONFIG_DVB_ZL10039=m
CONFIG_DVB_S5H1420=m
CONFIG_DVB_STV0288=m
CONFIG_DVB_STB6000=m
CONFIG_DVB_STV0299=m
CONFIG_DVB_STV6110=m
CONFIG_DVB_STV0900=m
CONFIG_DVB_TDA8083=m
CONFIG_DVB_TDA10086=m
CONFIG_DVB_TDA8261=m
CONFIG_DVB_VES1X93=m
CONFIG_DVB_TUNER_ITD1000=m
CONFIG_DVB_TUNER_CX24113=m
CONFIG_DVB_TDA826X=m
CONFIG_DVB_TUA6100=m
CONFIG_DVB_CX24116=m
CONFIG_DVB_CX24117=m
CONFIG_DVB_CX24120=m
CONFIG_DVB_SI21XX=m
CONFIG_DVB_TS2020=m
CONFIG_DVB_DS3000=m
CONFIG_DVB_MB86A16=m
CONFIG_DVB_TDA10071=m

#
# DVB-T (terrestrial) frontends
#
CONFIG_DVB_SP8870=m
CONFIG_DVB_SP887X=m
CONFIG_DVB_CX22700=m
CONFIG_DVB_CX22702=m
CONFIG_DVB_DRXD=m
CONFIG_DVB_L64781=m
CONFIG_DVB_TDA1004X=m
CONFIG_DVB_NXT6000=m
CONFIG_DVB_MT352=m
CONFIG_DVB_ZL10353=m
CONFIG_DVB_DIB3000MB=m
CONFIG_DVB_DIB3000MC=m
CONFIG_DVB_DIB7000M=m
CONFIG_DVB_DIB7000P=m
CONFIG_DVB_TDA10048=m
CONFIG_DVB_AF9013=m
CONFIG_DVB_EC100=m
CONFIG_DVB_STV0367=m
CONFIG_DVB_CXD2820R=m
CONFIG_DVB_CXD2841ER=m
CONFIG_DVB_RTL2830=m
CONFIG_DVB_RTL2832=m
CONFIG_DVB_SI2168=m
CONFIG_DVB_GP8PSK_FE=m

#
# DVB-C (cable) frontends
#
CONFIG_DVB_VES1820=m
CONFIG_DVB_TDA10021=m
CONFIG_DVB_TDA10023=m
CONFIG_DVB_STV0297=m

#
# ATSC (North American/Korean Terrestrial/Cable DTV) frontends #
CONFIG_DVB_NXT200X=m
CONFIG_DVB_OR51211=m
CONFIG_DVB_OR51132=m
CONFIG_DVB_BCM3510=m
CONFIG_DVB_LGDT330X=m
CONFIG_DVB_LGDT3305=m
CONFIG_DVB_LGDT3306A=m
CONFIG_DVB_LG2160=m
CONFIG_DVB_S5H1409=m
CONFIG_DVB_AU8522=m
CONFIG_DVB_AU8522_DTV=m
CONFIG_DVB_AU8522_V4L=m
CONFIG_DVB_S5H1411=m

#
# ISDB-T (terrestrial) frontends
#
CONFIG_DVB_S921=m
CONFIG_DVB_DIB8000=m
CONFIG_DVB_MB86A20S=m

#
# ISDB-S (satellite) & ISDB-T (terrestrial) frontends #
CONFIG_DVB_TC90522=m

#
# Digital terrestrial only tuners/PLL
#
CONFIG_DVB_PLL=m
CONFIG_DVB_TUNER_DIB0070=m
CONFIG_DVB_TUNER_DIB0090=m

#
# SEC control devices for DVB-S
#
CONFIG_DVB_DRX39XYJ=m
CONFIG_DVB_LNBH25=m
CONFIG_DVB_LNBP21=m
CONFIG_DVB_LNBP22=m
CONFIG_DVB_ISL6405=m
CONFIG_DVB_ISL6421=m
CONFIG_DVB_ISL6423=m
CONFIG_DVB_A8293=m
CONFIG_DVB_LGS8GXX=m
CONFIG_DVB_ATBM8830=m
CONFIG_DVB_TDA665x=m
CONFIG_DVB_IX2505V=m
CONFIG_DVB_M88RS2000=m
CONFIG_DVB_AF9033=m

#
# Common Interface (EN50221) controller drivers
#
CONFIG_DVB_CXD2099=m

#
# Tools to develop new frontends
#
CONFIG_DVB_DUMMY_FE=m

#
# Graphics support
#
CONFIG_AGP=y
CONFIG_AGP_AMD64=y
CONFIG_AGP_INTEL=y
CONFIG_AGP_SIS=y
CONFIG_AGP_VIA=y
CONFIG_INTEL_GTT=y
CONFIG_VGA_ARB=y
CONFIG_VGA_ARB_MAX_GPUS=64
CONFIG_VGA_SWITCHEROO=y
CONFIG_DRM=m
CONFIG_DRM_MIPI_DSI=y
CONFIG_DRM_DP_AUX_CHARDEV=y
CONFIG_DRM_DEBUG_SELFTEST=m
CONFIG_DRM_KMS_HELPER=m
CONFIG_DRM_KMS_FB_HELPER=y
CONFIG_DRM_FBDEV_EMULATION=y
CONFIG_DRM_FBDEV_OVERALLOC=100
# CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM is not set
CONFIG_DRM_LOAD_EDID_FIRMWARE=y
# CONFIG_DRM_DP_CEC is not set
CONFIG_DRM_TTM=m
CONFIG_DRM_VM=y
CONFIG_DRM_SCHED=m

#
# I2C encoder or helper chips
#
CONFIG_DRM_I2C_CH7006=m
CONFIG_DRM_I2C_SIL164=m
# CONFIG_DRM_I2C_NXP_TDA998X is not set
# CONFIG_DRM_I2C_NXP_TDA9950 is not set
CONFIG_DRM_RADEON=m
# CONFIG_DRM_RADEON_USERPTR is not set
CONFIG_DRM_AMDGPU=m
# CONFIG_DRM_AMDGPU_SI is not set
# CONFIG_DRM_AMDGPU_CIK is not set
# CONFIG_DRM_AMDGPU_USERPTR is not set
# CONFIG_DRM_AMDGPU_GART_DEBUGFS is not set

#
# ACP (Audio CoProcessor) Configuration
#
# CONFIG_DRM_AMD_ACP is not set

#
# Display Engine Configuration
#
CONFIG_DRM_AMD_DC=y
CONFIG_DRM_AMD_DC_DCN1_0=y
CONFIG_DRM_AMD_DC_DCN1_01=y
# CONFIG_DEBUG_KERNEL_DC is not set
# CONFIG_HSA_AMD is not set

#
# AMD Library routines
#
CONFIG_CHASH=m
# CONFIG_CHASH_STATS is not set
# CONFIG_CHASH_SELFTEST is not set
CONFIG_DRM_NOUVEAU=m
CONFIG_NOUVEAU_DEBUG=5
CONFIG_NOUVEAU_DEBUG_DEFAULT=3
# CONFIG_NOUVEAU_DEBUG_MMU is not set
CONFIG_DRM_NOUVEAU_BACKLIGHT=y
CONFIG_DRM_I915=m
# CONFIG_DRM_I915_ALPHA_SUPPORT is not set
CONFIG_DRM_I915_CAPTURE_ERROR=y
CONFIG_DRM_I915_COMPRESS_ERROR=y
CONFIG_DRM_I915_USERPTR=y
CONFIG_DRM_I915_GVT=y
CONFIG_DRM_I915_GVT_KVMGT=m

#

# drm/i915 Debugging
#
# CONFIG_DRM_I915_WERROR is not set
# CONFIG_DRM_I915_DEBUG is not set
# CONFIG_DRM_I915_SW_FENCE_DEBUG_OBJECTS is not set
# CONFIG_DRM_I915_SW_FENCE_CHECK_DAG is not set
# CONFIG_DRM_I915_DEBUG_GUC is not set
# CONFIG_DRM_I915_SELFTEST is not set
# CONFIG_DRM_I915_LOW_LEVEL_TRACEPOINTS is not set
# CONFIG_DRM_I915_DEBUG_VBLANK_EVADE is not set
# CONFIG_DRM_I915_DEBUG_RUNTIME_PM is not set
CONFIG_DRM_VGEM=m
# CONFIG_DRM_VKMS is not set
CONFIG_DRM_VMWGFX=m
CONFIG_DRM_VMWGFX_FBCON=y
CONFIG_DRM_GMA500=m
CONFIG_DRM_GMA600=y
CONFIG_DRM_GMA3600=y
CONFIG_DRM_UDL=m
CONFIG_DRM_AST=m
CONFIG_DRM_MGAG200=m
CONFIG_DRM_CIRRUS_QEMU=m
CONFIG_DRM_QXL=m
CONFIG_DRM_BOCHS=m
CONFIG_DRM_VIRTIO_GPU=m
CONFIG_DRM_PANEL=y

#
# Display Panels
#
# CONFIG_DRM_PANEL_RASPBERRYPI_TOUCHSCREEN is not set CONFIG_DRM_BRIDGE=y
CONFIG_DRM_PANEL_BRIDGE=y

#
# Display Interface Bridges
#
# CONFIG_DRM_ANALOGIX_ANX78XX is not set
# CONFIG_DRM_HISI_HIBMC is not set
# CONFIG_DRM_TINYDRM is not set
# CONFIG_DRM_XEN is not set
# CONFIG_DRM_LEGACY is not set
CONFIG_DRM_PANEL_ORIENTATION_QUIRKS=y
CONFIG_DRM_LIB_RANDOM=y

#
# Frame buffer Devices
#
CONFIG_FB_CMDLINE=y
CONFIG_FB_NOTIFY=y
CONFIG_FB=y
# CONFIG_FIRMWARE_EDID is not set
CONFIG_FB_BOOT_VESA_SUPPORT=y
CONFIG_FB_CFB_FILLRECT=y
CONFIG_FB_CFB_COPYAREA=y
CONFIG_FB_CFB_IMAGEBLIT=y
CONFIG_FB_SYS_FILLRECT=m
CONFIG_FB_SYS_COPYAREA=m
CONFIG_FB_SYS_IMAGEBLIT=m
# CONFIG_FB_FOREIGN_ENDIAN is not set
CONFIG_FB_SYS_FOPS=m
CONFIG_FB_DEFERRED_IO=y
# CONFIG_FB_MODE_HELPERS is not set
CONFIG_FB_TILEBLITTING=y

#
# Frame buffer hardware drivers
#
# CONFIG_FB_CIRRUS is not set
# CONFIG_FB_PM2 is not set
# CONFIG_FB_CYBER2000 is not set
# CONFIG_FB_ARC is not set
# CONFIG_FB_ASILIANT is not set
# CONFIG_FB_IMSTT is not set
# CONFIG_FB_VGA16 is not set
# CONFIG_FB_UVESA is not set
CONFIG_FB_VESA=y
CONFIG_FB_EFI=y
# CONFIG_FB_N411 is not set
# CONFIG_FB_HGA is not set
# CONFIG_FB_OPENCORES is not set
# CONFIG_FB_S1D13XXX is not set
# CONFIG_FB_NVIDIA is not set
# CONFIG_FB_RIVA is not set
# CONFIG_FB_I740 is not set
# CONFIG_FB_LE80578 is not set
# CONFIG_FB_INTEL is not set
# CONFIG_FB_MATROX is not set
# CONFIG_FB_RADEON is not set
# CONFIG_FB_ATY128 is not set
# CONFIG_FB_ATY is not set
# CONFIG_FB_S3 is not set
# CONFIG_FB_SAVAGE is not set
# CONFIG_FB_SIS is not set
# CONFIG_FB_VIA is not set
# CONFIG_FB_NEOMAGIC is not set
# CONFIG_FB_KYRO is not set
# CONFIG_FB_3DFX is not set
# CONFIG_FB_VOODOO1 is not set
# CONFIG_FB_VT8623 is not set
# CONFIG_FB_TRIDENT is not set
# CONFIG_FB_ARK is not set
# CONFIG_FB_PM3 is not set
# CONFIG_FB_CARMINE is not set
# CONFIG_FB_SM501 is not set
# CONFIG_FB_SMSCUFX is not set
# CONFIG_FB_UDL is not set
# CONFIG_FB_IBM_GXT4500 is not set
# CONFIG_FB_VIRTUAL is not set
# CONFIG_XEN_FBDEV_FRONTEND is not set
# CONFIG_FB_METRONOME is not set
# CONFIG_FB_MB862XX is not set
CONFIG_FB_HYPERV=m
# CONFIG_FB_SIMPLE is not set
# CONFIG_FB_SM712 is not set
CONFIG_BACKLIGHT_LCD_SUPPORT=y
CONFIG_LCD_CLASS_DEVICE=m
# CONFIG_LCD_L4F00242T03 is not set
# CONFIG_LCD_LMS283GF05 is not set
# CONFIG_LCD_LTV350QV is not set
# CONFIG_LCD_ILI922X is not set
# CONFIG_LCD_ILI9320 is not set
# CONFIG_LCD_TDO24M is not set
# CONFIG_LCD_VGG2432A4 is not set
CONFIG_LCD_PLATFORM=m
# CONFIG_LCD_AMS369FG06 is not set
# CONFIG_LCD_LMS501KF03 is not set
# CONFIG_LCD_HX8357 is not set
# CONFIG_LCD_OTM3225A is not set
CONFIG_BACKLIGHT_CLASS_DEVICE=y
# CONFIG_BACKLIGHT_GENERIC is not set
# CONFIG_BACKLIGHT_PWM is not set
CONFIG_BACKLIGHT_APPLE=m
# CONFIG_BACKLIGHT_PM8941_WLED is not set
# CONFIG_BACKLIGHT_SAHARA is not set
# CONFIG_BACKLIGHT_ADP8860 is not set
# CONFIG_BACKLIGHT_ADP8870 is not set
# CONFIG_BACKLIGHT_LM3630A is not set
# CONFIG_BACKLIGHT_LM3639 is not set
CONFIG_BACKLIGHT_LP855X=m
# CONFIG_BACKLIGHT_GPIO is not set
# CONFIG_BACKLIGHT_LV5207LP is not set
# CONFIG_BACKLIGHT_BD6107 is not set
# CONFIG_BACKLIGHT_ARCXCNN is not set
CONFIG_HDMI=y

#
# Console display driver support
#
CONFIG_VGA_CONSOLE=y
CONFIG_VGACON_SOFT_SCROLLBACK=y CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=64
# CONFIG_VGACON_SOFT_SCROLLBACK_PERSISTENT_ENABLE_BY_DEFAULT is not set CONFIG_DUMMY_CONSOLE=y
CONFIG_DUMMY_CONSOLE_COLUMNS=80
CONFIG_DUMMY_CONSOLE_ROWS=25
CONFIG_FRAMEBUFFER_CONSOLE=y CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
# CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER is not set CONFIG_LOGO=y
# CONFIG_LOGO_LINUX_MONO is not set
# CONFIG_LOGO_LINUX_VGA16 is not set CONFIG_LOGO_LINUX_CLUT224=y
CONFIG_SOUND=m
CONFIG_SOUND_OSS_CORE=y
CONFIG_SOUND_OSS_CORE_PRECLAIM=y
CONFIG_SND=m
CONFIG_SND_TIMER=m
CONFIG_SND_PCM=m
CONFIG_SND_PCM_ELD=y
CONFIG_SND_HWDEP=m
CONFIG_SND_SEQ_DEVICE=m
CONFIG_SND_RAWMIDI=m
CONFIG_SND_COMPRESS_OFFLOAD=m
CONFIG_SND_JACK=y
CONFIG_SND_JACK_INPUT_DEV=y
CONFIG_SND_OSSEMUL=y
# CONFIG_SND_MIXER_OSS is not set
# CONFIG_SND_PCM_OSS is not set
CONFIG_SND_PCM_TIMER=y
CONFIG_SND_HRTIMER=m
CONFIG_SND_DYNAMIC_MINORS=y
CONFIG_SND_MAX_CARDS=32
# CONFIG_SND_SUPPORT_OLD_API is not set
CONFIG_SND_PROC_FS=y
CONFIG_SND_VERBOSE_PROCFS=y
# CONFIG_SND_VERBOSE_PRINTK is not set
# CONFIG_SND_DEBUG is not set
CONFIG_SND_VMASTER=y
CONFIG_SND_DMA_SGBUF=y
CONFIG_SND_SEQUENCER=m
CONFIG_SND_SEQ_DUMMY=m
CONFIG_SND_SEQUENCER_OSS=m
CONFIG_SND_SEQ_HRTIMER_DEFAULT=y
CONFIG_SND_SEQ_MIDI_EVENT=m
CONFIG_SND_SEQ_MIDI=m
CONFIG_SND_SEQ_MIDI_EMUL=m
CONFIG_SND_SEQ_VIRMIDI=m
CONFIG_SND_MPU401_UART=m
CONFIG_SND_OPL3_LIB=m
CONFIG_SND_OPL3_LIB_SEQ=m
CONFIG_SND_VX_LIB=m
CONFIG_SND_AC97_CODEC=m
CONFIG_SND_DRIVERS=y
CONFIG_SND_PCSP=m
CONFIG_SND_DUMMY=m
CONFIG_SND_ALOOP=m
CONFIG_SND_VIRMIDI=m
CONFIG_SND_MTPAV=m
# CONFIG_SND_MTS64 is not set
# CONFIG_SND_SERIAL_U16550 is not set
CONFIG_SND_MPU401=m
# CONFIG_SND_PORTMAN2X4 is not set CONFIG_SND_AC97_POWER_SAVE=y CONFIG_SND_AC97_POWER_SAVE_DEFAULT=5
CONFIG_SND_PCI=y
CONFIG_SND_AD1889=m
# CONFIG_SND_ALS300 is not set
# CONFIG_SND_ALS4000 is not set
CONFIG_SND_ALI5451=m
CONFIG_SND_ASIHPI=m
CONFIG_SND_ATIIXP=m
CONFIG_SND_ATIIXP_MODEM=m
CONFIG_SND_AU8810=m
CONFIG_SND_AU8820=m
CONFIG_SND_AU8830=m
# CONFIG_SND_AW2 is not set
# CONFIG_SND_AZT3328 is not set
CONFIG_SND_BT87X=m
# CONFIG_SND_BT87X_OVERCLOCK is not set
CONFIG_SND_CA0106=m
CONFIG_SND_CMIPCI=m
CONFIG_SND_OXYGEN_LIB=m
CONFIG_SND_OXYGEN=m
# CONFIG_SND_CS4281 is not set
CONFIG_SND_CS46XX=m
CONFIG_SND_CS46XX_NEW_DSP=y
CONFIG_SND_CTXFI=m
CONFIG_SND_DARLA20=m
CONFIG_SND_GINA20=m
CONFIG_SND_LAYLA20=m
CONFIG_SND_DARLA24=m
CONFIG_SND_GINA24=m
CONFIG_SND_LAYLA24=m
CONFIG_SND_MONA=m
CONFIG_SND_MIA=m
CONFIG_SND_ECHO3G=m
CONFIG_SND_INDIGO=m
CONFIG_SND_INDIGOIO=m
CONFIG_SND_INDIGODJ=m
CONFIG_SND_INDIGOIOX=m
CONFIG_SND_INDIGODJX=m
CONFIG_SND_EMU10K1=m
CONFIG_SND_EMU10K1_SEQ=m
CONFIG_SND_EMU10K1X=m
CONFIG_SND_ENS1370=m
CONFIG_SND_ENS1371=m
# CONFIG_SND_ES1938 is not set
CONFIG_SND_ES1968=m
CONFIG_SND_ES1968_INPUT=y
CONFIG_SND_ES1968_RADIO=y
# CONFIG_SND_FM801 is not set
CONFIG_SND_HDSP=m
CONFIG_SND_HDSPM=m
CONFIG_SND_ICE1712=m
CONFIG_SND_ICE1724=m
CONFIG_SND_INTEL8X0=m
CONFIG_SND_INTEL8X0M=m
CONFIG_SND_KORG1212=m
CONFIG_SND_LOLA=m
CONFIG_SND_LX6464ES=m
CONFIG_SND_MAESTRO3=m
CONFIG_SND_MAESTRO3_INPUT=y
CONFIG_SND_MIXART=m
# CONFIG_SND_NM256 is not set
CONFIG_SND_PCXHR=m
# CONFIG_SND_RIPTIDE is not set
CONFIG_SND_RME32=m
CONFIG_SND_RME96=m
CONFIG_SND_RME9652=m
# CONFIG_SND_SONICVIBES is not set
CONFIG_SND_TRIDENT=m
CONFIG_SND_VIA82XX=m
CONFIG_SND_VIA82XX_MODEM=m
CONFIG_SND_VIRTUOSO=m
CONFIG_SND_VX222=m
# CONFIG_SND_YMFPCI is not set

#
# HD-Audio
#
CONFIG_SND_HDA=m
CONFIG_SND_HDA_INTEL=m
CONFIG_SND_HDA_HWDEP=y
CONFIG_SND_HDA_RECONFIG=y
CONFIG_SND_HDA_INPUT_BEEP=y
CONFIG_SND_HDA_INPUT_BEEP_MODE=0
CONFIG_SND_HDA_PATCH_LOADER=y
CONFIG_SND_HDA_CODEC_REALTEK=m
CONFIG_SND_HDA_CODEC_ANALOG=m
CONFIG_SND_HDA_CODEC_SIGMATEL=m
CONFIG_SND_HDA_CODEC_VIA=m
CONFIG_SND_HDA_CODEC_HDMI=m
CONFIG_SND_HDA_CODEC_CIRRUS=m
CONFIG_SND_HDA_CODEC_CONEXANT=m
CONFIG_SND_HDA_CODEC_CA0110=m
CONFIG_SND_HDA_CODEC_CA0132=m
CONFIG_SND_HDA_CODEC_CA0132_DSP=y
CONFIG_SND_HDA_CODEC_CMEDIA=m
CONFIG_SND_HDA_CODEC_SI3054=m
CONFIG_SND_HDA_GENERIC=m
CONFIG_SND_HDA_POWER_SAVE_DEFAULT=0
CONFIG_SND_HDA_CORE=m
CONFIG_SND_HDA_DSP_LOADER=y
CONFIG_SND_HDA_COMPONENT=y
CONFIG_SND_HDA_I915=y
CONFIG_SND_HDA_EXT_CORE=m
CONFIG_SND_HDA_PREALLOC_SIZE=512
# CONFIG_SND_SPI is not set
CONFIG_SND_USB=y
CONFIG_SND_USB_AUDIO=m
CONFIG_SND_USB_UA101=m
CONFIG_SND_USB_USX2Y=m
CONFIG_SND_USB_CAIAQ=m
CONFIG_SND_USB_CAIAQ_INPUT=y
CONFIG_SND_USB_US122L=m
CONFIG_SND_USB_6FIRE=m
CONFIG_SND_USB_HIFACE=m
CONFIG_SND_BCD2000=m
CONFIG_SND_USB_LINE6=m
CONFIG_SND_USB_POD=m
CONFIG_SND_USB_PODHD=m
CONFIG_SND_USB_TONEPORT=m
CONFIG_SND_USB_VARIAX=m
CONFIG_SND_FIREWIRE=y
CONFIG_SND_FIREWIRE_LIB=m
# CONFIG_SND_DICE is not set
# CONFIG_SND_OXFW is not set
CONFIG_SND_ISIGHT=m
# CONFIG_SND_FIREWORKS is not set
# CONFIG_SND_BEBOB is not set
# CONFIG_SND_FIREWIRE_DIGI00X is not set
# CONFIG_SND_FIREWIRE_TASCAM is not set
# CONFIG_SND_FIREWIRE_MOTU is not set
# CONFIG_SND_FIREFACE is not set
CONFIG_SND_SOC=m
CONFIG_SND_SOC_COMPRESS=y
CONFIG_SND_SOC_TOPOLOGY=y
CONFIG_SND_SOC_ACPI=m
# CONFIG_SND_SOC_AMD_ACP is not set
# CONFIG_SND_SOC_AMD_ACP3x is not set
# CONFIG_SND_ATMEL_SOC is not set
# CONFIG_SND_DESIGNWARE_I2S is not set

#
# SoC Audio for Freescale CPUs
#

#
# Common SoC Audio options for Freescale CPUs:
#
# CONFIG_SND_SOC_FSL_ASRC is not set
# CONFIG_SND_SOC_FSL_SAI is not set
# CONFIG_SND_SOC_FSL_SSI is not set
# CONFIG_SND_SOC_FSL_SPDIF is not set
# CONFIG_SND_SOC_FSL_ESAI is not set
# CONFIG_SND_SOC_IMX_AUDMUX is not set
# CONFIG_SND_I2S_HI6210_I2S is not set
# CONFIG_SND_SOC_IMG is not set CONFIG_SND_SOC_INTEL_SST_TOPLEVEL=y CONFIG_SND_SST_IPC=m
CONFIG_SND_SST_IPC_ACPI=m CONFIG_SND_SOC_INTEL_SST_ACPI=m CONFIG_SND_SOC_INTEL_SST=m CONFIG_SND_SOC_INTEL_SST_FIRMWARE=m CONFIG_SND_SOC_INTEL_HASWELL=m CONFIG_SND_SST_ATOM_HIFI2_PLATFORM=m
# CONFIG_SND_SST_ATOM_HIFI2_PLATFORM_PCI is not set CONFIG_SND_SST_ATOM_HIFI2_PLATFORM_ACPI=m CONFIG_SND_SOC_INTEL_SKYLAKE=m CONFIG_SND_SOC_INTEL_SKL=m CONFIG_SND_SOC_INTEL_APL=m CONFIG_SND_SOC_INTEL_KBL=m CONFIG_SND_SOC_INTEL_GLK=m CONFIG_SND_SOC_INTEL_CNL=m CONFIG_SND_SOC_INTEL_CFL=m CONFIG_SND_SOC_INTEL_SKYLAKE_FAMILY=m CONFIG_SND_SOC_INTEL_SKYLAKE_SSP_CLK=m
# CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC is not set CONFIG_SND_SOC_INTEL_SKYLAKE_COMMON=m CONFIG_SND_SOC_ACPI_INTEL_MATCH=m CONFIG_SND_SOC_INTEL_MACH=y CONFIG_SND_SOC_INTEL_HASWELL_MACH=m CONFIG_SND_SOC_INTEL_BDW_RT5677_MACH=m CONFIG_SND_SOC_INTEL_BROADWELL_MACH=m CONFIG_SND_SOC_INTEL_BYTCR_RT5640_MACH=m CONFIG_SND_SOC_INTEL_BYTCR_RT5651_MACH=m CONFIG_SND_SOC_INTEL_CHT_BSW_RT5672_MACH=m CONFIG_SND_SOC_INTEL_CHT_BSW_RT5645_MACH=m CONFIG_SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH=m
# CONFIG_SND_SOC_INTEL_CHT_BSW_NAU8824_MACH is not set CONFIG_SND_SOC_INTEL_BYT_CHT_DA7213_MACH=m CONFIG_SND_SOC_INTEL_BYT_CHT_ES8316_MACH=m CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH=m CONFIG_SND_SOC_INTEL_SKL_RT286_MACH=m CONFIG_SND_SOC_INTEL_SKL_NAU88L25_SSM4567_MACH=m CONFIG_SND_SOC_INTEL_SKL_NAU88L25_MAX98357A_MACH=m CONFIG_SND_SOC_INTEL_BXT_DA7219_MAX98357A_MACH=m CONFIG_SND_SOC_INTEL_BXT_RT298_MACH=m CONFIG_SND_SOC_INTEL_KBL_RT5663_MAX98927_MACH=m CONFIG_SND_SOC_INTEL_KBL_RT5663_RT5514_MAX98927_MACH=m # CONFIG_SND_SOC_INTEL_KBL_DA7219_MAX98357A_MACH is not set # CONFIG_SND_SOC_INTEL_KBL_DA7219_MAX98927_MACH is not set # CONFIG_SND_SOC_INTEL_KBL_RT5660_MACH is not set # CONFIG_SND_SOC_INTEL_GLK_RT5682_MAX98357A_MACH is not set

#
# STMicroelectronics STM32 SOC audio support
#
# CONFIG_SND_SOC_XILINX_I2S is not set
# CONFIG_SND_SOC_XTFPGA_I2S is not set
# CONFIG_ZX_TDM is not set
CONFIG_SND_SOC_I2C_AND_SPI=m

#
# CODEC drivers
#
# CONFIG_SND_SOC_AC97_CODEC is not set
# CONFIG_SND_SOC_ADAU1701 is not set
# CONFIG_SND_SOC_ADAU1761_I2C is not set
# CONFIG_SND_SOC_ADAU1761_SPI is not set
# CONFIG_SND_SOC_ADAU7002 is not set
# CONFIG_SND_SOC_AK4104 is not set
# CONFIG_SND_SOC_AK4118 is not set
# CONFIG_SND_SOC_AK4458 is not set
# CONFIG_SND_SOC_AK4554 is not set
# CONFIG_SND_SOC_AK4613 is not set
# CONFIG_SND_SOC_AK4642 is not set
# CONFIG_SND_SOC_AK5386 is not set
# CONFIG_SND_SOC_AK5558 is not set
# CONFIG_SND_SOC_ALC5623 is not set
# CONFIG_SND_SOC_BD28623 is not set
# CONFIG_SND_SOC_BT_SCO is not set
# CONFIG_SND_SOC_CS35L32 is not set
# CONFIG_SND_SOC_CS35L33 is not set
# CONFIG_SND_SOC_CS35L34 is not set
# CONFIG_SND_SOC_CS35L35 is not set
# CONFIG_SND_SOC_CS42L42 is not set
# CONFIG_SND_SOC_CS42L51_I2C is not set
# CONFIG_SND_SOC_CS42L52 is not set
# CONFIG_SND_SOC_CS42L56 is not set
# CONFIG_SND_SOC_CS42L73 is not set
# CONFIG_SND_SOC_CS4265 is not set
# CONFIG_SND_SOC_CS4270 is not set
# CONFIG_SND_SOC_CS4271_I2C is not set
# CONFIG_SND_SOC_CS4271_SPI is not set
# CONFIG_SND_SOC_CS42XX8_I2C is not set
# CONFIG_SND_SOC_CS43130 is not set
# CONFIG_SND_SOC_CS4349 is not set
# CONFIG_SND_SOC_CS53L30 is not set
CONFIG_SND_SOC_DA7213=m
CONFIG_SND_SOC_DA7219=m
CONFIG_SND_SOC_DMIC=m
# CONFIG_SND_SOC_ES7134 is not set
# CONFIG_SND_SOC_ES7241 is not set
CONFIG_SND_SOC_ES8316=m
# CONFIG_SND_SOC_ES8328_I2C is not set
# CONFIG_SND_SOC_ES8328_SPI is not set
# CONFIG_SND_SOC_GTM601 is not set
CONFIG_SND_SOC_HDAC_HDMI=m
# CONFIG_SND_SOC_INNO_RK3036 is not set
# CONFIG_SND_SOC_MAX98088 is not set
CONFIG_SND_SOC_MAX98090=m
CONFIG_SND_SOC_MAX98357A=m
# CONFIG_SND_SOC_MAX98504 is not set
# CONFIG_SND_SOC_MAX9867 is not set
CONFIG_SND_SOC_MAX98927=m
# CONFIG_SND_SOC_MAX98373 is not set
# CONFIG_SND_SOC_MAX9860 is not set
# CONFIG_SND_SOC_MSM8916_WCD_DIGITAL is not set
# CONFIG_SND_SOC_PCM1681 is not set
# CONFIG_SND_SOC_PCM1789_I2C is not set
# CONFIG_SND_SOC_PCM179X_I2C is not set
# CONFIG_SND_SOC_PCM179X_SPI is not set
# CONFIG_SND_SOC_PCM186X_I2C is not set
# CONFIG_SND_SOC_PCM186X_SPI is not set
# CONFIG_SND_SOC_PCM3060_I2C is not set
# CONFIG_SND_SOC_PCM3060_SPI is not set
# CONFIG_SND_SOC_PCM3168A_I2C is not set
# CONFIG_SND_SOC_PCM3168A_SPI is not set
# CONFIG_SND_SOC_PCM512x_I2C is not set
# CONFIG_SND_SOC_PCM512x_SPI is not set
CONFIG_SND_SOC_RL6231=m
CONFIG_SND_SOC_RL6347A=m
CONFIG_SND_SOC_RT286=m
CONFIG_SND_SOC_RT298=m
CONFIG_SND_SOC_RT5514=m
CONFIG_SND_SOC_RT5514_SPI=m
# CONFIG_SND_SOC_RT5616 is not set
# CONFIG_SND_SOC_RT5631 is not set
CONFIG_SND_SOC_RT5640=m
CONFIG_SND_SOC_RT5645=m
CONFIG_SND_SOC_RT5651=m
CONFIG_SND_SOC_RT5663=m
CONFIG_SND_SOC_RT5670=m
CONFIG_SND_SOC_RT5677=m
CONFIG_SND_SOC_RT5677_SPI=m
# CONFIG_SND_SOC_SGTL5000 is not set
# CONFIG_SND_SOC_SIMPLE_AMPLIFIER is not set
# CONFIG_SND_SOC_SIRF_AUDIO_CODEC is not set
# CONFIG_SND_SOC_SPDIF is not set
# CONFIG_SND_SOC_SSM2305 is not set
# CONFIG_SND_SOC_SSM2602_SPI is not set
# CONFIG_SND_SOC_SSM2602_I2C is not set
CONFIG_SND_SOC_SSM4567=m
# CONFIG_SND_SOC_STA32X is not set
# CONFIG_SND_SOC_STA350 is not set
# CONFIG_SND_SOC_STI_SAS is not set
# CONFIG_SND_SOC_TAS2552 is not set
# CONFIG_SND_SOC_TAS5086 is not set
# CONFIG_SND_SOC_TAS571X is not set
# CONFIG_SND_SOC_TAS5720 is not set
# CONFIG_SND_SOC_TAS6424 is not set
# CONFIG_SND_SOC_TDA7419 is not set
# CONFIG_SND_SOC_TFA9879 is not set
# CONFIG_SND_SOC_TLV320AIC23_I2C is not set
# CONFIG_SND_SOC_TLV320AIC23_SPI is not set
# CONFIG_SND_SOC_TLV320AIC31XX is not set
# CONFIG_SND_SOC_TLV320AIC32X4_I2C is not set
# CONFIG_SND_SOC_TLV320AIC32X4_SPI is not set
# CONFIG_SND_SOC_TLV320AIC3X is not set
CONFIG_SND_SOC_TS3A227E=m
# CONFIG_SND_SOC_TSCS42XX is not set
# CONFIG_SND_SOC_TSCS454 is not set
# CONFIG_SND_SOC_WM8510 is not set
# CONFIG_SND_SOC_WM8523 is not set
# CONFIG_SND_SOC_WM8524 is not set
# CONFIG_SND_SOC_WM8580 is not set
# CONFIG_SND_SOC_WM8711 is not set
# CONFIG_SND_SOC_WM8728 is not set
# CONFIG_SND_SOC_WM8731 is not set
# CONFIG_SND_SOC_WM8737 is not set
# CONFIG_SND_SOC_WM8741 is not set
# CONFIG_SND_SOC_WM8750 is not set
# CONFIG_SND_SOC_WM8753 is not set
# CONFIG_SND_SOC_WM8770 is not set
# CONFIG_SND_SOC_WM8776 is not set
# CONFIG_SND_SOC_WM8782 is not set
# CONFIG_SND_SOC_WM8804_I2C is not set
# CONFIG_SND_SOC_WM8804_SPI is not set
# CONFIG_SND_SOC_WM8903 is not set
# CONFIG_SND_SOC_WM8960 is not set
# CONFIG_SND_SOC_WM8962 is not set
# CONFIG_SND_SOC_WM8974 is not set
# CONFIG_SND_SOC_WM8978 is not set
# CONFIG_SND_SOC_WM8985 is not set
# CONFIG_SND_SOC_ZX_AUD96P22 is not set
# CONFIG_SND_SOC_MAX9759 is not set
# CONFIG_SND_SOC_MT6351 is not set
# CONFIG_SND_SOC_NAU8540 is not set
# CONFIG_SND_SOC_NAU8810 is not set
# CONFIG_SND_SOC_NAU8822 is not set
CONFIG_SND_SOC_NAU8824=m
CONFIG_SND_SOC_NAU8825=m
# CONFIG_SND_SOC_TPA6130A2 is not set
# CONFIG_SND_SIMPLE_CARD is not set
CONFIG_SND_X86=y
CONFIG_HDMI_LPE_AUDIO=m
CONFIG_SND_SYNTH_EMUX=m
# CONFIG_SND_XEN_FRONTEND is not set
CONFIG_AC97_BUS=m

#
# HID support
#
CONFIG_HID=y
CONFIG_HID_BATTERY_STRENGTH=y
CONFIG_HIDRAW=y
CONFIG_UHID=m
CONFIG_HID_GENERIC=y

#
# Special HID drivers
#
CONFIG_HID_A4TECH=y
# CONFIG_HID_ACCUTOUCH is not set
CONFIG_HID_ACRUX=m
# CONFIG_HID_ACRUX_FF is not set
CONFIG_HID_APPLE=y
CONFIG_HID_APPLEIR=m
# CONFIG_HID_ASUS is not set
CONFIG_HID_AUREAL=m
CONFIG_HID_BELKIN=y
# CONFIG_HID_BETOP_FF is not set
# CONFIG_HID_BIGBEN_FF is not set
CONFIG_HID_CHERRY=y
CONFIG_HID_CHICONY=y
# CONFIG_HID_CORSAIR is not set
# CONFIG_HID_COUGAR is not set
CONFIG_HID_PRODIKEYS=m
# CONFIG_HID_CMEDIA is not set
# CONFIG_HID_CP2112 is not set
CONFIG_HID_CYPRESS=y
CONFIG_HID_DRAGONRISE=m
# CONFIG_DRAGONRISE_FF is not set
# CONFIG_HID_EMS_FF is not set
# CONFIG_HID_ELAN is not set
CONFIG_HID_ELECOM=m
# CONFIG_HID_ELO is not set
CONFIG_HID_EZKEY=y
# CONFIG_HID_GEMBIRD is not set
# CONFIG_HID_GFRM is not set
CONFIG_HID_HOLTEK=m
# CONFIG_HOLTEK_FF is not set
# CONFIG_HID_GT683R is not set
CONFIG_HID_KEYTOUCH=m
CONFIG_HID_KYE=m
CONFIG_HID_UCLOGIC=m
CONFIG_HID_WALTOP=m
CONFIG_HID_GYRATION=m
CONFIG_HID_ICADE=m
CONFIG_HID_ITE=y
# CONFIG_HID_JABRA is not set
CONFIG_HID_TWINHAN=m
CONFIG_HID_KENSINGTON=y
CONFIG_HID_LCPOWER=m
CONFIG_HID_LED=m
# CONFIG_HID_LENOVO is not set
CONFIG_HID_LOGITECH=y
CONFIG_HID_LOGITECH_DJ=m
CONFIG_HID_LOGITECH_HIDPP=m
# CONFIG_LOGITECH_FF is not set
# CONFIG_LOGIRUMBLEPAD2_FF is not set
# CONFIG_LOGIG940_FF is not set
# CONFIG_LOGIWHEELS_FF is not set
CONFIG_HID_MAGICMOUSE=y
# CONFIG_HID_MAYFLASH is not set
CONFIG_HID_REDRAGON=y
CONFIG_HID_MICROSOFT=y
CONFIG_HID_MONTEREY=y
CONFIG_HID_MULTITOUCH=m
# CONFIG_HID_NTI is not set
CONFIG_HID_NTRIG=y
CONFIG_HID_ORTEK=m
CONFIG_HID_PANTHERLORD=m
# CONFIG_PANTHERLORD_FF is not set
# CONFIG_HID_PENMOUNT is not set
CONFIG_HID_PETALYNX=m
CONFIG_HID_PICOLCD=m
CONFIG_HID_PICOLCD_FB=y
CONFIG_HID_PICOLCD_BACKLIGHT=y
CONFIG_HID_PICOLCD_LCD=y
CONFIG_HID_PICOLCD_LEDS=y
CONFIG_HID_PICOLCD_CIR=y
CONFIG_HID_PLANTRONICS=y
CONFIG_HID_PRIMAX=m
# CONFIG_HID_RETRODE is not set
CONFIG_HID_ROCCAT=m
CONFIG_HID_SAITEK=m
CONFIG_HID_SAMSUNG=m
CONFIG_HID_SONY=m
# CONFIG_SONY_FF is not set
CONFIG_HID_SPEEDLINK=m
# CONFIG_HID_STEAM is not set
CONFIG_HID_STEELSERIES=m
CONFIG_HID_SUNPLUS=m
CONFIG_HID_RMI=m
CONFIG_HID_GREENASIA=m
# CONFIG_GREENASIA_FF is not set
CONFIG_HID_HYPERV_MOUSE=m
CONFIG_HID_SMARTJOYPLUS=m
# CONFIG_SMARTJOYPLUS_FF is not set
CONFIG_HID_TIVO=m
CONFIG_HID_TOPSEED=m
CONFIG_HID_THINGM=m
CONFIG_HID_THRUSTMASTER=m
# CONFIG_THRUSTMASTER_FF is not set
# CONFIG_HID_UDRAW_PS3 is not set
CONFIG_HID_WACOM=m
CONFIG_HID_WIIMOTE=m
# CONFIG_HID_XINMO is not set
CONFIG_HID_ZEROPLUS=m
# CONFIG_ZEROPLUS_FF is not set
CONFIG_HID_ZYDACRON=m
CONFIG_HID_SENSOR_HUB=m
CONFIG_HID_SENSOR_CUSTOM_SENSOR=m
CONFIG_HID_ALPS=m

#
# USB HID support
#
CONFIG_USB_HID=y
CONFIG_HID_PID=y
CONFIG_USB_HIDDEV=y

#
# I2C HID support
#
CONFIG_I2C_HID=m

#
# Intel ISH HID support
#
CONFIG_INTEL_ISH_HID=y
CONFIG_USB_OHCI_LITTLE_ENDIAN=y
CONFIG_USB_SUPPORT=y
CONFIG_USB_COMMON=y
CONFIG_USB_ARCH_HAS_HCD=y
CONFIG_USB=y
CONFIG_USB_PCI=y
CONFIG_USB_ANNOUNCE_NEW_DEVICES=y

#
# Miscellaneous USB options
#
CONFIG_USB_DEFAULT_PERSIST=y
# CONFIG_USB_DYNAMIC_MINORS is not set
# CONFIG_USB_OTG is not set
# CONFIG_USB_OTG_WHITELIST is not set
# CONFIG_USB_OTG_BLACKLIST_HUB is not set
CONFIG_USB_LEDS_TRIGGER_USBPORT=m
CONFIG_USB_MON=y
CONFIG_USB_WUSB=m
CONFIG_USB_WUSB_CBAF=m
# CONFIG_USB_WUSB_CBAF_DEBUG is not set

#
# USB Host Controller Drivers
#
# CONFIG_USB_C67X00_HCD is not set
CONFIG_USB_XHCI_HCD=y
# CONFIG_USB_XHCI_DBGCAP is not set
CONFIG_USB_XHCI_PCI=y
# CONFIG_USB_XHCI_PLATFORM is not set
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_EHCI_ROOT_HUB_TT=y
CONFIG_USB_EHCI_TT_NEWSCHED=y
CONFIG_USB_EHCI_PCI=y
# CONFIG_USB_EHCI_HCD_PLATFORM is not set
# CONFIG_USB_OXU210HP_HCD is not set
# CONFIG_USB_ISP116X_HCD is not set
# CONFIG_USB_FOTG210_HCD is not set
# CONFIG_USB_MAX3421_HCD is not set
CONFIG_USB_OHCI_HCD=y
CONFIG_USB_OHCI_HCD_PCI=y
# CONFIG_USB_OHCI_HCD_PLATFORM is not set
CONFIG_USB_UHCI_HCD=y
# CONFIG_USB_U132_HCD is not set
# CONFIG_USB_SL811_HCD is not set
# CONFIG_USB_R8A66597_HCD is not set
# CONFIG_USB_WHCI_HCD is not set
CONFIG_USB_HWA_HCD=m
# CONFIG_USB_HCD_BCMA is not set
# CONFIG_USB_HCD_SSB is not set
# CONFIG_USB_HCD_TEST_MODE is not set

#
# USB Device Class drivers
#
CONFIG_USB_ACM=m
CONFIG_USB_PRINTER=m
CONFIG_USB_WDM=m
CONFIG_USB_TMC=m

#
# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may #

#

# also be needed; see USB_STORAGE Help for more info
#
CONFIG_USB_STORAGE=m
# CONFIG_USB_STORAGE_DEBUG is not set
CONFIG_USB_STORAGE_REALTEK=m
CONFIG_REALTEK_AUTOPM=y
CONFIG_USB_STORAGE_DATAFAB=m
CONFIG_USB_STORAGE_FREECOM=m
CONFIG_USB_STORAGE_ISD200=m
CONFIG_USB_STORAGE_USBAT=m
CONFIG_USB_STORAGE_SDDR09=m
CONFIG_USB_STORAGE_SDDR55=m
CONFIG_USB_STORAGE_JUMPSHOT=m
CONFIG_USB_STORAGE_ALAUDA=m
CONFIG_USB_STORAGE_ONETOUCH=m
CONFIG_USB_STORAGE_KARMA=m
CONFIG_USB_STORAGE_CYPRESS_ATACB=m
CONFIG_USB_STORAGE_ENE_UB6250=m
CONFIG_USB_UAS=m

#
# USB Imaging devices
#
CONFIG_USB_MDC800=m
CONFIG_USB_MICROTEK=m
CONFIG_USBIP_CORE=m
# CONFIG_USBIP_VHCI_HCD is not set
# CONFIG_USBIP_HOST is not set
# CONFIG_USBIP_DEBUG is not set
# CONFIG_USB_MUSB_HDRC is not set
# CONFIG_USB_DWC3 is not set
# CONFIG_USB_DWC2 is not set
# CONFIG_USB_CHIPIDEA is not set
# CONFIG_USB_ISP1760 is not set

#
# USB port drivers
#
CONFIG_USB_USS720=m
CONFIG_USB_SERIAL=y
CONFIG_USB_SERIAL_CONSOLE=y
CONFIG_USB_SERIAL_GENERIC=y
# CONFIG_USB_SERIAL_SIMPLE is not set
CONFIG_USB_SERIAL_AIRCABLE=m
CONFIG_USB_SERIAL_ARK3116=m
CONFIG_USB_SERIAL_BELKIN=m
CONFIG_USB_SERIAL_CH341=m
CONFIG_USB_SERIAL_WHITEHEAT=m
CONFIG_USB_SERIAL_DIGI_ACCELEPORT=m
CONFIG_USB_SERIAL_CP210X=m
CONFIG_USB_SERIAL_CYPRESS_M8=m
CONFIG_USB_SERIAL_EMPEG=m
CONFIG_USB_SERIAL_FTDI_SIO=m
CONFIG_USB_SERIAL_VISOR=m
CONFIG_USB_SERIAL_IPAQ=m
CONFIG_USB_SERIAL_IR=m
CONFIG_USB_SERIAL_EDGEPORT=m
CONFIG_USB_SERIAL_EDGEPORT_TI=m
# CONFIG_USB_SERIAL_F81232 is not set
# CONFIG_USB_SERIAL_F8153X is not set
CONFIG_USB_SERIAL_GARMIN=m
CONFIG_USB_SERIAL_IPW=m
CONFIG_USB_SERIAL_IUU=m
CONFIG_USB_SERIAL_KEYSPAN_PDA=m
CONFIG_USB_SERIAL_KEYSPAN=m
CONFIG_USB_SERIAL_KLSI=m
CONFIG_USB_SERIAL_KOBIL_SCT=m
CONFIG_USB_SERIAL_MCT_U232=m
# CONFIG_USB_SERIAL_METRO is not set
CONFIG_USB_SERIAL_MOS7720=m
CONFIG_USB_SERIAL_MOS7715_PARPORT=y
CONFIG_USB_SERIAL_MOS7840=m
# CONFIG_USB_SERIAL_MXUPORT is not set
CONFIG_USB_SERIAL_NAVMAN=m
CONFIG_USB_SERIAL_PL2303=m
CONFIG_USB_SERIAL_OTI6858=m
CONFIG_USB_SERIAL_QCAUX=m
CONFIG_USB_SERIAL_QUALCOMM=m
CONFIG_USB_SERIAL_SPCP8X5=m
CONFIG_USB_SERIAL_SAFE=m
CONFIG_USB_SERIAL_SAFE_PADDED=y
CONFIG_USB_SERIAL_SIERRAWIRELESS=m
CONFIG_USB_SERIAL_SYMBOL=m
# CONFIG_USB_SERIAL_TI is not set
CONFIG_USB_SERIAL_CYBERJACK=m
CONFIG_USB_SERIAL_XIRCOM=m
CONFIG_USB_SERIAL_WWAN=m
CONFIG_USB_SERIAL_OPTION=m
CONFIG_USB_SERIAL_OMNINET=m
CONFIG_USB_SERIAL_OPTICON=m
CONFIG_USB_SERIAL_XSENS_MT=m
# CONFIG_USB_SERIAL_WISHBONE is not set
CONFIG_USB_SERIAL_SSU100=m
CONFIG_USB_SERIAL_QT2=m
# CONFIG_USB_SERIAL_UPD78F0730 is not set
CONFIG_USB_SERIAL_DEBUG=m

#
# USB Miscellaneous drivers
#
CONFIG_USB_EMI62=m
CONFIG_USB_EMI26=m
CONFIG_USB_ADUTUX=m
CONFIG_USB_SEVSEG=m
# CONFIG_USB_RIO500 is not set
CONFIG_USB_LEGOTOWER=m
CONFIG_USB_LCD=m
# CONFIG_USB_CYPRESS_CY7C63 is not set
# CONFIG_USB_CYTHERM is not set
CONFIG_USB_IDMOUSE=m
CONFIG_USB_FTDI_ELAN=m
CONFIG_USB_APPLEDISPLAY=m
CONFIG_USB_SISUSBVGA=m
CONFIG_USB_SISUSBVGA_CON=y
CONFIG_USB_LD=m
# CONFIG_USB_TRANCEVIBRATOR is not set
CONFIG_USB_IOWARRIOR=m
# CONFIG_USB_TEST is not set
# CONFIG_USB_EHSET_TEST_FIXTURE is not set
CONFIG_USB_ISIGHTFW=m
# CONFIG_USB_YUREX is not set
CONFIG_USB_EZUSB_FX2=m
# CONFIG_USB_HUB_USB251XB is not set
CONFIG_USB_HSIC_USB3503=m
# CONFIG_USB_HSIC_USB4604 is not set
# CONFIG_USB_LINK_LAYER_TEST is not set
# CONFIG_USB_CHAOSKEY is not set
CONFIG_USB_ATM=m
CONFIG_USB_SPEEDTOUCH=m
CONFIG_USB_CXACRU=m
CONFIG_USB_UEAGLEATM=m
CONFIG_USB_XUSBATM=m

#
# USB Physical Layer drivers
#
# CONFIG_NOP_USB_XCEIV is not set
# CONFIG_USB_GPIO_VBUS is not set
# CONFIG_USB_ISP1301 is not set
# CONFIG_USB_GADGET is not set
CONFIG_TYPEC=y
# CONFIG_TYPEC_TCPM is not set
CONFIG_TYPEC_UCSI=y
# CONFIG_UCSI_CCG is not set
CONFIG_UCSI_ACPI=y
# CONFIG_TYPEC_TPS6598X is not set

#
# USB Type-C Multiplexer/DeMultiplexer Switch support #
# CONFIG_TYPEC_MUX_PI3USB30532 is not set

#
# USB Type-C Alternate Mode drivers
#
# CONFIG_TYPEC_DP_ALTMODE is not set
# CONFIG_USB_ROLE_SWITCH is not set
# CONFIG_USB_LED_TRIG is not set
# CONFIG_USB_ULPI_BUS is not set
CONFIG_UWB=m
CONFIG_UWB_HWA=m
CONFIG_UWB_WHCI=m
CONFIG_UWB_I1480U=m
CONFIG_MMC=m
CONFIG_MMC_BLOCK=m
CONFIG_MMC_BLOCK_MINORS=8
CONFIG_SDIO_UART=m
# CONFIG_MMC_TEST is not set

#
# MMC/SD/SDIO Host Controller Drivers
#
# CONFIG_MMC_DEBUG is not set
CONFIG_MMC_SDHCI=m
CONFIG_MMC_SDHCI_PCI=m
CONFIG_MMC_RICOH_MMC=y
CONFIG_MMC_SDHCI_ACPI=m
CONFIG_MMC_SDHCI_PLTFM=m
# CONFIG_MMC_SDHCI_F_SDH30 is not set
# CONFIG_MMC_WBSD is not set
CONFIG_MMC_TIFM_SD=m
# CONFIG_MMC_SPI is not set
CONFIG_MMC_CB710=m
CONFIG_MMC_VIA_SDMMC=m
CONFIG_MMC_VUB300=m
CONFIG_MMC_USHC=m
# CONFIG_MMC_USDHI6ROL0 is not set
CONFIG_MMC_CQHCI=m
# CONFIG_MMC_TOSHIBA_PCI is not set
# CONFIG_MMC_MTK is not set
# CONFIG_MMC_SDHCI_XENON is not set
CONFIG_MEMSTICK=m
# CONFIG_MEMSTICK_DEBUG is not set

#
# MemoryStick drivers
#
# CONFIG_MEMSTICK_UNSAFE_RESUME is not set
CONFIG_MSPRO_BLOCK=m
# CONFIG_MS_BLOCK is not set

#
# MemoryStick Host Controller Drivers
#
CONFIG_MEMSTICK_TIFM_MS=m
CONFIG_MEMSTICK_JMICRON_38X=m
CONFIG_MEMSTICK_R592=m
CONFIG_NEW_LEDS=y
CONFIG_LEDS_CLASS=y
# CONFIG_LEDS_CLASS_FLASH is not set
# CONFIG_LEDS_BRIGHTNESS_HW_CHANGED is not set

#
# LED drivers
#
# CONFIG_LEDS_APU is not set
CONFIG_LEDS_LM3530=m
# CONFIG_LEDS_LM3642 is not set
# CONFIG_LEDS_PCA9532 is not set
# CONFIG_LEDS_GPIO is not set
CONFIG_LEDS_LP3944=m
# CONFIG_LEDS_LP3952 is not set
CONFIG_LEDS_LP55XX_COMMON=m
CONFIG_LEDS_LP5521=m
CONFIG_LEDS_LP5523=m
CONFIG_LEDS_LP5562=m
# CONFIG_LEDS_LP8501 is not set
CONFIG_LEDS_CLEVO_MAIL=m
# CONFIG_LEDS_PCA955X is not set
# CONFIG_LEDS_PCA963X is not set
# CONFIG_LEDS_DAC124S085 is not set
# CONFIG_LEDS_PWM is not set
# CONFIG_LEDS_BD2802 is not set
CONFIG_LEDS_INTEL_SS4200=m
CONFIG_LEDS_LT3593=m
# CONFIG_LEDS_TCA6507 is not set
# CONFIG_LEDS_TLC591XX is not set
# CONFIG_LEDS_LM355x is not set

#
# LED driver for blink(1) USB RGB LED is under Special HID drivers (HID_THINGM) #
CONFIG_LEDS_BLINKM=m
# CONFIG_LEDS_MLXCPLD is not set
# CONFIG_LEDS_MLXREG is not set
# CONFIG_LEDS_USER is not set
# CONFIG_LEDS_NIC78BX is not set

#
# LED Triggers
#
CONFIG_LEDS_TRIGGERS=y
CONFIG_LEDS_TRIGGER_TIMER=m
CONFIG_LEDS_TRIGGER_ONESHOT=m
# CONFIG_LEDS_TRIGGER_DISK is not set
# CONFIG_LEDS_TRIGGER_MTD is not set
CONFIG_LEDS_TRIGGER_HEARTBEAT=m
CONFIG_LEDS_TRIGGER_BACKLIGHT=m
# CONFIG_LEDS_TRIGGER_CPU is not set
# CONFIG_LEDS_TRIGGER_ACTIVITY is not set
CONFIG_LEDS_TRIGGER_GPIO=m
CONFIG_LEDS_TRIGGER_DEFAULT_ON=m

#

# iptables trigger is under Netfilter config (LED target)
#
CONFIG_LEDS_TRIGGER_TRANSIENT=m
CONFIG_LEDS_TRIGGER_CAMERA=m
# CONFIG_LEDS_TRIGGER_PANIC is not set
# CONFIG_LEDS_TRIGGER_NETDEV is not set
# CONFIG_LEDS_TRIGGER_PATTERN is not set
CONFIG_LEDS_TRIGGER_AUDIO=m
# CONFIG_ACCESSIBILITY is not set
CONFIG_INFINIBAND=m
CONFIG_INFINIBAND_USER_MAD=m
CONFIG_INFINIBAND_USER_ACCESS=m
# CONFIG_INFINIBAND_EXP_LEGACY_VERBS_NEW_UAPI is not set
CONFIG_INFINIBAND_USER_MEM=y
CONFIG_INFINIBAND_ON_DEMAND_PAGING=y
CONFIG_INFINIBAND_ADDR_TRANS=y
CONFIG_INFINIBAND_ADDR_TRANS_CONFIGFS=y
CONFIG_INFINIBAND_MTHCA=m
CONFIG_INFINIBAND_MTHCA_DEBUG=y
CONFIG_INFINIBAND_QIB=m
CONFIG_INFINIBAND_QIB_DCA=y
CONFIG_INFINIBAND_CXGB3=m
CONFIG_INFINIBAND_CXGB4=m
CONFIG_INFINIBAND_I40IW=m
CONFIG_MLX4_INFINIBAND=m
CONFIG_MLX5_INFINIBAND=m
CONFIG_INFINIBAND_NES=m
# CONFIG_INFINIBAND_NES_DEBUG is not set
CONFIG_INFINIBAND_OCRDMA=m
CONFIG_INFINIBAND_VMWARE_PVRDMA=m
CONFIG_INFINIBAND_USNIC=m
CONFIG_INFINIBAND_IPOIB=m
CONFIG_INFINIBAND_IPOIB_CM=y
CONFIG_INFINIBAND_IPOIB_DEBUG=y
# CONFIG_INFINIBAND_IPOIB_DEBUG_DATA is not set
CONFIG_INFINIBAND_SRP=m
CONFIG_INFINIBAND_SRPT=m
CONFIG_INFINIBAND_ISER=m
CONFIG_INFINIBAND_ISERT=m
CONFIG_INFINIBAND_OPA_VNIC=m
CONFIG_INFINIBAND_RDMAVT=m
CONFIG_RDMA_RXE=m
CONFIG_INFINIBAND_HFI1=m
# CONFIG_HFI1_DEBUG_SDMA_ORDER is not set
# CONFIG_SDMA_VERBOSITY is not set
CONFIG_INFINIBAND_QEDR=m

32 lines not shown · raw message

2,272 lines not shown · raw message

Part of this message is not shown here. View the raw message.

author maintainer
#46 lore raw

PATCH v2 7/7 bpf, selftest: test {rd,wr}only flags and direct value access

In reply to Daniel Borkmann

Extend test_verifier with various test cases around the two kernel extensions, that is, {rd,wr}only map support as well as direct map value access. All passing, one skipped due to xskmap not present on test machine:

  # ./test_verifier
  [...]
  #913/p XDP pkt read, pkt_data <= pkt_meta', bad access 1 OK
  #914/p XDP pkt read, pkt_data <= pkt_meta', bad access 2 OK
  Summary: 1352 PASSED, 1 SKIPPED, 0 FAILED
---
 tools/include/linux/filter.h                  |  19 +-
 tools/testing/selftests/bpf/test_verifier.c   |  40 ++++-
 .../selftests/bpf/verifier/array_access.c     | 159 ++++++++++++++++
 .../bpf/verifier/direct_value_access.c        | 170 ++++++++++++++++++
 4 files changed, 383 insertions(+), 5 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/verifier/direct_value_access.c
tools/include/linux/filter.h +18 -1
index cce0b02c0e28..fdf4383db556 100644
@@ -280,8 +280,25 @@
 
 /* pseudo BPF_LD_IMM64 insn used to refer to process-local map_fd */
 
+#define BPF_LD_IMM64_RAW2(DST, SRC, IMM1, IMM2)			\
+	((struct bpf_insn) {					\
+		.code  = BPF_LD | BPF_DW | BPF_IMM,		\
+		.dst_reg = DST,					\
+		.src_reg = SRC,					\
+		.off   = 0,					\
+		.imm   = IMM1 }),				\
+	((struct bpf_insn) {					\
+		.code  = 0, /* zero is reserved opcode */	\
+		.dst_reg = 0,					\
+		.src_reg = 0,					\
+		.off   = 0,					\
+		.imm   = IMM2 })
+
 #define BPF_LD_MAP_FD(DST, MAP_FD)				\
-	BPF_LD_IMM64_RAW(DST, BPF_PSEUDO_MAP_FD, MAP_FD)
+	BPF_LD_IMM64_RAW2(DST, BPF_PSEUDO_MAP_FD, MAP_FD, 0)
+
+#define BPF_LD_MAP_VALUE(DST, MAP_FD, VALUE_OFF)		\
+	BPF_LD_IMM64_RAW2(DST, BPF_PSEUDO_MAP_VALUE, MAP_FD, VALUE_OFF)
 
 /* Relative call */
 
tools/testing/selftests/bpf/test_verifier.c +36 -4
index 477a9dcf9fff..50359916b82a 100644
@@ -51,7 +51,7 @@
 
 #define MAX_INSNS	BPF_MAXINSNS
 #define MAX_FIXUPS	8
-#define MAX_NR_MAPS	14
+#define MAX_NR_MAPS	16
 #define MAX_TEST_RUNS	8
 #define POINTER_VALUE	0xcafe4all
 #define TEST_DATA_LEN	64
@@ -80,6 +80,8 @@ struct bpf_test {
 	int fixup_cgroup_storage[MAX_FIXUPS];
 	int fixup_percpu_cgroup_storage[MAX_FIXUPS];
 	int fixup_map_spin_lock[MAX_FIXUPS];
+	int fixup_map_array_ro[MAX_FIXUPS];
+	int fixup_map_array_wo[MAX_FIXUPS];
 	const char *errstr;
 	const char *errstr_unpriv;
 	uint32_t retval, retval_unpriv, insn_processed;
@@ -277,13 +279,15 @@ static bool skip_unsupported_map(enum bpf_map_type map_type)
 	return false;
 }
 
-static int create_map(uint32_t type, uint32_t size_key,
-		      uint32_t size_value, uint32_t max_elem)
+static int __create_map(uint32_t type, uint32_t size_key,
+			uint32_t size_value, uint32_t max_elem,
+			uint32_t extra_flags)
 {
 	int fd;
 
 	fd = bpf_create_map(type, size_key, size_value, max_elem,
-			    type == BPF_MAP_TYPE_HASH ? BPF_F_NO_PREALLOC : 0);
+			    (type == BPF_MAP_TYPE_HASH ?
+			     BPF_F_NO_PREALLOC : 0) | extra_flags);
 	if (fd < 0) {
 		if (skip_unsupported_map(type))
 			return -1;
@@ -293,6 +297,12 @@ static int create_map(uint32_t type, uint32_t size_key,
 	return fd;
 }
 
+static int create_map(uint32_t type, uint32_t size_key,
+		      uint32_t size_value, uint32_t max_elem)
+{
+	return __create_map(type, size_key, size_value, max_elem, 0);
+}
+
 static void update_map(int fd, int index)
 {
 	struct test_val value = {
@@ -519,6 +529,8 @@ static void do_test_fixup(struct bpf_test *test, enum bpf_prog_type prog_type,
 	int *fixup_cgroup_storage = test->fixup_cgroup_storage;
 	int *fixup_percpu_cgroup_storage = test->fixup_percpu_cgroup_storage;
 	int *fixup_map_spin_lock = test->fixup_map_spin_lock;
+	int *fixup_map_array_ro = test->fixup_map_array_ro;
+	int *fixup_map_array_wo = test->fixup_map_array_wo;
 
 	if (test->fill_helper)
 		test->fill_helper(test);
@@ -642,6 +654,26 @@ static void do_test_fixup(struct bpf_test *test, enum bpf_prog_type prog_type,
 			fixup_map_spin_lock++;
 		} while (*fixup_map_spin_lock);
 	}
+	if (*fixup_map_array_ro) {
+		map_fds[14] = __create_map(BPF_MAP_TYPE_ARRAY, sizeof(int),
+					   sizeof(struct test_val), 1,
+					   BPF_F_RDONLY_PROG);
+		update_map(map_fds[14], 0);
+		do {
+			prog[*fixup_map_array_ro].imm = map_fds[14];
+			fixup_map_array_ro++;
+		} while (*fixup_map_array_ro);
+	}
+	if (*fixup_map_array_wo) {
+		map_fds[15] = __create_map(BPF_MAP_TYPE_ARRAY, sizeof(int),
+					   sizeof(struct test_val), 1,
+					   BPF_F_WRONLY_PROG);
+		update_map(map_fds[15], 0);
+		do {
+			prog[*fixup_map_array_wo].imm = map_fds[15];
+			fixup_map_array_wo++;
+		} while (*fixup_map_array_wo);
+	}
 }
 
 static int set_admin(bool admin)
tools/testing/selftests/bpf/verifier/array_access.c +159 -0

162 lines not on this page · raw message

tools/testing/selftests/bpf/verifier/direct_value_access.c new file +170 -0

170 lines not on this page · raw message

Signature · 1 line
2.17.1