€•^íŒsphinx.addnodes”Œdocument”“”)�”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)�”}”(hhh]”(hŒ pending_xref”“”)�”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…”�”}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ%/translations/zh_CN/bpf/bpf_design_QA”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)�”}”(hhh]”hŒChinese (Traditional)”…”�”}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ%/translations/zh_TW/bpf/bpf_design_QA”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒItalian”…”�”}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ%/translations/it_IT/bpf/bpf_design_QA”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒJapanese”…”�”}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ%/translations/ja_JP/bpf/bpf_design_QA”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒKorean”…”�”}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ%/translations/ko_KR/bpf/bpf_design_QA”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒPortuguese (Brazilian)”…”�”}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ%/translations/pt_BR/bpf/bpf_design_QA”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒSpanish”…”�”}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ%/translations/sp_SP/bpf/bpf_design_QA”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒsection”“”)�”}”(hhh]”(hŒtitle”“”)�”}”(hŒBPF Design Q&A”h]”hŒBPF Design Q&A”…”�”}”(hh¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhh·h²hh³Œ?/var/lib/git/docbuild/linux/Documentation/bpf/bpf_design_QA.rst”h´KubhŒ paragraph”“”)�”}”(hX:BPF extensibility and applicability to networking, tracing, security in the linux kernel and several user space implementations of BPF virtual machine led to a number of misunderstanding on what BPF actually is. This short QA is an attempt to address that and outline a direction of where BPF is heading long term.”h]”hX:BPF extensibility and applicability to networking, tracing, security in the linux kernel and several user space implementations of BPF virtual machine led to a number of misunderstanding on what BPF actually is. This short QA is an attempt to address that and outline a direction of where BPF is heading long term.”…”�”}”(hhÍh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khh·h²hubhŒtopic”“”)�”}”(hhh]”hŒ bullet_list”“”)�”}”(hhh]”hŒ list_item”“”)�”}”(hhh]”(hÌ)�”}”(hhh]”hŒ reference”“”)�”}”(hhh]”hŒQuestions and Answers”…”�”}”(hhïh²hh³Nh´Nubah}”(h]”Œid1”ah ]”h"]”h$]”h&]”Œrefid”Œquestions-and-answers”uh1híhhêubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhhçubhá)�”}”(hhh]”(hæ)�”}”(hhh]”hÌ)�”}”(hhh]”hî)�”}”(hhh]”hŒ=Q: Is BPF a generic instruction set similar to x64 and arm64?”…”�”}”(hjh²hh³Nh´Nubah}”(h]”Œid2”ah ]”h"]”h$]”h&]”Œrefid”Œ;q-is-bpf-a-generic-instruction-set-similar-to-x64-and-arm64”uh1híhj ubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhjubah}”(h]”h ]”h"]”h$]”h&]”uh1håhjubhæ)�”}”(hhh]”hÌ)�”}”(hhh]”hî)�”}”(hhh]”hŒ%Q: Is BPF a generic virtual machine ?”…”�”}”(hj0h²hh³Nh´Nubah}”(h]”Œid3”ah ]”h"]”h$]”h&]”Œrefid”Œ"q-is-bpf-a-generic-virtual-machine”uh1híhj-ubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhj*ubah}”(h]”h ]”h"]”h$]”h&]”uh1håhjubhæ)�”}”(hhh]”(hÌ)�”}”(hhh]”hî)�”}”(hhh]”(hŒBPF is generic instruction set ”…”�”}”(hjRh²hh³Nh´NubhŒemphasis”“”)�”}”(hŒ*with*”h]”hŒwith”…”�”}”(hj[h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYh³Nh´NhjRubhŒ C calling convention.”…”�”}”(hjRh²hh³Nh´Nubeh}”(h]”Œid4”ah ]”h"]”h$]”h&]”Œrefid”Œ8bpf-is-generic-instruction-set-with-c-calling-convention”uh1híhjOubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhjLubhá)�”}”(hhh]”(hæ)�”}”(hhh]”hÌ)�”}”(hhh]”hî)�”}”(hhh]”hŒ'Q: Why C calling convention was chosen?”…”�”}”(hj…h²hh³Nh´Nubah}”(h]”Œid5”ah ]”h"]”h$]”h&]”Œrefid”Œ%q-why-c-calling-convention-was-chosen”uh1híhj‚ubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhjubah}”(h]”h ]”h"]”h$]”h&]”uh1håhj|ubhæ)�”}”(hhh]”hÌ)�”}”(hhh]”hî)�”}”(hhh]”hŒ9Q: Can multiple return values be supported in the future?”…”�”}”(hj§h²hh³Nh´Nubah}”(h]”Œid6”ah ]”h"]”h$]”h&]”Œrefid”Œ7q-can-multiple-return-values-be-supported-in-the-future”uh1híhj¤ubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhj¡ubah}”(h]”h ]”h"]”h$]”h&]”uh1håhj|ubhæ)�”}”(hhh]”hÌ)�”}”(hhh]”hî)�”}”(hhh]”hŒAQ: Can more than 5 function arguments be supported in the future?”…”�”}”(hjÉh²hh³Nh´Nubah}”(h]”Œid7”ah ]”h"]”h$]”h&]”Œrefid”Œ?q-can-more-than-5-function-arguments-be-supported-in-the-future”uh1híhjÆubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhjÃubah}”(h]”h ]”h"]”h$]”h&]”uh1håhj|ubeh}”(h]”h ]”h"]”h$]”h&]”uh1hàhjLubeh}”(h]”h ]”h"]”h$]”h&]”uh1håhjubhæ)�”}”(hhh]”hÌ)�”}”(hhh]”hî)�”}”(hhh]”hŒAQ: Can BPF programs access instruction pointer or return address?”…”�”}”(hj÷h²hh³Nh´Nubah}”(h]”Œid8”ah ]”h"]”h$]”h&]”Œrefid”Œ?q-can-bpf-programs-access-instruction-pointer-or-return-address”uh1híhjôubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhjñubah}”(h]”h ]”h"]”h$]”h&]”uh1håhjubhæ)�”}”(hhh]”hÌ)�”}”(hhh]”hî)�”}”(hhh]”hŒ*Q: Can BPF programs access stack pointer ?”…”�”}”(hjh²hh³Nh´Nubah}”(h]”Œid9”ah ]”h"]”h$]”h&]”Œrefid”Œ'q-can-bpf-programs-access-stack-pointer”uh1híhjubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhjubah}”(h]”h ]”h"]”h$]”h&]”uh1håhjubhæ)�”}”(hhh]”hÌ)�”}”(hhh]”hî)�”}”(hhh]”hŒ;Q: Does C-calling convention diminishes possible use cases?”…”�”}”(hj;h²hh³Nh´Nubah}”(h]”Œid10”ah ]”h"]”h$]”h&]”Œrefid”Œ9q-does-c-calling-convention-diminishes-possible-use-cases”uh1híhj8ubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhj5ubah}”(h]”h ]”h"]”h$]”h&]”uh1håhjubhæ)�”}”(hhh]”hÌ)�”}”(hhh]”hî)�”}”(hhh]”hŒLQ: Does it mean that ‘innovative’ extensions to BPF code are disallowed?”…”�”}”(hj]h²hh³Nh´Nubah}”(h]”Œid11”ah ]”h"]”h$]”h&]”Œrefid”ŒDq-does-it-mean-that-innovative-extensions-to-bpf-code-are-disallowed”uh1híhjZubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhjWubah}”(h]”h ]”h"]”h$]”h&]”uh1håhjubhæ)�”}”(hhh]”hÌ)�”}”(hhh]”hî)�”}”(hhh]”hŒ(Q: Can loops be supported in a safe way?”…”�”}”(hjh²hh³Nh´Nubah}”(h]”Œid12”ah ]”h"]”h$]”h&]”Œrefid”Œ&q-can-loops-be-supported-in-a-safe-way”uh1híhj|ubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhjyubah}”(h]”h ]”h"]”h$]”h&]”uh1håhjubhæ)�”}”(hhh]”hÌ)�”}”(hhh]”hî)�”}”(hhh]”hŒ Q: What are the verifier limits?”…”�”}”(hj¡h²hh³Nh´Nubah}”(h]”Œid13”ah ]”h"]”h$]”h&]”Œrefid”Œq-what-are-the-verifier-limits”uh1híhjžubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhj›ubah}”(h]”h ]”h"]”h$]”h&]”uh1håhjubhæ)�”}”(hhh]”(hÌ)�”}”(hhh]”hî)�”}”(hhh]”hŒInstruction level questions”…”�”}”(hjÃh²hh³Nh´Nubah}”(h]”Œid14”ah ]”h"]”h$]”h&]”Œrefid”Œinstruction-level-questions”uh1híhjÀubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhj½ubhá)�”}”(hhh]”(hæ)�”}”(hhh]”hÌ)�”}”(hhh]”hî)�”}”(hhh]”hŒ+Q: LD_ABS and LD_IND instructions vs C code”…”�”}”(hjâh²hh³Nh´Nubah}”(h]”Œid15”ah ]”h"]”h$]”h&]”Œrefid”Œ*q-ld-abs-and-ld-ind-instructions-vs-c-code”uh1híhjßubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhjÜubah}”(h]”h ]”h"]”h$]”h&]”uh1håhjÙubhæ)�”}”(hhh]”hÌ)�”}”(hhh]”hî)�”}”(hhh]”hŒ8Q: BPF instructions mapping not one-to-one to native CPU”…”�”}”(hjh²hh³Nh´Nubah}”(h]”Œid16”ah ]”h"]”h$]”h&]”Œrefid”Œ7q-bpf-instructions-mapping-not-one-to-one-to-native-cpu”uh1híhjubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhjþubah}”(h]”h ]”h"]”h$]”h&]”uh1håhjÙubhæ)�”}”(hhh]”hÌ)�”}”(hhh]”hî)�”}”(hhh]”hŒ4Q: Why BPF_DIV instruction doesn’t map to x64 div?”…”�”}”(hj&h²hh³Nh´Nubah}”(h]”Œid17”ah ]”h"]”h$]”h&]”Œrefid”Œ0q-why-bpf-div-instruction-doesn-t-map-to-x64-div”uh1híhj#ubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhj ubah}”(h]”h ]”h"]”h$]”h&]”uh1håhjÙubhæ)�”}”(hhh]”hÌ)�”}”(hhh]”hî)�”}”(hhh]”hŒ.Q: Why BPF has implicit prologue and epilogue?”…”�”}”(hjHh²hh³Nh´Nubah}”(h]”Œid18”ah ]”h"]”h$]”h&]”Œrefid”Œ,q-why-bpf-has-implicit-prologue-and-epilogue”uh1híhjEubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhjBubah}”(h]”h ]”h"]”h$]”h&]”uh1håhjÙubhæ)�”}”(hhh]”hÌ)�”}”(hhh]”hî)�”}”(hhh]”hŒMQ: Why BPF_JLT and BPF_JLE instructions were not introduced in the beginning?”…”�”}”(hjjh²hh³Nh´Nubah}”(h]”Œid19”ah ]”h"]”h$]”h&]”Œrefid”ŒKq-why-bpf-jlt-and-bpf-jle-instructions-were-not-introduced-in-the-beginning”uh1híhjgubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhjdubah}”(h]”h ]”h"]”h$]”h&]”uh1håhjÙubhæ)�”}”(hhh]”hÌ)�”}”(hhh]”hî)�”}”(hhh]”hŒ&Q: BPF 32-bit subregister requirements”…”�”}”(hjŒh²hh³Nh´Nubah}”(h]”Œid20”ah ]”h"]”h$]”h&]”Œrefid”Œ%q-bpf-32-bit-subregister-requirements”uh1híhj‰ubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhj†ubah}”(h]”h ]”h"]”h$]”h&]”uh1håhjÙubeh}”(h]”h ]”h"]”h$]”h&]”uh1hàhj½ubeh}”(h]”h ]”h"]”h$]”h&]”uh1håhjubhæ)�”}”(hhh]”hÌ)�”}”(hhh]”hî)�”}”(hhh]”hŒQ: Does BPF have a stable ABI?”…”�”}”(hjºh²hh³Nh´Nubah}”(h]”Œid21”ah ]”h"]”h$]”h&]”Œrefid”Œq-does-bpf-have-a-stable-abi”uh1híhj·ubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhj´ubah}”(h]”h ]”h"]”h$]”h&]”uh1håhjubhæ)�”}”(hhh]”hÌ)�”}”(hhh]”hî)�”}”(hhh]”hŒ*Q: Are tracepoints part of the stable ABI?”…”�”}”(hjÜh²hh³Nh´Nubah}”(h]”Œid22”ah ]”h"]”h$]”h&]”Œrefid”Œ(q-are-tracepoints-part-of-the-stable-abi”uh1híhjÙubah}”(h]”h ]”h"]”h$]”h&]”uh1hËhjÖubah}”(h]”h ]”h"]”h$]”h&]”uh1håhjubhæ)�”}”(hhh]”hÌ)�”}”(hhh]”hî)�”}”(hhh]”hŒ>Q: Are places where kprobes can attach part of the stable ABI?”…”�”}”(hjþh²hh³Nh´Nubah}”(h]”Œid23”ah ]”h"]”h$]”h&]”Œrefid”ŒA: NO. BPF allows only register R0 to be used as return value.”h]”hŒ>A: NO. BPF allows only register R0 to be used as return value.”…”�”}”(hj…h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K)hjth²hubeh}”(h]”j¶ah ]”h"]”Œ9q: can multiple return values be supported in the future?”ah$]”h&]”uh1hµhj,h²hh³hÊh´K(ubh¶)�”}”(hhh]”(h»)�”}”(hŒAQ: Can more than 5 function arguments be supported in the future?”h]”hŒAQ: Can more than 5 function arguments be supported in the future?”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßjÒuh1hºhjšh²hh³hÊh´K,ubhÌ)�”}”(hŒºA: NO. BPF calling convention only allows registers R1-R5 to be used as arguments. BPF is not a standalone instruction set. (unlike x64 ISA that allows msft, cdecl and other conventions)”h]”hŒºA: NO. BPF calling convention only allows registers R1-R5 to be used as arguments. BPF is not a standalone instruction set. (unlike x64 ISA that allows msft, cdecl and other conventions)”…”�”}”(hj«h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K-hjšh²hubeh}”(h]”jØah ]”h"]”ŒAq: can more than 5 function arguments be supported in the future?”ah$]”h&]”uh1hµhj,h²hh³hÊh´K,ubeh}”(h]”juah ]”h"]”Œ9bpf is generic instruction set with c calling convention.”ah$]”h&]”uh1hµhjÎh²hh³hÊh´Kubh¶)�”}”(hhh]”(h»)�”}”(hŒAQ: Can BPF programs access instruction pointer or return address?”h]”hŒAQ: Can BPF programs access instruction pointer or return address?”…”�”}”(hjÊh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßjuh1hºhjÇh²hh³hÊh´K2ubhÌ)�”}”(hŒA: NO.”h]”hŒA: NO.”…”�”}”(hjØh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K3hjÇh²hubeh}”(h]”jah ]”h"]”ŒAq: can bpf programs access instruction pointer or return address?”ah$]”h&]”uh1hµhjÎh²hh³hÊh´K2ubh¶)�”}”(hhh]”(h»)�”}”(hŒ*Q: Can BPF programs access stack pointer ?”h]”hŒ*Q: Can BPF programs access stack pointer ?”…”�”}”(hjðh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßj"uh1hºhjíh²hh³hÊh´K6ubhÌ)�”}”(hŒA: NO.”h]”hŒA: NO.”…”�”}”(hjþh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K7hjíh²hubhÌ)�”}”(hŒóOnly frame pointer (register R10) is accessible. From compiler point of view it's necessary to have stack pointer. For example, LLVM defines register R11 as stack pointer in its BPF backend, but it makes sure that generated code never uses it.”h]”hŒõOnly frame pointer (register R10) is accessible. From compiler point of view it’s necessary to have stack pointer. For example, LLVM defines register R11 as stack pointer in its BPF backend, but it makes sure that generated code never uses it.”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K9hjíh²hubeh}”(h]”j(ah ]”h"]”Œ*q: can bpf programs access stack pointer ?”ah$]”h&]”uh1hµhjÎh²hh³hÊh´K6ubh¶)�”}”(hhh]”(h»)�”}”(hŒ;Q: Does C-calling convention diminishes possible use cases?”h]”hŒ;Q: Does C-calling convention diminishes possible use cases?”…”�”}”(hj$h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßjDuh1hºhj!h²hh³hÊh´K?ubhÌ)�”}”(hŒA: YES.”h]”hŒA: YES.”…”�”}”(hj2h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K@hj!h²hubhÌ)�”}”(hX�BPF design forces addition of major functionality in the form of kernel helper functions and kernel objects like BPF maps with seamless interoperability between them. It lets kernel call into BPF programs and programs call kernel helpers with zero overhead, as all of them were native C code. That is particularly the case for JITed BPF programs that are indistinguishable from native kernel C code.”h]”hX�BPF design forces addition of major functionality in the form of kernel helper functions and kernel objects like BPF maps with seamless interoperability between them. It lets kernel call into BPF programs and programs call kernel helpers with zero overhead, as all of them were native C code. That is particularly the case for JITed BPF programs that are indistinguishable from native kernel C code.”…”�”}”(hj@h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KBhj!h²hubeh}”(h]”jJah ]”h"]”Œ;q: does c-calling convention diminishes possible use cases?”ah$]”h&]”uh1hµhjÎh²hh³hÊh´K?ubh¶)�”}”(hhh]”(h»)�”}”(hŒHQ: Does it mean that 'innovative' extensions to BPF code are disallowed?”h]”hŒLQ: Does it mean that ‘innovative’ extensions to BPF code are disallowed?”…”�”}”(hjXh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßjfuh1hºhjUh²hh³hÊh´KKubhÌ)�”}”(hŒ A: Soft yes.”h]”hŒ A: Soft yes.”…”�”}”(hjfh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KLhjUh²hubhÌ)�”}”(hŒÅAt least for now, until BPF core has support for bpf-to-bpf calls, indirect calls, loops, global variables, jump tables, read-only sections, and all other normal constructs that C code can produce.”h]”hŒÅAt least for now, until BPF core has support for bpf-to-bpf calls, indirect calls, loops, global variables, jump tables, read-only sections, and all other normal constructs that C code can produce.”…”�”}”(hjth²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KNhjUh²hubeh}”(h]”jlah ]”h"]”ŒHq: does it mean that 'innovative' extensions to bpf code are disallowed?”ah$]”h&]”uh1hµhjÎh²hh³hÊh´KKubh¶)�”}”(hhh]”(h»)�”}”(hŒ(Q: Can loops be supported in a safe way?”h]”hŒ(Q: Can loops be supported in a safe way?”…”�”}”(hjŒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßjˆuh1hºhj‰h²hh³hÊh´KTubhÌ)�”}”(hŒA: It's not clear yet.”h]”hŒA: It’s not clear yet.”…”�”}”(hjšh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KUhj‰h²hubhÌ)�”}”(hŒABPF developers are trying to find a way to support bounded loops.”h]”hŒABPF developers are trying to find a way to support bounded loops.”…”�”}”(hj¨h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KWhj‰h²hubeh}”(h]”jŽah ]”h"]”Œ(q: can loops be supported in a safe way?”ah$]”h&]”uh1hµhjÎh²hh³hÊh´KTubh¶)�”}”(hhh]”(h»)�”}”(hŒ Q: What are the verifier limits?”h]”hŒ Q: What are the verifier limits?”…”�”}”(hjÀh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßjªuh1hºhj½h²hh³hÊh´K[ubhÌ)�”}”(hXAA: The only limit known to the user space is BPF_MAXINSNS (4096). It's the maximum number of instructions that the unprivileged bpf program can have. The verifier has various internal limits. Like the maximum number of instructions that can be explored during program analysis. Currently, that limit is set to 1 million. Which essentially means that the largest program can consist of 1 million NOP instructions. There is a limit to the maximum number of subsequent branches, a limit to the number of nested bpf-to-bpf calls, a limit to the number of the verifier states per instruction, a limit to the number of maps used by the program. All these limits can be hit with a sufficiently complex program. There are also non-numerical limits that can cause the program to be rejected. The verifier used to recognize only pointer + constant expressions. Now it can recognize pointer + bounded_register. bpf_lookup_map_elem(key) had a requirement that 'key' must be a pointer to the stack. Now, 'key' can be a pointer to map value. The verifier is steadily getting 'smarter'. The limits are being removed. The only way to know that the program is going to be accepted by the verifier is to try to load it. The bpf development process guarantees that the future kernel versions will accept all bpf programs that were accepted by the earlier versions.”h]”hXOA: The only limit known to the user space is BPF_MAXINSNS (4096). It’s the maximum number of instructions that the unprivileged bpf program can have. The verifier has various internal limits. Like the maximum number of instructions that can be explored during program analysis. Currently, that limit is set to 1 million. Which essentially means that the largest program can consist of 1 million NOP instructions. There is a limit to the maximum number of subsequent branches, a limit to the number of nested bpf-to-bpf calls, a limit to the number of the verifier states per instruction, a limit to the number of maps used by the program. All these limits can be hit with a sufficiently complex program. There are also non-numerical limits that can cause the program to be rejected. The verifier used to recognize only pointer + constant expressions. Now it can recognize pointer + bounded_register. bpf_lookup_map_elem(key) had a requirement that ‘key’ must be a pointer to the stack. Now, ‘key’ can be a pointer to map value. The verifier is steadily getting ‘smarter’. The limits are being removed. The only way to know that the program is going to be accepted by the verifier is to try to load it. The bpf development process guarantees that the future kernel versions will accept all bpf programs that were accepted by the earlier versions.”…”�”}”(hjÎh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K\hj½h²hubeh}”(h]”j°ah ]”h"]”Œ q: what are the verifier limits?”ah$]”h&]”uh1hµhjÎh²hh³hÊh´K[ubh¶)�”}”(hhh]”(h»)�”}”(hŒInstruction level questions”h]”hŒInstruction level questions”…”�”}”(hjæh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßjÌuh1hºhjãh²hh³hÊh´Kuubh¶)�”}”(hhh]”(h»)�”}”(hŒ+Q: LD_ABS and LD_IND instructions vs C code”h]”hŒ+Q: LD_ABS and LD_IND instructions vs C code”…”�”}”(hj÷h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßjëuh1hºhjôh²hh³hÊh´KxubhÌ)�”}”(hŒ‚Q: How come LD_ABS and LD_IND instruction are present in BPF whereas C code cannot express them and has to use builtin intrinsics?”h]”hŒ‚Q: How come LD_ABS and LD_IND instruction are present in BPF whereas C code cannot express them and has to use builtin intrinsics?”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kzhjôh²hubhÌ)�”}”(hŒŽA: This is artifact of compatibility with classic BPF. Modern networking code in BPF performs better without them. See 'direct packet access'.”h]”hŒ’A: This is artifact of compatibility with classic BPF. Modern networking code in BPF performs better without them. See ‘direct packet access’.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K}hjôh²hubeh}”(h]”jñah ]”h"]”Œ+q: ld_abs and ld_ind instructions vs c code”ah$]”h&]”uh1hµhjãh²hh³hÊh´Kxubh¶)�”}”(hhh]”(h»)�”}”(hŒ8Q: BPF instructions mapping not one-to-one to native CPU”h]”hŒ8Q: BPF instructions mapping not one-to-one to native CPU”…”�”}”(hj+h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßj uh1hºhj(h²hh³hÊh´K‚ubhÌ)�”}”(hŒˆQ: It seems not all BPF instructions are one-to-one to native CPU. For example why BPF_JNE and other compare and jumps are not cpu-like?”h]”hŒˆQ: It seems not all BPF instructions are one-to-one to native CPU. For example why BPF_JNE and other compare and jumps are not cpu-like?”…”�”}”(hj9h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kƒhj(h²hubhÌ)�”}”(hŒ†A: This was necessary to avoid introducing flags into ISA which are impossible to make generic and efficient across CPU architectures.”h]”hŒ†A: This was necessary to avoid introducing flags into ISA which are impossible to make generic and efficient across CPU architectures.”…”�”}”(hjGh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K†hj(h²hubeh}”(h]”jah ]”h"]”Œ8q: bpf instructions mapping not one-to-one to native cpu”ah$]”h&]”uh1hµhjãh²hh³hÊh´K‚ubh¶)�”}”(hhh]”(h»)�”}”(hŒ2Q: Why BPF_DIV instruction doesn't map to x64 div?”h]”hŒ4Q: Why BPF_DIV instruction doesn’t map to x64 div?”…”�”}”(hj_h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßj/uh1hºhj\h²hh³hÊh´KŠubhÌ)�”}”(hŒ«A: Because if we picked one-to-one relationship to x64 it would have made it more complicated to support on arm64 and other archs. Also it needs div-by-zero runtime check.”h]”hŒ«A: Because if we picked one-to-one relationship to x64 it would have made it more complicated to support on arm64 and other archs. Also it needs div-by-zero runtime check.”…”�”}”(hjmh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K‹hj\h²hubeh}”(h]”j5ah ]”h"]”Œ2q: why bpf_div instruction doesn't map to x64 div?”ah$]”h&]”uh1hµhjãh²hh³hÊh´KŠubh¶)�”}”(hhh]”(h»)�”}”(hŒ.Q: Why BPF has implicit prologue and epilogue?”h]”hŒ.Q: Why BPF has implicit prologue and epilogue?”…”�”}”(hj…h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßjQuh1hºhj‚h²hh³hÊh´K�ubhÌ)�”}”(hXaA: Because architectures like sparc have register windows and in general there are enough subtle differences between architectures, so naive store return address into stack won't work. Another reason is BPF has to be safe from division by zero (and legacy exception path of LD_ABS insn). Those instructions need to invoke epilogue and return implicitly.”h]”hXcA: Because architectures like sparc have register windows and in general there are enough subtle differences between architectures, so naive store return address into stack won’t work. Another reason is BPF has to be safe from division by zero (and legacy exception path of LD_ABS insn). Those instructions need to invoke epilogue and return implicitly.”…”�”}”(hj“h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K‘hj‚h²hubeh}”(h]”jWah ]”h"]”Œ.q: why bpf has implicit prologue and epilogue?”ah$]”h&]”uh1hµhjãh²hh³hÊh´K�ubh¶)�”}”(hhh]”(h»)�”}”(hŒMQ: Why BPF_JLT and BPF_JLE instructions were not introduced in the beginning?”h]”hŒMQ: Why BPF_JLT and BPF_JLE instructions were not introduced in the beginning?”…”�”}”(hj«h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßjsuh1hºhj¨h²hh³hÊh´K™ubhÌ)�”}”(hXëA: Because classic BPF didn't have them and BPF authors felt that compiler workaround would be acceptable. Turned out that programs lose performance due to lack of these compare instructions and they were added. These two instructions is a perfect example what kind of new BPF instructions are acceptable and can be added in the future. These two already had equivalent instructions in native CPUs. New instructions that don't have one-to-one mapping to HW instructions will not be accepted.”h]”hXïA: Because classic BPF didn’t have them and BPF authors felt that compiler workaround would be acceptable. Turned out that programs lose performance due to lack of these compare instructions and they were added. These two instructions is a perfect example what kind of new BPF instructions are acceptable and can be added in the future. These two already had equivalent instructions in native CPUs. New instructions that don’t have one-to-one mapping to HW instructions will not be accepted.”…”�”}”(hj¹h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kšhj¨h²hubeh}”(h]”jyah ]”h"]”ŒMq: why bpf_jlt and bpf_jle instructions were not introduced in the beginning?”ah$]”h&]”uh1hµhjãh²hh³hÊh´K™ubh¶)�”}”(hhh]”(h»)�”}”(hŒ&Q: BPF 32-bit subregister requirements”h]”hŒ&Q: BPF 32-bit subregister requirements”…”�”}”(hjÑh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßj•uh1hºhjÎh²hh³hÊh´K¤ubhÌ)�”}”(hŒòQ: BPF 32-bit subregisters have a requirement to zero upper 32-bits of BPF registers which makes BPF inefficient virtual machine for 32-bit CPU architectures and 32-bit HW accelerators. Can true 32-bit registers be added to BPF in the future?”h]”hŒòQ: BPF 32-bit subregisters have a requirement to zero upper 32-bits of BPF registers which makes BPF inefficient virtual machine for 32-bit CPU architectures and 32-bit HW accelerators. Can true 32-bit registers be added to BPF in the future?”…”�”}”(hjßh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K¥hjÎh²hubhÌ)�”}”(hŒA: NO.”h]”hŒA: NO.”…”�”}”(hjíh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KªhjÎh²hubhÌ)�”}”(hŒµBut some optimizations on zero-ing the upper 32 bits for BPF registers are available, and can be leveraged to improve the performance of JITed BPF programs for 32-bit architectures.”h]”hŒµBut some optimizations on zero-ing the upper 32 bits for BPF registers are available, and can be leveraged to improve the performance of JITed BPF programs for 32-bit architectures.”…”�”}”(hjûh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K¬hjÎh²hubhÌ)�”}”(hXøStarting with version 7, LLVM is able to generate instructions that operate on 32-bit subregisters, provided the option -mattr=+alu32 is passed for compiling a program. Furthermore, the verifier can now mark the instructions for which zero-ing the upper bits of the destination register is required, and insert an explicit zero-extension (zext) instruction (a mov32 variant). This means that for architectures without zext hardware support, the JIT back-ends do not need to clear the upper bits for subregisters written by alu32 instructions or narrow loads. Instead, the back-ends simply need to support code generation for that mov32 variant, and to overwrite bpf_jit_needs_zext() to make it return "true" (in order to enable zext insertion in the verifier).”h]”hXüStarting with version 7, LLVM is able to generate instructions that operate on 32-bit subregisters, provided the option -mattr=+alu32 is passed for compiling a program. Furthermore, the verifier can now mark the instructions for which zero-ing the upper bits of the destination register is required, and insert an explicit zero-extension (zext) instruction (a mov32 variant). This means that for architectures without zext hardware support, the JIT back-ends do not need to clear the upper bits for subregisters written by alu32 instructions or narrow loads. Instead, the back-ends simply need to support code generation for that mov32 variant, and to overwrite bpf_jit_needs_zext() to make it return “trueâ€� (in order to enable zext insertion in the verifier).”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K°hjÎh²hubhÌ)�”}”(hXÇNote that it is possible for a JIT back-end to have partial hardware support for zext. In that case, if verifier zext insertion is enabled, it could lead to the insertion of unnecessary zext instructions. Such instructions could be removed by creating a simple peephole inside the JIT back-end: if one instruction has hardware support for zext and if the next instruction is an explicit zext, then the latter can be skipped when doing the code generation.”h]”hXÇNote that it is possible for a JIT back-end to have partial hardware support for zext. In that case, if verifier zext insertion is enabled, it could lead to the insertion of unnecessary zext instructions. Such instructions could be removed by creating a simple peephole inside the JIT back-end: if one instruction has hardware support for zext and if the next instruction is an explicit zext, then the latter can be skipped when doing the code generation.”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K¼hjÎh²hubeh}”(h]”j›ah ]”h"]”Œ&q: bpf 32-bit subregister requirements”ah$]”h&]”uh1hµhjãh²hh³hÊh´K¤ubeh}”(h]”jÒah ]”h"]”Œinstruction level questions”ah$]”h&]”uh1hµhjÎh²hh³hÊh´Kuubh¶)�”}”(hhh]”(h»)�”}”(hŒQ: Does BPF have a stable ABI?”h]”hŒQ: Does BPF have a stable ABI?”…”�”}”(hj6 h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßjÃuh1hºhj3 h²hh³hÊh´KÅubhÌ)�”}”(hX×A: YES. BPF instructions, arguments to BPF programs, set of helper functions and their arguments, recognized return codes are all part of ABI. However there is one specific exception to tracing programs which are using helpers like bpf_probe_read() to walk kernel internal data structures and compile with kernel internal headers. Both of these kernel internals are subject to change and can break with newer kernels such that the program needs to be adapted accordingly.”h]”hX×A: YES. BPF instructions, arguments to BPF programs, set of helper functions and their arguments, recognized return codes are all part of ABI. However there is one specific exception to tracing programs which are using helpers like bpf_probe_read() to walk kernel internal data structures and compile with kernel internal headers. Both of these kernel internals are subject to change and can break with newer kernels such that the program needs to be adapted accordingly.”…”�”}”(hjD h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KÆhj3 h²hubhÌ)�”}”(hŒïNew BPF functionality is generally added through the use of kfuncs instead of new helpers. Kfuncs are not considered part of the stable API, and have their own lifecycle expectations as described in :ref:`BPF_kfunc_lifecycle_expectations`.”h]”(hŒÇNew BPF functionality is generally added through the use of kfuncs instead of new helpers. Kfuncs are not considered part of the stable API, and have their own lifecycle expectations as described in ”…”�”}”(hjR h²hh³Nh´Nubh)�”}”(hŒ':ref:`BPF_kfunc_lifecycle_expectations`”h]”hŒinline”“”)�”}”(hj\ h]”hŒ BPF_kfunc_lifecycle_expectations”…”�”}”(hj` h²hh³Nh´Nubah}”(h]”h ]”(Œxref”Œstd”Œstd-ref”eh"]”h$]”h&]”uh1j^ hjZ ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”Œbpf/bpf_design_QA”Œ refdomain”jk Œreftype”Œref”Œ refexplicit”‰Œrefwarn”ˆŒ reftarget”Œ bpf_kfunc_lifecycle_expectations”uh1hh³hÊh´KÎhjR ubhŒ.”…”�”}”(hjR h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KÎhj3 h²hubeh}”(h]”jÉah ]”h"]”Œq: does bpf have a stable abi?”ah$]”h&]”uh1hµhjÎh²hh³hÊh´KÅubh¶)�”}”(hhh]”(h»)�”}”(hŒ*Q: Are tracepoints part of the stable ABI?”h]”hŒ*Q: Are tracepoints part of the stable ABI?”…”�”}”(hj“ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßjåuh1hºhj� h²hh³hÊh´KÓubhÌ)�”}”(hŒ¼A: NO. Tracepoints are tied to internal implementation details hence they are subject to change and can break with newer kernels. BPF programs need to change accordingly when this happens.”h]”hŒ¼A: NO. Tracepoints are tied to internal implementation details hence they are subject to change and can break with newer kernels. BPF programs need to change accordingly when this happens.”…”�”}”(hj¡ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KÔhj� h²hubeh}”(h]”jëah ]”h"]”Œ*q: are tracepoints part of the stable abi?”ah$]”h&]”uh1hµhjÎh²hh³hÊh´KÓubh¶)�”}”(hhh]”(h»)�”}”(hŒ>Q: Are places where kprobes can attach part of the stable ABI?”h]”hŒ>Q: Are places where kprobes can attach part of the stable ABI?”…”�”}”(hj¹ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßjuh1hºhj¶ h²hh³hÊh´KÙubhÌ)�”}”(hŒÛA: NO. The places to which kprobes can attach are internal implementation details, which means that they are subject to change and can break with newer kernels. BPF programs need to change accordingly when this happens.”h]”hŒÛA: NO. The places to which kprobes can attach are internal implementation details, which means that they are subject to change and can break with newer kernels. BPF programs need to change accordingly when this happens.”…”�”}”(hjÇ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KÚhj¶ h²hubeh}”(h]”j ah ]”h"]”Œ>q: are places where kprobes can attach part of the stable abi?”ah$]”h&]”uh1hµhjÎh²hh³hÊh´KÙubh¶)�”}”(hhh]”(h»)�”}”(hŒ+Q: How much stack space a BPF program uses?”h]”hŒ+Q: How much stack space a BPF program uses?”…”�”}”(hjß h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßj)uh1hºhjÜ h²hh³hÊh´KßubhÌ)�”}”(hŒÄA: Currently all program types are limited to 512 bytes of stack space, but the verifier computes the actual amount of stack used and both interpreter and most JITed code consume necessary amount.”h]”hŒÄA: Currently all program types are limited to 512 bytes of stack space, but the verifier computes the actual amount of stack used and both interpreter and most JITed code consume necessary amount.”…”�”}”(hjí h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KàhjÜ h²hubeh}”(h]”j/ah ]”h"]”Œ+q: how much stack space a bpf program uses?”ah$]”h&]”uh1hµhjÎh²hh³hÊh´Kßubh¶)�”}”(hhh]”(h»)�”}”(hŒQ: Can BPF be offloaded to HW?”h]”hŒQ: Can BPF be offloaded to HW?”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßjKuh1hºhj h²hh³hÊh´KåubhÌ)�”}”(hŒ2A: YES. BPF HW offload is supported by NFP driver.”h]”hŒ2A: YES. BPF HW offload is supported by NFP driver.”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kæhj h²hubeh}”(h]”jQah ]”h"]”Œq: can bpf be offloaded to hw?”ah$]”h&]”uh1hµhjÎh²hh³hÊh´Kåubh¶)�”}”(hhh]”(h»)�”}”(hŒ,Q: Does classic BPF interpreter still exist?”h]”hŒ,Q: Does classic BPF interpreter still exist?”…”�”}”(hj+ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßjmuh1hºhj( h²hh³hÊh´KéubhÌ)�”}”(hŒGA: NO. Classic BPF programs are converted into extend BPF instructions.”h]”hŒGA: NO. Classic BPF programs are converted into extend BPF instructions.”…”�”}”(hj9 h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kêhj( h²hubeh}”(h]”jsah ]”h"]”Œ,q: does classic bpf interpreter still exist?”ah$]”h&]”uh1hµhjÎh²hh³hÊh´Kéubh¶)�”}”(hhh]”(h»)�”}”(hŒ+Q: Can BPF call arbitrary kernel functions?”h]”hŒ+Q: Can BPF call arbitrary kernel functions?”…”�”}”(hjQ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßj�uh1hºhjN h²hh³hÊh´KíubhÌ)�”}”(hŒ˜A: NO. BPF programs can only call specific functions exposed as BPF helpers or kfuncs. The set of available functions is defined for every program type.”h]”hŒ˜A: NO. BPF programs can only call specific functions exposed as BPF helpers or kfuncs. The set of available functions is defined for every program type.”…”�”}”(hj_ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KîhjN h²hubeh}”(h]”j•ah ]”h"]”Œ+q: can bpf call arbitrary kernel functions?”ah$]”h&]”uh1hµhjÎh²hh³hÊh´Kíubh¶)�”}”(hhh]”(h»)�”}”(hŒ-Q: Can BPF overwrite arbitrary kernel memory?”h]”hŒ-Q: Can BPF overwrite arbitrary kernel memory?”…”�”}”(hjw h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßj±uh1hºhjt h²hh³hÊh´KòubhÌ)�”}”(hŒA: NO.”h]”hŒA: NO.”…”�”}”(hj… h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kóhjt h²hubhÌ)�”}”(hXTracing bpf programs can *read* arbitrary memory with bpf_probe_read() and bpf_probe_read_str() helpers. Networking programs cannot read arbitrary memory, since they don't have access to these helpers. Programs can never read or write arbitrary memory directly.”h]”(hŒTracing bpf programs can ”…”�”}”(hj“ h²hh³Nh´NubjZ)�”}”(hŒ*read*”h]”hŒread”…”�”}”(hj› h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj“ ubhŒè arbitrary memory with bpf_probe_read() and bpf_probe_read_str() helpers. Networking programs cannot read arbitrary memory, since they don’t have access to these helpers. Programs can never read or write arbitrary memory directly.”…”�”}”(hj“ h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kõhjt h²hubeh}”(h]”j·ah ]”h"]”Œ-q: can bpf overwrite arbitrary kernel memory?”ah$]”h&]”uh1hµhjÎh²hh³hÊh´Kòubh¶)�”}”(hhh]”(h»)�”}”(hŒ+Q: Can BPF overwrite arbitrary user memory?”h]”hŒ+Q: Can BPF overwrite arbitrary user memory?”…”�”}”(hj½ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßjÓuh1hºhjº h²hh³hÊh´KûubhÌ)�”}”(hŒ A: Sort-of.”h]”hŒ A: Sort-of.”…”�”}”(hjË h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kühjº h²hubhÌ)�”}”(hXTracing BPF programs can overwrite the user memory of the current task with bpf_probe_write_user(). Every time such program is loaded the kernel will print warning message, so this helper is only useful for experiments and prototypes. Tracing BPF programs are root only.”h]”hXTracing BPF programs can overwrite the user memory of the current task with bpf_probe_write_user(). Every time such program is loaded the kernel will print warning message, so this helper is only useful for experiments and prototypes. Tracing BPF programs are root only.”…”�”}”(hjÙ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kþhjº h²hubeh}”(h]”jÙah ]”h"]”Œ+q: can bpf overwrite arbitrary user memory?”ah$]”h&]”uh1hµhjÎh²hh³hÊh´Kûubh¶)�”}”(hhh]”(h»)�”}”(hŒ(Q: New functionality via kernel modules?”h]”hŒ(Q: New functionality via kernel modules?”…”�”}”(hjñ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßjõuh1hºhjî h²hh³hÊh´MubhÌ)�”}”(hŒoQ: Can BPF functionality such as new program or map types, new helpers, etc be added out of kernel module code?”h]”hŒoQ: Can BPF functionality such as new program or map types, new helpers, etc be added out of kernel module code?”…”�”}”(hjÿ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhjî h²hubhÌ)�”}”(hŒ A: Yes, through kfuncs and kptrs”h]”hŒ A: Yes, through kfuncs and kptrs”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M hjî h²hubhÌ)�”}”(hŒøThe core BPF functionality such as program types, maps and helpers cannot be added to by modules. However, modules can expose functionality to BPF programs by exporting kfuncs (which may return pointers to module-internal data structures as kptrs).”h]”hŒøThe core BPF functionality such as program types, maps and helpers cannot be added to by modules. However, modules can expose functionality to BPF programs by exporting kfuncs (which may return pointers to module-internal data structures as kptrs).”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M hjî h²hubeh}”(h]”jûah ]”h"]”Œ(q: new functionality via kernel modules?”ah$]”h&]”uh1hµhjÎh²hh³hÊh´Mubh¶)�”}”(hhh]”(h»)�”}”(hŒ.Q: Directly calling kernel function is an ABI?”h]”hŒ.Q: Directly calling kernel function is an ABI?”…”�”}”(hj3 h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßjuh1hºhj0 h²hh³hÊh´MubhÌ)�”}”(hŒwQ: Some kernel functions (e.g. tcp_slow_start) can be called by BPF programs. Do these kernel functions become an ABI?”h]”hŒwQ: Some kernel functions (e.g. tcp_slow_start) can be called by BPF programs. Do these kernel functions become an ABI?”…”�”}”(hjA h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhj0 h²hubhÌ)�”}”(hŒA: NO.”h]”hŒA: NO.”…”�”}”(hjO h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhj0 h²hubhÌ)�”}”(hXøThe kernel function protos will change and the bpf programs will be rejected by the verifier. Also, for example, some of the bpf-callable kernel functions have already been used by other kernel tcp cc (congestion-control) implementations. If any of these kernel functions has changed, both the in-tree and out-of-tree kernel tcp cc implementations have to be changed. The same goes for the bpf programs and they have to be adjusted accordingly. See :ref:`BPF_kfunc_lifecycle_expectations` for details.”h]”(hXÄThe kernel function protos will change and the bpf programs will be rejected by the verifier. Also, for example, some of the bpf-callable kernel functions have already been used by other kernel tcp cc (congestion-control) implementations. If any of these kernel functions has changed, both the in-tree and out-of-tree kernel tcp cc implementations have to be changed. The same goes for the bpf programs and they have to be adjusted accordingly. See ”…”�”}”(hj] h²hh³Nh´Nubh)�”}”(hŒ':ref:`BPF_kfunc_lifecycle_expectations`”h]”j_ )�”}”(hjg h]”hŒ BPF_kfunc_lifecycle_expectations”…”�”}”(hji h²hh³Nh´Nubah}”(h]”h ]”(jj Œstd”Œstd-ref”eh"]”h$]”h&]”uh1j^ hje ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jw Œ refdomain”js Œreftype”Œref”Œ refexplicit”‰Œrefwarn”ˆj} Œ bpf_kfunc_lifecycle_expectations”uh1hh³hÊh´Mhj] ubhŒ for details.”…”�”}”(hj] h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhj0 h²hubeh}”(h]”jah ]”h"]”Œ.q: directly calling kernel function is an abi?”ah$]”h&]”uh1hµhjÎh²hh³hÊh´Mubh¶)�”}”(hhh]”(h»)�”}”(hŒ5Q: Attaching to arbitrary kernel functions is an ABI?”h]”hŒ5Q: Attaching to arbitrary kernel functions is an ABI?”…”�”}”(hj™ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßj9uh1hºhj– h²hh³hÊh´M!ubhÌ)�”}”(hŒlQ: BPF programs can be attached to many kernel functions. Do these kernel functions become part of the ABI?”h]”hŒlQ: BPF programs can be attached to many kernel functions. Do these kernel functions become part of the ABI?”…”�”}”(hj§ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M"hj– h²hubhÌ)�”}”(hŒA: NO.”h]”hŒA: NO.”…”�”}”(hjµ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M%hj– h²hubhÌ)�”}”(hŒúThe kernel function prototypes will change, and BPF programs attaching to them will need to change. The BPF compile-once-run-everywhere (CO-RE) should be used in order to make it easier to adapt your BPF programs to different versions of the kernel.”h]”hŒúThe kernel function prototypes will change, and BPF programs attaching to them will need to change. The BPF compile-once-run-everywhere (CO-RE) should be used in order to make it easier to adapt your BPF programs to different versions of the kernel.”…”�”}”(hjà h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M'hj– h²hubeh}”(h]”j?ah ]”h"]”Œ5q: attaching to arbitrary kernel functions is an abi?”ah$]”h&]”uh1hµhjÎh²hh³hÊh´M!ubh¶)�”}”(hhh]”(h»)�”}”(hŒ=Q: Marking a function with BTF_ID makes that function an ABI?”h]”hŒ=Q: Marking a function with BTF_ID makes that function an ABI?”…”�”}”(hjÛ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßj[uh1hºhjØ h²hh³hÊh´M-ubhÌ)�”}”(hŒA: NO.”h]”hŒA: NO.”…”�”}”(hjé h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M.hjØ h²hubhÌ)�”}”(hŒtThe BTF_ID macro does not cause a function to become part of the ABI any more than does the EXPORT_SYMBOL_GPL macro.”h]”hŒtThe BTF_ID macro does not cause a function to become part of the ABI any more than does the EXPORT_SYMBOL_GPL macro.”…”�”}”(hj÷ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M0hjØ h²hubeh}”(h]”jaah ]”h"]”Œ=q: marking a function with btf_id makes that function an abi?”ah$]”h&]”uh1hµhjÎh²hh³hÊh´M-ubh¶)�”}”(hhh]”(h»)�”}”(hŒGQ: What is the compatibility story for special BPF types in map values?”h]”hŒGQ: What is the compatibility story for special BPF types in map values?”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßj}uh1hºhj h²hh³hÊh´M4ubhÌ)�”}”(hX{Q: Users are allowed to embed bpf_spin_lock, bpf_timer fields in their BPF map values (when using BTF support for BPF maps). This allows to use helpers for such objects on these fields inside map values. Users are also allowed to embed pointers to some kernel types (with __kptr_untrusted and __kptr BTF tags). Will the kernel preserve backwards compatibility for these features?”h]”hX{Q: Users are allowed to embed bpf_spin_lock, bpf_timer fields in their BPF map values (when using BTF support for BPF maps). This allows to use helpers for such objects on these fields inside map values. Users are also allowed to embed pointers to some kernel types (with __kptr_untrusted and __kptr BTF tags). Will the kernel preserve backwards compatibility for these features?”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M5hj h²hubhÌ)�”}”(hŒbA: It depends. For bpf_spin_lock, bpf_timer: YES, for kptr and everything else: NO, but see below.”h]”hŒbA: It depends. For bpf_spin_lock, bpf_timer: YES, for kptr and everything else: NO, but see below.”…”�”}”(hj+ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M;hj h²hubhÌ)�”}”(hŒœFor struct types that have been added already, like bpf_spin_lock and bpf_timer, the kernel will preserve backwards compatibility, as they are part of UAPI.”h]”hŒœFor struct types that have been added already, like bpf_spin_lock and bpf_timer, the kernel will preserve backwards compatibility, as they are part of UAPI.”…”�”}”(hj9 h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M>hj h²hubhÌ)�”}”(hXªFor kptrs, they are also part of UAPI, but only with respect to the kptr mechanism. The types that you can use with a __kptr_untrusted and __kptr tagged pointer in your struct are NOT part of the UAPI contract. The supported types can and will change across kernel releases. However, operations like accessing kptr fields and bpf_kptr_xchg() helper will continue to be supported across kernel releases for the supported types.”h]”hXªFor kptrs, they are also part of UAPI, but only with respect to the kptr mechanism. The types that you can use with a __kptr_untrusted and __kptr tagged pointer in your struct are NOT part of the UAPI contract. The supported types can and will change across kernel releases. However, operations like accessing kptr fields and bpf_kptr_xchg() helper will continue to be supported across kernel releases for the supported types.”…”�”}”(hjG h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MAhj h²hubhÌ)�”}”(hX�For any other supported struct type, unless explicitly stated in this document and added to bpf.h UAPI header, such types can and will arbitrarily change their size, type, and alignment, or any other user visible API or ABI detail across kernel releases. The users must adapt their BPF programs to the new changes and update them to make sure their programs continue to work correctly.”h]”hX�For any other supported struct type, unless explicitly stated in this document and added to bpf.h UAPI header, such types can and will arbitrarily change their size, type, and alignment, or any other user visible API or ABI detail across kernel releases. The users must adapt their BPF programs to the new changes and update them to make sure their programs continue to work correctly.”…”�”}”(hjU h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MHhj h²hubhÌ)�”}”(hXSNOTE: BPF subsystem specially reserves the 'bpf\_' prefix for type names, in order to introduce more special fields in the future. Hence, user programs must avoid defining types with 'bpf\_' prefix to not be broken in future releases. In other words, no backwards compatibility is guaranteed if one using a type in BTF with 'bpf\_' prefix.”h]”hX_NOTE: BPF subsystem specially reserves the ‘bpf_’ prefix for type names, in order to introduce more special fields in the future. Hence, user programs must avoid defining types with ‘bpf_’ prefix to not be broken in future releases. In other words, no backwards compatibility is guaranteed if one using a type in BTF with ‘bpf_’ prefix.”…”�”}”(hjc h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MNhj h²hubeh}”(h]”jƒah ]”h"]”ŒGq: what is the compatibility story for special bpf types in map values?”ah$]”h&]”uh1hµhjÎh²hh³hÊh´M4ubh¶)�”}”(hhh]”(h»)�”}”(hŒNQ: What is the compatibility story for special BPF types in allocated objects?”h]”hŒNQ: What is the compatibility story for special BPF types in allocated objects?”…”�”}”(hj{ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”jßjŸuh1hºhjx h²hh³hÊh´MUubhÌ)�”}”(hŒ³Q: Same as above, but for allocated objects (i.e. objects allocated using bpf_obj_new for user defined types). Will the kernel preserve backwards compatibility for these features?”h]”hŒ³Q: Same as above, but for allocated objects (i.e. objects allocated using bpf_obj_new for user defined types). Will the kernel preserve backwards compatibility for these features?”…”�”}”(hj‰ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MVhjx h²hubhÌ)�”}”(hŒA: NO.”h]”hŒA: NO.”…”�”}”(hj— h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MZhjx h²hubhÌ)�”}”(hXUnlike map value types, the API to work with allocated objects and any support for special fields inside them is exposed through kfuncs, and thus has the same lifecycle expectations as the kfuncs themselves. See :ref:`BPF_kfunc_lifecycle_expectations` for details.”h]”(hŒÔUnlike map value types, the API to work with allocated objects and any support for special fields inside them is exposed through kfuncs, and thus has the same lifecycle expectations as the kfuncs themselves. See ”…”�”}”(hj¥ h²hh³Nh´Nubh)�”}”(hŒ':ref:`BPF_kfunc_lifecycle_expectations`”h]”j_ )�”}”(hj¯ h]”hŒ BPF_kfunc_lifecycle_expectations”…”�”}”(hj± h²hh³Nh´Nubah}”(h]”h ]”(jj Œstd”Œstd-ref”eh"]”h$]”h&]”uh1j^ hj­ ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jw Œ refdomain”j» Œreftype”Œref”Œ refexplicit”‰Œrefwarn”ˆj} Œ bpf_kfunc_lifecycle_expectations”uh1hh³hÊh´M\hj¥ ubhŒ for details.”…”�”}”(hj¥ h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M\hjx h²hubeh}”(h]”j¥ah ]”h"]”ŒNq: what is the compatibility story for special bpf types in allocated objects?”ah$]”h&]”uh1hµhjÎh²hh³hÊh´MUubeh}”(h]”hþah ]”h"]”Œquestions and answers”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kubeh}”(h]”Œbpf-design-q-a”ah ]”h"]”Œbpf design q&a”ah$]”h&]”uh1hµhhh²hh³hÊh´Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÊuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)�”}”(hºNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”j Œerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÊŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(jê jç jËjÆjâ hþjjj)j?jÄjujqj”j—j¶j½jØjêjjj(jRjJj†jljºjŽjàj°j0 jÒj%jñjYjjj5j¥jWjËjyj) j›j� jÉj³ jëjÙ j jÿ j/j% jQjK jsjq j•j· j·jë jÙj- jûj“ jjÕ j?j jaju jƒjÛ j¥uŒ nametypes”}”(jê ‰jˉjâ ‰j‰j)‰jĉjq‰j—‰j½‰jê‰j‰jR‰j†‰jº‰jà‰j0 ‰j%‰jY‰j‰j¥‰jˉj) ‰j� ‰j³ ‰jÙ ‰jÿ ‰j% ‰jK ‰jq ‰j· ‰jë ‰j- ‰j“ ‰jÕ ‰j ‰ju ‰jÛ ‰uh}”(jç h·jÆhÝhþjÎjjàj?jjuj,j”jNj¶jtjØjšjjÇj(jíjJj!jljUjŽj‰j°j½jÒjãjñjôjj(j5j\jWj‚jyj¨j›jÎjÉj3 jëj� j j¶ j/jÜ jQj jsj( j•jN j·jt jÙjº jûjî jj0 j?j– jajØ jƒj j¥jx høhïjjj9j0jojRjŽj…j°j§jÒjÉjj÷j"jjDj;jfj]jˆjjªj¡jÌjÃjëjâj jj/j&jQjHjsjjj•jŒjÃjºjåjÜjjþj)j jKjBjmjdj�j†j±j¨jÓjÊjõjìjjj9j0j[jRj}jtjŸj–uŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”j K#s…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nh²hub.