Skip to content

Commit

Permalink
switch to latest stable toolchain 1.83.0
Browse files Browse the repository at this point in the history
CI script, makefile and docs are updated.

Signed-off-by: Jiaqi Gao <jiaqi.gao@intel.com>
  • Loading branch information
gaojiaqi7 committed Dec 18, 2024
1 parent 1e6b546 commit 9c68f0e
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 112 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/devtools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ name: Devtools

env:
AS: nasm
STABLE_RUST_TOOLCHAIN: 1.75.0
NIGHTLY_RUST_TOOLCHAIN: nightly-2023-12-31
RUST_TOOLCHAIN: 1.83.0
TOOLCHAIN_PROFILE: minimal

jobs:
Expand Down Expand Up @@ -44,12 +43,7 @@ jobs:
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.STABLE_RUST_TOOLCHAIN }}

- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.NIGHTLY_RUST_TOOLCHAIN }}
toolchain: ${{ env.RUST_TOOLCHAIN }}

- name: Preparation work
run: make preparation
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ env:
AS: nasm
AR: llvm-ar
CC: clang
RUST_TOOLCHAIN: 1.83.0

jobs:
clippy:
Expand All @@ -30,7 +31,7 @@ jobs:
- name: Install toolchain with clippy available
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2023-12-31
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: clippy

- name: Add target
Expand Down Expand Up @@ -65,7 +66,7 @@ jobs:
- name: Install toolchain with rustfmt available
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2023-12-31
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt

- name: Preparation Work
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:
AS: nasm
AR_x86_64_unknown_none: llvm-ar
CC_x86_64_unknown_none: clang
RUST_TOOLCHAIN: nightly-2023-12-31
RUST_TOOLCHAIN: 1.83.0
TOOLCHAIN_PROFILE: minimal

jobs:
Expand All @@ -35,9 +35,9 @@ jobs:
with:
components: rust-src, llvm-tools-preview

- name: Run cargo install cargo-xbuild
run: cargo install cargo-xbuild
- name: Add `x86_64-unknown-none` target
run: rustup target add x86_64-unknown-none

- name: install NASM
uses: ilammy/setup-nasm@v1

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/integration-tdx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ name: Integration Test on TDX Server

env:
AS: nasm
RUST_TOOLCHAIN: nightly-2023-12-31
RUST_TOOLCHAIN: 1.83.0
TOOLCHAIN_PROFILE: minimal

jobs:
Expand All @@ -36,8 +36,8 @@ jobs:
- name: Install toolchain
run: bash sh_script/update_toolchain.sh ${{ env.RUST_TOOLCHAIN }}

- name: Run cargo install cargo-xbuild
run: cargo install cargo-xbuild
- name: Add `x86_64-unknown-none` target
run: rustup target add x86_64-unknown-none

- name: Preparation Work
run: bash sh_script/preparation.sh
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ name: Integration Test

env:
AS: nasm
RUST_TOOLCHAIN: nightly-2023-12-31
RUST_TOOLCHAIN: 1.83.0
TOOLCHAIN_PROFILE: minimal

jobs:
Expand Down Expand Up @@ -47,8 +47,8 @@ jobs:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rust-src, llvm-tools-preview

- name: Run cargo install cargo-xbuild
run: cargo install cargo-xbuild
- name: Add `x86_64-unknown-none` target
run: rustup target add x86_64-unknown-none

# install QEMU
- name: Install QEMU (Linux)
Expand Down
21 changes: 5 additions & 16 deletions .github/workflows/library.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ name: Library Crates

env:
AS: nasm
STABLE_RUST_TOOLCHAIN: 1.75.0
NIGHTLY_RUST_TOOLCHAIN: nightly-2023-12-31
RUST_TOOLCHAIN: 1.83.0
TOOLCHAIN_PROFILE: minimal

jobs:
Expand All @@ -37,15 +36,10 @@ jobs:
- name: install NASM
uses: ilammy/setup-nasm@v1

- name: Install stable toolchain
- name: Install rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.STABLE_RUST_TOOLCHAIN }}

- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.NIGHTLY_RUST_TOOLCHAIN }}
toolchain: ${{ env.RUST_TOOLCHAIN }}

