From f8618a8f0c76636f8e11a5d60e6602006129d807 Mon Sep 17 00:00:00 2001 From: Jiaqi Gao Date: Thu, 26 Dec 2024 03:01:38 -0500 Subject: [PATCH] remove nightly features and switch to stable toolchain Signed-off-by: Jiaqi Gao --- .github/workflows/format.yml | 18 ++++++------------ .github/workflows/fuzz.yml | 18 ++++-------------- .github/workflows/integration-tdx.yml | 2 +- .github/workflows/library.yml | 7 +++++-- .github/workflows/main.yml | 16 +++++----------- Cargo.lock | 8 ++++---- readme.md | 8 +++----- rust-toolchain | 2 +- sh_script/build_final.sh | 10 +++++----- src/attestation/src/lib.rs | 1 - src/devices/virtio_serial/src/lib.rs | 1 - src/devices/vsock/src/lib.rs | 1 - src/migtd/Cargo.toml | 2 +- src/migtd/src/lib.rs | 2 -- src/std-support/sys_time/Cargo.toml | 2 +- tests/test-td-payload/src/main.rs | 1 - xtask/src/build.rs | 2 +- 17 files changed, 37 insertions(+), 64 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index e577f268..0b153adc 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -6,6 +6,7 @@ env: AS: nasm AR: llvm-ar CC: clang + RUST_TOOLCHAIN: 1.83.0 permissions: contents: read @@ -38,26 +39,19 @@ jobs: uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7 with: profile: minimal - toolchain: nightly-2023-12-31 + toolchain: ${{ env.RUST_TOOLCHAIN }} override: true components: clippy - - name: install stable rust toolchain - uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7 - with: - toolchain: 1.78.0 - profile: minimal - override: true - - name: Install required cargo - run: cargo +stable-x86_64-unknown-linux-gnu install clippy-sarif sarif-fmt + run: cargo install clippy-sarif sarif-fmt - name: Preparation Work run: bash sh_script/preparation.sh - name: Run rust-clippy for result collection run: - cargo +nightly-2023-12-31-x86_64-unknown-linux-gnu clippy + cargo clippy --features stack-guard,virtio-vsock,virtio-serial,vmcall-interrupt --message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt continue-on-error: true @@ -69,7 +63,7 @@ jobs: wait-for-processing: true - name: Run rust-clippy - run: cargo +nightly-2023-12-31-x86_64-unknown-linux-gnu clippy --features stack-guard,virtio-vsock,virtio-serial,vmcall-interrupt + run: cargo clippy --features stack-guard,virtio-vsock,virtio-serial,vmcall-interrupt rustfmt: name: Format @@ -95,7 +89,7 @@ jobs: uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7 with: profile: minimal - toolchain: nightly-2023-12-31 + toolchain: ${{ env.RUST_TOOLCHAIN }} override: true components: rustfmt diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index 0fab967c..701f87aa 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -13,8 +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_STABLE_TOOLCHAIN: 1.78.0 + RUST_TOOLCHAIN: nightly TOOLCHAIN_PROFILE: minimal AFL_NO_AFFINITY: 1 @@ -37,19 +36,10 @@ jobs: - uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7 with: - toolchain: 1.78.0 - profile: minimal - override: true - - - uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7 - with: - toolchain: nightly-2023-12-31 + toolchain: ${{ env.RUST_TOOLCHAIN }} profile: minimal override: true components: rust-src, llvm-tools-preview - - - name: Run cargo install cargo-xbuild - run: cargo install cargo-xbuild - name: install NASM uses: ilammy/setup-nasm@13cbeb366c45c4379d3478cdcbadd8295feb5028 # v1.5.1 @@ -58,10 +48,10 @@ jobs: run: cargo install cargo-afl - name: Install Cargo-Fuzz - run: cargo +stable-x86_64-unknown-linux-gnu install cargo-fuzz + run: cargo install cargo-fuzz - name: Select default toolchain - run: rustup default nightly-2023-12-31 + run: rustup default ${{ env.RUST_TOOLCHAIN }} - name: Preparation work run: bash sh_script/preparation.sh diff --git a/.github/workflows/integration-tdx.yml b/.github/workflows/integration-tdx.yml index 524b663b..4f4a4fa3 100644 --- a/.github/workflows/integration-tdx.yml +++ b/.github/workflows/integration-tdx.yml @@ -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 permissions: diff --git a/.github/workflows/library.yml b/.github/workflows/library.yml index 1d92fd96..f2d05ad2 100644 --- a/.github/workflows/library.yml +++ b/.github/workflows/library.yml @@ -13,7 +13,7 @@ env: AS: nasm AR: llvm-ar CC: clang - NIGHTLY_RUST_TOOLCHAIN: nightly-2023-12-31 + RUST_TOOLCHAIN: 1.83.0 TOOLCHAIN_PROFILE: minimal permissions: @@ -43,7 +43,7 @@ jobs: uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7 with: profile: ${{ env.TOOLCHAIN_PROFILE }} - toolchain: ${{ env.NIGHTLY_RUST_TOOLCHAIN }} + toolchain: ${{ env.RUST_TOOLCHAIN }} override: true - name: Checkout sources @@ -51,6 +51,9 @@ jobs: with: submodules: recursive + - name: Add `x86_64-unknown-none` target + run: rustup target add x86_64-unknown-none + - name: Preparation work run: bash sh_script/preparation.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7c0f412c..712ede62 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,7 @@ name: main env: AS: nasm - RUST_TOOLCHAIN: nightly-2023-12-31 + RUST_TOOLCHAIN: 1.83.0 TOOLCHAIN_PROFILE: minimal permissions: @@ -50,11 +50,8 @@ jobs: override: true components: rust-src - - name: Run cargo install cargo-xbuild - uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3 - with: - command: install - args: 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 @@ -103,11 +100,8 @@ jobs: override: true components: rust-src - - name: Run cargo install cargo-xbuild - uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3 - with: - command: install - args: 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 diff --git a/Cargo.lock b/Cargo.lock index b570a2a3..adb98cfb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "ahash" @@ -1516,12 +1516,12 @@ dependencies = [ [[package]] name = "x86_64" -version = "0.14.11" +version = "0.14.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b835097a84e4457323331ec5d6eb23d096066cbfb215d54096dcb4b2e85f500" +checksum = "958cd5cb28e720db2f59ee9dc4235b5f82a183d079fb0e6caf43ad074cfdc66a" dependencies = [ "bit_field", - "bitflags 2.4.1", + "bitflags 1.3.2", "rustversion", "volatile 0.4.6", ] diff --git a/readme.md b/readme.md index 8f8f35ce..0528a51f 100644 --- a/readme.md +++ b/readme.md @@ -19,13 +19,11 @@ This package is the sample code to show the concept of Migration TD in TDX Migra * Install [Rust](https://www.rust-lang.org/tools/install): ``` -curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh +curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain 1.83.0 ``` -* Install toolchain and components required by MigTD: +* Add Rust target required by MigTD: ``` -rustup toolchain install nightly-2023-12-31 -rustup component add --toolchain nightly-2023-12-31 rust-src -cargo install cargo-xbuild +rustup target add x86_64-unknown-none ``` 2. [clang](https://releases.llvm.org/download.html#13.0.1) diff --git a/rust-toolchain b/rust-toolchain index f819c018..0193dee3 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,2 +1,2 @@ [toolchain] -channel = "nightly-2023-12-31" +channel = "1.83.0" diff --git a/sh_script/build_final.sh b/sh_script/build_final.sh index b5fc5ca0..92dafd15 100644 --- a/sh_script/build_final.sh +++ b/sh_script/build_final.sh @@ -91,11 +91,11 @@ function final_test_td_payload() { cleanup pushd tests - cargo xbuild -p test-td-payload --target x86_64-unknown-none --release --features=main,tdx --no-default-features + cargo build -p test-td-payload --target x86_64-unknown-none --release --features=main,tdx --no-default-features popd pushd deps/td-shim - 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 set_cc cargo run -p td-shim-tools --bin td-shim-strip-info -- -n test-td-payload -w ../../ --target x86_64-unknown-none @@ -245,20 +245,20 @@ function final_migtd() { } function build_migtd() { - cargo xbuild -p migtd --target x86_64-unknown-none --release --features=${MIGTD_FEATURE} + cargo build -p migtd --target x86_64-unknown-none --release --features=${MIGTD_FEATURE} check_file_exist "./target/x86_64-unknown-none/release/migtd" } function build_tdshim() { pushd deps/td-shim - 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 check_file_exist "./target/x86_64-unknown-none/release/td-shim" popd } function build_tdshim_sb() { pushd deps/td-shim - cargo xbuild -p td-shim --target x86_64-unknown-none --release --features=main,tdx,secure-boot --no-default-features + cargo build -p td-shim --target x86_64-unknown-none --release --features=main,tdx,secure-boot --no-default-features check_file_exist "./target/x86_64-unknown-none/release/td-shim" popd } diff --git a/src/attestation/src/lib.rs b/src/attestation/src/lib.rs index 37392504..0b9ebb1f 100644 --- a/src/attestation/src/lib.rs +++ b/src/attestation/src/lib.rs @@ -3,7 +3,6 @@ // SPDX-License-Identifier: BSD-2-Clause-Patent #![no_std] -#![feature(naked_functions)] extern crate alloc; diff --git a/src/devices/virtio_serial/src/lib.rs b/src/devices/virtio_serial/src/lib.rs index 1dc66817..630ffd52 100644 --- a/src/devices/virtio_serial/src/lib.rs +++ b/src/devices/virtio_serial/src/lib.rs @@ -3,7 +3,6 @@ // SPDX-License-Identifier: BSD-2-Clause-Patent #![cfg_attr(not(test), no_std)] -#![feature(naked_functions)] extern crate alloc; diff --git a/src/devices/vsock/src/lib.rs b/src/devices/vsock/src/lib.rs index b17dd95d..bb48f9e0 100644 --- a/src/devices/vsock/src/lib.rs +++ b/src/devices/vsock/src/lib.rs @@ -3,7 +3,6 @@ // SPDX-License-Identifier: BSD-2-Clause-Patent #![cfg_attr(not(test), no_std)] -#![feature(naked_functions)] extern crate alloc; use alloc::vec::Vec; diff --git a/src/migtd/Cargo.toml b/src/migtd/Cargo.toml index 8a8d5503..0dae283a 100644 --- a/src/migtd/Cargo.toml +++ b/src/migtd/Cargo.toml @@ -33,7 +33,7 @@ virtio = { path="../devices/virtio" } vsock = { path="../devices/vsock" } virtio_serial = { path="../devices/virtio_serial", optional = true } x86 = "0.47.0" -x86_64 = "0.14.9" +x86_64 = { version = "0.14", default-features = false, features = ["instructions"] } zerocopy = { version = "0.7", features = ["derive"] } minicov = { version = "0.2", default-features = false, optional = true } diff --git a/src/migtd/src/lib.rs b/src/migtd/src/lib.rs index 224f81c8..7e5fcd7d 100644 --- a/src/migtd/src/lib.rs +++ b/src/migtd/src/lib.rs @@ -4,8 +4,6 @@ #![cfg_attr(not(test), no_std)] #![cfg_attr(not(test), no_main)] -#![feature(alloc_error_handler)] -#![feature(naked_functions)] #[cfg_attr(feature = "main", macro_use)] extern crate alloc; diff --git a/src/std-support/sys_time/Cargo.toml b/src/std-support/sys_time/Cargo.toml index 3af9ded5..55b029d0 100644 --- a/src/std-support/sys_time/Cargo.toml +++ b/src/std-support/sys_time/Cargo.toml @@ -8,5 +8,5 @@ edition = "2018" [dependencies] lazy_static = { version = "1.4.0", features = ["spin_no_std"] } -x86_64 = "0.14" +x86_64 = { version = "0.14", default-features = false, features = ["instructions"] } time = { version = "0.3", default-features = false } diff --git a/tests/test-td-payload/src/main.rs b/tests/test-td-payload/src/main.rs index 5cc6bdbd..8194013d 100644 --- a/tests/test-td-payload/src/main.rs +++ b/tests/test-td-payload/src/main.rs @@ -5,7 +5,6 @@ #![no_std] #![no_main] #![allow(unused)] -#![feature(alloc_error_handler)] #[macro_use] mod testattestation; diff --git a/xtask/src/build.rs b/xtask/src/build.rs index ad4a76ff..5b196c93 100644 --- a/xtask/src/build.rs +++ b/xtask/src/build.rs @@ -170,7 +170,7 @@ impl BuildArgs { sh.set_var("CC_x86_64_unknown_none", "clang"); sh.set_var("AR_x86_64_unknown_none", "llvm-ar"); - cmd!(sh, "cargo xbuild -p migtd --target x86_64-unknown-none") + cmd!(sh, "cargo build -p migtd --target x86_64-unknown-none") .args(["--features", self.features().as_str()]) .args(["--profile", self.profile()]) .run()?;