1*deb88407SDavid Vernet.. contents:: 2*deb88407SDavid Vernet.. sectnum:: 3*deb88407SDavid Vernet 4*deb88407SDavid Vernet=================================================== 5*deb88407SDavid VernetBPF ABI Recommended Conventions and Guidelines v1.0 6*deb88407SDavid Vernet=================================================== 7*deb88407SDavid Vernet 8*deb88407SDavid VernetThis is version 1.0 of an informational document containing recommended 9*deb88407SDavid Vernetconventions and guidelines for producing portable BPF program binaries. 10*deb88407SDavid Vernet 11*deb88407SDavid VernetRegisters and calling convention 12*deb88407SDavid Vernet================================ 13*deb88407SDavid Vernet 14*deb88407SDavid VernetBPF has 10 general purpose registers and a read-only frame pointer register, 15*deb88407SDavid Vernetall of which are 64-bits wide. 16*deb88407SDavid Vernet 17*deb88407SDavid VernetThe BPF calling convention is defined as: 18*deb88407SDavid Vernet 19*deb88407SDavid Vernet* R0: return value from function calls, and exit value for BPF programs 20*deb88407SDavid Vernet* R1 - R5: arguments for function calls 21*deb88407SDavid Vernet* R6 - R9: callee saved registers that function calls will preserve 22*deb88407SDavid Vernet* R10: read-only frame pointer to access stack 23*deb88407SDavid Vernet 24*deb88407SDavid VernetR0 - R5 are scratch registers and BPF programs needs to spill/fill them if 25*deb88407SDavid Vernetnecessary across calls. 26