Description

Newbie level knowledge of eBPF and some knowledge of Haskell. The goal for this hackweek is to catch two birds with one stone; get familiar with eBPF and learn more about Haskell, hence implement something related to eBPF in Haskell. Given an input, which is a program, represented as eBPF instructions, prepare a fully built eBPF bytecode ready to be loaded into the Kernel.

Goals

  • Recap on ADTs in Haskell, type classes and their instances / deriving, on pattern matching and higher order functions
  • Read and understand RFC 9669
  • Implement the entire pipeline; parsing the input, verifying the input, building instructions, encoding them and concatenating them
  • Deal with all the learning, bugs and difficulties encountered on the way

Progress

Last day of hackweek and this is what I have so far.

  • ADTs implemented to correctly type all operations, classes, opcodes, instructions and other instruction specific types
  • opcodes and opcode builders based on specification are implemented.
  • Encoder is ready for 64-bit instruction format. Extended 128-bit instruction format is not yet supported
  • Only ALU and ALU64 instructions API is provided. JMP, LD, ST for base32 and base64 are missing. swap and atomic are missing
  • All ALU and ALU64 instructions (except MOV and MOVSX) are tested manually and are correctly encoded

Whats next?

There is still a lot left to do:

  • Input parser and formatter + some kind of basic verifier
  • API for remaining instruction classes
  • Proper testing mechanism
  • swap and atomic instructions
  • Loader

Resources

  • RFC 9669
  • https://ebpf.io/
  • https://www.haskell.org/documentation/

Looking for hackers with the skills:

ebpf haskell

This project is part of:

Hack Week 25

Activity

  • 12 minutes ago: kalfalakh started this project.
  • about 2 hours ago: alnovak liked this project.
  • about 5 hours ago: kalfalakh added keyword "ebpf" to this project.
  • about 5 hours ago: kalfalakh added keyword "haskell" to this project.
  • about 5 hours ago: kalfalakh originated this project.

  • Comments

    Be the first to comment!

    Similar Projects

    bpftrace contribution by mkoutny

    Description

    bpftrace is a great tool, no need to sing odes to it here. It can access any kernel data and process them in real time. It provides helpers for some common Linux kernel structures but not all.

    Goals

    • set up bpftrace toolchain
    • learn about bpftrace implementation and internals
    • implement support for percpu_counters
    • look into some of the first issues
    • send a refined PR (on Thu)

    Resources


    GHC-9.14 and split Hadrian from GHC build by osukup

    Description

    Prepare openSUSE Tumbleweed project for new GHC Haskell compiler and separate builder (Hadrian) from GHC build

    Goals

    • have GHC-9.14 project with working compiler and if possible filled with packageset
    • have Hadrian in own package built with bootstrap compiler to separate Hadrian bootstrap from ghc bootstrap

    Resources

    devel:languages:haskell

    d:l:h:ghc-9.12.x

    opensuse Haskell rpm macros

    opensuse haskell package gen project