From: Arnaldo Carvalho de Melo <acme@redhat.com>
To: Yonghong Song <yhs@fb.com>
Cc: Alexei Starovoitov <ast@fb.com>,
Daniel Borkmann <daniel@iogearbox.net>,
David Miller <davem@davemloft.net>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
acme@kernel.org,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: bpf: handling non BPF register names in inline assembly with -target bpf
Date: Wed, 11 Apr 2018 15:39:02 -0300 [thread overview]
Message-ID: <20180411183902.GC12166@redhat.com> (raw)
In-Reply-To: <c8b0b3c0-6687-1be2-66d0-95b20662145d@fb.com>
Em Wed, Apr 11, 2018 at 09:37:46AM -0700, Yonghong Song escreveu:
> Hi, Arnaldo,
> When I studied the bpf compilation issue with latest linus/net-next
> kernel (https://patchwork.kernel.org/patch/10333829/), an alternative
> approach I tried is to use __BPF__ macro.
You mean you used an alternative approach that does _not_ use the
__BPF__ macro, right? I looked at the patch and yeah, looks sane as
well, since the kernel build process already defines that
CC_HAVE_ASM_GOTO, checking if gcc has that feature, etc.
> The following patch introduced "#ifndef __BPF__" in
> arch/x86/include/asm/asm.h for some inline assembly related to x86
> "esp" register name.
> ==========
> commit ca26cffa4e4aaeb09bb9e308f95c7835cb149248
> Author: Arnaldo Carvalho de Melo <acme@redhat.com>
> Date: Mon Dec 4 13:08:47 2017 -0300
>
> x86/asm: Allow again using asm.h when building for the 'bpf'
> clang target
>
> Up to f5caf621ee35 ("x86/asm: Fix inline asm call constraints
> for Clang")
> we were able to use x86 headers to build to the 'bpf' clang target, as
> done by the BPF code in tools/perf/.
> ...
> diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h
> index 219faae..386a690 100644
> --- a/arch/x86/include/asm/asm.h
> +++ b/arch/x86/include/asm/asm.h
> @@ -136,6 +136,7 @@
> #endif
>
> #ifndef __ASSEMBLY__
> +#ifndef __BPF__
> /*
> * This output constraint should be used for any inline asm which
> has a "call"
> * instruction. Otherwise the asm may be inserted before the frame
> pointer
> @@ -145,5 +146,6 @@
> register unsigned long current_stack_pointer asm(_ASM_SP);
> #define ASM_CALL_CONSTRAINT "+r" (current_stack_pointer)
> #endif
> +#endif
> ...
> ==========
>
> I just landed a clang patch (clang 7.0.0 trunk)
> https://reviews.llvm.org/rL329823
> which will permit bpf clang target to accept ANY register
> names. In this case, the inline assembly will be accepted by clang
> and will be thrown away since variable current_stack_pointer is
> not used in bpf programs.
Ok, then that ifndef __BPF__ above will not be needed anymore, but only
people with clang > that version will be able to build tools/perf/
> If the inline assembly is indeed for BPF program, later llc
> AsmParser will do syntax and semantics checking again.
>
> With the above clang patch, the above "#ifndef __BPF__" can be removed.
> You can decide when is the appropriate time to use latest clang compiler
> and remove the above "#ifndef __BPF__".
So are you proposing that we have something similar to that
CC_HAVE_ASM_GOTO check in the kernel main Makefile, to define something
like CC_HAVE_ASM_REGS (or some better name), i.e. something like:
# check for 'asm(_ASM_SP)'
ifeq ($(call shell-cached,$(CONFIG_SHELL) $(srctree)/scripts/cc-asm-regs.sh
$(CC) $(KBUILD_CFLAGS)), y)
CC_HAVE_ASM_REGS := 1
KBUILD_CFLAGS += -DCC_HAVE_ASM_REGS
KBUILD_AFLAGS += -DCC_HAVE_ASM_REGS
endif
?
- Arnaldo
next prev parent reply other threads:[~2018-04-11 21:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-11 16:37 bpf: handling non BPF register names in inline assembly with -target bpf Yonghong Song
2018-04-11 18:39 ` Arnaldo Carvalho de Melo [this message]
2018-04-11 19:22 ` Yonghong Song
2018-04-11 19:47 ` Arnaldo Carvalho de Melo
2018-04-11 23:17 ` Arnaldo Carvalho de Melo
2018-04-11 23:22 ` Yonghong Song
2018-04-16 6:44 ` [tip:perf/urgent] perf tests bpf: Remove unused ptrace.h include from LLVM test tip-bot for Arnaldo Carvalho de Melo
2018-04-16 6:44 ` [tip:perf/urgent] Revert "x86/asm: Allow again using asm.h when building for the 'bpf' clang target" tip-bot for Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180411183902.GC12166@redhat.com \
--to=acme@redhat.com \
--cc=acme@kernel.org \
--cc=ast@fb.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.