Netdev List
 help / color / mirror / Atom feed
* [PATCH bpf-next] selftests/bpf: enforce no-ALU32 for test_progs-no_alu32
@ 2019-11-20  0:25 Andrii Nakryiko
  2019-11-20  0:32 ` Yonghong Song
  0 siblings, 1 reply; 3+ messages in thread
From: Andrii Nakryiko @ 2019-11-20  0:25 UTC (permalink / raw)
  To: bpf, netdev, ast, daniel; +Cc: andrii.nakryiko, kernel-team, Andrii Nakryiko

With the most recent Clang, alu32 is enabled by default if -mcpu=probe or
-mcpu=v3 is specified. Use a separate build rule with -mcpu=v2 to enforce no
ALU32 mode.

Suggested-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
---
 tools/testing/selftests/bpf/Makefile | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index d4400fbe6634..4fe4aec0367c 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -163,6 +163,12 @@ define CLANG_BPF_BUILD_RULE
 		-c $1 -o - || echo "BPF obj compilation failed") | 	\
 	$(LLC) -march=bpf -mcpu=probe $4 -filetype=obj -o $2
 endef
+# Similar to CLANG_BPF_BUILD_RULE, but with disabled alu32
+define CLANG_NOALU32_BPF_BUILD_RULE
+	($(CLANG) $3 -O2 -target bpf -emit-llvm				\
+		-c $1 -o - || echo "BPF obj compilation failed") | 	\
+	$(LLC) -march=bpf -mcpu=v2 $4 -filetype=obj -o $2
+endef
 # Similar to CLANG_BPF_BUILD_RULE, but using native Clang and bpf LLC
 define CLANG_NATIVE_BPF_BUILD_RULE
 	($(CLANG) $3 -O2 -emit-llvm					\
@@ -275,6 +281,7 @@ TRUNNER_BPF_LDFLAGS := -mattr=+alu32
 $(eval $(call DEFINE_TEST_RUNNER,test_progs))
 
 # Define test_progs-no_alu32 test runner.
+TRUNNER_BPF_BUILD_RULE := CLANG_NOALU32_BPF_BUILD_RULE
 TRUNNER_BPF_LDFLAGS :=
 $(eval $(call DEFINE_TEST_RUNNER,test_progs,no_alu32))
 
-- 
2.17.1


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

* Re: [PATCH bpf-next] selftests/bpf: enforce no-ALU32 for test_progs-no_alu32
  2019-11-20  0:25 [PATCH bpf-next] selftests/bpf: enforce no-ALU32 for test_progs-no_alu32 Andrii Nakryiko
@ 2019-11-20  0:32 ` Yonghong Song
  2019-11-20  0:55   ` Alexei Starovoitov
  0 siblings, 1 reply; 3+ messages in thread
From: Yonghong Song @ 2019-11-20  0:32 UTC (permalink / raw)
  To: Andrii Nakryiko, bpf@vger.kernel.org, netdev@vger.kernel.org,
	Alexei Starovoitov, daniel@iogearbox.net
  Cc: andrii.nakryiko@gmail.com, Kernel Team



On 11/19/19 4:25 PM, Andrii Nakryiko wrote:
> With the most recent Clang, alu32 is enabled by default if -mcpu=probe or
> -mcpu=v3 is specified. Use a separate build rule with -mcpu=v2 to enforce no

A little bit clarification -mcpu=probe may not enable alu32 for old 
kernels. alu32 enabled with -mcpu=probe only if kernel supports jmp32, 
which is merged in January this year.

> ALU32 mode.
> 
> Suggested-by: Yonghong Song <yhs@fb.com>
> Signed-off-by: Andrii Nakryiko <andriin@fb.com>

With the above nit,
Acked-by: Yonghong Song <yhs@fb.com>

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

* Re: [PATCH bpf-next] selftests/bpf: enforce no-ALU32 for test_progs-no_alu32
  2019-11-20  0:32 ` Yonghong Song
@ 2019-11-20  0:55   ` Alexei Starovoitov
  0 siblings, 0 replies; 3+ messages in thread
From: Alexei Starovoitov @ 2019-11-20  0:55 UTC (permalink / raw)
  To: Yonghong Song
  Cc: Andrii Nakryiko, bpf@vger.kernel.org, netdev@vger.kernel.org,
	Alexei Starovoitov, daniel@iogearbox.net,
	andrii.nakryiko@gmail.com, Kernel Team

On Tue, Nov 19, 2019 at 4:32 PM Yonghong Song <yhs@fb.com> wrote:
>
>
>
> On 11/19/19 4:25 PM, Andrii Nakryiko wrote:
> > With the most recent Clang, alu32 is enabled by default if -mcpu=probe or
> > -mcpu=v3 is specified. Use a separate build rule with -mcpu=v2 to enforce no
>
> A little bit clarification -mcpu=probe may not enable alu32 for old
> kernels. alu32 enabled with -mcpu=probe only if kernel supports jmp32,
> which is merged in January this year.
>
> > ALU32 mode.
> >
> > Suggested-by: Yonghong Song <yhs@fb.com>
> > Signed-off-by: Andrii Nakryiko <andriin@fb.com>
>
> With the above nit,
> Acked-by: Yonghong Song <yhs@fb.com>

Applied. Thanks for the fix.

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

end of thread, other threads:[~2019-11-20  0:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-20  0:25 [PATCH bpf-next] selftests/bpf: enforce no-ALU32 for test_progs-no_alu32 Andrii Nakryiko
2019-11-20  0:32 ` Yonghong Song
2019-11-20  0:55   ` Alexei Starovoitov

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