All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf] selftests/bpf: Fix casting error when cross-compiling test_verifier for 32-bit platforms
@ 2022-11-08 12:19 Pu Lehui
  2022-11-08 12:29 ` Eduard Zingerman
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Pu Lehui @ 2022-11-08 12:19 UTC (permalink / raw)
  To: bpf, linux-kernel
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Eduard Zingerman, Pu Lehui, Pu Lehui

From: Pu Lehui <pulehui@huawei.com>

When cross-compiling test_verifier for 32-bit platforms, the casting error is shown below:

test_verifier.c:1263:27: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
 1263 |  info.xlated_prog_insns = (__u64)*buf;
      |                           ^
cc1: all warnings being treated as errors

Fix it by adding zero-extension for it.

Fixes: 933ff53191eb ("selftests/bpf: specify expected instructions in test_verifier tests")
Signed-off-by: Pu Lehui <pulehui@huawei.com>
---
 tools/testing/selftests/bpf/test_verifier.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
index 2dbcbf363c18..b605a70d4f6b 100644
--- a/tools/testing/selftests/bpf/test_verifier.c
+++ b/tools/testing/selftests/bpf/test_verifier.c
@@ -1260,7 +1260,7 @@ static int get_xlated_program(int fd_prog, struct bpf_insn **buf, int *cnt)
 
 	bzero(&info, sizeof(info));
 	info.xlated_prog_len = xlated_prog_len;
-	info.xlated_prog_insns = (__u64)*buf;
+	info.xlated_prog_insns = (__u64)(unsigned long)*buf;
 	if (bpf_obj_get_info_by_fd(fd_prog, &info, &info_len)) {
 		perror("second bpf_obj_get_info_by_fd failed");
 		goto out_free_buf;
-- 
2.25.1


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

* Re: [PATCH bpf] selftests/bpf: Fix casting error when cross-compiling test_verifier for 32-bit platforms
  2022-11-08 12:19 [PATCH bpf] selftests/bpf: Fix casting error when cross-compiling test_verifier for 32-bit platforms Pu Lehui
@ 2022-11-08 12:29 ` Eduard Zingerman
  2022-11-08 14:45 ` Yonghong Song
  2022-11-09 20:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Eduard Zingerman @ 2022-11-08 12:29 UTC (permalink / raw)
  To: Pu Lehui, bpf, linux-kernel
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Pu Lehui

On Tue, 2022-11-08 at 20:19 +0800, Pu Lehui wrote:
> From: Pu Lehui <pulehui@huawei.com>
> 
> When cross-compiling test_verifier for 32-bit platforms, the casting error is shown below:
> 
> test_verifier.c:1263:27: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
>  1263 |  info.xlated_prog_insns = (__u64)*buf;
>       |                           ^
> cc1: all warnings being treated as errors
> 
> Fix it by adding zero-extension for it.

Looks good, sorry missed this case when coding this function...

> 
> Fixes: 933ff53191eb ("selftests/bpf: specify expected instructions in test_verifier tests")
> Signed-off-by: Pu Lehui <pulehui@huawei.com>
> ---
>  tools/testing/selftests/bpf/test_verifier.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
> index 2dbcbf363c18..b605a70d4f6b 100644
> --- a/tools/testing/selftests/bpf/test_verifier.c
> +++ b/tools/testing/selftests/bpf/test_verifier.c
> @@ -1260,7 +1260,7 @@ static int get_xlated_program(int fd_prog, struct bpf_insn **buf, int *cnt)
>  
>  	bzero(&info, sizeof(info));
>  	info.xlated_prog_len = xlated_prog_len;
> -	info.xlated_prog_insns = (__u64)*buf;
> +	info.xlated_prog_insns = (__u64)(unsigned long)*buf;
>  	if (bpf_obj_get_info_by_fd(fd_prog, &info, &info_len)) {
>  		perror("second bpf_obj_get_info_by_fd failed");
>  		goto out_free_buf;


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

* Re: [PATCH bpf] selftests/bpf: Fix casting error when cross-compiling test_verifier for 32-bit platforms
  2022-11-08 12:19 [PATCH bpf] selftests/bpf: Fix casting error when cross-compiling test_verifier for 32-bit platforms Pu Lehui
  2022-11-08 12:29 ` Eduard Zingerman
@ 2022-11-08 14:45 ` Yonghong Song
  2022-11-09 20:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Yonghong Song @ 2022-11-08 14:45 UTC (permalink / raw)
  To: Pu Lehui, bpf, linux-kernel
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Eduard Zingerman, Pu Lehui



On 11/8/22 4:19 AM, Pu Lehui wrote:
> From: Pu Lehui <pulehui@huawei.com>
> 
> When cross-compiling test_verifier for 32-bit platforms, the casting error is shown below:
> 
> test_verifier.c:1263:27: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
>   1263 |  info.xlated_prog_insns = (__u64)*buf;
>        |                           ^
> cc1: all warnings being treated as errors
> 
> Fix it by adding zero-extension for it.
> 
> Fixes: 933ff53191eb ("selftests/bpf: specify expected instructions in test_verifier tests")
> Signed-off-by: Pu Lehui <pulehui@huawei.com>

Acked-by: Yonghong Song <yhs@fb.com>

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

* Re: [PATCH bpf] selftests/bpf: Fix casting error when cross-compiling test_verifier for 32-bit platforms
  2022-11-08 12:19 [PATCH bpf] selftests/bpf: Fix casting error when cross-compiling test_verifier for 32-bit platforms Pu Lehui
  2022-11-08 12:29 ` Eduard Zingerman
  2022-11-08 14:45 ` Yonghong Song
@ 2022-11-09 20:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-11-09 20:40 UTC (permalink / raw)
  To: Pu Lehui
  Cc: bpf, linux-kernel, ast, daniel, andrii, martin.lau, song, yhs,
	john.fastabend, kpsingh, sdf, haoluo, jolsa, eddyz87, pulehui

Hello:

This patch was applied to bpf/bpf.git (master)
by Martin KaFai Lau <martin.lau@kernel.org>:

On Tue,  8 Nov 2022 20:19:45 +0800 you wrote:
> From: Pu Lehui <pulehui@huawei.com>
> 
> When cross-compiling test_verifier for 32-bit platforms, the casting error is shown below:
> 
> test_verifier.c:1263:27: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
>  1263 |  info.xlated_prog_insns = (__u64)*buf;
>       |                           ^
> cc1: all warnings being treated as errors
> 
> [...]

Here is the summary with links:
  - [bpf] selftests/bpf: Fix casting error when cross-compiling test_verifier for 32-bit platforms
    https://git.kernel.org/bpf/bpf/c/0811664da064

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2022-11-09 20:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-08 12:19 [PATCH bpf] selftests/bpf: Fix casting error when cross-compiling test_verifier for 32-bit platforms Pu Lehui
2022-11-08 12:29 ` Eduard Zingerman
2022-11-08 14:45 ` Yonghong Song
2022-11-09 20:40 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.