Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
3ff86009
Commit
3ff86009
authored
Oct 10, 2018
by
Nick Hynes
Committed by
Tianqi Chen
Oct 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update SGX example (#1879)
parent
11050fda
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
82 additions
and
27 deletions
+82
-27
apps/sgx/Makefile
+1
-1
apps/sgx/README.md
+7
-3
apps/sgx/enclave/Cargo.toml
+1
-2
apps/sgx/enclave/Makefile
+10
-3
apps/sgx/enclave/Xargo.toml
+2
-6
apps/sgx/enclave/enclave_config.xml.in
+2
-2
apps/sgx/enclave/sgx-deps.diff
+13
-0
apps/sgx/enclave/x86_64-unknown-linux-sgx.json
+31
-0
apps/sgx/run_example.sh
+7
-3
docker/install/ubuntu_install_rust.sh
+2
-2
docker/install/ubuntu_install_sgx.sh
+6
-4
rust/src/lib.rs
+0
-1
No files found.
apps/sgx/Makefile
View file @
3ff86009
...
...
@@ -4,7 +4,7 @@ SGX_MODE ?= SIM
DEBUG
?=
true
NUM_THREADS
?=
4
TVM_DIR
?=
../..
TVM_DIR
?=
$(
shell
git rev-parse
--show-toplevel
)
export
...
...
apps/sgx/README.md
View file @
3ff86009
...
...
@@ -22,7 +22,7 @@ Check out the `/tvm/install/ubuntu_install_sgx.sh` for the commands to get these
If using Docker, start by running
```
git clone https://github.com/dmlc/tvm.git
git clone
--recursive
https://github.com/dmlc/tvm.git
docker run --rm -it -v $(pwd)/tvm:/mnt tvmai/ci-cpu /bin/bash
```
then, in the container
...
...
@@ -31,10 +31,14 @@ cd /mnt
mkdir build && cd build
cmake .. -DUSE_LLVM=ON -DUSE_SGX=/opt/sgxsdk -DRUST_SGX_SDK=/opt/rust-sgx-sdk
make -j4
cd ../apps/sgx
cd ..
pip install -e python -e topi/python -e nnvm/python
cd apps/sgx
```
`bash run_example.sh`
Once TVM is build and installed, just
`./run_example.sh`
If everything goes well, you should see a lot of build messages and below them
the text
`It works!`
.
...
...
apps/sgx/enclave/Cargo.toml
View file @
3ff86009
...
...
@@ -8,8 +8,7 @@ crate-type = ["staticlib"]
[dependencies]
lazy_static
=
"1.1.0"
# tvm = { path = "../../../rust", default-features = false, features = ["sgx"] }
tvm
=
{
path
=
"/home/nhynes/myelin/deps/tvm-rs"
,
default-features
=
false
,
features
=
["sgx"]
}
tvm
=
{
path
=
"../../../rust"
,
default-features
=
false
,
features
=
["sgx"]
}
[profile.release]
lto
=
true
...
...
apps/sgx/enclave/Makefile
View file @
3ff86009
...
...
@@ -13,7 +13,9 @@ else
debug
:=
debug
endif
target/x86_64-unknown-linux-sgx/$(debug)/libmodel-enclave.a
:
$(build_dir)/libmodel.a **/*
target
=
target/x86_64-unknown-linux-sgx/
$(debug)
/libmodel-enclave.a
$(target)
:
$(build_dir)/libmodel.a **/* $(TVM_DIR)/rust/patched.txt
RUST_TARGET_PATH
=
$(
shell
pwd
)
\
RUST_TARGET_DIR
=
$(
shell
pwd
)
/target
\
RUSTFLAGS
=
"-Z force-unstable-if-unmarked"
\
...
...
@@ -21,11 +23,16 @@ target/x86_64-unknown-linux-sgx/$(debug)/libmodel-enclave.a: $(build_dir)/libmod
BUILD_DIR
=
../build
\
xargo build
--target
x86_64-unknown-linux-sgx
$(xargo_args)
-q
$(TVM_DIR)/rust/patched.txt
:
$(shell pwd)/sgx-deps.diff
echo
$(TVM_DIR)
cd
$(TVM_DIR)
&&
git apply
$<
touch
$@
$(build_dir)/libmodel.a
:
$(build_dir)/model.o
llvm-ar
cr
$@
$^
$(AR)
cr
$@
$^
$(build_dir)/model.o
:
$(build_dir)/model.bc
clang
-c
$<
-o
$@
-fPIC
-O3
$(CC)
-c
$<
-o
$@
-fPIC
-O3
objcopy
--globalize-symbol
__tvm_module_startup
$@
$(build_dir)/model.bc
:
src/build_model.py
...
...
apps/sgx/enclave/Xargo.toml
View file @
3ff86009
...
...
@@ -4,14 +4,10 @@ panic_unwind = {}
panic_abort
=
{}
[dependencies.std]
path
=
"/opt/rust-sgx-sdk/xargo/sgx_tstd"
features
=
[
"backtrace"
,
"stdio"
,
"untrusted_time"
]
path
=
"/home/nhynes/myelin/deps/rust-sgx-sdk/xargo/sgx_tstd"
# git = "https://github.com/oasislabs/rust-sgx-sdk"
# rev = "7334c30d85cb1752577998705110b7b27c69b570"
stage
=
2
[dependencies.xargo_sgx_rand]
# git = "https://github.com/oasislabs/rust-sgx-sdk"
path
=
"/home/nhynes/myelin/deps/rust-sgx-sdk/xargo/sgx_rand"
# rev = "7334c30d85cb1752577998705110b7b27c69b570"
path
=
"/opt/rust-sgx-sdk/xargo/sgx_rand"
stage
=
3
apps/sgx/enclave/enclave_config.xml.in
View file @
3ff86009
<EnclaveConfiguration>
<ProdID>0</ProdID>
<ISVSVN>0</ISVSVN>
<StackMaxSize>0x
10
0000</StackMaxSize>
<HeapMaxSize>0x
f0
000000</HeapMaxSize>
<StackMaxSize>0x
2
0000</StackMaxSize>
<HeapMaxSize>0x
5
000000</HeapMaxSize>
<TCSNum>NUM_THREADS</TCSNum>
<TCSPolicy>0</TCSPolicy> <!-- must be "bound" to use thread_local -->
<DisableDebug>0</DisableDebug>
...
...
apps/sgx/enclave/sgx-deps.diff
0 → 100644
View file @
3ff86009
diff --git a/rust/Cargo.toml b/rust/Cargo.toml
index 0819e0c7..e56f4ef2 100644
--- a/rust/Cargo.toml
+++ b/rust/Cargo.toml
@@ -14,7 +14,7 @@ default = ["nom/std"]
sgx = ["nom/alloc"]
[dependencies]
-bounded-spsc-queue = "0.4.0"
+bounded-spsc-queue = { git = "https://github.com/nhynes/bounded-spsc-queue", branch = "sgx" }
error-chain = { version = "0.12.0", default-features = false }
itertools = "0.7.8"
lazy_static = "1.1.0"
apps/sgx/enclave/x86_64-unknown-linux-sgx.json
0 → 100644
View file @
3ff86009
{
"arch"
:
"x86_64"
,
"cpu"
:
"x86-64"
,
"data-layout"
:
"e-m:e-i64:64-f80:128-n8:16:32:64-S128"
,
"dynamic-linking"
:
true
,
"env"
:
"sgx"
,
"exe-allocation-crate"
:
"alloc_system"
,
"executables"
:
true
,
"has-elf-tls"
:
true
,
"has-rpath"
:
true
,
"linker-flavor"
:
"gcc"
,
"linker-is-gnu"
:
true
,
"llvm-target"
:
"x86_64-unknown-linux-gnu"
,
"max-atomic-width"
:
64
,
"os"
:
"linux"
,
"position-independent-executables"
:
true
,
"pre-link-args"
:
{
"gcc"
:
[
"-Wl,--as-needed"
,
"-Wl,-z,noexecstack"
,
"-m64"
]
},
"relro-level"
:
"full"
,
"stack-probes"
:
true
,
"target-c-int-width"
:
"32"
,
"target-endian"
:
"little"
,
"target-family"
:
"unix"
,
"target-pointer-width"
:
"64"
,
"vendor"
:
"unknown"
}
apps/sgx/run_example.sh
View file @
3ff86009
#!/bin/bash
sgx_sdk
=
${
SGX_SDK
:
=/opt/sgxsdk
}
LD_LIBRARY_PATH
=
"
$sgx_sdk
/lib64"
:
${
LD_LIBRARY_PATH
}
make
printf
"
\n
"
LD_LIBRARY_PATH
=
"
$sgx_sdk
/lib64"
:
${
LD_LIBRARY_PATH
}
TVM_CACHE_DIR
=
/tmp python3 run_model.py
export
LD_LIBRARY_PATH
=
"
$sgx_sdk
/lib64"
:
${
LD_LIBRARY_PATH
}
export
CC
=
clang-6.0
export
AR
=
llvm-ar-6.0
export
TVM_CACHE_DIR
=
/tmp
make
&&
printf
"
\n
"
&&
python3 run_model.py
docker/install/ubuntu_install_rust.sh
View file @
3ff86009
...
...
@@ -2,8 +2,8 @@ apt-get update && apt-get install -y --no-install-recommends --force-yes curl
export
RUSTUP_HOME
=
/opt/rust
export
CARGO_HOME
=
/opt/rust
#
rustc nightly-2018-08-25 is the version supported by the
rust-sgx-sdk
curl https://sh.rustup.rs
-sSf
| sh
-s
--
-y
--no-modify-path
--default-toolchain
nightly-2018-0
8
-25
#
this rustc is one supported by the installed version of
rust-sgx-sdk
curl https://sh.rustup.rs
-sSf
| sh
-s
--
-y
--no-modify-path
--default-toolchain
nightly-2018-0
9
-25
.
$CARGO_HOME
/env
rustup toolchain add nightly
rustup component add rust-src
...
...
docker/install/ubuntu_install_sgx.sh
View file @
3ff86009
...
...
@@ -2,18 +2,20 @@ apt-get update && apt-get install -y --no-install-recommends --force-yes \
build-essential git cmake
\
wget python pkg-config software-properties-common
\
autoconf automake libtool ocaml
\
protobuf-compiler libprotobuf-dev
\
libssl-dev libcurl4-openssl-dev curl
git clone https://github.com/intel/linux-sgx.git
cd
linux-sgx
git checkout sgx_2.2
curl
'https://gist.github
.com/nhynes/c770b0e91610f8c020a8d1a803a1e7cb'
| git am
curl
'https://gist.github
usercontent.com/nhynes/c770b0e91610f8c020a8d1a803a1e7cb/raw/8f5372d9cb88929b3cc49a384943bb363bc06827/intel-sgx.patch'
| git apply
./download_prebuilt.sh
make
-j
sdk
&&
make
-j
sdk_install_pkg
./linux/installer/bin/sgx_linux_x64_sdk
_2.2.100.45311
.bin
--prefix
/opt
make
-j
4
sdk
&&
make
-j4
sdk_install_pkg
./linux/installer/bin/sgx_linux_x64_sdk
*
.bin
--prefix
/opt
cd
-
git clone https://github.com/baidu/rust-sgx-sdk.git /opt/rust-sgx-sdk
cd
/opt/rust-sgx-sdk
git checkout bdd75ca05f66d1f5df637182ec335970f769b03a
git checkout v1.0.4
curl
'https://gist.githubusercontent.com/nhynes/37164039c5d3f33aa4f123e4ba720036/raw/5b7fc24d4faa0bd6efce19f8324f79d5562991e0/rust-sgx-sdk.diff'
| git apply
cd
-
rust/src/lib.rs
View file @
3ff86009
...
...
@@ -13,7 +13,6 @@
alloc
,
allocator_api
,
box_syntax
,
extern_prelude
,
fn_traits
,
try_from
,
unboxed_closures
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment