Skip to content

Commit

Permalink
add std support
Browse files Browse the repository at this point in the history
  • Loading branch information
DemesneGH committed Jul 8, 2024
1 parent 0f1f526 commit a25a679
Show file tree
Hide file tree
Showing 143 changed files with 4,004 additions and 343 deletions.
78 changes: 51 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ jobs:
source environment

# Build Rust optee-utee and optee-teec
(cd optee-utee && cargo build --target aarch64-unknown-linux-gnu --no-default-features -vv)
(cd optee-utee && cargo build --target aarch64-unknown-linux-gnu -vv)
(cd optee-teec && cargo build --target aarch64-unknown-linux-gnu -vv)

build-examples:
build-and-test-examples:
runs-on: ubuntu-latest
container: teaclave/teaclave-trustzone-sdk-build:0.3.0
steps:
Expand All @@ -67,39 +67,59 @@ jobs:
# Build optee_os and optee_client for qemu_v8
./build_optee_libraries.sh $HOME
# Setup environment
export OPTEE_DIR=$HOME
source environment
# Build OP-TEE Rust examples for Arm 64-bit both host and TA
# Build OP-TEE Rust examples for Arm 32-bit both host and TA
export ARCH_HOST=arm
export ARCH_TA=arm
source environment
make -j`nproc`
# Build OP-TEE Rust examples for Arm 64-bit host and 32-bit TA
export TA_DEV_KIT_DIR=~/optee_os/out/arm-plat-vexpress/export-ta_arm32/
export CROSS_COMPILE_HOST=$CROSS_COMPILE64
export CROSS_COMPILE_TA=$CROSS_COMPILE32
export TARGET_HOST="aarch64-unknown-linux-gnu"
export TARGET_TA="arm-unknown-linux-gnueabihf"
# Build OP-TEE Rust examples for Arm 64-bit both host and TA
unset ARCH_TA
unset ARCH_HOST
source environment
make clean && make -j`nproc`
- name: Run tests for Arm 64-bit both host and TA
run: |
apt update && apt install libslirp-dev -y
source environment
(cd ci && ./ci.sh)
build-and-test-examples-for-std-TAs:
runs-on: ubuntu-latest
container: teaclave/teaclave-trustzone-sdk-build:0.3.0
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setting up $HOME
run: |
cp /root/.bashrc $HOME/.bashrc &&
ln -sf /root/.rustup ~/.rustup &&
ln -sf /root/.cargo ~/.cargo
- name: Building Arm 64-bit both host and TA (with STD enabled)
run: |
# Setup Rust and toolchains
./setup.sh
# Build OP-TEE Rust examples for Arm 32-bit both host and TA
export TA_DEV_KIT_DIR=~/optee_os/out/arm-plat-vexpress/export-ta_arm32/
export CROSS_COMPILE_HOST=$CROSS_COMPILE32
export CROSS_COMPILE_TA=$CROSS_COMPILE32
export TARGET_HOST="arm-unknown-linux-gnueabihf"
export TARGET_TA="arm-unknown-linux-gnueabihf"
(cd ~/optee_client && make clean && make CROSS_COMPILE=$CROSS_COMPILE32 WITH_TEEACL=0)
make clean && make -j`nproc`
# Setup std dependencies
./setup_std_dependencies.sh
# Build OP-TEE Rust examples for Arm 32-bit host and 64-bit TA
export TA_DEV_KIT_DIR=~/optee_os/out/arm-plat-vexpress/export-ta_arm64/
export CROSS_COMPILE_HOST=$CROSS_COMPILE32
export CROSS_COMPILE_TA=$CROSS_COMPILE64
export TARGET_HOST="arm-unknown-linux-gnueabihf"
export TARGET_TA="aarch64-unknown-linux-gnu"
make clean && make -j`nproc`
# Build optee_os and optee_client for qemu_v8
./build_optee_libraries.sh $HOME
# Setup environment
export OPTEE_DIR=$HOME
export STD=y
source environment
# Build OP-TEE Rust examples for Arm 64-bit both host and TA
make -j`nproc`
- name: Run tests for Arm 64-bit both host and TA
run: |
apt update && apt install libslirp-dev -y
export STD=y
source environment
(cd ci && ./ci.sh)
OPTEE-repo-build-and-run-examples-64bit-TAs:
runs-on: ubuntu-latest
container: teaclave/teaclave-trustzone-sdk-build:0.3.0
Expand All @@ -123,6 +143,8 @@ jobs:
run: |
apt update && apt install libslirp-dev -y
cd ~/optee-qemuv8
# fixed the error: configure: error: you should not run configure as root:
export FORCE_UNSAFE_CONFIGURE=1
rm -rf optee_rust/ &&
mv $GITHUB_WORKSPACE/incubator-teaclave-trustzone-sdk optee_rust/
cd build &&
Expand Down Expand Up @@ -152,6 +174,8 @@ jobs:
run: |
apt update && apt install libslirp-dev -y
cd ~/optee-qemuv8
# fixed the error: configure: error: you should not run configure as root:
export FORCE_UNSAFE_CONFIGURE=1
rm -rf optee_rust/ &&
mv $GITHUB_WORKSPACE/incubator-teaclave-trustzone-sdk optee_rust/
cd build &&
Expand Down
1 change: 1 addition & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ header:
- '**/Cargo.lock'
- 'KEYS'
- 'DISCLAIMER-WIP'
- '*.json'
21 changes: 21 additions & 0 deletions aarch64-unknown-optee.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"arch": "aarch64",
"data-layout": "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
"features": "+strict-align",
"dynamic-linking": false,
"executables": true,
"has-rpath": true,
"linker-flavor": "ld",
"linker-is-gnu": true,
"llvm-target": "aarch64-unknown-linux-gnu",
"max-atomic-width": 128,
"os": "optee",
"position-independent-executables": true,
"relro-level": "full",
"target-c-int-width": "32",
"target-endian": "little",
"target-pointer-width": "64",
"vendor": "unknown",
"panic-strategy": "abort"
}

