2018-05-14 21:42:27 +08:00
|
|
|
=================================
|
|
|
|
HOWTO interact with BPF subsystem
|
|
|
|
=================================
|
|
|
|
|
2017-12-06 08:12:41 +08:00
|
|
|
This document provides information for the BPF subsystem about various
|
|
|
|
workflows related to reporting bugs, submitting patches, and queueing
|
|
|
|
patches for stable kernels.
|
|
|
|
|
|
|
|
For general information about submitting patches, please refer to
|
2018-05-14 21:42:27 +08:00
|
|
|
`Documentation/process/`_. This document only describes additional specifics
|
2017-12-06 08:12:41 +08:00
|
|
|
related to BPF.
|
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
.. contents::
|
|
|
|
:local:
|
|
|
|
:depth: 2
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
Reporting bugs
|
|
|
|
==============
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
Q: How do I report bugs for BPF kernel code?
|
|
|
|
--------------------------------------------
|
2017-12-06 08:12:41 +08:00
|
|
|
A: Since all BPF kernel development as well as bpftool and iproute2 BPF
|
2020-02-21 08:43:54 +08:00
|
|
|
loader development happens through the bpf kernel mailing list,
|
2018-05-14 21:42:27 +08:00
|
|
|
please report any found issues around BPF to the following mailing
|
|
|
|
list:
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2020-02-21 08:43:54 +08:00
|
|
|
bpf@vger.kernel.org
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
This may also include issues related to XDP, BPF tracing, etc.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
Given netdev has a high volume of traffic, please also add the BPF
|
|
|
|
maintainers to Cc (from kernel MAINTAINERS_ file):
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
* Alexei Starovoitov <ast@kernel.org>
|
|
|
|
* Daniel Borkmann <daniel@iogearbox.net>
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
In case a buggy commit has already been identified, make sure to keep
|
|
|
|
the actual commit authors in Cc as well for the report. They can
|
|
|
|
typically be identified through the kernel's git tree.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
**Please do NOT report BPF issues to bugzilla.kernel.org since it
|
|
|
|
is a guarantee that the reported issue will be overlooked.**
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
Submitting patches
|
|
|
|
==================
|
2017-12-06 08:12:41 +08:00
|
|
|
|
|
|
|
Q: To which mailing list do I need to submit my BPF patches?
|
2018-05-14 21:42:27 +08:00
|
|
|
------------------------------------------------------------
|
2020-02-21 08:43:54 +08:00
|
|
|
A: Please submit your BPF patches to the bpf kernel mailing list:
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2020-02-21 08:43:54 +08:00
|
|
|
bpf@vger.kernel.org
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
In case your patch has changes in various different subsystems (e.g.
|
2020-02-21 08:43:54 +08:00
|
|
|
networking, tracing, security, etc), make sure to Cc the related kernel mailing
|
2018-05-14 21:42:27 +08:00
|
|
|
lists and maintainers from there as well, so they are able to review
|
|
|
|
the changes and provide their Acked-by's to the patches.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
|
|
|
Q: Where can I find patches currently under discussion for BPF subsystem?
|
2018-05-14 21:42:27 +08:00
|
|
|
-------------------------------------------------------------------------
|
2017-12-06 08:12:41 +08:00
|
|
|
A: All patches that are Cc'ed to netdev are queued for review under netdev
|
2018-05-14 21:42:27 +08:00
|
|
|
patchwork project:
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2020-10-12 04:01:49 +08:00
|
|
|
https://patchwork.kernel.org/project/netdevbpf/list/
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
Those patches which target BPF, are assigned to a 'bpf' delegate for
|
|
|
|
further processing from BPF maintainers. The current queue with
|
|
|
|
patches under review can be found at:
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2020-10-12 04:01:49 +08:00
|
|
|
https://patchwork.kernel.org/project/netdevbpf/list/?delegate=121173
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
Once the patches have been reviewed by the BPF community as a whole
|
|
|
|
and approved by the BPF maintainers, their status in patchwork will be
|
|
|
|
changed to 'Accepted' and the submitter will be notified by mail. This
|
|
|
|
means that the patches look good from a BPF perspective and have been
|
|
|
|
applied to one of the two BPF kernel trees.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
In case feedback from the community requires a respin of the patches,
|
|
|
|
their status in patchwork will be set to 'Changes Requested', and purged
|
|
|
|
from the current review queue. Likewise for cases where patches would
|
|
|
|
get rejected or are not applicable to the BPF trees (but assigned to
|
|
|
|
the 'bpf' delegate).
|
2017-12-06 08:12:41 +08:00
|
|
|
|
|
|
|
Q: How do the changes make their way into Linux?
|
2018-05-14 21:42:27 +08:00
|
|
|
------------------------------------------------
|
2017-12-06 08:12:41 +08:00
|
|
|
A: There are two BPF kernel trees (git repositories). Once patches have
|
2018-05-14 21:42:27 +08:00
|
|
|
been accepted by the BPF maintainers, they will be applied to one
|
|
|
|
of the two BPF trees:
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
* https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git/
|
|
|
|
* https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
The bpf tree itself is for fixes only, whereas bpf-next for features,
|
|
|
|
cleanups or other kind of improvements ("next-like" content). This is
|
|
|
|
analogous to net and net-next trees for networking. Both bpf and
|
|
|
|
bpf-next will only have a master branch in order to simplify against
|
|
|
|
which branch patches should get rebased to.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
Accumulated BPF patches in the bpf tree will regularly get pulled
|
|
|
|
into the net kernel tree. Likewise, accumulated BPF patches accepted
|
|
|
|
into the bpf-next tree will make their way into net-next tree. net and
|
|
|
|
net-next are both run by David S. Miller. From there, they will go
|
|
|
|
into the kernel mainline tree run by Linus Torvalds. To read up on the
|
|
|
|
process of net and net-next being merged into the mainline tree, see
|
2018-07-26 13:02:26 +08:00
|
|
|
the :ref:`netdev-FAQ`
|
|
|
|
|
2017-12-06 08:12:41 +08:00
|
|
|
|
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
Occasionally, to prevent merge conflicts, we might send pull requests
|
|
|
|
to other trees (e.g. tracing) with a small subset of the patches, but
|
|
|
|
net and net-next are always the main trees targeted for integration.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
The pull requests will contain a high-level summary of the accumulated
|
|
|
|
patches and can be searched on netdev kernel mailing list through the
|
|
|
|
following subject lines (``yyyy-mm-dd`` is the date of the pull
|
|
|
|
request)::
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
pull-request: bpf yyyy-mm-dd
|
|
|
|
pull-request: bpf-next yyyy-mm-dd
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
Q: How do I indicate which tree (bpf vs. bpf-next) my patch should be applied to?
|
|
|
|
---------------------------------------------------------------------------------
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-07-26 13:02:26 +08:00
|
|
|
A: The process is the very same as described in the :ref:`netdev-FAQ`,
|
|
|
|
so please read up on it. The subject line must indicate whether the
|
2018-05-14 21:42:27 +08:00
|
|
|
patch is a fix or rather "next-like" content in order to let the
|
|
|
|
maintainers know whether it is targeted at bpf or bpf-next.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
For fixes eventually landing in bpf -> net tree, the subject must
|
|
|
|
look like::
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
git format-patch --subject-prefix='PATCH bpf' start..finish
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
For features/improvements/etc that should eventually land in
|
|
|
|
bpf-next -> net-next, the subject must look like::
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
git format-patch --subject-prefix='PATCH bpf-next' start..finish
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
If unsure whether the patch or patch series should go into bpf
|
|
|
|
or net directly, or bpf-next or net-next directly, it is not a
|
|
|
|
problem either if the subject line says net or net-next as target.
|
|
|
|
It is eventually up to the maintainers to do the delegation of
|
|
|
|
the patches.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
If it is clear that patches should go into bpf or bpf-next tree,
|
|
|
|
please make sure to rebase the patches against those trees in
|
|
|
|
order to reduce potential conflicts.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
In case the patch or patch series has to be reworked and sent out
|
|
|
|
again in a second or later revision, it is also required to add a
|
|
|
|
version number (``v2``, ``v3``, ...) into the subject prefix::
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2020-08-21 13:28:17 +08:00
|
|
|
git format-patch --subject-prefix='PATCH bpf-next v2' start..finish
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
When changes have been requested to the patch series, always send the
|
|
|
|
whole patch series again with the feedback incorporated (never send
|
|
|
|
individual diffs on top of the old series).
|
2017-12-06 08:12:41 +08:00
|
|
|
|
|
|
|
Q: What does it mean when a patch gets applied to bpf or bpf-next tree?
|
2018-05-14 21:42:27 +08:00
|
|
|
-----------------------------------------------------------------------
|
2017-12-06 08:12:41 +08:00
|
|
|
A: It means that the patch looks good for mainline inclusion from
|
2018-05-14 21:42:27 +08:00
|
|
|
a BPF point of view.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
Be aware that this is not a final verdict that the patch will
|
|
|
|
automatically get accepted into net or net-next trees eventually:
|
|
|
|
|
2020-02-21 08:43:54 +08:00
|
|
|
On the bpf kernel mailing list reviews can come in at any point
|
2018-05-14 21:42:27 +08:00
|
|
|
in time. If discussions around a patch conclude that they cannot
|
|
|
|
get included as-is, we will either apply a follow-up fix or drop
|
|
|
|
them from the trees entirely. Therefore, we also reserve to rebase
|
|
|
|
the trees when deemed necessary. After all, the purpose of the tree
|
|
|
|
is to:
|
|
|
|
|
|
|
|
i) accumulate and stage BPF patches for integration into trees
|
|
|
|
like net and net-next, and
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
ii) run extensive BPF test suite and
|
|
|
|
workloads on the patches before they make their way any further.
|
|
|
|
|
|
|
|
Once the BPF pull request was accepted by David S. Miller, then
|
|
|
|
the patches end up in net or net-next tree, respectively, and
|
|
|
|
make their way from there further into mainline. Again, see the
|
2018-07-26 13:02:26 +08:00
|
|
|
:ref:`netdev-FAQ` for additional information e.g. on how often they are
|
2018-05-14 21:42:27 +08:00
|
|
|
merged to mainline.
|
|
|
|
|
|
|
|
Q: How long do I need to wait for feedback on my BPF patches?
|
|
|
|
-------------------------------------------------------------
|
2017-12-06 08:12:41 +08:00
|
|
|
A: We try to keep the latency low. The usual time to feedback will
|
2018-05-14 21:42:27 +08:00
|
|
|
be around 2 or 3 business days. It may vary depending on the
|
|
|
|
complexity of changes and current patch load.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
Q: How often do you send pull requests to major kernel trees like net or net-next?
|
|
|
|
----------------------------------------------------------------------------------
|
2017-12-06 08:12:41 +08:00
|
|
|
|
|
|
|
A: Pull requests will be sent out rather often in order to not
|
2018-05-14 21:42:27 +08:00
|
|
|
accumulate too many patches in bpf or bpf-next.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
As a rule of thumb, expect pull requests for each tree regularly
|
|
|
|
at the end of the week. In some cases pull requests could additionally
|
|
|
|
come also in the middle of the week depending on the current patch
|
|
|
|
load or urgency.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
|
|
|
Q: Are patches applied to bpf-next when the merge window is open?
|
2018-05-14 21:42:27 +08:00
|
|
|
-----------------------------------------------------------------
|
2017-12-06 08:12:41 +08:00
|
|
|
A: For the time when the merge window is open, bpf-next will not be
|
2018-05-14 21:42:27 +08:00
|
|
|
processed. This is roughly analogous to net-next patch processing,
|
2018-07-26 13:02:26 +08:00
|
|
|
so feel free to read up on the :ref:`netdev-FAQ` about further details.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
During those two weeks of merge window, we might ask you to resend
|
|
|
|
your patch series once bpf-next is open again. Once Linus released
|
|
|
|
a ``v*-rc1`` after the merge window, we continue processing of bpf-next.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
For non-subscribers to kernel mailing lists, there is also a status
|
|
|
|
page run by David S. Miller on net-next that provides guidance:
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
http://vger.kernel.org/~davem/net-next.html
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
Q: Verifier changes and test cases
|
|
|
|
----------------------------------
|
2017-12-06 08:12:41 +08:00
|
|
|
Q: I made a BPF verifier change, do I need to add test cases for
|
2018-05-14 21:42:27 +08:00
|
|
|
BPF kernel selftests_?
|
2017-12-06 08:12:41 +08:00
|
|
|
|
|
|
|
A: If the patch has changes to the behavior of the verifier, then yes,
|
2018-05-14 21:42:27 +08:00
|
|
|
it is absolutely necessary to add test cases to the BPF kernel
|
|
|
|
selftests_ suite. If they are not present and we think they are
|
|
|
|
needed, then we might ask for them before accepting any changes.
|
|
|
|
|
|
|
|
In particular, test_verifier.c is tracking a high number of BPF test
|
|
|
|
cases, including a lot of corner cases that LLVM BPF back end may
|
|
|
|
generate out of the restricted C code. Thus, adding test cases is
|
|
|
|
absolutely crucial to make sure future changes do not accidentally
|
|
|
|
affect prior use-cases. Thus, treat those test cases as: verifier
|
|
|
|
behavior that is not tracked in test_verifier.c could potentially
|
|
|
|
be subject to change.
|
|
|
|
|
|
|
|
Q: samples/bpf preference vs selftests?
|
|
|
|
---------------------------------------
|
|
|
|
Q: When should I add code to `samples/bpf/`_ and when to BPF kernel
|
|
|
|
selftests_ ?
|
|
|
|
|
|
|
|
A: In general, we prefer additions to BPF kernel selftests_ rather than
|
|
|
|
`samples/bpf/`_. The rationale is very simple: kernel selftests are
|
|
|
|
regularly run by various bots to test for kernel regressions.
|
|
|
|
|
|
|
|
The more test cases we add to BPF selftests, the better the coverage
|
|
|
|
and the less likely it is that those could accidentally break. It is
|
|
|
|
not that BPF kernel selftests cannot demo how a specific feature can
|
|
|
|
be used.
|
|
|
|
|
|
|
|
That said, `samples/bpf/`_ may be a good place for people to get started,
|
|
|
|
so it might be advisable that simple demos of features could go into
|
|
|
|
`samples/bpf/`_, but advanced functional and corner-case testing rather
|
|
|
|
into kernel selftests.
|
|
|
|
|
|
|
|
If your sample looks like a test case, then go for BPF kernel selftests
|
|
|
|
instead!
|
2017-12-06 08:12:41 +08:00
|
|
|
|
|
|
|
Q: When should I add code to the bpftool?
|
2018-05-14 21:42:27 +08:00
|
|
|
-----------------------------------------
|
2017-12-06 08:12:41 +08:00
|
|
|
A: The main purpose of bpftool (under tools/bpf/bpftool/) is to provide
|
2018-05-14 21:42:27 +08:00
|
|
|
a central user space tool for debugging and introspection of BPF programs
|
|
|
|
and maps that are active in the kernel. If UAPI changes related to BPF
|
|
|
|
enable for dumping additional information of programs or maps, then
|
|
|
|
bpftool should be extended as well to support dumping them.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
|
|
|
Q: When should I add code to iproute2's BPF loader?
|
2018-05-14 21:42:27 +08:00
|
|
|
---------------------------------------------------
|
|
|
|
A: For UAPI changes related to the XDP or tc layer (e.g. ``cls_bpf``),
|
|
|
|
the convention is that those control-path related changes are added to
|
|
|
|
iproute2's BPF loader as well from user space side. This is not only
|
|
|
|
useful to have UAPI changes properly designed to be usable, but also
|
|
|
|
to make those changes available to a wider user base of major
|
|
|
|
downstream distributions.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
|
|
|
Q: Do you accept patches as well for iproute2's BPF loader?
|
2018-05-14 21:42:27 +08:00
|
|
|
-----------------------------------------------------------
|
2017-12-06 08:12:41 +08:00
|
|
|
A: Patches for the iproute2's BPF loader have to be sent to:
|
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
netdev@vger.kernel.org
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
While those patches are not processed by the BPF kernel maintainers,
|
|
|
|
please keep them in Cc as well, so they can be reviewed.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
The official git repository for iproute2 is run by Stephen Hemminger
|
|
|
|
and can be found at:
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
https://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git/
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
The patches need to have a subject prefix of '``[PATCH iproute2
|
|
|
|
master]``' or '``[PATCH iproute2 net-next]``'. '``master``' or
|
|
|
|
'``net-next``' describes the target branch where the patch should be
|
|
|
|
applied to. Meaning, if kernel changes went into the net-next kernel
|
|
|
|
tree, then the related iproute2 changes need to go into the iproute2
|
|
|
|
net-next branch, otherwise they can be targeted at master branch. The
|
|
|
|
iproute2 net-next branch will get merged into the master branch after
|
|
|
|
the current iproute2 version from master has been released.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
Like BPF, the patches end up in patchwork under the netdev project and
|
|
|
|
are delegated to 'shemminger' for further processing:
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
http://patchwork.ozlabs.org/project/netdev/list/?delegate=389
|
2017-12-06 08:12:41 +08:00
|
|
|
|
|
|
|
Q: What is the minimum requirement before I submit my BPF patches?
|
2018-05-14 21:42:27 +08:00
|
|
|
------------------------------------------------------------------
|
2017-12-06 08:12:41 +08:00
|
|
|
A: When submitting patches, always take the time and properly test your
|
2018-05-14 21:42:27 +08:00
|
|
|
patches *prior* to submission. Never rush them! If maintainers find
|
|
|
|
that your patches have not been properly tested, it is a good way to
|
|
|
|
get them grumpy. Testing patch submissions is a hard requirement!
|
|
|
|
|
|
|
|
Note, fixes that go to bpf tree *must* have a ``Fixes:`` tag included.
|
|
|
|
The same applies to fixes that target bpf-next, where the affected
|
|
|
|
commit is in net-next (or in some cases bpf-next). The ``Fixes:`` tag is
|
|
|
|
crucial in order to identify follow-up commits and tremendously helps
|
|
|
|
for people having to do backporting, so it is a must have!
|
|
|
|
|
|
|
|
We also don't accept patches with an empty commit message. Take your
|
|
|
|
time and properly write up a high quality commit message, it is
|
|
|
|
essential!
|
|
|
|
|
|
|
|
Think about it this way: other developers looking at your code a month
|
|
|
|
from now need to understand *why* a certain change has been done that
|
|
|
|
way, and whether there have been flaws in the analysis or assumptions
|
|
|
|
that the original author did. Thus providing a proper rationale and
|
|
|
|
describing the use-case for the changes is a must.
|
|
|
|
|
|
|
|
Patch submissions with >1 patch must have a cover letter which includes
|
|
|
|
a high level description of the series. This high level summary will
|
|
|
|
then be placed into the merge commit by the BPF maintainers such that
|
|
|
|
it is also accessible from the git log for future reference.
|
|
|
|
|
|
|
|
Q: Features changing BPF JIT and/or LLVM
|
|
|
|
----------------------------------------
|
2017-12-06 08:12:41 +08:00
|
|
|
Q: What do I need to consider when adding a new instruction or feature
|
2018-05-14 21:42:27 +08:00
|
|
|
that would require BPF JIT and/or LLVM integration as well?
|
2017-12-06 08:12:41 +08:00
|
|
|
|
|
|
|
A: We try hard to keep all BPF JITs up to date such that the same user
|
2018-05-14 21:42:27 +08:00
|
|
|
experience can be guaranteed when running BPF programs on different
|
|
|
|
architectures without having the program punt to the less efficient
|
|
|
|
interpreter in case the in-kernel BPF JIT is enabled.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
If you are unable to implement or test the required JIT changes for
|
|
|
|
certain architectures, please work together with the related BPF JIT
|
|
|
|
developers in order to get the feature implemented in a timely manner.
|
|
|
|
Please refer to the git log (``arch/*/net/``) to locate the necessary
|
|
|
|
people for helping out.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
Also always make sure to add BPF test cases (e.g. test_bpf.c and
|
|
|
|
test_verifier.c) for new instructions, so that they can receive
|
|
|
|
broad test coverage and help run-time testing the various BPF JITs.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
In case of new BPF instructions, once the changes have been accepted
|
|
|
|
into the Linux kernel, please implement support into LLVM's BPF back
|
|
|
|
end. See LLVM_ section below for further information.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
Stable submission
|
|
|
|
=================
|
2017-12-06 08:12:41 +08:00
|
|
|
|
|
|
|
Q: I need a specific BPF commit in stable kernels. What should I do?
|
2018-05-14 21:42:27 +08:00
|
|
|
--------------------------------------------------------------------
|
2017-12-06 08:12:41 +08:00
|
|
|
A: In case you need a specific fix in stable kernels, first check whether
|
2018-05-14 21:42:27 +08:00
|
|
|
the commit has already been applied in the related ``linux-*.y`` branches:
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
If not the case, then drop an email to the BPF maintainers with the
|
|
|
|
netdev kernel mailing list in Cc and ask for the fix to be queued up:
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
netdev@vger.kernel.org
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
The process in general is the same as on netdev itself, see also the
|
2018-07-26 13:02:26 +08:00
|
|
|
:ref:`netdev-FAQ`.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
|
|
|
Q: Do you also backport to kernels not currently maintained as stable?
|
2018-05-14 21:42:27 +08:00
|
|
|
----------------------------------------------------------------------
|
2017-12-06 08:12:41 +08:00
|
|
|
A: No. If you need a specific BPF commit in kernels that are currently not
|
2018-05-14 21:42:27 +08:00
|
|
|
maintained by the stable maintainers, then you are on your own.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
The current stable and longterm stable kernels are all listed here:
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
https://www.kernel.org/
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
Q: The BPF patch I am about to submit needs to go to stable as well
|
|
|
|
-------------------------------------------------------------------
|
|
|
|
What should I do?
|
2017-12-06 08:12:41 +08:00
|
|
|
|
|
|
|
A: The same rules apply as with netdev patch submissions in general, see
|
2018-07-26 13:02:26 +08:00
|
|
|
the :ref:`netdev-FAQ`.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
Never add "``Cc: stable@vger.kernel.org``" to the patch description, but
|
|
|
|
ask the BPF maintainers to queue the patches instead. This can be done
|
|
|
|
with a note, for example, under the ``---`` part of the patch which does
|
|
|
|
not go into the git log. Alternatively, this can be done as a simple
|
|
|
|
request by mail instead.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
Q: Queue stable patches
|
|
|
|
-----------------------
|
2017-12-06 08:12:41 +08:00
|
|
|
Q: Where do I find currently queued BPF patches that will be submitted
|
2018-05-14 21:42:27 +08:00
|
|
|
to stable?
|
2017-12-06 08:12:41 +08:00
|
|
|
|
|
|
|
A: Once patches that fix critical bugs got applied into the bpf tree, they
|
2018-05-14 21:42:27 +08:00
|
|
|
are queued up for stable submission under:
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
http://patchwork.ozlabs.org/bundle/bpf/stable/?state=*
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
They will be on hold there at minimum until the related commit made its
|
|
|
|
way into the mainline kernel tree.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
After having been under broader exposure, the queued patches will be
|
|
|
|
submitted by the BPF maintainers to the stable maintainers.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
Testing patches
|
|
|
|
===============
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:32 +08:00
|
|
|
Q: How to run BPF selftests
|
|
|
|
---------------------------
|
|
|
|
A: After you have booted into the newly compiled kernel, navigate to
|
|
|
|
the BPF selftests_ suite in order to test BPF functionality (current
|
|
|
|
working directory points to the root of the cloned git tree)::
|
|
|
|
|
|
|
|
$ cd tools/testing/selftests/bpf/
|
|
|
|
$ make
|
|
|
|
|
|
|
|
To run the verifier tests::
|
|
|
|
|
|
|
|
$ sudo ./test_verifier
|
|
|
|
|
|
|
|
The verifier tests print out all the current checks being
|
|
|
|
performed. The summary at the end of running all tests will dump
|
|
|
|
information of test successes and failures::
|
|
|
|
|
|
|
|
Summary: 418 PASSED, 0 FAILED
|
|
|
|
|
|
|
|
In order to run through all BPF selftests, the following command is
|
|
|
|
needed::
|
|
|
|
|
|
|
|
$ sudo make run_tests
|
|
|
|
|
|
|
|
See the kernels selftest `Documentation/dev-tools/kselftest.rst`_
|
|
|
|
document for further documentation.
|
|
|
|
|
2020-05-22 19:24:34 +08:00
|
|
|
To maximize the number of tests passing, the .config of the kernel
|
|
|
|
under test should match the config file fragment in
|
|
|
|
tools/testing/selftests/bpf as closely as possible.
|
|
|
|
|
|
|
|
Finally to ensure support for latest BPF Type Format features -
|
|
|
|
discussed in `Documentation/bpf/btf.rst`_ - pahole version 1.16
|
|
|
|
is required for kernels built with CONFIG_DEBUG_INFO_BTF=y.
|
|
|
|
pahole is delivered in the dwarves package or can be built
|
|
|
|
from source at
|
|
|
|
|
|
|
|
https://github.com/acmel/dwarves
|
|
|
|
|
|
|
|
Some distros have pahole version 1.16 packaged already, e.g.
|
|
|
|
Fedora, Gentoo.
|
|
|
|
|
2017-12-06 08:12:41 +08:00
|
|
|
Q: Which BPF kernel selftests version should I run my kernel against?
|
2018-05-14 21:42:27 +08:00
|
|
|
---------------------------------------------------------------------
|
|
|
|
A: If you run a kernel ``xyz``, then always run the BPF kernel selftests
|
|
|
|
from that kernel ``xyz`` as well. Do not expect that the BPF selftest
|
|
|
|
from the latest mainline tree will pass all the time.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
In particular, test_bpf.c and test_verifier.c have a large number of
|
|
|
|
test cases and are constantly updated with new BPF test sequences, or
|
|
|
|
existing ones are adapted to verifier changes e.g. due to verifier
|
|
|
|
becoming smarter and being able to better track certain things.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
LLVM
|
|
|
|
====
|
2017-12-06 08:12:41 +08:00
|
|
|
|
|
|
|
Q: Where do I find LLVM with BPF support?
|
2018-05-14 21:42:27 +08:00
|
|
|
-----------------------------------------
|
2017-12-06 08:12:41 +08:00
|
|
|
A: The BPF back end for LLVM is upstream in LLVM since version 3.7.1.
|
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
All major distributions these days ship LLVM with BPF back end enabled,
|
|
|
|
so for the majority of use-cases it is not required to compile LLVM by
|
|
|
|
hand anymore, just install the distribution provided package.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
LLVM's static compiler lists the supported targets through
|
|
|
|
``llc --version``, make sure BPF targets are listed. Example::
|
2017-12-06 08:12:41 +08:00
|
|
|
|
|
|
|
$ llc --version
|
|
|
|
LLVM (http://llvm.org/):
|
2020-08-21 13:28:17 +08:00
|
|
|
LLVM version 10.0.0
|
2017-12-06 08:12:41 +08:00
|
|
|
Optimized build.
|
|
|
|
Default target: x86_64-unknown-linux-gnu
|
|
|
|
Host CPU: skylake
|
|
|
|
|
|
|
|
Registered Targets:
|
2020-08-21 13:28:17 +08:00
|
|
|
aarch64 - AArch64 (little endian)
|
|
|
|
bpf - BPF (host endian)
|
|
|
|
bpfeb - BPF (big endian)
|
|
|
|
bpfel - BPF (little endian)
|
|
|
|
x86 - 32-bit X86: Pentium-Pro and above
|
|
|
|
x86-64 - 64-bit X86: EM64T and AMD64
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
For developers in order to utilize the latest features added to LLVM's
|
|
|
|
BPF back end, it is advisable to run the latest LLVM releases. Support
|
|
|
|
for new BPF kernel features such as additions to the BPF instruction
|
|
|
|
set are often developed together.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
All LLVM releases can be found at: http://releases.llvm.org/
|
2017-12-06 08:12:41 +08:00
|
|
|
|
|
|
|
Q: Got it, so how do I build LLVM manually anyway?
|
2018-05-14 21:42:27 +08:00
|
|
|
--------------------------------------------------
|
bpf, docs: Update build procedure for manually compiling LLVM and Clang
The current LLVM and Clang build procedure in samples/bpf/README.rst is
out of date. See below that the links are not accessible any more.
$ git clone http://llvm.org/git/llvm.git
Cloning into 'llvm'...
fatal: unable to access 'http://llvm.org/git/llvm.git/': Maximum (20) redirects followed
$ git clone --depth 1 http://llvm.org/git/clang.git
Cloning into 'clang'...
fatal: unable to access 'http://llvm.org/git/clang.git/': Maximum (20) redirects followed
The LLVM community has adopted new ways to build the compiler. There are
different ways to build LLVM and Clang, the Clang Getting Started page [1]
has one way. As Yonghong said, it is better to copy the build procedure
in Documentation/bpf/bpf_devel_QA.rst to keep consistent.
I verified the procedure and it is proved to be feasible, so we should
update README.rst to reflect the reality. At the same time, update the
related comment in Makefile.
Additionally, as Fangrui said, the dir llvm-project/llvm/build/install is
not used, BUILD_SHARED_LIBS=OFF is the default option [2], so also change
Documentation/bpf/bpf_devel_QA.rst together.
At last, we recommend that developers who want the fastest incremental
builds use the Ninja build system [1], you can find it in your system's
package manager, usually the package is ninja or ninja-build [3], so add
ninja to build dependencies suggested by Nathan.
[1] https://clang.llvm.org/get_started.html
[2] https://www.llvm.org/docs/CMake.html
[3] https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Acked-by: Yonghong Song <yhs@fb.com>
Cc: Fangrui Song <maskray@google.com>
Link: https://lore.kernel.org/bpf/1611279584-26047-1-git-send-email-yangtiezhu@loongson.cn
2021-01-22 09:39:44 +08:00
|
|
|
A: We recommend that developers who want the fastest incremental builds
|
|
|
|
use the Ninja build system, you can find it in your system's package
|
|
|
|
manager, usually the package is ninja or ninja-build.
|
|
|
|
|
|
|
|
You need ninja, cmake and gcc-c++ as build requisites for LLVM. Once you
|
|
|
|
have that set up, proceed with building the latest LLVM and clang version
|
2018-05-14 21:42:27 +08:00
|
|
|
from the git repositories::
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2020-02-21 08:43:54 +08:00
|
|
|
$ git clone https://github.com/llvm/llvm-project.git
|
bpf, docs: Update build procedure for manually compiling LLVM and Clang
The current LLVM and Clang build procedure in samples/bpf/README.rst is
out of date. See below that the links are not accessible any more.
$ git clone http://llvm.org/git/llvm.git
Cloning into 'llvm'...
fatal: unable to access 'http://llvm.org/git/llvm.git/': Maximum (20) redirects followed
$ git clone --depth 1 http://llvm.org/git/clang.git
Cloning into 'clang'...
fatal: unable to access 'http://llvm.org/git/clang.git/': Maximum (20) redirects followed
The LLVM community has adopted new ways to build the compiler. There are
different ways to build LLVM and Clang, the Clang Getting Started page [1]
has one way. As Yonghong said, it is better to copy the build procedure
in Documentation/bpf/bpf_devel_QA.rst to keep consistent.
I verified the procedure and it is proved to be feasible, so we should
update README.rst to reflect the reality. At the same time, update the
related comment in Makefile.
Additionally, as Fangrui said, the dir llvm-project/llvm/build/install is
not used, BUILD_SHARED_LIBS=OFF is the default option [2], so also change
Documentation/bpf/bpf_devel_QA.rst together.
At last, we recommend that developers who want the fastest incremental
builds use the Ninja build system [1], you can find it in your system's
package manager, usually the package is ninja or ninja-build [3], so add
ninja to build dependencies suggested by Nathan.
[1] https://clang.llvm.org/get_started.html
[2] https://www.llvm.org/docs/CMake.html
[3] https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Acked-by: Yonghong Song <yhs@fb.com>
Cc: Fangrui Song <maskray@google.com>
Link: https://lore.kernel.org/bpf/1611279584-26047-1-git-send-email-yangtiezhu@loongson.cn
2021-01-22 09:39:44 +08:00
|
|
|
$ mkdir -p llvm-project/llvm/build
|
2020-02-21 08:43:54 +08:00
|
|
|
$ cd llvm-project/llvm/build
|
|
|
|
$ cmake .. -G "Ninja" -DLLVM_TARGETS_TO_BUILD="BPF;X86" \
|
|
|
|
-DLLVM_ENABLE_PROJECTS="clang" \
|
2017-12-06 08:12:41 +08:00
|
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
|
|
-DLLVM_BUILD_RUNTIME=OFF
|
2020-02-21 08:43:54 +08:00
|
|
|
$ ninja
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
The built binaries can then be found in the build/bin/ directory, where
|
|
|
|
you can point the PATH variable to.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2020-08-21 13:28:17 +08:00
|
|
|
Set ``-DLLVM_TARGETS_TO_BUILD`` equal to the target you wish to build, you
|
|
|
|
will find a full list of targets within the llvm-project/llvm/lib/Target
|
|
|
|
directory.
|
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
Q: Reporting LLVM BPF issues
|
|
|
|
----------------------------
|
2017-12-06 08:12:41 +08:00
|
|
|
Q: Should I notify BPF kernel maintainers about issues in LLVM's BPF code
|
2018-05-14 21:42:27 +08:00
|
|
|
generation back end or about LLVM generated code that the verifier
|
|
|
|
refuses to accept?
|
|
|
|
|
|
|
|
A: Yes, please do!
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
LLVM's BPF back end is a key piece of the whole BPF
|
|
|
|
infrastructure and it ties deeply into verification of programs from the
|
|
|
|
kernel side. Therefore, any issues on either side need to be investigated
|
|
|
|
and fixed whenever necessary.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
Therefore, please make sure to bring them up at netdev kernel mailing
|
|
|
|
list and Cc BPF maintainers for LLVM and kernel bits:
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
* Yonghong Song <yhs@fb.com>
|
|
|
|
* Alexei Starovoitov <ast@kernel.org>
|
|
|
|
* Daniel Borkmann <daniel@iogearbox.net>
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
LLVM also has an issue tracker where BPF related bugs can be found:
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
https://bugs.llvm.org/buglist.cgi?quicksearch=bpf
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
However, it is better to reach out through mailing lists with having
|
|
|
|
maintainers in Cc.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
Q: New BPF instruction for kernel and LLVM
|
|
|
|
------------------------------------------
|
2017-12-06 08:12:41 +08:00
|
|
|
Q: I have added a new BPF instruction to the kernel, how can I integrate
|
2018-05-14 21:42:27 +08:00
|
|
|
it into LLVM?
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
A: LLVM has a ``-mcpu`` selector for the BPF back end in order to allow
|
|
|
|
the selection of BPF instruction set extensions. By default the
|
|
|
|
``generic`` processor target is used, which is the base instruction set
|
|
|
|
(v1) of BPF.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
LLVM has an option to select ``-mcpu=probe`` where it will probe the host
|
|
|
|
kernel for supported BPF instruction set extensions and selects the
|
|
|
|
optimal set automatically.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
For cross-compilation, a specific version can be select manually as well ::
|
2017-12-06 08:12:41 +08:00
|
|
|
|
|
|
|
$ llc -march bpf -mcpu=help
|
|
|
|
Available CPUs for this target:
|
|
|
|
|
|
|
|
generic - Select the generic processor.
|
|
|
|
probe - Select the probe processor.
|
|
|
|
v1 - Select the v1 processor.
|
|
|
|
v2 - Select the v2 processor.
|
|
|
|
[...]
|
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
Newly added BPF instructions to the Linux kernel need to follow the same
|
|
|
|
scheme, bump the instruction set version and implement probing for the
|
|
|
|
extensions such that ``-mcpu=probe`` users can benefit from the
|
|
|
|
optimization transparently when upgrading their kernels.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
If you are unable to implement support for the newly added BPF instruction
|
|
|
|
please reach out to BPF developers for help.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
By the way, the BPF kernel selftests run with ``-mcpu=probe`` for better
|
|
|
|
test coverage.
|
2017-12-06 08:12:41 +08:00
|
|
|
|
2018-05-14 21:42:27 +08:00
|
|
|
Q: clang flag for target bpf?
|
|
|
|
-----------------------------
|
|
|
|
Q: In some cases clang flag ``-target bpf`` is used but in other cases the
|
|
|
|
default clang target, which matches the underlying architecture, is used.
|
|
|
|
What is the difference and when I should use which?
|
2018-02-02 15:00:11 +08:00
|
|
|
|
|
|
|
A: Although LLVM IR generation and optimization try to stay architecture
|
2018-05-14 21:42:27 +08:00
|
|
|
independent, ``-target <arch>`` still has some impact on generated code:
|
|
|
|
|
|
|
|
- BPF program may recursively include header file(s) with file scope
|
|
|
|
inline assembly codes. The default target can handle this well,
|
|
|
|
while ``bpf`` target may fail if bpf backend assembler does not
|
|
|
|
understand these assembly codes, which is true in most cases.
|
|
|
|
|
|
|
|
- When compiled without ``-g``, additional elf sections, e.g.,
|
|
|
|
.eh_frame and .rela.eh_frame, may be present in the object file
|
|
|
|
with default target, but not with ``bpf`` target.
|
|
|
|
|
|
|
|
- The default target may turn a C switch statement into a switch table
|
|
|
|
lookup and jump operation. Since the switch table is placed
|
|
|
|
in the global readonly section, the bpf program will fail to load.
|
|
|
|
The bpf target does not support switch table optimization.
|
|
|
|
The clang option ``-fno-jump-tables`` can be used to disable
|
|
|
|
switch table generation.
|
|
|
|
|
|
|
|
- For clang ``-target bpf``, it is guaranteed that pointer or long /
|
|
|
|
unsigned long types will always have a width of 64 bit, no matter
|
|
|
|
whether underlying clang binary or default target (or kernel) is
|
|
|
|
32 bit. However, when native clang target is used, then it will
|
|
|
|
compile these types based on the underlying architecture's conventions,
|
|
|
|
meaning in case of 32 bit architecture, pointer or long / unsigned
|
|
|
|
long types e.g. in BPF context structure will have width of 32 bit
|
|
|
|
while the BPF LLVM back end still operates in 64 bit. The native
|
|
|
|
target is mostly needed in tracing for the case of walking ``pt_regs``
|
|
|
|
or other kernel structures where CPU's register width matters.
|
|
|
|
Otherwise, ``clang -target bpf`` is generally recommended.
|
|
|
|
|
|
|
|
You should use default target when:
|
|
|
|
|
|
|
|
- Your program includes a header file, e.g., ptrace.h, which eventually
|
|
|
|
pulls in some header files containing file scope host assembly codes.
|
|
|
|
|
|
|
|
- You can add ``-fno-jump-tables`` to work around the switch table issue.
|
|
|
|
|
|
|
|
Otherwise, you can use ``bpf`` target. Additionally, you *must* use bpf target
|
|
|
|
when:
|
|
|
|
|
|
|
|
- Your program uses data structures with pointer or long / unsigned long
|
|
|
|
types that interface with BPF helpers or context data structures. Access
|
|
|
|
into these structures is verified by the BPF verifier and may result
|
|
|
|
in verification failures if the native architecture is not aligned with
|
|
|
|
the BPF architecture, e.g. 64-bit. An example of this is
|
|
|
|
BPF_PROG_TYPE_SK_MSG require ``-target bpf``
|
|
|
|
|
|
|
|
|
|
|
|
.. Links
|
|
|
|
.. _Documentation/process/: https://www.kernel.org/doc/html/latest/process/
|
|
|
|
.. _MAINTAINERS: ../../MAINTAINERS
|
2018-07-26 13:02:26 +08:00
|
|
|
.. _netdev-FAQ: ../networking/netdev-FAQ.rst
|
2018-05-14 21:42:27 +08:00
|
|
|
.. _samples/bpf/: ../../samples/bpf/
|
|
|
|
.. _selftests: ../../tools/testing/selftests/bpf/
|
2018-05-14 21:42:32 +08:00
|
|
|
.. _Documentation/dev-tools/kselftest.rst:
|
|
|
|
https://www.kernel.org/doc/html/latest/dev-tools/kselftest.html
|
2020-07-19 00:51:00 +08:00
|
|
|
.. _Documentation/bpf/btf.rst: btf.rst
|
2018-02-02 15:00:11 +08:00
|
|
|
|
2017-12-06 08:12:41 +08:00
|
|
|
Happy BPF hacking!
|