In the instruction descriptions below the following field descriptors are used:
%d%sdisp16disp32offset16imm32imm64The destination register in these instructions act like an accumulator.
add %d, (%s|imm32)sub %d, (%s|imm32)mul %d, (%s|imm32)div %d, (%s|imm32)mod %d, (%s|imm32)and %d, (%s|imm32)or %d, (%s|imm32)xor %d, (%s|imm32)lsh %d, (%s|imm32)%s or imm32 bits.
rsh %d, (%s|imm32)%s or imm32 bits.
arsh %d, (%s|imm32)%s or imm32 bits.
neg %dmov %d, (%s|imm32)%s in %d, or load imm32
in %d.
The destination register in these instructions act as an accumulator.
add32 %d, (%s|imm32)sub32 %d, (%s|imm32)mul32 %d, (%s|imm32)div32 %d, (%s|imm32)mod32 %d, (%s|imm32)and32 %d, (%s|imm32)or32 %d, (%s|imm32)xor32 %d, (%s|imm32)lsh32 %d, (%s|imm32)%s or imm32 bits.
rsh32 %d, (%s|imm32)%s or imm32 bits.
arsh32 %d, (%s|imm32)%s or imm32 bits.
neg32 %dmov32 %d, (%s|imm32)%s in %d, or load imm32
in %d.
endle %d, (8|16|32)%d to
little-endian.
endbe %d, (8|16|32)%d to big-endian.
lddw %d, imm64%d.
lddw %d, %map_fd(N)%d.
The following instructions are intended to be used in socket filters, and are therefore not general-purpose: they make assumptions on the contents of several registers. See the file Documentation/networking/filter.txt in the Linux kernel source tree for more information.
Absolute loads:
ldabsdw imm32ldabsw imm32ldabsh imm32ldabsb imm32Indirect loads:
ldinddw %s, imm32ldindw %s, imm32ldindh %s, imm32ldindb %s, imm32General-purpose load and store instructions are provided for several word sizes.
Load to register instructions:
ldxdw %d, [%s+offset16]ldxw %d, [%s+offset16]ldxh %d, [%s+offset16]ldxb %d, [%s+offset16]Store from register instructions:
stxdw [%d+offset16], %sstxw [%d+offset16], %sstxh [%d+offset16], %sstxb [%d+offset16], %sStore from immediates instructions:
stddw [%d+offset16], imm32stdw [%d+offset16], imm32stdh [%d+offset16], imm32stdb [%d+offset16], imm32eBPF provides the following compare-and-jump instructions, which compare the values of the two given registers, or the values of a register and an immediate, and perform a branch in case the comparison holds true.
ja %d,(%s|imm32),disp16jeq %d,(%s|imm32),disp16jgt %d,(%s|imm32),disp16jge %d,(%s|imm32),disp16jlt %d,(%s|imm32),disp16jle %d,(%s|imm32),disp16jset %d,(%s|imm32),disp16jne %d,(%s|imm32),disp16jsgt %d,(%s|imm32),disp16jsge %d,(%s|imm32),disp16jslt %d,(%s|imm32),disp16jsle %d,(%s|imm32),disp16A call instruction is provided in order to perform calls to other eBPF functions, or to external kernel helpers:
call (disp32|imm32)Finally:
exitAtomic exchange-and-add instructions are provided in two flavors: one for swapping 64-bit quantities and another for 32-bit quantities.
xadddw [%d+offset16],%sxaddw [%d+offset16],%s