bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests/bpf: add GCC compatible builtins to bpf_legacy.h
@ 2022-12-01 19:09 James Hilliard
  2022-12-03  0:23 ` Andrii Nakryiko
  2022-12-03  0:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: James Hilliard @ 2022-12-01 19:09 UTC (permalink / raw)
  To: bpf
  Cc: James Hilliard, Jose E . Marchesi, David Faust,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Mykola Lysenko,
	Shuah Khan, Nathan Chancellor, Nick Desaulniers, Tom Rix,
	linux-kselftest, linux-kernel, llvm

The bpf_legacy.h header uses llvm specific load functions, add
GCC compatible variants as well to fix tests using these functions
under GCC.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
Cc: Jose E. Marchesi <jose.marchesi@oracle.com>
Cc: David Faust <david.faust@oracle.com>
---
 tools/testing/selftests/bpf/bpf_legacy.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tools/testing/selftests/bpf/bpf_legacy.h b/tools/testing/selftests/bpf/bpf_legacy.h
index 845209581440..256c2a90aa20 100644
--- a/tools/testing/selftests/bpf/bpf_legacy.h
+++ b/tools/testing/selftests/bpf/bpf_legacy.h
@@ -2,6 +2,15 @@
 #ifndef __BPF_LEGACY__
 #define __BPF_LEGACY__
 
+#if __GNUC__ && !__clang__
+/* Functions to emit BPF_LD_ABS and BPF_LD_IND instructions.  We
+ * provide the "standard" names as synonyms of the corresponding GCC
+ * builtins.  Note how the SKB argument is ignored.
+ */
+#define load_byte(skb,off) __builtin_bpf_load_byte((off))
+#define load_half(skb,off) __builtin_bpf_load_half((off))
+#define load_word(skb,off) __builtin_bpf_load_word((off))
+#else
 /* llvm builtin functions that eBPF C program may use to
  * emit BPF_LD_ABS and BPF_LD_IND instructions
  */
@@ -11,6 +20,7 @@ unsigned long long load_half(void *skb,
 			     unsigned long long off) asm("llvm.bpf.load.half");
 unsigned long long load_word(void *skb,
 			     unsigned long long off) asm("llvm.bpf.load.word");
+#endif
 
 #endif
 
-- 
2.34.1


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

* Re: [PATCH] selftests/bpf: add GCC compatible builtins to bpf_legacy.h
  2022-12-01 19:09 [PATCH] selftests/bpf: add GCC compatible builtins to bpf_legacy.h James Hilliard
@ 2022-12-03  0:23 ` Andrii Nakryiko
  2022-12-03  0:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Andrii Nakryiko @ 2022-12-03  0:23 UTC (permalink / raw)
  To: James Hilliard
  Cc: bpf, Jose E . Marchesi, David Faust, Alexei Starovoitov,
	Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
	Hao Luo, Jiri Olsa, Mykola Lysenko, Shuah Khan,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, linux-kselftest,
	linux-kernel, llvm

On Thu, Dec 1, 2022 at 11:10 AM James Hilliard
<james.hilliard1@gmail.com> wrote:
>
> The bpf_legacy.h header uses llvm specific load functions, add
> GCC compatible variants as well to fix tests using these functions
> under GCC.
>
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> Cc: Jose E. Marchesi <jose.marchesi@oracle.com>
> Cc: David Faust <david.faust@oracle.com>
> ---

Please use [PATCH bpf-next] prefix to target patches for bpf-next
tree. This helps some of our automation.

>  tools/testing/selftests/bpf/bpf_legacy.h | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/bpf_legacy.h b/tools/testing/selftests/bpf/bpf_legacy.h
> index 845209581440..256c2a90aa20 100644
> --- a/tools/testing/selftests/bpf/bpf_legacy.h
> +++ b/tools/testing/selftests/bpf/bpf_legacy.h
> @@ -2,6 +2,15 @@
>  #ifndef __BPF_LEGACY__
>  #define __BPF_LEGACY__
>
> +#if __GNUC__ && !__clang__
> +/* Functions to emit BPF_LD_ABS and BPF_LD_IND instructions.  We
> + * provide the "standard" names as synonyms of the corresponding GCC
> + * builtins.  Note how the SKB argument is ignored.
> + */
> +#define load_byte(skb,off) __builtin_bpf_load_byte((off))
> +#define load_half(skb,off) __builtin_bpf_load_half((off))
> +#define load_word(skb,off) __builtin_bpf_load_word((off))

added space between skb, and off. And we don't need those extra ()
around off, right? I stripped them away, but let me know if that's
wrong.

> +#else
>  /* llvm builtin functions that eBPF C program may use to
>   * emit BPF_LD_ABS and BPF_LD_IND instructions
>   */
> @@ -11,6 +20,7 @@ unsigned long long load_half(void *skb,
>                              unsigned long long off) asm("llvm.bpf.load.half");
>  unsigned long long load_word(void *skb,
>                              unsigned long long off) asm("llvm.bpf.load.word");
> +#endif
>
>  #endif
>
> --
> 2.34.1
>

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

* Re: [PATCH] selftests/bpf: add GCC compatible builtins to bpf_legacy.h
  2022-12-01 19:09 [PATCH] selftests/bpf: add GCC compatible builtins to bpf_legacy.h James Hilliard
  2022-12-03  0:23 ` Andrii Nakryiko
@ 2022-12-03  0:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-12-03  0:30 UTC (permalink / raw)
  To: James Hilliard
  Cc: bpf, jose.marchesi, david.faust, ast, daniel, andrii, martin.lau,
	song, yhs, john.fastabend, kpsingh, sdf, haoluo, jolsa, mykolal,
	shuah, nathan, ndesaulniers, trix, linux-kselftest, linux-kernel,
	llvm

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Thu,  1 Dec 2022 12:09:39 -0700 you wrote:
> The bpf_legacy.h header uses llvm specific load functions, add
> GCC compatible variants as well to fix tests using these functions
> under GCC.
> 
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> Cc: Jose E. Marchesi <jose.marchesi@oracle.com>
> Cc: David Faust <david.faust@oracle.com>
> 
> [...]

Here is the summary with links:
  - selftests/bpf: add GCC compatible builtins to bpf_legacy.h
    https://git.kernel.org/bpf/bpf-next/c/f16a7aa5c2be

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] 3+ messages in thread

end of thread, other threads:[~2022-12-03  0:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-01 19:09 [PATCH] selftests/bpf: add GCC compatible builtins to bpf_legacy.h James Hilliard
2022-12-03  0:23 ` Andrii Nakryiko
2022-12-03  0:30 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).