ubpf_register_stack_usage_calculator

Function ubpf_register_stack_usage_calculator 

Source
pub unsafe extern "C" fn ubpf_register_stack_usage_calculator(
    vm: *mut ubpf_vm,
    calculator: stack_usage_calculator_t,
    cookie: *mut c_void,
) -> c_int
Expand description

@brief Register a function that will be called during eBPF program validation to determine stack usage for a local function.

In eBPF, the frame pointer is a read-only register. Therefore, the eBPF interpreter or the eBPF JITer need to know the stack usage for each local function so that the frame pointer can be adjusted properly on behalf of the calling function. The callback registered here has access to a cookie for context (specified in the call to this function), the PC (in the eBPF program) of the first instruction of a local function and the ubpf_vm.

The callback’s job is to calculate the amount of stack space used by the local function that starts at the given PC.

If the callback returns 0 or there is no callback registered, the eBPF interpreter/JITer assume that the local function uses the maximum stack available according to the spec (512K).

@param[in] vm The VM to register the callback with. @param[in] dispatcher The callback that will be invoked to determine the amount of stack usage for a local function that starts at … @param[in] pc The pc of the function whose stack usage the callback must caculate. @retval 0 Success. @retval -1 Failure.