- name: Checkout sources
uses: actions/checkout@v4
Expand Down Expand Up @@ -82,15 +76,10 @@ jobs:
- name: install NASM
uses: ilammy/setup-nasm@v1

- name: Install stable toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.STABLE_RUST_TOOLCHAIN }}

- name: Install nightly toolchain
- name: Install rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.NIGHTLY_RUST_TOOLCHAIN }}
toolchain: ${{ env.RUST_TOOLCHAIN }}

- name: Checkout sources
uses: actions/checkout@v4
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:
CC_x86_64_unknown_linux_gnu: clang
AR_x86_64_unknown_none: llvm-ar
CC_x86_64_unknown_none: clang
RUST_TOOLCHAIN: nightly-2023-12-31
RUST_TOOLCHAIN: 1.83.0
TOOLCHAIN_PROFILE: minimal

jobs:
Expand Down Expand Up @@ -51,8 +51,8 @@ jobs:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rust-src

- name: Run cargo install cargo-xbuild
run: cargo install cargo-xbuild
- name: Add `x86_64-unknown-none` target
run: rustup target add x86_64-unknown-none

- name: Preparation Work
run: bash sh_script/preparation.sh
Expand All @@ -61,10 +61,10 @@ jobs:
run: make test

- name: Build Release TdShim
run: cargo xbuild -p td-shim --target x86_64-unknown-none --release --features=main,tdx
run: cargo build -p td-shim --target x86_64-unknown-none --release --features=main,tdx

- name: Build Debug TdShim
run: cargo xbuild -p td-shim --target x86_64-unknown-none --features=main,tdx --no-default-features
run: cargo build -p td-shim --target x86_64-unknown-none --features=main,tdx --no-default-features

- name: Build td-shim-tools
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Release TD-shim
on: create

env:
RUST_TOOLCHAIN: nightly-2023-12-31
RUST_TOOLCHAIN: 1.83.0
TOOLCHAIN_PROFILE: minimal

jobs:
Expand Down Expand Up @@ -33,8 +33,8 @@ jobs:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rust-src

- name: Run cargo install cargo-xbuild
run: cargo install cargo-xbuild
- name: Add `x86_64-unknown-none` target
run: rustup target add x86_64-unknown-none

- name: Preparation Work
run: make preparation
Expand Down
51 changes: 18 additions & 33 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export CARGO=cargo
export STABLE_TOOLCHAIN:=1.75.0
export NIGHTLY_TOOLCHAIN:=nightly-2023-12-31
export RUST_TOOLCHAIN:=1.83.0
export BUILD_TYPE:=release
export PREFIX:=/usr/local

Expand All @@ -11,8 +10,7 @@ else
export BUILD_TYPE_FLAG=
endif