21 changes: 21 additions & 0 deletions arm-unknown-optee.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"arch": "arm",
"data-layout": "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64",
"dynamic-linking": false,
"executables": true,
"features": "+strict-align,+v6,+vfp2",
"has-rpath": true,
"linker-flavor": "ld",
"linker-is-gnu": true,
"llvm-target": "arm-unknown-linux-gnueabihf",
"max-atomic-width": 64,
"os": "optee",
"position-independent-executables": true,
"relro-level": "full",
"target-c-int-width": "32",
"target-endian": "little",
"target-pointer-width": "32",
"vendor": "unknown",
"panic-strategy": "abort",
"singlethread": true
}
24 changes: 15 additions & 9 deletions build_optee_libraries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,29 @@
set -e

OPTEE_VERSION=4.2.0

TARGET_PATH=$1
OPTEE_DIR=$1

# check arguments
if [ -z "$TARGET_PATH" ]; then
echo "Usage: $0 <path_for_storage>"
if [ -z "$OPTEE_DIR" ]; then
echo "Usage: $0 <optee_root_path>"
exit 1
else
export OPTEE_DIR=$OPTEE_DIR
echo "OPTEE_DIR=$OPTEE_DIR"
fi

if [ ! -d $OPTEE_DIR ]; then
mkdir -p $OPTEE_DIR
fi

# set toolchain
export CROSS_COMPILE="aarch64-linux-gnu-"
export CROSS_COMPILE32="arm-linux-gnueabihf-"
export CROSS_COMPILE64="aarch64-linux-gnu-"

# build optee_os and optee_client for qemu_v8
git clone https://github.com/OP-TEE/optee_os.git -b $OPTEE_VERSION $TARGET_PATH/optee_os
(cd $TARGET_PATH/optee_os && make PLATFORM=vexpress-qemu_armv8a)
git clone https://github.com/OP-TEE/optee_os.git -b $OPTEE_VERSION $OPTEE_DIR/optee_os
(cd $OPTEE_DIR/optee_os && make PLATFORM=vexpress-qemu_armv8a)

