From: Yonghong Song <yhs@fb.com>
To: Daniel Borkmann <daniel@iogearbox.net>, <alexei.starovoitov@gmail.com>
Cc: <bpf@vger.kernel.org>, <netdev@vger.kernel.org>,
<yanivagman@gmail.com>, <andrii.nakryiko@gmail.com>
Subject: Re: [PATCH bpf] bpf, libbpf: guard bpf inline asm from bpf_tail_call_static
Date: Wed, 21 Oct 2020 13:49:46 -0700 [thread overview]
Message-ID: <0c4af0f3-2aee-52f3-e294-cfe047d017f7@fb.com> (raw)
In-Reply-To: <20201021203257.26223-1-daniel@iogearbox.net>
On 10/21/20 1:32 PM, Daniel Borkmann wrote:
> Yaniv reported a compilation error after pulling latest libbpf:
>
> [...]
> ../libbpf/src/root/usr/include/bpf/bpf_helpers.h:99:10: error:
> unknown register name 'r0' in asm
> : "r0", "r1", "r2", "r3", "r4", "r5");
> [...]
>
> The issue got triggered given Yaniv was compiling tracing programs with native
> target (e.g. x86) instead of BPF target, hence no BTF generated vmlinux.h nor
> CO-RE used, and later llc with -march=bpf was invoked to compile from LLVM IR
> to BPF object file. Given that clang was expecting x86 inline asm and not BPF
> one the error complained that these regs don't exist on the former.
>
> Guard bpf_tail_call_static() with defined(__bpf__) where BPF inline asm is valid
> to use. BPF tracing programs on more modern kernels use BPF target anyway and
> thus the bpf_tail_call_static() function will be available for them. BPF inline
> asm is supported since clang 7 (clang <= 6 otherwise throws same above error),
> and __bpf_unreachable() since clang 8, therefore include the latter condition
> in order to prevent compilation errors for older clang versions. Given even an
> old Ubuntu 18.04 LTS has official LLVM packages all the way up to llvm-10, I did
> not bother to special case the __bpf_unreachable() inside bpf_tail_call_static()
> further.
>
> Fixes: 0e9f6841f664 ("bpf, libbpf: Add bpf_tail_call_static helper for bpf programs")
> Reported-by: Yaniv Agman <yanivagman@gmail.com>
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> Link: https://lore.kernel.org/bpf/CAMy7=ZUk08w5Gc2Z-EKi4JFtuUCaZYmE4yzhJjrExXpYKR4L8w@mail.gmail.com
Acked-by: Yonghong Song <yhs@fb.com>
next prev parent reply other threads:[~2020-10-21 20:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-21 20:32 [PATCH bpf] bpf, libbpf: guard bpf inline asm from bpf_tail_call_static Daniel Borkmann
2020-10-21 20:49 ` Yonghong Song [this message]
2020-10-21 22:20 ` Yaniv Agman
2020-10-21 23:18 ` Andrii Nakryiko
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=0c4af0f3-2aee-52f3-e294-cfe047d017f7@fb.com \
--to=yhs@fb.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=netdev@vger.kernel.org \
--cc=yanivagman@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox