BPF Instructions

Created

  • 2024-07-12

Last Updated

  • 2024-11-22

Available Formats


BPF Instruction Conformance Groups

Expert(s)

  • Alexei Starovoitov, David Vernet

Reference

  • RFC 9669: BPF Instruction Set Architecture (ISA)

Available Formats

RangeRegistration Procedures
PermanentStandards Action or IESG Approval
ProvisionalSpecification Required
HistoricalSpecification Required
NameDescriptionIncludesExcludesStatusReferenceChange Controller
atomic3232-bit atomic instructions--PermanentRFC 9669, Section 5.3 (Atomic Operations)IETF
atomic6464-bit atomic instructionsatomic32-PermanentRFC 9669, Section 5.3 (Atomic Operations)IETF
base3232-bit base instructions--PermanentRFC 9669IETF
base6464-bit base instructionsbase32-PermanentRFC 9669IETF
divmul3232-bit division and modulo--PermanentRFC 9669, Section 4.1 (Arithmetic Instructions)IETF
divmul6464-bit division and modulodivmul32-PermanentRFC 9669, Section 4.1 (Arithmetic Instructions)IETF
packetLegacy packet instructions--HistoricalRFC 9669, Section 5.5 (Legacy BPF Packet Access Instructions)IETF

BPF Instruction Set

Expert(s)

  • Alexei Starovoitov, David Vernet

Reference

  • RFC 9669: BPF Instruction Set Architecture (ISA)

Available Formats

