commit | 8871c5e38f6d4ae44305b0f429d06f7f4f61f6df | [log] [tgz] |
---|---|---|
author | Rich Lane <rlane@bigswitch.com> | Sun Nov 29 16:54:38 2015 -0800 |
committer | Rich Lane <rlane@bigswitch.com> | Thu Dec 03 10:41:14 2015 -0800 |
tree | f991e0fa6f4eff5978bc109fb4944ab73c715053 | |
parent | 2d47202829179a4b3f3d9862828e2ca2eb62ce75 [diff] |
vm: add standalone JIT The old JIT's dependency on Lua and DynASM made it a little harder to integrate with a larger project. Worse, DynASM has bugs that prevented us from using the using the exact instruction we needed and forced us to fall back to a longer instruction sequence (STXB/LDXB/BSWAP). The main disadvantage is readability since we're now writing machine code instead of assembly. The new JIT isn't (yet) able to emit short 8-bit jump offsets.
Userspace eBPF VM
This project aims to create an Apache-licensed library for executing eBPF programs. The primary implementation of eBPF lives in the Linux kernel, but due to its GPL license it can't be used in many projects.
[Linux documentation for the eBPF instruction set] (https://www.kernel.org/doc/Documentation/networking/filter.txt)
[Instruction set reference] (https://github.com/iovisor/bpf-docs/blob/master/eBPF.md)
This project includes an eBPF assembler, disassembler, interpreter, and JIT compiler for x86-64.
Run make -c vm
to build the VM. This produces a static library libubpf.a
and a simple executable used by the testsuite.
You'll need [Clang 3.7] (http://llvm.org/releases/download.html#3.7.0).
clang-3.7 -O2 -target bpf -c prog.c -o prog.o
You can then pass the contents of prog.o
to ubpf_load_elf
, or to the stdin of the vm/test
binary.
Please fork the project on GitHub and open a pull request. You can run all the tests with nosetests
.
Copyright 2015, Big Switch Networks, Inc. Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0>.