git clone https://github.com/OP-TEE/optee_client.git -b $OPTEE_VERSION $TARGET_PATH/optee_client
(cd $TARGET_PATH/optee_client && make WITH_TEEACL=0)
git clone https://github.com/OP-TEE/optee_client.git -b $OPTEE_VERSION $OPTEE_DIR/optee_client
(cd $OPTEE_DIR/optee_client && make WITH_TEEACL=0 DESTDIR=$PWD/export_arm32 CROSS_COMPILE=$CROSS_COMPILE32)
(cd $OPTEE_DIR/optee_client && make clean && make WITH_TEEACL=0 DESTDIR=$PWD/export_arm64 CROSS_COMPILE=$CROSS_COMPILE64)
51 changes: 42 additions & 9 deletions environment
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# under the License.

export PATH=$PATH:$HOME/.cargo/bin
# for std: specify the target json file
export RUST_TARGET_PATH="$(pwd)"

if [ -z "$OPTEE_DIR" ]
then
Expand All @@ -26,22 +28,36 @@ fi
export OPTEE_OS_DIR="$OPTEE_DIR/optee_os"
export OPTEE_CLIENT_DIR="$OPTEE_DIR/optee_client"

export CROSS_COMPILE="aarch64-linux-gnu-"
export CROSS_COMPILE32="arm-linux-gnueabihf-"
export CROSS_COMPILE64="aarch64-linux-gnu-"

if [ "$ARCH" = "arm" ]
if [ "$ARCH_TA" = "arm" ]
then
# build host and TA as 32-bit
# build TA as 32-bit
export TA_DEV_KIT_DIR="$OPTEE_OS_DIR/out/arm-plat-vexpress/export-ta_arm32"
export OPTEE_CLIENT_EXPORT="$OPTEE_CLIENT_DIR/out/export"
export TARGET="arm-unknown-linux-gnueabihf"
if [ "$STD" ]
then
export TARGET_TA="arm-unknown-optee"
echo "set TARGET_TA=$TARGET_TA (std)"
else
export TARGET_TA="arm-unknown-linux-gnueabihf"
echo "set TARGET_TA=$TARGET_TA (no-std)"
fi
export CROSS_COMPILE_TA="$CROSS_COMPILE32"
echo "set CROSS_COMPILE_TA=$CROSS_COMPILE_TA"
else
# build host and TA as 64-bit by default
unset ARCH
# build TA as 64-bit by default
export TA_DEV_KIT_DIR="$OPTEE_OS_DIR/out/arm-plat-vexpress/export-ta_arm64"
export OPTEE_CLIENT_EXPORT="$OPTEE_CLIENT_DIR/out/export"
export TARGET="aarch64-unknown-linux-gnu"
if [ "$STD" ]
then
export TARGET_TA="aarch64-unknown-optee"
echo "set TARGET_TA=$TARGET_TA (std)"
else
export TARGET_TA="aarch64-unknown-linux-gnu"
echo "set TARGET_TA=$TARGET_TA (no-std)"
fi
export CROSS_COMPILE_TA="$CROSS_COMPILE64"
echo "set CROSS_COMPILE_TA=$CROSS_COMPILE_TA"
fi

# check if libraries exist
Expand All @@ -53,6 +69,23 @@ else
unset OPTEE_DIR
fi

if [ "$ARCH_HOST" = "arm" ]
then
# build host as 32-bit
export OPTEE_CLIENT_EXPORT="$OPTEE_CLIENT_DIR/export_arm32"
export TARGET_HOST="arm-unknown-linux-gnueabihf"
echo "set TARGET_HOST=$TARGET_HOST"
export CROSS_COMPILE_HOST="$CROSS_COMPILE32"
echo "set CROSS_COMPILE_HOST=$CROSS_COMPILE_HOST"
else
# build host as 64-bit by default
export OPTEE_CLIENT_EXPORT="$OPTEE_CLIENT_DIR/export_arm64"
export TARGET_HOST="aarch64-unknown-linux-gnu"
echo "set TARGET_HOST=$TARGET_HOST"
export CROSS_COMPILE_HOST="$CROSS_COMPILE64"
echo "set CROSS_COMPILE_HOST=$CROSS_COMPILE_HOST"
fi

if [ -d "$OPTEE_CLIENT_EXPORT" ]
then
echo "set OPTEE_CLIENT_EXPORT=$OPTEE_CLIENT_EXPORT"
Expand Down
104 changes: 104 additions & 0 deletions examples/acipher-rs/host/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a25a679

Please sign in to comment.