RangeRegistration Procedures
PermanentStandards Action or IESG Approval
ProvisionalSpecification Required
HistoricalSpecification Required
OpcodeSrc_RegOffsetImmDescriptionGroupsReferenceChange Controller
0x000x00any(additional immediate value)base64RFC 9669, Section 5.4 (64-bit Immediate Instructions)IETF
0x040x00anydst = (u32)((u32)dst + (u32)imm)base32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x050x0any0x00goto +offsetbase32RFC 9669, Section 4.3 (Jump Instructions)IETF
0x060x00anygoto +immbase32RFC 9669, Section 4.3 (Jump Instructions)IETF
0x070x00anydst += immbase64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x0cany00x00dst = (u32)((u32)dst + (u32)src)base32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x0fany00x00dst += srcbase64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x140x00anydst = (u32)((u32)dst - (u32)imm)base32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x150x0anyanyif dst == imm goto +offsetbase64RFC 9669, Section 4.3 (Jump Instructions)IETF
0x160x0anyanyif (u32)dst == imm goto +offsetbase32RFC 9669, Section 4.3 (Jump Instructions)IETF
0x170x00anydst -= immbase64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x180x00anydst = (next_imm << 32) | immbase64RFC 9669, Section 5.4 (64-bit Immediate Instructions)IETF
0x180x10anydst = map_by_fd(imm)base64RFC 9669, Section 5.4 (64-bit Immediate Instructions)IETF
0x180x20anydst = map_val(map_by_fd(imm)) + next_immbase64RFC 9669, Section 5.4 (64-bit Immediate Instructions)IETF
0x180x30anydst = var_addr(imm)base64RFC 9669, Section 5.4 (64-bit Immediate Instructions)IETF
0x180x40anydst = code_addr(imm)base64RFC 9669, Section 5.4 (64-bit Immediate Instructions)IETF
0x180x50anydst = map_by_idx(imm)base64RFC 9669, Section 5.4 (64-bit Immediate Instructions)IETF
0x180x60anydst = map_val(map_by_idx(imm)) + next_immbase64RFC 9669, Section 5.4 (64-bit Immediate Instructions)IETF
0x1cany00x00dst = (u32)((u32)dst - (u32)src)base32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x1danyany0x00if dst == src goto +offsetbase64RFC 9669, Section 4.3 (Jump Instructions)IETF
0x1eanyany0x00if (u32)dst == (u32)src goto +offsetbase32RFC 9669, Section 4.3 (Jump Instructions)IETF
0x1fany00x00dst -= srcbase64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x200x00any(deprecated, implementation-specific)packetRFC 9669, Section 5.5 (Legacy BPF Packet Access Instructions)IETF
0x240x00anydst = (u32)(dst * imm)divmul32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x250x0anyanyif dst > imm goto +offsetbase64RFC 9669, Section 4.3 (Jump Instructions)IETF
0x260x0anyanyif (u32)dst > imm goto +offsetbase32RFC 9669, Section 4.3 (Jump Instructions)IETF
0x270x00anydst *= immdivmul64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x280x00any(deprecated, implementation-specific)packetRFC 9669, Section 5.5 (Legacy BPF Packet Access Instructions)IETF
0x2cany00x00dst = (u32)(dst * src)divmul32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x2danyany0x00if dst > src goto +offsetbase64RFC 9669, Section 4.3 (Jump Instructions)IETF
0x2eanyany0x00if (u32)dst > (u32)src goto +offsetbase32RFC 9669, Section 4.3 (Jump Instructions)IETF
0x2fany00x00dst *= srcdivmul64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x300x00any(deprecated, implementation-specific)packetRFC 9669, Section 5.5 (Legacy BPF Packet Access Instructions)IETF
0x340x00anydst = (u32)((imm != 0) ? ((u32)dst / (u32)imm) : 0)divmul32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x340x01anydst = (u32)((imm != 0) ? ((s32)dst s/ imm) : 0)divmul32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x350x0anyanyif dst >= imm goto +offsetbase64RFC 9669, Section 4.3 (Jump Instructions)IETF
0x360x0anyanyif (u32)dst >= imm goto +offsetbase32RFC 9669, Section 4.3 (Jump Instructions)IETF
0x370x00anydst = (imm != 0) ? (dst / (u32)imm) : 0divmul64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x370x01anydst = (imm != 0) ? (dst s/ imm) : 0divmul64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x3cany00x00dst = (u32)((src != 0) ? ((u32)dst / (u32)src) : 0)divmul32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x3cany10x00dst = (u32)((src != 0) ? ((s32)dst s/(s32)src) : 0)divmul32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x3danyany0x00if dst >= src goto +offsetbase64RFC 9669, Section 4.3 (Jump Instructions)IETF
0x3eanyany0x00if (u32)dst >= (u32)src goto +offsetbase32RFC 9669, Section 4.3 (Jump Instructions)IETF
0x3fany00x00dst = (src != 0) ? (dst / src) : 0divmul64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x3fany10x00dst = (src != 0) ? (dst s/ src) : 0divmul64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x40any0any(deprecated, implementation-specific)packetRFC 9669, Section 5.5 (Legacy BPF Packet Access Instructions)IETF
0x440x00anydst = (u32)(dst | imm)base32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x450x0anyanyif dst & imm goto +offsetbase64RFC 9669, Section 4.3 (Jump Instructions)IETF
0x460x0anyanyif (u32)dst & imm goto +offsetbase32RFC 9669, Section 4.3 (Jump Instructions)IETF
0x470x00anydst |= immbase64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x48any0any(deprecated, implementation-specific)packetRFC 9669, Section 5.5 (Legacy BPF Packet Access Instructions)IETF
0x4cany00x00dst = (u32)(dst | src)base32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x4danyany0x00if dst & src goto +offsetbase64RFC 9669, Section 4.3 (Jump Instructions)IETF
0x4eanyany0x00if (u32)dst & (u32)src goto +offsetbase32RFC 9669, Section 4.3 (Jump Instructions)IETF
0x4fany00x00dst |= srcbase64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x50any0any(deprecated, implementation-specific)packetRFC 9669, Section 5.5 (Legacy BPF Packet Access Instructions)IETF
0x540x00anydst = (u32)(dst & imm)base32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x550x0anyanyif dst != imm goto +offsetbase64RFC 9669, Section 4.3 (Jump Instructions)IETF
0x560x0anyanyif (u32)dst != imm goto +offsetbase32RFC 9669, Section 4.3 (Jump Instructions)IETF
0x570x00anydst &= immbase64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x5cany00x00dst = (u32)(dst & src)base32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x5danyany0x00if dst != src goto +offsetbase64RFC 9669, Section 4.3 (Jump Instructions)IETF
0x5eanyany0x00if (u32)dst != (u32)src goto +offsetbase32RFC 9669, Section 4.3 (Jump Instructions)IETF
0x5fany00x00dst &= srcbase64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x61anyany0x00dst = *(u32 *)(src + offset)base32RFC 9669, Section 5 (Load and Store Instructions)IETF
0x620x0anyany*(u32 *)(dst + offset) = immbase32RFC 9669, Section 5 (Load and Store Instructions)IETF
0x63anyany0x00*(u32 *)(dst + offset) = srcbase32RFC 9669, Section 5 (Load and Store Instructions)IETF
0x640x00anydst = (u32)(dst << imm)base32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x650x0anyanyif dst s> imm goto +offsetbase64RFC 9669, Section 4.3 (Jump Instructions)IETF
0x660x0anyanyif (s32)dst s> (s32)imm goto +offsetbase32RFC 9669, Section 4.3 (Jump Instructions)IETF
0x670x00anydst <<= immbase64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x69anyany0x00dst = *(u16 *)(src + offset)base32RFC 9669, Section 5 (Load and Store Instructions)IETF
0x6a0x0anyany*(u16 *)(dst + offset) = immbase32RFC 9669, Section 5 (Load and Store Instructions)IETF
0x6banyany0x00*(u16 *)(dst + offset) = srcbase32RFC 9669, Section 5 (Load and Store Instructions)IETF
0x6cany00x00dst = (u32)(dst << src)base32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x6danyany0x00if dst s> src goto +offsetbase64RFC 9669, Section 4.3 (Jump Instructions)IETF
0x6eanyany0x00if (s32)dst s> (s32)src goto +offsetbase32RFC 9669, Section 4.3 (Jump Instructions)IETF
0x6fany00x00dst <<= srcbase64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x71anyany0x00dst = *(u8 *)(src + offset)base32RFC 9669, Section 5 (Load and Store Instructions)IETF
0x720x0anyany*(u8 *)(dst + offset) = immbase32RFC 9669, Section 5 (Load and Store Instructions)IETF
0x73anyany0x00*(u8 *)(dst + offset) = srcbase32RFC 9669, Section 5 (Load and Store Instructions)IETF
0x740x00anydst = (u32)(dst >> imm)base32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x750x0anyanyif dst s>= imm goto +offsetbase64RFC 9669, Section 4.3 (Jump Instructions)IETF
0x760x0anyanyif (s32)dst s>= (s32)imm goto +offsetbase32RFC 9669, Section 4.3 (Jump Instructions)IETF
0x770x00anydst >>= immbase64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x79anyany0x00dst = *(u64 *)(src + offset)base64RFC 9669, Section 5 (Load and Store Instructions)IETF
0x7a0x0anyany*(u64 *)(dst + offset) = immbase64RFC 9669, Section 5 (Load and Store Instructions)IETF
0x7banyany0x00*(u64 *)(dst + offset) = srcbase64RFC 9669, Section 5 (Load and Store Instructions)IETF
0x7cany00x00dst = (u32)(dst >> src)base32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x7danyany0x00if dst s>= src goto +offsetbase64RFC 9669, Section 4.3 (Jump Instructions)IETF
0x7eanyany0x00if (s32)dst s>= (s32)src goto +offsetbase32RFC 9669, Section 4.3 (Jump Instructions)IETF
0x7fany00x00dst >>= srcbase64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x840x000x00dst = (u32)-dstbase32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x850x00anycall helper function by static IDbase32RFC 9669, Section 4.3.1 (Helper Functions)IETF
0x850x10anycall PC += immbase32RFC 9669, Section 4.3.2 (Program-local functions)IETF
0x850x20anycall helper function by BTF IDbase32RFC 9669, Section 4.3.1 (Helper Functions)IETF
0x870x000x00dst = -dstbase64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x940x00anydst = (u32)((imm != 0)?((u32)dst % (u32)imm) : dst)divmul32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x940x01anydst = (u32)((imm != 0) ? ((s32)dst s% imm) : dst)divmul32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x950x000x00returnbase32RFC 9669, Section 4.3 (Jump Instructions)IETF
0x970x00anydst = (imm != 0) ? (dst % (u32)imm) : dstdivmul64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x970x01anydst = (imm != 0) ? (dst s% imm) : dstdivmul64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x9cany00x00dst = (u32)((src != 0)?((u32)dst % (u32)src) : dst)divmul32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x9cany10x00dst = (u32)((src != 0)?((s32)dst s% (s32)src) :dst)divmul32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x9fany00x00dst = (src != 0) ? (dst % src) : dstdivmul64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0x9fany10x00dst = (src != 0) ? (dst s% src) : dstdivmul64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0xa40x00anydst = (u32)(dst ^ imm)base32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0xa50x0anyanyif dst < imm goto +offsetbase64RFC 9669, Section 4.3 (Jump Instructions)IETF
0xa60x0anyanyif (u32)dst < imm goto +offsetbase32RFC 9669, Section 4.3 (Jump Instructions)IETF
0xa70x00anydst ^= immbase64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0xacany00x00dst = (u32)(dst ^ src)base32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0xadanyany0x00if dst < src goto +offsetbase64RFC 9669, Section 4.3 (Jump Instructions)IETF
0xaeanyany0x00if (u32)dst < (u32)src goto +offsetbase32RFC 9669, Section 4.3 (Jump Instructions)IETF
0xafany00x00dst ^= srcbase64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0xb40x00anydst = (u32) immbase32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0xb50x0anyanyif dst <= imm goto +offsetbase64RFC 9669, Section 4.3 (Jump Instructions)IETF
0xb60x0anyanyif (u32)dst <= imm goto +offsetbase32RFC 9669, Section 4.3 (Jump Instructions)IETF
0xb70x00anydst = immbase64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0xbcany00x00dst = (u32) srcbase32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0xbcany80x00dst = (u32) (s32) (s8) srcbase32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0xbcany160x00dst = (u32) (s32) (s16) srcbase32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0xbdanyany0x00if dst <= src goto +offsetbase64RFC 9669, Section 4.3 (Jump Instructions)IETF
0xbeanyany0x00if (u32)dst <= (u32)src goto +offsetbase32RFC 9669, Section 4.3 (Jump Instructions)IETF
0xbfany00x00dst = srcbase64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0xbfany80x00dst = (s64) (s8) srcbase64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0xbfany160x00dst = (s64) (s16) srcbase64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0xbfany320x00dst = (s64) (s32) srcbase64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0xc3anyany0x00lock *(u32 *)(dst + offset) += srcatomic32RFC 9669, Section 5.3 (Atomic Operations)IETF
0xc3anyany0x01src = atomic_fetch_add_32((u32 *)(dst + offset), src)atomic32RFC 9669, Section 5.3 (Atomic Operations)IETF
0xc3anyany0x40lock *(u32 *)(dst + offset) |= srcatomic32RFC 9669, Section 5.3 (Atomic Operations)IETF
0xc3anyany0x41src = atomic_fetch_or_32((u32 *)(dst + offset), src)atomic32RFC 9669, Section 5.3 (Atomic Operations)IETF
0xc3anyany0x50lock *(u32 *)(dst + offset) &= srcatomic32RFC 9669, Section 5.3 (Atomic Operations)IETF
0xc3anyany0x51src = atomic_fetch_and_32((u32 *)(dst + offset), src)atomic32RFC 9669, Section 5.3 (Atomic Operations)IETF
0xc3anyany0xa0lock *(u32 *)(dst + offset) ^= srcatomic32RFC 9669, Section 5.3 (Atomic Operations)IETF
0xc3anyany0xa1src = atomic_fetch_xor_32((u32 *)(dst + offset), src)atomic32RFC 9669, Section 5.3 (Atomic Operations)IETF
0xc3anyany0xe1src = xchg_32((u32 *)(dst + offset), src)atomic32RFC 9669, Section 5.3 (Atomic Operations)IETF
0xc3anyany0xf1r0 = cmpxchg_32((u32 *)(dst + offset), r0, src)atomic32RFC 9669, Section 5.3 (Atomic Operations)IETF
0xc40x00anydst = (u32)(dst s>> imm)base32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0xc50x0anyanyif dst s< imm goto +offsetbase64RFC 9669, Section 4.3 (Jump Instructions)IETF
0xc60x0anyanyif (s32)dst s< (s32)imm goto +offsetbase32RFC 9669, Section 4.3 (Jump Instructions)IETF
0xc70x00anydst s>>= immbase64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0xccany00x00dst = (u32)(dst s>> src)base32RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0xcdanyany0x00if dst s< src goto +offsetbase64RFC 9669, Section 4.3 (Jump Instructions)IETF
0xceanyany0x00if (s32)dst s< (s32)src goto +offsetbase32RFC 9669, Section 4.3 (Jump Instructions)IETF
0xcfany00x00dst s>>= srcbase64RFC 9669, Section 4.1 (Arithmetic Instructions)IETF
0xd40x000x10dst = htole16(dst)base32RFC 9669, Section 4.2 (Byte Swap Instructions)IETF
0xd40x000x20dst = htole32(dst)base32RFC 9669, Section 4.2 (Byte Swap Instructions)IETF
0xd40x000x40dst = htole64(dst)base64RFC 9669, Section 4.2 (Byte Swap Instructions)IETF
0xd50x0anyanyif dst s<= imm goto +offsetbase64RFC 9669, Section 4.3 (Jump Instructions)IETF
0xd60x0anyanyif (s32)dst s<= (s32)imm goto +offsetbase32RFC 9669, Section 4.3 (Jump Instructions)IETF
0xd70x000x10dst = bswap16(dst)base32RFC 9669, Section 4.2 (Byte Swap Instructions)IETF
0xd70x000x20dst = bswap32(dst)base32RFC 9669, Section 4.2 (Byte Swap Instructions)IETF
0xd70x000x40dst = bswap64(dst)base64RFC 9669, Section 4.2 (Byte Swap Instructions)IETF
0xdbanyany0x00lock *(u64 *)(dst + offset) += srcatomic64RFC 9669, Section 5.3 (Atomic Operations)IETF
0xdbanyany0x01src = atomic_fetch_add_64((u64 *)(dst + offset), src)atomic64RFC 9669, Section 5.3 (Atomic Operations)IETF
0xdbanyany0x40lock *(u64 *)(dst + offset) |= srcatomic64RFC 9669, Section 5.3 (Atomic Operations)IETF
0xdbanyany0x41src = atomic_fetch_or_64((u64 *)(dst + offset), src)atomic64RFC 9669, Section 5.3 (Atomic Operations)IETF
0xdbanyany0x50lock *(u64 *)(dst + offset) &= srcatomic64RFC 9669, Section 5.3 (Atomic Operations)IETF
0xdbanyany0x51src = atomic_fetch_and_64((u64 *)(dst + offset), src)atomic64RFC 9669, Section 5.3 (Atomic Operations)IETF
0xdbanyany0xa0lock *(u64 *)(dst + offset) ^= srcatomic64RFC 9669, Section 5.3 (Atomic Operations)IETF
0xdbanyany0xa1src = atomic_fetch_xor_64((u64 *)(dst + offset), src)atomic64RFC 9669, Section 5.3 (Atomic Operations)IETF
0xdbanyany0xe1src = xchg_64((u64 *)(dst + offset), src)atomic64RFC 9669, Section 5.3 (Atomic Operations)IETF
0xdbanyany0xf1r0 = cmpxchg_64((u64 *)(dst + offset), r0, src)atomic64RFC 9669, Section 5.3 (Atomic Operations)IETF
0xdc0x000x10dst = htobe16(dst)base32RFC 9669, Section 4.2 (Byte Swap Instructions)IETF
0xdc0x000x20dst = htobe32(dst)base32RFC 9669, Section 4.2 (Byte Swap Instructions)IETF
0xdc0x000x40dst = htobe64(dst)base64RFC 9669, Section 4.2 (Byte Swap Instructions)IETF
0xddanyany0x00if dst s<= src goto +offsetbase64RFC 9669, Section 4.3 (Jump Instructions)IETF
0xdeanyany0x00if (s32)dst s<= (s32)src goto +offsetbase32RFC 9669, Section 4.3 (Jump Instructions)IETF