Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Alan Jowett <[email protected]>
  • Loading branch information
Alan Jowett committed Oct 16, 2024
1 parent af1d247 commit 85dc99a
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions vm/inc/ubpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ extern "C"
*
* @param[in] vm The VM to compile the program in.
* @param[out] errmsg The error message, if any. This should be freed by the caller.
* @return ubpf_jit_fn A pointer to the compiled program, or NULL on failure.
* @return A pointer to the compiled program, or NULL on failure.
*/
ubpf_jit_fn
ubpf_compile(struct ubpf_vm* vm, char** errmsg);
Expand All @@ -375,7 +375,7 @@ extern "C"
* @param[in] vm The VM to compile the program in.
* @param[out] errmsg The error message, if any. This should be freed by the caller.
* @param[in] jit_mode The mode in which to execute the JITer -- basic or extended.
* @return ubpf_jit_fn A pointer to the compiled program, or NULL on failure.
* @return A pointer to the compiled program, or NULL on failure.
*/
ubpf_jit_ex_fn
ubpf_compile_ex(struct ubpf_vm* vm, char** errmsg, enum JitMode jit_mode);
Expand All @@ -391,7 +391,7 @@ extern "C"
*
* @param[in] vm The VM of the already JIT'd program.
* @param[out] errmsg The error message, if any. This should be freed by the caller.
* @return ubpf_jit_fn A pointer to the compiled program (the same as buffer), or
* @return A pointer to the compiled program (the same as buffer), or
* NULL on failure.
*/
ubpf_jit_fn
Expand Down Expand Up @@ -461,7 +461,7 @@ extern "C"
* @brief Retrieve the storage location for the BPF registers in the VM.
*
* @param[in] vm The VM to get the register storage from.
* @return uint64_t* A pointer to the register storage.
* @return A pointer to the register storage.
*/
uint64_t*
ubpf_get_registers(const struct ubpf_vm* vm);
Expand All @@ -487,7 +487,7 @@ extern "C"
* @param[in] symbol_name Name of the symbol that is referenced.
* @param[in] symbol_offset Offset of the symbol relative to the start of the map section.
* @param[in] symbol_size Size of the symbol.
* @return uint64_t The value to insert into the BPF program.
* @return The value to insert into the BPF program.
*/
typedef uint64_t (*ubpf_data_relocation)(
void* user_context,
Expand All @@ -502,7 +502,7 @@ extern "C"
*
* @param[in] vm The VM to set the relocation function for.
* @param[in] relocation The relocation function.
* @return int The value to insert into the BPF program.
* @return The value to insert into the BPF program.
*/
int
ubpf_register_data_relocation(struct ubpf_vm* vm, void* user_context, ubpf_data_relocation relocation);
Expand All @@ -513,7 +513,8 @@ extern "C"
* @param[in] context The user context that was passed to ubpf_register_data_bounds_check.
* @param[in] addr The address to check.
* @param[in] size The size of the memory access.
* @return bool True if the memory access is within bounds, false otherwise.
* @retval True The memory access is within bounds.
* @retval False The memory access is out of bounds.
*/
typedef bool (*ubpf_bounds_check)(void* context, uint64_t addr, uint64_t size);

Expand Down Expand Up @@ -552,8 +553,8 @@ extern "C"
* @param[in] vm The VM to set the instruction limit for.
* @param[in] limit The maximum number of instructions that a program may execute or 0 for no limit.
* @param[out] previous_limit Optional pointer to store the previous instruction limit.
* @return 0 Success.
* @return -1 Failure.
* @retval 0 Success.
* @retval -1 Failure.
*/
int
ubpf_set_instruction_limit(struct ubpf_vm* vm, uint32_t limit, uint32_t* previous_limit);
Expand All @@ -565,8 +566,8 @@ extern "C"
*
* @param[in] vm VM to enable or disable undefined behavior checks on.
* @param[in] enable Enable undefined behavior checks if true, disable if false.
* @return true if undefined behavior checks were previously enabled.
* @return false if undefined behavior checks were previously disabled.
* @retval true Undefined behavior checks were previously enabled.
* @retval false Undefined behavior checks were previously disabled.
*/
bool
ubpf_toggle_undefined_behavior_check(struct ubpf_vm* vm, bool enable);
Expand All @@ -582,9 +583,9 @@ extern "C"
* @param[in] register_mask Bitmask of registers that have been modified since the start of the program.
* Each set bit represents 1 modified register. LSB corresponds to register 0 and so on.
* @param[in] stack_mask_start Bitmask of the stack that has been modified since the start of the program.
* Each set bit represents 1 byte of the stack that has been modified. LSB corresponds to the first byte relative to stack_start
* and the MSB corresponds to the last byte. Note that the stack grows downwards, so the byte corresponding to the MSB is the first byte
* of the stack from the POV of the program and LSB is the last byte.
* Each set bit represents 1 byte of the stack that has been modified. LSB corresponds to the first byte relative
* to stack_start and the MSB corresponds to the last byte. Note that the stack grows downwards, so the byte
* corresponding to the MSB is the first byte of the stack from the POV of the program and LSB is the last byte.
*/
typedef void (*ubpf_debug_fn)(
void* context,
Expand All @@ -601,8 +602,8 @@ extern "C"
*
* @param[in] vm VM to add the option to.
* @param[in] debug_fn Function to invoke before each instruction. Pass NULL to remove the function.
* @return 0 on success.
* @return -1 on failure.
* @retval 0 Success.
* @retval -1 Failure.
*/
int
ubpf_register_debug_fn(struct ubpf_vm* vm, void* context, ubpf_debug_fn debug_function);
Expand Down

0 comments on commit 85dc99a

Please sign in to comment.