Memory operations for BPF programs.
Provides:
Memory operations for BPF programs. Provides: - Load operations (ldx, ld) - Store operations (stx, st) - Atomic operations (atomic-add, atomic-xchg, etc.) - 64-bit immediate loads (lddw)
(atomic-add size dst src offset)Atomic add to memory.
(size)(dst + offset) += src
Arguments:
Atomic add to memory. *(size*)(dst + offset) += src Arguments: - size: :w (32-bit) or :dw (64-bit) - dst: Destination register (memory address) - src: Source register - offset: Memory offset
(atomic-and size dst src offset)Atomic AND to memory.
(size)(dst + offset) &= src
Atomic AND to memory. *(size*)(dst + offset) &= src
(atomic-cmpxchg size dst src offset)Atomic compare and exchange.
r0 = cmpxchg((size)(dst + offset), r0, src) If *addr == r0, then *addr = src
Atomic compare and exchange. r0 = cmpxchg(*(size*)(dst + offset), r0, src) If *addr == r0, then *addr = src
(atomic-fetch-add size dst src offset)Atomic fetch and add.
src = fetch_add((size)(dst + offset), src) Returns old value in src.
Atomic fetch and add. src = fetch_add(*(size*)(dst + offset), src) Returns old value in src.
(atomic-fetch-and size dst src offset)Atomic fetch and AND.
Atomic fetch and AND.
(atomic-fetch-or size dst src offset)Atomic fetch and OR.
Atomic fetch and OR.
(atomic-fetch-xor size dst src offset)Atomic fetch and XOR.
Atomic fetch and XOR.
(atomic-or size dst src offset)Atomic OR to memory.
(size)(dst + offset) |= src
Atomic OR to memory. *(size*)(dst + offset) |= src
(atomic-xchg size dst src offset)Atomic exchange.
src = xchg((size)(dst + offset), src)
Atomic exchange. src = xchg(*(size*)(dst + offset), src)
(atomic-xor size dst src offset)Atomic XOR to memory.
(size)(dst + offset) ^= src
Atomic XOR to memory. *(size*)(dst + offset) ^= src
(ld-map-fd dst map-fd)Load map file descriptor as a pseudo 64-bit immediate.
dst = map_fd (with BPF_PSEUDO_MAP_FD marker)
Arguments:
Load map file descriptor as a pseudo 64-bit immediate. dst = map_fd (with BPF_PSEUDO_MAP_FD marker) Arguments: - dst: Destination register - map-fd: Map file descriptor
(ld-map-value dst map-fd)Load map value pointer as 64-bit immediate.
dst = &map[0] (for direct value access)
Arguments:
Load map value pointer as 64-bit immediate. dst = &map[0] (for direct value access) Arguments: - dst: Destination register - map-fd: Map file descriptor
(lddw dst imm)Load 64-bit immediate to register.
dst = imm64
This requires two instructions due to the 64-bit immediate. Returns a vector of two instructions.
Load 64-bit immediate to register. dst = imm64 This requires two instructions due to the 64-bit immediate. Returns a vector of two instructions.
(ldx size dst src offset)Load from memory to register.
dst = (size)(src + offset)
Arguments:
Load from memory to register. dst = *(size*)(src + offset) Arguments: - size: :b (byte), :h (half-word), :w (word), :dw (double-word) - dst: Destination register - src: Source register (base address) - offset: Memory offset
(ldxb dst src offset)Load byte from memory.
dst = (u8)(src + offset)
Load byte from memory. dst = *(u8*)(src + offset)
(ldxdw dst src offset)Load double-word (8 bytes) from memory.
dst = (u64)(src + offset)
Load double-word (8 bytes) from memory. dst = *(u64*)(src + offset)
(ldxh dst src offset)Load half-word (2 bytes) from memory.
dst = (u16)(src + offset)
Load half-word (2 bytes) from memory. dst = *(u16*)(src + offset)
(ldxw dst src offset)Load word (4 bytes) from memory.
dst = (u32)(src + offset)
Load word (4 bytes) from memory. dst = *(u32*)(src + offset)
(size->bytes size)Convert size keyword to byte count
Convert size keyword to byte count
Map of size keywords to BPF size constants
Map of size keywords to BPF size constants
(st size dst offset imm)Store immediate to memory.
(size)(dst + offset) = imm
Arguments:
Store immediate to memory. *(size*)(dst + offset) = imm Arguments: - size: :b, :h, :w, :dw - dst: Destination register (base address) - offset: Memory offset - imm: Immediate value
(stack-alloc size)Generate instructions to allocate space on stack.
Arguments:
Returns mov instruction to set up stack pointer offset.
Generate instructions to allocate space on stack. Arguments: - size: Number of bytes to allocate (should be 8-byte aligned) Returns mov instruction to set up stack pointer offset.
(stack-load size dst offset)Load from stack.
dst = (size)(fp - offset)
Arguments:
Load from stack. dst = *(size*)(fp - offset) Arguments: - size: :b, :h, :w, :dw - dst: Destination register - offset: Positive offset from frame pointer
(stack-store size offset src)Store to stack from register.
(size)(fp - offset) = src
Arguments:
Store to stack from register. *(size*)(fp - offset) = src Arguments: - size: :b, :h, :w, :dw - offset: Positive offset from frame pointer - src: Source register
(stack-store-imm size offset imm)Store to stack from immediate.
(size)(fp - offset) = imm
Store to stack from immediate. *(size*)(fp - offset) = imm
(stb dst offset imm)Store byte to memory from immediate.
(u8)(dst + offset) = imm
Store byte to memory from immediate. *(u8*)(dst + offset) = imm
(stdw dst offset imm)Store double-word to memory from immediate.
(u64)(dst + offset) = imm
Store double-word to memory from immediate. *(u64*)(dst + offset) = imm
(sth dst offset imm)Store half-word to memory from immediate.
(u16)(dst + offset) = imm
Store half-word to memory from immediate. *(u16*)(dst + offset) = imm
(stw dst offset imm)Store word to memory from immediate.
(u32)(dst + offset) = imm
Store word to memory from immediate. *(u32*)(dst + offset) = imm
(stx size dst src offset)Store register to memory.
(size)(dst + offset) = src
Arguments:
Store register to memory. *(size*)(dst + offset) = src Arguments: - size: :b, :h, :w, :dw - dst: Destination register (base address) - src: Source register - offset: Memory offset
(stxb dst src offset)Store byte to memory from register.
(u8)(dst + offset) = src
Store byte to memory from register. *(u8*)(dst + offset) = src
(stxdw dst src offset)Store double-word to memory from register.
(u64)(dst + offset) = src
Store double-word to memory from register. *(u64*)(dst + offset) = src
(stxh dst src offset)Store half-word to memory from register.
(u16)(dst + offset) = src
Store half-word to memory from register. *(u16*)(dst + offset) = src
(stxw dst src offset)Store word to memory from register.
(u32)(dst + offset) = src
Store word to memory from register. *(u32*)(dst + offset) = src
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |