Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1667618 > unrolled thread

Re: [PATCH RFC 2/3] samples/bpf: Add define __EMITTING_BPF__ when building BPF

Started byDaniel Borkmann <daniel@iogearbox.net>
First post2017-06-16 12:30 +0200
Last post2017-06-16 18:20 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH RFC 2/3] samples/bpf: Add define __EMITTING_BPF__ when  building BPF Daniel Borkmann <daniel@iogearbox.net> - 2017-06-16 12:30 +0200
    Re: [PATCH RFC 2/3] samples/bpf: Add define __EMITTING_BPF__ when  building BPF David Miller <davem@davemloft.net> - 2017-06-16 18:20 +0200

#1667618 — Re: [PATCH RFC 2/3] samples/bpf: Add define __EMITTING_BPF__ when building BPF

FromDaniel Borkmann <daniel@iogearbox.net>
Date2017-06-16 12:30 +0200
SubjectRe: [PATCH RFC 2/3] samples/bpf: Add define __EMITTING_BPF__ when building BPF
Message-ID<tSWFQ-7co-23@gated-at.bofh.it>
On 06/16/2017 12:35 AM, David Daney wrote:
> ... this allows gating of inline assembly code that causes llvm to
> fail when emitting BPF.
>
> Signed-off-by: David Daney <david.daney@cavium.com>

I don't have a better idea at the moment, perhaps there could be
a clang rewrite plugin that would ignore all inline assembly code
since this is never used from BPF progs. Hmm. Really ugly that
we have to add this __EMITTING_BPF__ into arch asm files, but I
don't have a better idea for an immediate workaround right now ...
I would really prefer if we could avoid just for the sake of the
kernel samples going down the road of adding a !defined(__EMITTING_BPF__)
into a uapi asm header for mips, though. Is this coming from
networking sample code or rather tracing?

> ---
>   samples/bpf/Makefile | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
> index a0561dc762fe..4979e6b56662 100644
> --- a/samples/bpf/Makefile
> +++ b/samples/bpf/Makefile
> @@ -193,12 +193,12 @@ $(src)/*.c: verify_target_bpf
>
>   $(obj)/tracex5_kern.o: $(obj)/syscall_nrs.h
>
> -# asm/sysreg.h - inline assembly used by it is incompatible with llvm.
> -# But, there is no easy way to fix it, so just exclude it since it is
> -# useless for BPF samples.
> +# __EMITTING_BPF__ used to exclude inline assembly, which cannot be
> +# emitted in BPF code.
>   $(obj)/%.o: $(src)/%.c
>   	$(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \
> -		-D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \
> +		-D__KERNEL__ -D__EMITTING_BPF__ \
> +		-Wno-unused-value -Wno-pointer-sign \
>   		-Wno-compare-distinct-pointer-types \
>   		-Wno-gnu-variable-sized-type-not-at-end \
>   		-Wno-address-of-packed-member -Wno-tautological-compare \
>

[toc] | [next] | [standalone]


#1667870

FromDavid Miller <davem@davemloft.net>
Date2017-06-16 18:20 +0200
Message-ID<tT28y-2qw-17@gated-at.bofh.it>
In reply to#1667618
From: Daniel Borkmann <daniel@iogearbox.net>
Date: Fri, 16 Jun 2017 12:24:06 +0200

> On 06/16/2017 12:35 AM, David Daney wrote:
>> ... this allows gating of inline assembly code that causes llvm to
>> fail when emitting BPF.
>>
>> Signed-off-by: David Daney <david.daney@cavium.com>
> 
> I don't have a better idea at the moment, perhaps there could be
> a clang rewrite plugin that would ignore all inline assembly code
> since this is never used from BPF progs. Hmm. Really ugly that
> we have to add this __EMITTING_BPF__ into arch asm files, but I
> don't have a better idea for an immediate workaround right now ...
> I would really prefer if we could avoid just for the sake of the
> kernel samples going down the road of adding a
> !defined(__EMITTING_BPF__)
> into a uapi asm header for mips, though. Is this coming from
> networking sample code or rather tracing?

The problem is that we include the arch include/asm files at all.

When we build bpf stuff, we should have a set of asm/ files
specifically for builds targetting BPF.

Let's just fix this right and stop putting all of these hacks in.

Thank you.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web