···3636defines calling convention that is compatible with C calling3737convention of the linux kernel on those architectures.38383939-Q: can multiple return values be supported in the future?3939+Q: Can multiple return values be supported in the future?4040~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~4141A: NO. BPF allows only register R0 to be used as return value.42424343-Q: can more than 5 function arguments be supported in the future?4343+Q: Can more than 5 function arguments be supported in the future?4444~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~4545A: NO. BPF calling convention only allows registers R1-R5 to be used4646as arguments. BPF is not a standalone instruction set.4747(unlike x64 ISA that allows msft, cdecl and other conventions)48484949-Q: can BPF programs access instruction pointer or return address?4949+Q: Can BPF programs access instruction pointer or return address?5050-----------------------------------------------------------------5151A: NO.52525353-Q: can BPF programs access stack pointer ?5353+Q: Can BPF programs access stack pointer ?5454------------------------------------------5555A: NO.56565757Only frame pointer (register R10) is accessible.5858From compiler point of view it's necessary to have stack pointer.5959-For example LLVM defines register R11 as stack pointer in its5959+For example, LLVM defines register R11 as stack pointer in its6060BPF backend, but it makes sure that generated code never uses it.61616262Q: Does C-calling convention diminishes possible use cases?···6666BPF design forces addition of major functionality in the form6767of kernel helper functions and kernel objects like BPF maps with6868seamless interoperability between them. It lets kernel call into6969-BPF programs and programs call kernel helpers with zero overhead.7070-As all of them were native C code. That is particularly the case6969+BPF programs and programs call kernel helpers with zero overhead,7070+as all of them were native C code. That is particularly the case7171for JITed BPF programs that are indistinguishable from7272native kernel C code.7373···7575------------------------------------------------------------------------7676A: Soft yes.77777878-At least for now until BPF core has support for7878+At least for now, until BPF core has support for7979bpf-to-bpf calls, indirect calls, loops, global variables,8080-jump tables, read only sections and all other normal constructs8080+jump tables, read-only sections, and all other normal constructs8181that C code can produce.82828383Q: Can loops be supported in a safe way?···109109A: This was necessary to avoid introducing flags into ISA which are110110impossible to make generic and efficient across CPU architectures.111111112112-Q: why BPF_DIV instruction doesn't map to x64 div?112112+Q: Why BPF_DIV instruction doesn't map to x64 div?113113~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~114114A: Because if we picked one-to-one relationship to x64 it would have made115115it more complicated to support on arm64 and other archs. Also it116116needs div-by-zero runtime check.117117118118-Q: why there is no BPF_SDIV for signed divide operation?118118+Q: Why there is no BPF_SDIV for signed divide operation?119119~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~120120A: Because it would be rarely used. llvm errors in such case and121121-prints a suggestion to use unsigned divide instead121121+prints a suggestion to use unsigned divide instead.122122123123Q: Why BPF has implicit prologue and epilogue?124124~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+1-1
Documentation/networking/filter.txt
···829829is not used by socket filters either, but more complex filters may be running830830out of registers and would have to resort to spill/fill to stack.831831832832-Internal BPF can used as generic assembler for last step performance832832+Internal BPF can be used as a generic assembler for last step performance833833optimizations, socket filters and seccomp are using it as assembler. Tracing834834filters may use it as assembler to generate code from kernel. In kernel usage835835may not be bounded by security considerations, since generated internal BPF code