Embive (Embedded RISC-V)
Embive is a low-level sandboxing library focused on the embedding of untrusted code for constrained environments.
As it interprets RISC-V bytecode, multiple languages are supported out of the box by Embive (Rust, C, C++, Zig, TinyGo, etc.).
By default, Embive doesn’t require any external crate, dynamic memory allocation or the standard library (no_std and no_alloc).
Currently, it supports the RV32I[M] unprivileged instruction set (M extension enabled by default).
Example
use ;
// A simple syscall example. Check [`engine::SyscallFn`] for more information.
Roadmap
- Fully support
RV32G(RV32IMAFDZicsr_Zifencei)- RV32I Base Integer Instruction Set
- M Extension (Multiplication and Division Instructions)
- Zifencei
- Implemented as a no-operation as it isn't applicable (Single HART, no cache, no memory-mapped devices, etc.).
- Zicsr
- At least the unprivileged CSRs
- F Extension (Single-Precision Floating-Point Instructions)
- D Extension (Double-Precision Floating-Point Instructions)
- A Extension (Atomic Instructions)
- System Calls
- Function calls from interpreted to native code
- Resource limiter
- Yield the engine after a configurable amount of instructions are executed.
- CI/CD
- Incorporate more tests into the repository and create test automations for PRs
- Bytecode optimization (AOT and JIT)
- Allow in-place JIT and AOT compilation to a format easier to parse.
- Less bit-shifting, faster instruction matching, etc.
- Should be kept as close as possible to native RISC-V bytecode.
- Allow in-place JIT and AOT compilation to a format easier to parse.
- Callbacks
- Function calls from native to interpreted code.
- Macros for converting native functions to system calls / callbacks
- Use Rust type-system instead of only allowing
i32arguments / results
- Use Rust type-system instead of only allowing
- Support C Extension (Compressed Instructions)
- This is a maybe, but good to keep in mind while developing other features (especially AOT/JIT).
Minimum supported Rust version (MSRV)
Embive is guaranteed to compile on stable Rust 1.81 and up.
License
Embive is licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.