GENERIC_LIB_CRATES = td-layout td-logger td-shim-interface td-loader cc-measurement
NIGHTLY_LIB_CRATES = td-exception td-paging tdx-tdcall
LIB_CRATES = td-layout td-logger td-shim-interface td-loader cc-measurement td-exception td-paging tdx-tdcall
SHIM_CRATES = td-shim td-payload
TEST_CRATES = test-td-exception test-td-paging
TOOL_CRATES = td-shim-tools
Expand Down Expand Up @@ -51,7 +49,7 @@ uninstall-devtools: uninstall-subdir-devtools $(TOOL_CRATES:%=uninstall-devtool-
.PHONY: tools-devtools
tools-devtools: tools-subdir-devtools

install-devtool-%: nightly-build-%
install-devtool-%:
mkdir -p ${TOPDIR}/devtools/bin
${CARGO} install --bins --target-dir ${TOPDIR}/devtools/bin/ --path $(patsubst install-devtool-%,%,$@)

Expand All @@ -71,13 +69,13 @@ afl-test: afl_test
libfuzzer-test: libfuzzer_test

# Targets for library crates
lib-build: $(GENERIC_LIB_CRATES:%=build-%) $(NIGHTLY_LIB_CRATES:%=nightly-build-%)
lib-build: $(LIB_CRATES:%=build-%)

lib-check: $(GENERIC_LIB_CRATES:%=check-%) $(NIGHTLY_LIB_CRATES:%=nightly-check-%)
lib-check: $(LIB_CRATES:%=check-%)

lib-test: $(GENERIC_LIB_CRATES:%=test-%) $(NIGHTLY_LIB_CRATES:%=nightly-test-%)
lib-test: $(LIB_CRATES:%=test-%)

lib-clean: $(GENERIC_LIB_CRATES:%=clean-%) $(NIGHTLY_LIB_CRATES:%=nightly-clean-%)
lib-clean: $(LIB_CRATES:%=clean-%)

# Targets for integration test crates
integration-build: $(TEST_CRATES:%=integration-build-%)
Expand All @@ -90,52 +88,39 @@ integration-clean: $(TEST_CRATES:%=integration-clean-%)

# Target for crates which should be compiled with `x86_64-unknown-none` target
none-build-%:
${CARGO} +${NIGHTLY_TOOLCHAIN} xbuild --target x86_64-unknown-none -p $(patsubst none-build-%,%,$@) ${BUILD_TYPE_FLAG}
${CARGO} +${RUST_TOOLCHAIN} build --target x86_64-unknown-none -p $(patsubst none-build-%,%,$@) ${BUILD_TYPE_FLAG}

none-check-%:
${CARGO} +${NIGHTLY_TOOLCHAIN}xcheck --target x86_64-unknown-none -p $(patsubst none-check-%,%,$@) ${BUILD_TYPE_FLAG}
${CARGO} +${RUST_TOOLCHAIN} check --target x86_64-unknown-none -p $(patsubst none-check-%,%,$@) ${BUILD_TYPE_FLAG}

none-clean-%:
${CARGO} +${NIGHTLY_TOOLCHAIN} clean --target x86_64-unknown-none -p $(patsubst none-clean-%,%,$@) ${BUILD_TYPE_FLAG}
${CARGO} +${RUST_TOOLCHAIN} clean --target x86_64-unknown-none -p $(patsubst none-clean-%,%,$@) ${BUILD_TYPE_FLAG}

# Target for integration test crates which should be compiled with `x86_64-custom.json` target
integration-build-%:
${CARGO} +${NIGHTLY_TOOLCHAIN} xbuild --target ${TOPDIR}/devtools/rustc-targets/x86_64-custom.json -p $(patsubst integration-build-%,%,$@) ${BUILD_TYPE_FLAG}
${CARGO} +${RUST_TOOLCHAIN} build --target x86_64-unknown-none -p $(patsubst integration-build-%,%,$@) ${BUILD_TYPE_FLAG}

integration-check-%:
${CARGO} +${NIGHTLY_TOOLCHAIN} xcheck --target ${TOPDIR}/devtools/rustc-targets/x86_64-custom.json -p $(patsubst integration-check-%,%,$@) ${BUILD_TYPE_FLAG}
${CARGO} +${RUST_TOOLCHAIN} check --target x86_64-unknown-none -p $(patsubst integration-check-%,%,$@) ${BUILD_TYPE_FLAG}

integration-test-%:
${CARGO} +${NIGHTLY_TOOLCHAIN} xtest --target ${TOPDIR}/devtools/rustc-targets/x86_64-custom.json -p $(patsubst integration-test-%,%,$@) ${BUILD_TYPE_FLAG}
${CARGO} +${RUST_TOOLCHAIN} test --target x86_64-unknown-none -p $(patsubst integration-test-%,%,$@) ${BUILD_TYPE_FLAG}

integration-clean-%:
${CARGO} +${NIGHTLY_TOOLCHAIN} clean --target ${TOPDIR}/devtools/rustc-targets/x86_64-custom.json -p $(patsubst integration-clean-%,%,$@) ${BUILD_TYPE_FLAG}
${CARGO} +${RUST_TOOLCHAIN} clean --target x86_64-unknown-none -p $(patsubst integration-clean-%,%,$@) ${BUILD_TYPE_FLAG}

# Targets for normal library/binary crates
build-%:
${CARGO} +${STABLE_TOOLCHAIN} build -p $(patsubst build-%,%,$@) ${BUILD_TYPE_FLAG}
${CARGO} +${RUST_TOOLCHAIN} build -p $(patsubst build-%,%,$@) ${BUILD_TYPE_FLAG}

check-%:
${CARGO} +${STABLE_TOOLCHAIN} check -p $(patsubst check-%,%,$@) ${BUILD_TYPE_FLAG}
${CARGO} +${RUST_TOOLCHAIN} check -p $(patsubst check-%,%,$@) ${BUILD_TYPE_FLAG}

clean-%:
${CARGO} +${STABLE_TOOLCHAIN} clean -p $(patsubst clean-%,%,$@) ${BUILD_TYPE_FLAG}
${CARGO} +${RUST_TOOLCHAIN} clean -p $(patsubst clean-%,%,$@) ${BUILD_TYPE_FLAG}

test-%:
${CARGO} +${NIGHTLY_TOOLCHAIN} test -p $(patsubst test-%,%,$@) ${BUILD_TYPE_FLAG}

# Targets for normal library/binary crates
nightly-build-%:
${CARGO} +${NIGHTLY_TOOLCHAIN} build -p $(patsubst nightly-build-%,%,$@) ${BUILD_TYPE_FLAG}

nightly-check-%:
${CARGO} +${NIGHTLY_TOOLCHAIN} check -p $(patsubst nightly-check-%,%,$@) ${BUILD_TYPE_FLAG}

nightly-clean-%:
${CARGO} +${NIGHTLY_TOOLCHAIN} clean -p $(patsubst nightly-clean-%,%,$@) ${BUILD_TYPE_FLAG}

nightly-test-%:
${CARGO} +${NIGHTLY_TOOLCHAIN} test -p $(patsubst nightly-test-%,%,$@) ${BUILD_TYPE_FLAG}
${CARGO} +${RUST_TOOLCHAIN} test -p $(patsubst test-%,%,$@) ${BUILD_TYPE_FLAG}

# Targets for subdirectories
build-subdir-%:
Expand Down
19 changes: 7 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,13 @@ The threat model analysis is at [td-shim threat model](doc/threat_model.md).

1. Install [RUST](https://www.rust-lang.org/)

please use nightly-2023-12-31.

NOTE: We need install nightly version because we use cargo-xbuild.

1.1. Install xbuild
please use 1.83.0.

```
cargo install cargo-xbuild
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain 1.83.0
rustup target add x86_64-unknown-none
```

Please reinstall cargo-xbuild, after you update the rust toolchain.

2. Install [NASM](https://www.nasm.us/)

Please make sure nasm can be found in PATH.
Expand Down Expand Up @@ -121,27 +116,27 @@ cargo image --example-payload --release
Build TdShim to launch a payload support Linux Boot Protocol

```
cargo xbuild -p td-shim --target x86_64-unknown-none --release --features=main,tdx
cargo build -p td-shim --target x86_64-unknown-none --release --features=main,tdx
cargo run -p td-shim-tools --bin td-shim-ld --features=linker -- target/x86_64-unknown-none/release/ResetVector.bin target/x86_64-unknown-none/release/td-shim -o target/release/final.bin
```

Build TdShim to launch a executable payload

```
cargo xbuild -p td-shim --target x86_64-unknown-none --release --features=main,tdx --no-default-features
cargo build -p td-shim --target x86_64-unknown-none --release --features=main,tdx --no-default-features
```

Build Elf format payload

```
cargo xbuild -p td-payload --target x86_64-unknown-none --release --bin example --features=tdx,start,cet-shstk,stack-guard
cargo build -p td-payload --target x86_64-unknown-none --release --bin example --features=tdx,start,cet-shstk,stack-guard
cargo run -p td-shim-tools --bin td-shim-ld -- target/x86_64-unknown-none/release/ResetVector.bin target/x86_64-unknown-none/release/td-shim -t executable -p target/x86_64-unknown-none/release/example -o target/release/final-elf.bin
```

To build the debug TdShim, please use `dev-opt` profile to build `td-shim` binary. For example:

```
cargo xbuild -p td-shim --target x86_64-unknown-none --profile dev-opt --features=main,tdx
cargo build -p td-shim --target x86_64-unknown-none --profile dev-opt --features=main,tdx
cargo run -p td-shim-tools --bin td-shim-ld --features=linker -- target/x86_64-unknown-none/dev-opt/ResetVector.bin target/x86_64-unknown-none/dev-opt/td-shim -o target/debug/final.bin
```

Expand Down
Loading

0 comments on commit 9c68f0e

Please sign in to comment.