diff --git a/Cargo.toml b/Cargo.toml index 83cc8a2e..da16994c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,16 +21,5 @@ members = [ "xtask", ] -# the profile used for `cargo build` -[profile.dev] -panic = "abort" # disable stack unwinding on panic -opt-level = "z" -lto = true - -# the profile used for `cargo build --release` -[profile.release] -panic = "abort" # disable stack unwinding on panic -lto = true # Link-time optimization - [patch.crates-io] ring = { path = "library/ring" } diff --git a/README.md b/README.md index 340d6133..ef4114b5 100644 --- a/README.md +++ b/README.md @@ -121,20 +121,26 @@ cargo image --example-payload --release Build TdShim to launch a payload support Linux Boot Protocol ``` +cd td-shim cargo xbuild -p td-shim --target x86_64-unknown-none --release --features=main,tdx +cd .. 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 ``` +cd td-shim cargo xbuild -p td-shim --target x86_64-unknown-none --release --features=main,tdx --no-default-features +cd .. ``` Build Elf format payload ``` +cd td-payload cargo xbuild -p td-payload --target x86_64-unknown-none --release --bin example --features=tdx,start,cet-shstk,stack-guard +cd .. 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 ``` diff --git a/td-payload/.cargo/config.toml b/td-payload/.cargo/config.toml new file mode 100644 index 00000000..8fe65a87 --- /dev/null +++ b/td-payload/.cargo/config.toml @@ -0,0 +1,10 @@ +# the profile used for `cargo build` +[profile.dev] +panic = "abort" # disable stack unwinding on panic +opt-level = "z" +lto = true + +# the profile used for `cargo build --release` +[profile.release] +panic = "abort" # disable stack unwinding on panic +lto = true # Link-time optimization diff --git a/td-shim/.cargo/config.toml b/td-shim/.cargo/config.toml new file mode 100644 index 00000000..8fe65a87 --- /dev/null +++ b/td-shim/.cargo/config.toml @@ -0,0 +1,10 @@ +# the profile used for `cargo build` +[profile.dev] +panic = "abort" # disable stack unwinding on panic +opt-level = "z" +lto = true + +# the profile used for `cargo build --release` +[profile.release] +panic = "abort" # disable stack unwinding on panic +lto = true # Link-time optimization diff --git a/xtask/src/build.rs b/xtask/src/build.rs index 21bbc2d9..15fe4fe1 100644 --- a/xtask/src/build.rs +++ b/xtask/src/build.rs @@ -113,6 +113,9 @@ impl BuildArgs { self.build_shim_layout()?; let sh = Shell::new()?; + // Switch to the crate folder to use profile of crate rather than workspace + sh.change_dir(PROJECT_ROOT.join("td-shim")); + cmd!( sh, "cargo xbuild -p td-shim --target x86_64-unknown-none --no-default-features" @@ -135,6 +138,9 @@ impl BuildArgs { fn build_example_payload(&self) -> Result { let sh = Shell::new()?; + // Switch to the crate folder to use profile of crate rather than workspace + sh.change_dir(PROJECT_ROOT.join("td-payload")); + cmd!( sh, "cargo xbuild -p td-payload --bin example --target x86_64-unknown-none"