Skip to content

[RFC][SGX] Use Fortanix EDP instead of rust-sgx-sdk #2887

@nhynes

Description

@nhynes

(WIP PR: #2885)

tl;dr: The Rust compiler now has support for an SGX target, so users can make their own enclaves using the unmodified TVM Rust runtime. In other words, TVM no longer needs to explicitly support SGX.

The current TVM SGX infrastructure is built on baidu/rust-sgx-sdk. The proposal is to replace r-s-s with fortanix/rust-sgx. Indeed, removing the rust-sgx-sdk completely obviates the need for TVM to explicitly support SGX.

Rationale

The Fortanix EDP is now a tier 3 target for Rust which vastly simplifies the build process compared to r-s-s which requires compiling a custom sysroot. Among other things, this

  • eliminates the need for adding SGX-specific codes to TVM (in fact, we can remove any mention of SGX from the TVM C++ and Rust codebases)
  • eliminates the need for adding xargo and a patched version of rust-sgx-sdk to the TVM Dockerfile
  • allows the use of more packages from the Rust ecosystem (e.g., the rand crate now has SGX support)
  • allows the use of the real Rust standard library (instead of the custom one designed by rust-sgx-sdk) and newer rustc nightlies. This benefits both correctness and security (more maintainers + reviewers).

Additionally, the EDP is a pure-Rust implementation of SGX enclaves. Compared to the Intel C++ implementation (which includes an entire C++ standard library), there is a smaller surface area of attack. That the EDP is part of the Rust compiler and is used by the Fortanix company means that the code is more actively maintained.

As shown in the updated SGX example, the EDP allows users to compile TVM modules into enclaves using nothing more than the unmodified TVM Rust runtime. Indeed, as the EDP allows running TCP servers in enclaves, all that must be done to provide a high-quality user experience for enclaves is to add TVM RPC support to the Rust runtime.

To address @tqchen's comment in #2885:

Dependency and license issue(The Fortanix one is MPL while the original one is BSD)

It actually doesn't matter because TVM under the new proposal doesn't even know that SGX exists. All we need to do is write a high-quality Rust runtime using the usual Rust toolchain.

Would the original C++ example makes it easier to port to other enclave based runtime?

Strictly speaking, the answer is "yes," but using the C++ SGX libraries is incredibly painful. For now, this does require users to write model harnesses in Rust, but we can automatically generate TVM RPC enclaves that can be called from Python.

cc @dmlc/tvm-team

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions