BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next 1/3] bpf: remove unused parameter in bpf_jit_binary_pack_finalize
       [not found] <20240613020729.43953-1-rafael@rcpassos.me>
@ 2024-06-13  2:03 ` Rafael Passos
  2024-06-13 11:27   ` kernel test robot
  2024-06-13 19:24   ` kernel test robot
  2024-06-13  2:03 ` [PATCH bpf-next 2/3] bpf: remove unused parameter in __bpf_free_used_btfs Rafael Passos
  2024-06-13  2:03 ` [PATCH bpf-next 3/3] bpf: remove redeclaration of new_n in bpf_verifier_vlog Rafael Passos
  2 siblings, 2 replies; 5+ messages in thread
From: Rafael Passos @ 2024-06-13  2:03 UTC (permalink / raw)
  To: davem, dsahern, ast, daniel, andrii, tglx, mingo, bp; +Cc: Rafael Passos, bpf

Fixes a compiler warning. the bpf_jit_binary_pack_finalize function
was taking an extra bpf_prog parameter that went unused.

Signed-off-by: Rafael Passos <rafael@rcpassos.me>
---
 arch/x86/net/bpf_jit_comp.c | 4 ++--
 include/linux/filter.h      | 3 +--
 kernel/bpf/core.c           | 3 +--
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index 5159c7a22922..bd7e13602bf6 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -3363,7 +3363,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
 			 *
 			 * Both cases are serious bugs and justify WARN_ON.
 			 */
-			if (WARN_ON(bpf_jit_binary_pack_finalize(prog, header, rw_header))) {
+			if (WARN_ON(bpf_jit_binary_pack_finalize(header, rw_header))) {
 				/* header has been freed */
 				header = NULL;
 				goto out_image;
@@ -3442,7 +3442,7 @@ void bpf_jit_free(struct bpf_prog *prog)
 		 * before freeing it.
 		 */
 		if (jit_data) {
-			bpf_jit_binary_pack_finalize(prog, jit_data->header,
+			bpf_jit_binary_pack_finalize(jit_data->header,
 						     jit_data->rw_header);
 			kvfree(jit_data->addrs);
 			kfree(jit_data);
diff --git a/include/linux/filter.h b/include/linux/filter.h
index b02aea291b7e..dd41a93f06b2 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -1129,8 +1129,7 @@ bpf_jit_binary_pack_alloc(unsigned int proglen, u8 **ro_image,
 			  struct bpf_binary_header **rw_hdr,
 			  u8 **rw_image,
 			  bpf_jit_fill_hole_t bpf_fill_ill_insns);
-int bpf_jit_binary_pack_finalize(struct bpf_prog *prog,
-				 struct bpf_binary_header *ro_header,
+int bpf_jit_binary_pack_finalize(struct bpf_binary_header *ro_header,
 				 struct bpf_binary_header *rw_header);
 void bpf_jit_binary_pack_free(struct bpf_binary_header *ro_header,
 			      struct bpf_binary_header *rw_header);
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 1a6c3faa6e4a..f6951c33790d 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -1174,8 +1174,7 @@ bpf_jit_binary_pack_alloc(unsigned int proglen, u8 **image_ptr,
 }
 
 /* Copy JITed text from rw_header to its final location, the ro_header. */
-int bpf_jit_binary_pack_finalize(struct bpf_prog *prog,
-				 struct bpf_binary_header *ro_header,
+int bpf_jit_binary_pack_finalize(struct bpf_binary_header *ro_header,
 				 struct bpf_binary_header *rw_header)
 {
 	void *ptr;
-- 
2.45.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH bpf-next 2/3] bpf: remove unused parameter in __bpf_free_used_btfs
       [not found] <20240613020729.43953-1-rafael@rcpassos.me>
  2024-06-13  2:03 ` [PATCH bpf-next 1/3] bpf: remove unused parameter in bpf_jit_binary_pack_finalize Rafael Passos
@ 2024-06-13  2:03 ` Rafael Passos
  2024-06-13  2:03 ` [PATCH bpf-next 3/3] bpf: remove redeclaration of new_n in bpf_verifier_vlog Rafael Passos
  2 siblings, 0 replies; 5+ messages in thread
From: Rafael Passos @ 2024-06-13  2:03 UTC (permalink / raw)
  To: ast, daniel, andrii; +Cc: Rafael Passos, bpf

Fixes a compiler warning. The __bpf_free_used_btfs function
was taking an extra unused struct bpf_prog_aux *aux param

Signed-off-by: Rafael Passos <rafael@rcpassos.me>
---
 include/linux/bpf.h   | 3 +--
 kernel/bpf/core.c     | 5 ++---
 kernel/bpf/verifier.c | 3 +--
 3 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index f636b4998bf7..960780ef04e1 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -2933,8 +2933,7 @@ bpf_probe_read_kernel_common(void *dst, u32 size, const void *unsafe_ptr)
 	return ret;
 }
 
-void __bpf_free_used_btfs(struct bpf_prog_aux *aux,
-			  struct btf_mod_pair *used_btfs, u32 len);
+void __bpf_free_used_btfs(struct btf_mod_pair *used_btfs, u32 len);
 
 static inline struct bpf_prog *bpf_prog_get_type(u32 ufd,
 						 enum bpf_prog_type type)
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index f6951c33790d..ae2e1eeda0d4 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -2742,8 +2742,7 @@ static void bpf_free_used_maps(struct bpf_prog_aux *aux)
 	kfree(aux->used_maps);
 }
 
-void __bpf_free_used_btfs(struct bpf_prog_aux *aux,
-			  struct btf_mod_pair *used_btfs, u32 len)
+void __bpf_free_used_btfs(struct btf_mod_pair *used_btfs, u32 len)
 {
 #ifdef CONFIG_BPF_SYSCALL
 	struct btf_mod_pair *btf_mod;
@@ -2760,7 +2759,7 @@ void __bpf_free_used_btfs(struct bpf_prog_aux *aux,
 
 static void bpf_free_used_btfs(struct bpf_prog_aux *aux)
 {
-	__bpf_free_used_btfs(aux, aux->used_btfs, aux->used_btf_cnt);
+	__bpf_free_used_btfs(aux->used_btfs, aux->used_btf_cnt);
 	kfree(aux->used_btfs);
 }
 
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index acc9dd830807..c703612e04f7 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -18619,8 +18619,7 @@ static void release_maps(struct bpf_verifier_env *env)
 /* drop refcnt of maps used by the rejected program */
 static void release_btfs(struct bpf_verifier_env *env)
 {
-	__bpf_free_used_btfs(env->prog->aux, env->used_btfs,
-			     env->used_btf_cnt);
+	__bpf_free_used_btfs(env->used_btfs, env->used_btf_cnt);
 }
 
 /* convert pseudo BPF_LD_IMM64 into generic BPF_LD_IMM64 */
-- 
2.45.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH bpf-next 3/3] bpf: remove redeclaration of new_n in bpf_verifier_vlog
       [not found] <20240613020729.43953-1-rafael@rcpassos.me>
  2024-06-13  2:03 ` [PATCH bpf-next 1/3] bpf: remove unused parameter in bpf_jit_binary_pack_finalize Rafael Passos
  2024-06-13  2:03 ` [PATCH bpf-next 2/3] bpf: remove unused parameter in __bpf_free_used_btfs Rafael Passos
@ 2024-06-13  2:03 ` Rafael Passos
  2 siblings, 0 replies; 5+ messages in thread
From: Rafael Passos @ 2024-06-13  2:03 UTC (permalink / raw)
  To: ast, daniel, andrii; +Cc: Rafael Passos, bpf

This new_n is defined in the start of this function.
Its value is overwritten by `new_n = min(n, log->len_total);`
a couple lines before my change,
rendering the shadow declaration unnecessary.

Signed-off-by: Rafael Passos <rafael@rcpassos.me>
---
 kernel/bpf/log.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/bpf/log.c b/kernel/bpf/log.c
index 4bd8f17a9f24..10b2ed6995eb 100644
--- a/kernel/bpf/log.c
+++ b/kernel/bpf/log.c
@@ -91,7 +91,7 @@ void bpf_verifier_vlog(struct bpf_verifier_log *log, const char *fmt,
 			goto fail;
 	} else {
 		u64 new_end, new_start;
-		u32 buf_start, buf_end, new_n;
+		u32 buf_start, buf_end;
 
 		new_end = log->end_pos + n;
 		if (new_end - log->start_pos >= log->len_total)
-- 
2.45.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH bpf-next 1/3] bpf: remove unused parameter in bpf_jit_binary_pack_finalize
  2024-06-13  2:03 ` [PATCH bpf-next 1/3] bpf: remove unused parameter in bpf_jit_binary_pack_finalize Rafael Passos
@ 2024-06-13 11:27   ` kernel test robot
  2024-06-13 19:24   ` kernel test robot
  1 sibling, 0 replies; 5+ messages in thread
From: kernel test robot @ 2024-06-13 11:27 UTC (permalink / raw)
  To: Rafael Passos, davem, dsahern, ast, daniel, andrii, tglx, mingo,
	bp
  Cc: oe-kbuild-all, Rafael Passos, bpf

Hi Rafael,

kernel test robot noticed the following build errors:

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

url:    https://github.com/intel-lab-lkp/linux/commits/Rafael-Passos/bpf-remove-unused-parameter-in-__bpf_free_used_btfs/20240613-110048
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
patch link:    https://lore.kernel.org/r/7eaed3dc-28e5-409f-8f73-a1bf8acc2937%40smtp-relay.sendinblue.com
patch subject: [PATCH bpf-next 1/3] bpf: remove unused parameter in bpf_jit_binary_pack_finalize
config: arm64-defconfig (https://download.01.org/0day-ci/archive/20240613/202406131947.L4MhzX6z-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240613/202406131947.L4MhzX6z-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202406131947.L4MhzX6z-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from arch/arm64/include/asm/bug.h:26,
                    from include/linux/ktime.h:24,
                    from include/linux/timer.h:6,
                    from include/linux/workqueue.h:9,
                    from include/linux/bpf.h:10,
                    from arch/arm64/net/bpf_jit_comp.c:11:
   arch/arm64/net/bpf_jit_comp.c: In function 'bpf_int_jit_compile':
>> arch/arm64/net/bpf_jit_comp.c:1832:58: error: passing argument 1 of 'bpf_jit_binary_pack_finalize' from incompatible pointer type [-Werror=incompatible-pointer-types]
    1832 |                 if (WARN_ON(bpf_jit_binary_pack_finalize(prog, ro_header,
         |                                                          ^~~~
         |                                                          |
         |                                                          struct bpf_prog *
   include/asm-generic/bug.h:123:32: note: in definition of macro 'WARN_ON'
     123 |         int __ret_warn_on = !!(condition);                              \
         |                                ^~~~~~~~~
   In file included from arch/arm64/net/bpf_jit_comp.c:12:
   include/linux/filter.h:1132:60: note: expected 'struct bpf_binary_header *' but argument is of type 'struct bpf_prog *'
    1132 | int bpf_jit_binary_pack_finalize(struct bpf_binary_header *ro_header,
         |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
>> arch/arm64/net/bpf_jit_comp.c:1832:29: error: too many arguments to function 'bpf_jit_binary_pack_finalize'
    1832 |                 if (WARN_ON(bpf_jit_binary_pack_finalize(prog, ro_header,
         |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/asm-generic/bug.h:123:32: note: in definition of macro 'WARN_ON'
     123 |         int __ret_warn_on = !!(condition);                              \
         |                                ^~~~~~~~~
   include/linux/filter.h:1132:5: note: declared here
    1132 | int bpf_jit_binary_pack_finalize(struct bpf_binary_header *ro_header,
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors


vim +/bpf_jit_binary_pack_finalize +1832 arch/arm64/net/bpf_jit_comp.c

db496944fdaaf2 Alexei Starovoitov    2017-12-14  1685  
d1c55ab5e41fcd Daniel Borkmann       2016-05-13  1686  struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
e54bcde3d69d40 Zi Shen Lim           2014-08-26  1687  {
b2ad54e1533e91 Xu Kuohai             2022-07-11  1688  	int image_size, prog_size, extable_size, extable_align, extable_offset;
26eb042ee4c784 Daniel Borkmann       2016-05-13  1689  	struct bpf_prog *tmp, *orig_prog = prog;
b569c1c622c5e6 Daniel Borkmann       2014-09-16  1690  	struct bpf_binary_header *header;
1dad391daef129 Puranjay Mohan        2024-02-28  1691  	struct bpf_binary_header *ro_header;
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1692  	struct arm64_jit_data *jit_data;
56ea6a8b4949c6 Daniel Borkmann       2018-05-14  1693  	bool was_classic = bpf_prog_was_classic(prog);
26eb042ee4c784 Daniel Borkmann       2016-05-13  1694  	bool tmp_blinded = false;
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1695  	bool extra_pass = false;
e54bcde3d69d40 Zi Shen Lim           2014-08-26  1696  	struct jit_ctx ctx;
339af577ec05c8 Puranjay Mohan        2024-03-25  1697  	u64 arena_vm_start;
b569c1c622c5e6 Daniel Borkmann       2014-09-16  1698  	u8 *image_ptr;
1dad391daef129 Puranjay Mohan        2024-02-28  1699  	u8 *ro_image_ptr;
e54bcde3d69d40 Zi Shen Lim           2014-08-26  1700  
60b58afc96c9df Alexei Starovoitov    2017-12-14  1701  	if (!prog->jit_requested)
26eb042ee4c784 Daniel Borkmann       2016-05-13  1702  		return orig_prog;
26eb042ee4c784 Daniel Borkmann       2016-05-13  1703  
26eb042ee4c784 Daniel Borkmann       2016-05-13  1704  	tmp = bpf_jit_blind_constants(prog);
26eb042ee4c784 Daniel Borkmann       2016-05-13  1705  	/* If blinding was requested and we failed during blinding,
26eb042ee4c784 Daniel Borkmann       2016-05-13  1706  	 * we must fall back to the interpreter.
26eb042ee4c784 Daniel Borkmann       2016-05-13  1707  	 */
26eb042ee4c784 Daniel Borkmann       2016-05-13  1708  	if (IS_ERR(tmp))
26eb042ee4c784 Daniel Borkmann       2016-05-13  1709  		return orig_prog;
26eb042ee4c784 Daniel Borkmann       2016-05-13  1710  	if (tmp != prog) {
26eb042ee4c784 Daniel Borkmann       2016-05-13  1711  		tmp_blinded = true;
26eb042ee4c784 Daniel Borkmann       2016-05-13  1712  		prog = tmp;
26eb042ee4c784 Daniel Borkmann       2016-05-13  1713  	}
e54bcde3d69d40 Zi Shen Lim           2014-08-26  1714  
339af577ec05c8 Puranjay Mohan        2024-03-25  1715  	arena_vm_start = bpf_arena_get_kern_vm_start(prog->aux->arena);
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1716  	jit_data = prog->aux->jit_data;
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1717  	if (!jit_data) {
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1718  		jit_data = kzalloc(sizeof(*jit_data), GFP_KERNEL);
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1719  		if (!jit_data) {
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1720  			prog = orig_prog;
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1721  			goto out;
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1722  		}
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1723  		prog->aux->jit_data = jit_data;
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1724  	}
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1725  	if (jit_data->ctx.offset) {
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1726  		ctx = jit_data->ctx;
1dad391daef129 Puranjay Mohan        2024-02-28  1727  		ro_image_ptr = jit_data->ro_image;
1dad391daef129 Puranjay Mohan        2024-02-28  1728  		ro_header = jit_data->ro_header;
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1729  		header = jit_data->header;
1dad391daef129 Puranjay Mohan        2024-02-28  1730  		image_ptr = (void *)header + ((void *)ro_image_ptr
1dad391daef129 Puranjay Mohan        2024-02-28  1731  						 - (void *)ro_header);
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1732  		extra_pass = true;
800834285361dc Jean-Philippe Brucker 2020-07-28  1733  		prog_size = sizeof(u32) * ctx.idx;
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1734  		goto skip_init_ctx;
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1735  	}
e54bcde3d69d40 Zi Shen Lim           2014-08-26  1736  	memset(&ctx, 0, sizeof(ctx));
e54bcde3d69d40 Zi Shen Lim           2014-08-26  1737  	ctx.prog = prog;
e54bcde3d69d40 Zi Shen Lim           2014-08-26  1738  
19f68ed6dc90c9 Aijun Sun             2022-08-04  1739  	ctx.offset = kvcalloc(prog->len + 1, sizeof(int), GFP_KERNEL);
26eb042ee4c784 Daniel Borkmann       2016-05-13  1740  	if (ctx.offset == NULL) {
26eb042ee4c784 Daniel Borkmann       2016-05-13  1741  		prog = orig_prog;
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1742  		goto out_off;
26eb042ee4c784 Daniel Borkmann       2016-05-13  1743  	}
e54bcde3d69d40 Zi Shen Lim           2014-08-26  1744  
5b3d19b9bd4080 Xu Kuohai             2022-03-21  1745  	ctx.fpb_offset = find_fpb_offset(prog);
4dd31243e30843 Puranjay Mohan        2024-03-25  1746  	ctx.user_vm_start = bpf_arena_get_user_vm_start(prog->aux->arena);
5b3d19b9bd4080 Xu Kuohai             2022-03-21  1747  
68e4f238b0e9d3 Hou Tao               2022-02-26  1748  	/*
68e4f238b0e9d3 Hou Tao               2022-02-26  1749  	 * 1. Initial fake pass to compute ctx->idx and ctx->offset.
68e4f238b0e9d3 Hou Tao               2022-02-26  1750  	 *
68e4f238b0e9d3 Hou Tao               2022-02-26  1751  	 * BPF line info needs ctx->offset[i] to be the offset of
68e4f238b0e9d3 Hou Tao               2022-02-26  1752  	 * instruction[i] in jited image, so build prologue first.
68e4f238b0e9d3 Hou Tao               2022-02-26  1753  	 */
339af577ec05c8 Puranjay Mohan        2024-03-25  1754  	if (build_prologue(&ctx, was_classic, prog->aux->exception_cb,
339af577ec05c8 Puranjay Mohan        2024-03-25  1755  			   arena_vm_start)) {
26eb042ee4c784 Daniel Borkmann       2016-05-13  1756  		prog = orig_prog;
26eb042ee4c784 Daniel Borkmann       2016-05-13  1757  		goto out_off;
26eb042ee4c784 Daniel Borkmann       2016-05-13  1758  	}
e54bcde3d69d40 Zi Shen Lim           2014-08-26  1759  
68e4f238b0e9d3 Hou Tao               2022-02-26  1760  	if (build_body(&ctx, extra_pass)) {
ddb55992b04d97 Zi Shen Lim           2016-06-08  1761  		prog = orig_prog;
ddb55992b04d97 Zi Shen Lim           2016-06-08  1762  		goto out_off;
ddb55992b04d97 Zi Shen Lim           2016-06-08  1763  	}
51c9fbb1b146f3 Zi Shen Lim           2014-12-03  1764  
51c9fbb1b146f3 Zi Shen Lim           2014-12-03  1765  	ctx.epilogue_offset = ctx.idx;
22fc0e80aeb5c0 Puranjay Mohan        2024-02-01  1766  	build_epilogue(&ctx, prog->aux->exception_cb);
b2ad54e1533e91 Xu Kuohai             2022-07-11  1767  	build_plt(&ctx);
e54bcde3d69d40 Zi Shen Lim           2014-08-26  1768  
b2ad54e1533e91 Xu Kuohai             2022-07-11  1769  	extable_align = __alignof__(struct exception_table_entry);
800834285361dc Jean-Philippe Brucker 2020-07-28  1770  	extable_size = prog->aux->num_exentries *
800834285361dc Jean-Philippe Brucker 2020-07-28  1771  		sizeof(struct exception_table_entry);
800834285361dc Jean-Philippe Brucker 2020-07-28  1772  
e54bcde3d69d40 Zi Shen Lim           2014-08-26  1773  	/* Now we know the actual image size. */
800834285361dc Jean-Philippe Brucker 2020-07-28  1774  	prog_size = sizeof(u32) * ctx.idx;
b2ad54e1533e91 Xu Kuohai             2022-07-11  1775  	/* also allocate space for plt target */
b2ad54e1533e91 Xu Kuohai             2022-07-11  1776  	extable_offset = round_up(prog_size + PLT_TARGET_SIZE, extable_align);
b2ad54e1533e91 Xu Kuohai             2022-07-11  1777  	image_size = extable_offset + extable_size;
1dad391daef129 Puranjay Mohan        2024-02-28  1778  	ro_header = bpf_jit_binary_pack_alloc(image_size, &ro_image_ptr,
1dad391daef129 Puranjay Mohan        2024-02-28  1779  					      sizeof(u32), &header, &image_ptr,
1dad391daef129 Puranjay Mohan        2024-02-28  1780  					      jit_fill_hole);
1dad391daef129 Puranjay Mohan        2024-02-28  1781  	if (!ro_header) {
26eb042ee4c784 Daniel Borkmann       2016-05-13  1782  		prog = orig_prog;
26eb042ee4c784 Daniel Borkmann       2016-05-13  1783  		goto out_off;
26eb042ee4c784 Daniel Borkmann       2016-05-13  1784  	}
e54bcde3d69d40 Zi Shen Lim           2014-08-26  1785  
e54bcde3d69d40 Zi Shen Lim           2014-08-26  1786  	/* 2. Now, the actual pass. */
e54bcde3d69d40 Zi Shen Lim           2014-08-26  1787  
1dad391daef129 Puranjay Mohan        2024-02-28  1788  	/*
1dad391daef129 Puranjay Mohan        2024-02-28  1789  	 * Use the image(RW) for writing the JITed instructions. But also save
1dad391daef129 Puranjay Mohan        2024-02-28  1790  	 * the ro_image(RX) for calculating the offsets in the image. The RW
1dad391daef129 Puranjay Mohan        2024-02-28  1791  	 * image will be later copied to the RX image from where the program
1dad391daef129 Puranjay Mohan        2024-02-28  1792  	 * will run. The bpf_jit_binary_pack_finalize() will do this copy in the
1dad391daef129 Puranjay Mohan        2024-02-28  1793  	 * final step.
1dad391daef129 Puranjay Mohan        2024-02-28  1794  	 */
425e1ed73e6574 Luc Van Oostenryck    2017-06-28  1795  	ctx.image = (__le32 *)image_ptr;
1dad391daef129 Puranjay Mohan        2024-02-28  1796  	ctx.ro_image = (__le32 *)ro_image_ptr;
800834285361dc Jean-Philippe Brucker 2020-07-28  1797  	if (extable_size)
1dad391daef129 Puranjay Mohan        2024-02-28  1798  		prog->aux->extable = (void *)ro_image_ptr + extable_offset;
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1799  skip_init_ctx:
e54bcde3d69d40 Zi Shen Lim           2014-08-26  1800  	ctx.idx = 0;
800834285361dc Jean-Philippe Brucker 2020-07-28  1801  	ctx.exentry_idx = 0;
b569c1c622c5e6 Daniel Borkmann       2014-09-16  1802  
339af577ec05c8 Puranjay Mohan        2024-03-25  1803  	build_prologue(&ctx, was_classic, prog->aux->exception_cb, arena_vm_start);
e54bcde3d69d40 Zi Shen Lim           2014-08-26  1804  
8c11ea5ce13da0 Daniel Borkmann       2018-11-26  1805  	if (build_body(&ctx, extra_pass)) {
26eb042ee4c784 Daniel Borkmann       2016-05-13  1806  		prog = orig_prog;
1dad391daef129 Puranjay Mohan        2024-02-28  1807  		goto out_free_hdr;
60ef0494f197d4 Daniel Borkmann       2014-09-11  1808  	}
e54bcde3d69d40 Zi Shen Lim           2014-08-26  1809  
22fc0e80aeb5c0 Puranjay Mohan        2024-02-01  1810  	build_epilogue(&ctx, prog->aux->exception_cb);
b2ad54e1533e91 Xu Kuohai             2022-07-11  1811  	build_plt(&ctx);
e54bcde3d69d40 Zi Shen Lim           2014-08-26  1812  
42ff712bc0c3d7 Zi Shen Lim           2016-01-13  1813  	/* 3. Extra pass to validate JITed code. */
efc9909fdce00a Xu Kuohai             2022-07-11  1814  	if (validate_ctx(&ctx)) {
26eb042ee4c784 Daniel Borkmann       2016-05-13  1815  		prog = orig_prog;
1dad391daef129 Puranjay Mohan        2024-02-28  1816  		goto out_free_hdr;
42ff712bc0c3d7 Zi Shen Lim           2016-01-13  1817  	}
42ff712bc0c3d7 Zi Shen Lim           2016-01-13  1818  
e54bcde3d69d40 Zi Shen Lim           2014-08-26  1819  	/* And we're done. */
e54bcde3d69d40 Zi Shen Lim           2014-08-26  1820  	if (bpf_jit_enable > 1)
800834285361dc Jean-Philippe Brucker 2020-07-28  1821  		bpf_jit_dump(prog->len, prog_size, 2, ctx.image);
e54bcde3d69d40 Zi Shen Lim           2014-08-26  1822  
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1823  	if (!prog->is_func || extra_pass) {
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1824  		if (extra_pass && ctx.idx != jit_data->ctx.idx) {
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1825  			pr_err_once("multi-func JIT bug %d != %d\n",
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1826  				    ctx.idx, jit_data->ctx.idx);
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1827  			prog->bpf_func = NULL;
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1828  			prog->jited = 0;
10f3b29c65bb2f Eric Dumazet          2022-05-31  1829  			prog->jited_len = 0;
1dad391daef129 Puranjay Mohan        2024-02-28  1830  			goto out_free_hdr;
1dad391daef129 Puranjay Mohan        2024-02-28  1831  		}
1dad391daef129 Puranjay Mohan        2024-02-28 @1832  		if (WARN_ON(bpf_jit_binary_pack_finalize(prog, ro_header,
1dad391daef129 Puranjay Mohan        2024-02-28  1833  							 header))) {
1dad391daef129 Puranjay Mohan        2024-02-28  1834  			/* ro_header has been freed */
1dad391daef129 Puranjay Mohan        2024-02-28  1835  			ro_header = NULL;
1dad391daef129 Puranjay Mohan        2024-02-28  1836  			prog = orig_prog;
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1837  			goto out_off;
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1838  		}
1dad391daef129 Puranjay Mohan        2024-02-28  1839  		/*
1dad391daef129 Puranjay Mohan        2024-02-28  1840  		 * The instructions have now been copied to the ROX region from
1dad391daef129 Puranjay Mohan        2024-02-28  1841  		 * where they will execute. Now the data cache has to be cleaned to
1dad391daef129 Puranjay Mohan        2024-02-28  1842  		 * the PoU and the I-cache has to be invalidated for the VAs.
1dad391daef129 Puranjay Mohan        2024-02-28  1843  		 */
1dad391daef129 Puranjay Mohan        2024-02-28  1844  		bpf_flush_icache(ro_header, ctx.ro_image + ctx.idx);
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1845  	} else {
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1846  		jit_data->ctx = ctx;
1dad391daef129 Puranjay Mohan        2024-02-28  1847  		jit_data->ro_image = ro_image_ptr;
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1848  		jit_data->header = header;
1dad391daef129 Puranjay Mohan        2024-02-28  1849  		jit_data->ro_header = ro_header;
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1850  	}
1dad391daef129 Puranjay Mohan        2024-02-28  1851  
1dad391daef129 Puranjay Mohan        2024-02-28  1852  	prog->bpf_func = (void *)ctx.ro_image;
a91263d520246b Daniel Borkmann       2015-09-30  1853  	prog->jited = 1;
800834285361dc Jean-Philippe Brucker 2020-07-28  1854  	prog->jited_len = prog_size;
26eb042ee4c784 Daniel Borkmann       2016-05-13  1855  
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1856  	if (!prog->is_func || extra_pass) {
dda7596c109fc3 Hou Tao               2022-02-26  1857  		int i;
dda7596c109fc3 Hou Tao               2022-02-26  1858  
dda7596c109fc3 Hou Tao               2022-02-26  1859  		/* offset[prog->len] is the size of program */
dda7596c109fc3 Hou Tao               2022-02-26  1860  		for (i = 0; i <= prog->len; i++)
dda7596c109fc3 Hou Tao               2022-02-26  1861  			ctx.offset[i] *= AARCH64_INSN_SIZE;
32f6865c7aa3c4 Ilias Apalodimas      2020-09-17  1862  		bpf_prog_fill_jited_linfo(prog, ctx.offset + 1);
26eb042ee4c784 Daniel Borkmann       2016-05-13  1863  out_off:
19f68ed6dc90c9 Aijun Sun             2022-08-04  1864  		kvfree(ctx.offset);
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1865  		kfree(jit_data);
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1866  		prog->aux->jit_data = NULL;
db496944fdaaf2 Alexei Starovoitov    2017-12-14  1867  	}
26eb042ee4c784 Daniel Borkmann       2016-05-13  1868  out:
26eb042ee4c784 Daniel Borkmann       2016-05-13  1869  	if (tmp_blinded)
26eb042ee4c784 Daniel Borkmann       2016-05-13  1870  		bpf_jit_prog_release_other(prog, prog == orig_prog ?
26eb042ee4c784 Daniel Borkmann       2016-05-13  1871  					   tmp : orig_prog);
d1c55ab5e41fcd Daniel Borkmann       2016-05-13  1872  	return prog;
1dad391daef129 Puranjay Mohan        2024-02-28  1873  
1dad391daef129 Puranjay Mohan        2024-02-28  1874  out_free_hdr:
1dad391daef129 Puranjay Mohan        2024-02-28  1875  	if (header) {
1dad391daef129 Puranjay Mohan        2024-02-28  1876  		bpf_arch_text_copy(&ro_header->size, &header->size,
1dad391daef129 Puranjay Mohan        2024-02-28  1877  				   sizeof(header->size));
1dad391daef129 Puranjay Mohan        2024-02-28  1878  		bpf_jit_binary_pack_free(ro_header, header);
1dad391daef129 Puranjay Mohan        2024-02-28  1879  	}
1dad391daef129 Puranjay Mohan        2024-02-28  1880  	goto out_off;
e54bcde3d69d40 Zi Shen Lim           2014-08-26  1881  }
91fc957c9b1d6c Ard Biesheuvel        2018-11-23  1882  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH bpf-next 1/3] bpf: remove unused parameter in bpf_jit_binary_pack_finalize
  2024-06-13  2:03 ` [PATCH bpf-next 1/3] bpf: remove unused parameter in bpf_jit_binary_pack_finalize Rafael Passos
  2024-06-13 11:27   ` kernel test robot
@ 2024-06-13 19:24   ` kernel test robot
  1 sibling, 0 replies; 5+ messages in thread
From: kernel test robot @ 2024-06-13 19:24 UTC (permalink / raw)
  To: Rafael Passos, davem, dsahern, ast, daniel, andrii, tglx, mingo,
	bp
  Cc: oe-kbuild-all, Rafael Passos, bpf

Hi Rafael,

kernel test robot noticed the following build errors:

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

url:    https://github.com/intel-lab-lkp/linux/commits/Rafael-Passos/bpf-remove-unused-parameter-in-__bpf_free_used_btfs/20240613-110048
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
patch link:    https://lore.kernel.org/r/7eaed3dc-28e5-409f-8f73-a1bf8acc2937%40smtp-relay.sendinblue.com
patch subject: [PATCH bpf-next 1/3] bpf: remove unused parameter in bpf_jit_binary_pack_finalize
config: powerpc-mpc885_ads_defconfig (https://download.01.org/0day-ci/archive/20240614/202406140304.4Rf0F9mg-lkp@intel.com/config)
compiler: powerpc-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240614/202406140304.4Rf0F9mg-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202406140304.4Rf0F9mg-lkp@intel.com/

All errors (new ones prefixed by >>):

   arch/powerpc/net/bpf_jit_comp.c: In function 'bpf_int_jit_compile':
>> arch/powerpc/net/bpf_jit_comp.c:228:50: error: passing argument 1 of 'bpf_jit_binary_pack_finalize' from incompatible pointer type [-Werror=incompatible-pointer-types]
     228 |                 if (bpf_jit_binary_pack_finalize(fp, fhdr, hdr)) {
         |                                                  ^~
         |                                                  |
         |                                                  struct bpf_prog *
   In file included from arch/powerpc/net/bpf_jit_comp.c:14:
   include/linux/filter.h:1132:60: note: expected 'struct bpf_binary_header *' but argument is of type 'struct bpf_prog *'
    1132 | int bpf_jit_binary_pack_finalize(struct bpf_binary_header *ro_header,
         |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
>> arch/powerpc/net/bpf_jit_comp.c:228:21: error: too many arguments to function 'bpf_jit_binary_pack_finalize'
     228 |                 if (bpf_jit_binary_pack_finalize(fp, fhdr, hdr)) {
         |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/filter.h:1132:5: note: declared here
    1132 | int bpf_jit_binary_pack_finalize(struct bpf_binary_header *ro_header,
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/powerpc/net/bpf_jit_comp.c: In function 'bpf_jit_free':
   arch/powerpc/net/bpf_jit_comp.c:351:54: error: passing argument 1 of 'bpf_jit_binary_pack_finalize' from incompatible pointer type [-Werror=incompatible-pointer-types]
     351 |                         bpf_jit_binary_pack_finalize(fp, jit_data->fhdr, jit_data->hdr);
         |                                                      ^~
         |                                                      |
         |                                                      struct bpf_prog *
   include/linux/filter.h:1132:60: note: expected 'struct bpf_binary_header *' but argument is of type 'struct bpf_prog *'
    1132 | int bpf_jit_binary_pack_finalize(struct bpf_binary_header *ro_header,
         |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
   arch/powerpc/net/bpf_jit_comp.c:351:25: error: too many arguments to function 'bpf_jit_binary_pack_finalize'
     351 |                         bpf_jit_binary_pack_finalize(fp, jit_data->fhdr, jit_data->hdr);
         |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/filter.h:1132:5: note: declared here
    1132 | int bpf_jit_binary_pack_finalize(struct bpf_binary_header *ro_header,
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors


vim +/bpf_jit_binary_pack_finalize +228 arch/powerpc/net/bpf_jit_comp.c

4ea76e90a97d22 Christophe Leroy 2021-03-22  222  
90d862f370b6e9 Hari Bathini     2023-10-20  223  	fp->bpf_func = (void *)fimage;
4ea76e90a97d22 Christophe Leroy 2021-03-22  224  	fp->jited = 1;
983bdc0245a29c Ravi Bangoria    2021-10-12  225  	fp->jited_len = proglen + FUNCTION_DESCR_SIZE;
4ea76e90a97d22 Christophe Leroy 2021-03-22  226  
4ea76e90a97d22 Christophe Leroy 2021-03-22  227  	if (!fp->is_func || extra_pass) {
90d862f370b6e9 Hari Bathini     2023-10-20 @228  		if (bpf_jit_binary_pack_finalize(fp, fhdr, hdr)) {
90d862f370b6e9 Hari Bathini     2023-10-20  229  			fp = org_fp;
90d862f370b6e9 Hari Bathini     2023-10-20  230  			goto out_addrs;
90d862f370b6e9 Hari Bathini     2023-10-20  231  		}
4ea76e90a97d22 Christophe Leroy 2021-03-22  232  		bpf_prog_fill_jited_linfo(fp, addrs);
4ea76e90a97d22 Christophe Leroy 2021-03-22  233  out_addrs:
4ea76e90a97d22 Christophe Leroy 2021-03-22  234  		kfree(addrs);
4ea76e90a97d22 Christophe Leroy 2021-03-22  235  		kfree(jit_data);
4ea76e90a97d22 Christophe Leroy 2021-03-22  236  		fp->aux->jit_data = NULL;
4ea76e90a97d22 Christophe Leroy 2021-03-22  237  	} else {
4ea76e90a97d22 Christophe Leroy 2021-03-22  238  		jit_data->addrs = addrs;
4ea76e90a97d22 Christophe Leroy 2021-03-22  239  		jit_data->ctx = cgctx;
4ea76e90a97d22 Christophe Leroy 2021-03-22  240  		jit_data->proglen = proglen;
90d862f370b6e9 Hari Bathini     2023-10-20  241  		jit_data->fimage = fimage;
90d862f370b6e9 Hari Bathini     2023-10-20  242  		jit_data->fhdr = fhdr;
90d862f370b6e9 Hari Bathini     2023-10-20  243  		jit_data->hdr = hdr;
4ea76e90a97d22 Christophe Leroy 2021-03-22  244  	}
4ea76e90a97d22 Christophe Leroy 2021-03-22  245  
4ea76e90a97d22 Christophe Leroy 2021-03-22  246  out:
4ea76e90a97d22 Christophe Leroy 2021-03-22  247  	if (bpf_blinded)
4ea76e90a97d22 Christophe Leroy 2021-03-22  248  		bpf_jit_prog_release_other(fp, fp == org_fp ? tmp_fp : org_fp);
4ea76e90a97d22 Christophe Leroy 2021-03-22  249  
4ea76e90a97d22 Christophe Leroy 2021-03-22  250  	return fp;
4ea76e90a97d22 Christophe Leroy 2021-03-22  251  }
983bdc0245a29c Ravi Bangoria    2021-10-12  252  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-06-13 19:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20240613020729.43953-1-rafael@rcpassos.me>
2024-06-13  2:03 ` [PATCH bpf-next 1/3] bpf: remove unused parameter in bpf_jit_binary_pack_finalize Rafael Passos
2024-06-13 11:27   ` kernel test robot
2024-06-13 19:24   ` kernel test robot
2024-06-13  2:03 ` [PATCH bpf-next 2/3] bpf: remove unused parameter in __bpf_free_used_btfs Rafael Passos
2024-06-13  2:03 ` [PATCH bpf-next 3/3] bpf: remove redeclaration of new_n in bpf_verifier_vlog Rafael Passos

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox