From 9b1947b7f14172fe94925592d44de282b2b3162d Mon Sep 17 00:00:00 2001 From: OuyangHang33 Date: Mon, 26 Feb 2024 20:46:23 +0800 Subject: [PATCH] Create td-shim-interface crate for publishig Signed-off-by: OuyangHang33 --- Cargo.lock | 290 ++++++------ Cargo.toml | 1 + sh_script/fuzzing.sh | 2 +- sh_script/rudra.sh | 2 +- td-layout/Cargo.toml | 2 +- td-payload/Cargo.toml | 2 +- td-payload/src/acpi.rs | 2 +- td-payload/src/bin/example/main.rs | 4 +- td-payload/src/hob.rs | 2 +- td-payload/src/mm/mod.rs | 2 +- td-shim-interface/Cargo.lock | 414 ++++++++++++++++++ td-shim-interface/Cargo.toml | 28 ++ td-shim-interface/README.md | 57 +++ {td-shim => td-shim-interface}/src/acpi.rs | 0 .../src}/fuzz/Cargo.toml | 0 .../src}/fuzz/fuzz_targets/afl_cfv_parser.rs | 0 .../src}/fuzz/fuzz_targets/afl_hob_parser.rs | 0 .../fuzz/fuzz_targets/afl_payload_parser.rs | 0 .../src}/fuzz/fuzz_targets/cfv_parser.rs | 0 .../src}/fuzz/fuzz_targets/fuzzlib.rs | 2 +- .../src}/fuzz/fuzz_targets/hob_parser.rs | 0 .../src}/fuzz/fuzz_targets/payload_parser.rs | 0 .../src}/fuzz/seeds/cfv_parser/cfv | Bin .../src}/fuzz/seeds/hob_parser/hob_buffer | Bin .../src}/fuzz/seeds/payload_parser/fv_buffer | Bin td-shim-interface/src/lib.rs | 134 ++++++ .../src/metadata.rs | 2 +- .../src/td_uefi_pi}/Cargo.toml | 0 .../src/td_uefi_pi}/fv.rs | 0 .../src/td_uefi_pi}/hob.rs | 0 .../src/td_uefi_pi/mod.rs | 1 - .../src/td_uefi_pi}/pi/boot_mode.rs | 0 .../src/td_uefi_pi}/pi/fv.rs | 0 .../src/td_uefi_pi}/pi/guid.rs | 0 .../src/td_uefi_pi}/pi/hob.rs | 0 .../src/td_uefi_pi}/pi/mod.rs | 0 td-shim-tools/Cargo.toml | 2 +- td-shim-tools/src/bin/td-shim-checker/main.rs | 2 +- td-shim-tools/src/bin/td-shim-enroll/main.rs | 2 +- td-shim-tools/src/enroller.rs | 4 +- td-shim-tools/src/linker.rs | 4 +- td-shim-tools/src/loader.rs | 2 +- td-shim-tools/src/metadata.rs | 6 +- td-shim-tools/src/tee_info_hash.rs | 2 +- td-shim/Cargo.toml | 2 +- td-shim/src/bin/td-shim/acpi.rs | 2 +- td-shim/src/bin/td-shim/main.rs | 4 +- td-shim/src/bin/td-shim/memory.rs | 6 +- td-shim/src/bin/td-shim/mp.rs | 2 +- td-shim/src/bin/td-shim/payload_hob.rs | 4 +- td-shim/src/bin/td-shim/shim_info.rs | 8 +- td-shim/src/fv.rs | 2 +- td-shim/src/lib.rs | 4 +- td-shim/src/reset_vector.rs | 4 +- td-shim/src/secure_boot.rs | 2 +- tests/test-td-payload/Cargo.toml | 2 +- tests/test-td-payload/src/main.rs | 2 +- tests/test-td-payload/src/testacpi.rs | 4 +- tests/test-td-payload/src/testmemmap.rs | 2 +- tests/test-td-payload/src/testtrustedboot.rs | 4 +- 60 files changed, 831 insertions(+), 194 deletions(-) create mode 100644 td-shim-interface/Cargo.lock create mode 100644 td-shim-interface/Cargo.toml create mode 100644 td-shim-interface/README.md rename {td-shim => td-shim-interface}/src/acpi.rs (100%) rename {td-uefi-pi => td-shim-interface/src}/fuzz/Cargo.toml (100%) rename {td-uefi-pi => td-shim-interface/src}/fuzz/fuzz_targets/afl_cfv_parser.rs (100%) rename {td-uefi-pi => td-shim-interface/src}/fuzz/fuzz_targets/afl_hob_parser.rs (100%) rename {td-uefi-pi => td-shim-interface/src}/fuzz/fuzz_targets/afl_payload_parser.rs (100%) rename {td-uefi-pi => td-shim-interface/src}/fuzz/fuzz_targets/cfv_parser.rs (100%) rename {td-uefi-pi => td-shim-interface/src}/fuzz/fuzz_targets/fuzzlib.rs (97%) rename {td-uefi-pi => td-shim-interface/src}/fuzz/fuzz_targets/hob_parser.rs (100%) rename {td-uefi-pi => td-shim-interface/src}/fuzz/fuzz_targets/payload_parser.rs (100%) rename {td-uefi-pi => td-shim-interface/src}/fuzz/seeds/cfv_parser/cfv (100%) rename {td-uefi-pi => td-shim-interface/src}/fuzz/seeds/hob_parser/hob_buffer (100%) rename {td-uefi-pi => td-shim-interface/src}/fuzz/seeds/payload_parser/fv_buffer (100%) create mode 100644 td-shim-interface/src/lib.rs rename {td-shim => td-shim-interface}/src/metadata.rs (99%) rename {td-uefi-pi => td-shim-interface/src/td_uefi_pi}/Cargo.toml (100%) rename {td-uefi-pi/src => td-shim-interface/src/td_uefi_pi}/fv.rs (100%) rename {td-uefi-pi/src => td-shim-interface/src/td_uefi_pi}/hob.rs (100%) rename td-uefi-pi/src/lib.rs => td-shim-interface/src/td_uefi_pi/mod.rs (99%) rename {td-uefi-pi/src => td-shim-interface/src/td_uefi_pi}/pi/boot_mode.rs (100%) rename {td-uefi-pi/src => td-shim-interface/src/td_uefi_pi}/pi/fv.rs (100%) rename {td-uefi-pi/src => td-shim-interface/src/td_uefi_pi}/pi/guid.rs (100%) rename {td-uefi-pi/src => td-shim-interface/src/td_uefi_pi}/pi/hob.rs (100%) rename {td-uefi-pi/src => td-shim-interface/src/td_uefi_pi}/pi/mod.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 51831519..815a17f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -47,9 +47,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.7" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd2405b3ac1faab2990b74d728624cd9fd115651fcecc7c2d8daf01376275ba" +checksum = "96b09b5178381e0874812a9b157f7fe84982617e48f71f4e3235482775e5b540" dependencies = [ "anstyle", "anstyle-parse", @@ -61,9 +61,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "anstyle-parse" @@ -95,9 +95,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" +checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" [[package]] name = "argparse" @@ -131,9 +131,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "block-buffer" @@ -170,9 +170,9 @@ dependencies = [ [[package]] name = "bstr" -version = "1.9.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c48f0051a4b4c5e0b6d365cd04af53aeaa209e3cc15ec2cdb69e73cc87fbd0dc" +checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706" dependencies = [ "memchr", "serde", @@ -180,9 +180,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "8ea184aa71bb362a1157c896979544cc23974e08fd265f29ea96b59f0b4a555b" [[package]] name = "byteorder" @@ -192,12 +192,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cc" -version = "1.0.83" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" -dependencies = [ - "libc", -] +checksum = "02f341c093d19155a6e41631ce5971aac4e9a868262212153124c15fa22d1cdc" [[package]] name = "cc-measurement" @@ -216,21 +213,21 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.31" +version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" dependencies = [ "android-tzdata", "iana-time-zone", "num-traits", - "windows-targets 0.48.5", + "windows-targets 0.52.3", ] [[package]] name = "chrono-tz" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d7b79e99bfaa0d47da0687c43aa3b7381938a62ad3a6498599039321f660b7" +checksum = "d59ae0466b83e838b81a54256c39d5d7c20b9d7daa10510a242d9b75abd5936e" dependencies = [ "chrono", "chrono-tz-build", @@ -250,9 +247,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.17" +version = "4.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80932e03c33999b9235edb8655bc9df3204adc9887c2f95b50cb1deb9fd54253" +checksum = "c918d541ef2913577a0f9566e9ce27cb35b6df072075769e0b26cb5a554520da" dependencies = [ "clap_builder", "clap_derive", @@ -260,9 +257,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.17" +version = "4.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c0db58c659eef1c73e444d298c27322a1b52f6927d2ad470c0c0f96fa7b8fa" +checksum = "9f3e7391dad68afb0c2ede1bf619f579a3dc9c2ec67f089baa397123a2f3d1eb" dependencies = [ "anstream", "anstyle", @@ -272,21 +269,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.4.7" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", ] [[package]] name = "clap_lex" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "colorchoice" @@ -374,9 +371,9 @@ dependencies = [ [[package]] name = "deunicode" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ae2a35373c5c74340b79ae6780b498b2b183915ec5dacf263aac5a099bf485a" +checksum = "b6e854126756c496b8c81dec88f9a706b15b875c5849d4097a3854476b9fdf94" [[package]] name = "digest" @@ -390,15 +387,15 @@ dependencies = [ [[package]] name = "either" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "env_logger" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" +checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" dependencies = [ "humantime", "is-terminal", @@ -470,9 +467,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.3" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "379dada1584ad501b383485dd706b8afb7a70fcbc7f4da7d780638a5a6124a60" [[package]] name = "hex" @@ -509,9 +506,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "iana-time-zone" -version = "0.1.59" +version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -548,12 +545,12 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.10" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455" +checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ "hermit-abi", - "rustix", + "libc", "windows-sys 0.52.0", ] @@ -565,9 +562,9 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "js-sys" -version = "0.3.67" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" +checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" dependencies = [ "wasm-bindgen", ] @@ -600,9 +597,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.152" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libm" @@ -621,9 +618,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "locate-cargo-manifest" @@ -677,9 +674,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", ] @@ -716,9 +713,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.6" +version = "2.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f200d8d83c44a45b21764d1916299752ca035d15ecd46faca3e9a2a2bf6ad06" +checksum = "219c0dcc30b6a27553f9cc242972b67f75b60eb0db71f0b5462f38b058c41546" dependencies = [ "memchr", "thiserror", @@ -727,9 +724,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.6" +version = "2.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcd6ab1236bbdb3a49027e920e693192ebfe8913f6d60e294de57463a493cfde" +checksum = "22e1288dbd7786462961e69bfd4df7848c1e37e8b74303dbdab82c3a9cdd2809" dependencies = [ "pest", "pest_generator", @@ -737,22 +734,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.6" +version = "2.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a31940305ffc96863a735bef7c7994a00b325a7138fdbc5bda0f1a0476d3275" +checksum = "1381c29a877c6d34b8c176e734f35d7f7f5b3adaefe940cb4d1bb7af94678e2e" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", ] [[package]] name = "pest_meta" -version = "2.7.6" +version = "2.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7ff62f5259e53b78d1af898941cdcdccfae7385cf7d793a6e55de5d05bb4b7d" +checksum = "d0934d6907f148c22a3acbda520c7eed243ad7487a30f51f6ce52b58b7077a8a" dependencies = [ "once_cell", "pest", @@ -805,9 +802,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.76" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -868,9 +865,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.2" +version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", @@ -880,9 +877,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" dependencies = [ "aho-corasick", "memchr", @@ -919,11 +916,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.30" +version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "errno", "libc", "linux-raw-sys", @@ -938,9 +935,9 @@ checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "ryu" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "same-file" @@ -979,29 +976,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.195" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.195" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", ] [[package]] name = "serde_json" -version = "1.0.111" +version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ "itoa", "ryu", @@ -1061,9 +1058,9 @@ dependencies = [ [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" [[package]] name = "syn" @@ -1078,9 +1075,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "6ab617d94515e94ae53b8406c628598680aa0c9587474ecbe58188f7b345d66c" dependencies = [ "proc-macro2", "quote", @@ -1132,7 +1129,7 @@ dependencies = [ "log", "memoffset", "scroll", - "td-uefi-pi", + "td-shim-interface", ] [[package]] @@ -1200,7 +1197,7 @@ dependencies = [ "td-logger", "td-paging", "td-shim", - "td-uefi-pi", + "td-shim-interface", "tdx-tdcall", "x86", "x86_64", @@ -1227,7 +1224,7 @@ dependencies = [ "td-loader", "td-logger", "td-paging", - "td-uefi-pi", + "td-shim-interface", "tdx-tdcall", "which", "x86", @@ -1235,6 +1232,22 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "td-shim-interface" +version = "0.1.0" +dependencies = [ + "anyhow", + "cc", + "lazy_static", + "log", + "r-efi", + "scroll", + "which", + "x86", + "x86_64", + "zerocopy", +] + [[package]] name = "td-shim-tools" version = "0.1.0" @@ -1260,19 +1273,10 @@ dependencies = [ "td-layout", "td-loader", "td-shim", - "td-uefi-pi", + "td-shim-interface", "zeroize", ] -[[package]] -name = "td-uefi-pi" -version = "0.1.0" -dependencies = [ - "log", - "r-efi", - "scroll", -] - [[package]] name = "tdx-tdcall" version = "0.1.0" @@ -1375,7 +1379,7 @@ dependencies = [ "td-paging", "td-payload", "td-shim", - "td-uefi-pi", + "td-shim-interface", "tdx-tdcall", "x86", "zerocopy", @@ -1383,22 +1387,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.56" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.56" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", ] [[package]] @@ -1537,9 +1541,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" +checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1547,24 +1551,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" +checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" +checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1572,22 +1576,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" +checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" +checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" [[package]] name = "which" @@ -1639,7 +1643,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.3", ] [[package]] @@ -1657,7 +1661,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.3", ] [[package]] @@ -1677,17 +1681,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "d380ba1dc7187569a8a9e91ed34b8ccfc33123bbacb8c0aed2d1ad7f3ef2dc5f" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.3", + "windows_aarch64_msvc 0.52.3", + "windows_i686_gnu 0.52.3", + "windows_i686_msvc 0.52.3", + "windows_x86_64_gnu 0.52.3", + "windows_x86_64_gnullvm 0.52.3", + "windows_x86_64_msvc 0.52.3", ] [[package]] @@ -1698,9 +1702,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "68e5dcfb9413f53afd9c8f86e56a7b4d86d9a2fa26090ea2dc9e40fba56c6ec6" [[package]] name = "windows_aarch64_msvc" @@ -1710,9 +1714,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "8dab469ebbc45798319e69eebf92308e541ce46760b49b18c6b3fe5e8965b30f" [[package]] name = "windows_i686_gnu" @@ -1722,9 +1726,9 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "2a4e9b6a7cac734a8b4138a4e1044eac3404d8326b6c0f939276560687a033fb" [[package]] name = "windows_i686_msvc" @@ -1734,9 +1738,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "28b0ec9c422ca95ff34a78755cfa6ad4a51371da2a5ace67500cf7ca5f232c58" [[package]] name = "windows_x86_64_gnu" @@ -1746,9 +1750,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "704131571ba93e89d7cd43482277d6632589b18ecf4468f591fbae0a8b101614" [[package]] name = "windows_x86_64_gnullvm" @@ -1758,9 +1762,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "42079295511643151e98d61c38c0acc444e52dd42ab456f7ccfd5152e8ecf21c" [[package]] name = "windows_x86_64_msvc" @@ -1770,9 +1774,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "0770833d60a970638e989b3fa9fd2bb1aaadcf88963d1659fd7d9990196ed2d6" [[package]] name = "x86" @@ -1787,12 +1791,12 @@ dependencies = [ [[package]] name = "x86_64" -version = "0.14.11" +version = "0.14.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b835097a84e4457323331ec5d6eb23d096066cbfb215d54096dcb4b2e85f500" +checksum = "96cb6fd45bfeab6a5055c5bffdb08768bd0c069f1d946debe585bbb380a7c062" dependencies = [ "bit_field", - "bitflags 2.4.1", + "bitflags 2.4.2", "rustversion", "volatile", ] @@ -1840,7 +1844,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.51", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 52622029..31469800 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,7 @@ members = [ "tests/test-td-paging", "tests/test-td-payload", "xtask", + "td-shim-interface", ] # the profile used for debug build of `td-shim` and `td-payload` diff --git a/sh_script/fuzzing.sh b/sh_script/fuzzing.sh index 446e52bc..4af7586a 100644 --- a/sh_script/fuzzing.sh +++ b/sh_script/fuzzing.sh @@ -8,7 +8,7 @@ readonly script_name=${0##*/} fuzz_folder=( "td-loader" - "td-uefi-pi" + "td-shim-interface/src" "td-shim" ) diff --git a/sh_script/rudra.sh b/sh_script/rudra.sh index b10c8e5a..b88a5dfb 100644 --- a/sh_script/rudra.sh +++ b/sh_script/rudra.sh @@ -25,7 +25,7 @@ paths=( "td-paging" "td-payload" "td-shim" - "td-uefi-pi" + "td-shim-interface/src" "td-shim-tools" "tdx-tdcall" ) diff --git a/td-layout/Cargo.toml b/td-layout/Cargo.toml index 2e636bdc..1d525b0c 100644 --- a/td-layout/Cargo.toml +++ b/td-layout/Cargo.toml @@ -12,7 +12,7 @@ edition = "2018" [dependencies] scroll = { version = "0.10", default-features = false, features = ["derive"]} log = "0.4.13" -td-uefi-pi = { path = "../td-uefi-pi" } +td-shim-interface = { path = "../td-shim-interface" } [dev-dependencies] memoffset = "0.6" \ No newline at end of file diff --git a/td-payload/Cargo.toml b/td-payload/Cargo.toml index 75a759fe..4604e3ea 100644 --- a/td-payload/Cargo.toml +++ b/td-payload/Cargo.toml @@ -23,7 +23,7 @@ serde_json = { version = "1.0", default-features = false, features = ["alloc"] } spin = "0.9" td-logger = { path = "../td-logger" } td-shim = { path = "../td-shim", default-features = false } -td-uefi-pi = { path = "../td-uefi-pi" } +td-shim-interface = { path = "../td-shim-interface" } td-exception = { path = "../td-exception" } td-paging = { path = "../td-paging" } x86 = "0.47.0" diff --git a/td-payload/src/acpi.rs b/td-payload/src/acpi.rs index 6fbbf2f0..bd6fe523 100644 --- a/td-payload/src/acpi.rs +++ b/td-payload/src/acpi.rs @@ -6,7 +6,7 @@ use alloc::vec::Vec; use scroll::Pread; use spin::Once; use td_shim::TD_ACPI_TABLE_HOB_GUID; -use td_uefi_pi::{ +use td_shim_interface::td_uefi_pi::{ hob as hob_lib, pi::hob::{GuidExtension, Header, HOB_TYPE_END_OF_HOB_LIST, HOB_TYPE_GUID_EXTENSION}, }; diff --git a/td-payload/src/bin/example/main.rs b/td-payload/src/bin/example/main.rs index 50c19581..36dd2053 100644 --- a/td-payload/src/bin/example/main.rs +++ b/td-payload/src/bin/example/main.rs @@ -26,8 +26,8 @@ use td_payload as _; use td_payload::println; use td_shim::e820::{E820Entry, E820Type}; use td_shim::{TD_ACPI_TABLE_HOB_GUID, TD_E820_TABLE_HOB_GUID}; -use td_uefi_pi::hob; -use td_uefi_pi::pi; +use td_shim_interface::td_uefi_pi::hob; +use td_shim_interface::td_uefi_pi::pi; use zerocopy::FromBytes; #[macro_use] diff --git a/td-payload/src/hob.rs b/td-payload/src/hob.rs index 170792b6..ab0917fc 100644 --- a/td-payload/src/hob.rs +++ b/td-payload/src/hob.rs @@ -5,7 +5,7 @@ use core::mem::size_of; use scroll::Pread; use spin::Once; -use td_uefi_pi::{ +use td_shim_interface::td_uefi_pi::{ hob::check_hob_integrity, pi::hob::{HandoffInfoTable, HOB_TYPE_HANDOFF}, }; diff --git a/td-payload/src/mm/mod.rs b/td-payload/src/mm/mod.rs index c794a1b4..d2479ae5 100644 --- a/td-payload/src/mm/mod.rs +++ b/td-payload/src/mm/mod.rs @@ -11,7 +11,7 @@ use td_shim::{ e820::{E820Entry, E820Type}, TD_E820_TABLE_HOB_GUID, }; -use td_uefi_pi::{ +use td_shim_interface::td_uefi_pi::{ hob as hob_lib, pi::hob::{GuidExtension, Header, HOB_TYPE_END_OF_HOB_LIST, HOB_TYPE_GUID_EXTENSION}, }; diff --git a/td-shim-interface/Cargo.lock b/td-shim-interface/Cargo.lock new file mode 100644 index 00000000..ffe56670 --- /dev/null +++ b/td-shim-interface/Cargo.lock @@ -0,0 +1,414 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "anyhow" +version = "1.0.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" + +[[package]] +name = "bit_field" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cc" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f9fa1897e4325be0d68d48df6aa1a71ac2ed4d27723887e7754192705350730" + +[[package]] +name = "either" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" + +[[package]] +name = "errno" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin", +] + +[[package]] +name = "libc" +version = "0.2.153" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" + +[[package]] +name = "linux-raw-sys" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "proc-macro2" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6198999a900fd9cf051f2109ec3b9589b5c67cbfc77ff82c9fdff24aec83aa7b" + +[[package]] +name = "raw-cpuid" +version = "10.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c297679cb867470fa8c9f67dbba74a78d78e3e98d7cf2b08d6d71540f797332" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "rustix" +version = "0.38.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +dependencies = [ + "bitflags 2.4.2", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustversion" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" + +[[package]] +name = "scroll" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fda28d4b4830b807a8b43f7b0e6b5df875311b3e7621d84577188c175b6ec1ec" +dependencies = [ + "scroll_derive", +] + +[[package]] +name = "scroll_derive" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaaae8f38bb311444cfb7f1979af0bc9240d95795f75f9ceddf6a59b79ceffa0" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74f1bdc9872430ce9b75da68329d1c1746faf50ffac5f19e02b71e37ff881ffb" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "td-shim-metadata" +version = "0.1.0" +dependencies = [ + "anyhow", + "cc", + "lazy_static", + "log", + "r-efi", + "scroll", + "which", + "x86", + "x86_64", + "zerocopy", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "volatile" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "442887c63f2c839b346c192d047a7c87e73d0689c9157b00b53dcc27dd5ea793" + +[[package]] +name = "which" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bf3ea8596f3a0dd5980b46430f2058dfe2c36a27ccfbb1845d6fbfcd9ba6e14" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", + "windows-sys 0.48.0", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.3", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d380ba1dc7187569a8a9e91ed34b8ccfc33123bbacb8c0aed2d1ad7f3ef2dc5f" +dependencies = [ + "windows_aarch64_gnullvm 0.52.3", + "windows_aarch64_msvc 0.52.3", + "windows_i686_gnu 0.52.3", + "windows_i686_msvc 0.52.3", + "windows_x86_64_gnu 0.52.3", + "windows_x86_64_gnullvm 0.52.3", + "windows_x86_64_msvc 0.52.3", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68e5dcfb9413f53afd9c8f86e56a7b4d86d9a2fa26090ea2dc9e40fba56c6ec6" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dab469ebbc45798319e69eebf92308e541ce46760b49b18c6b3fe5e8965b30f" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a4e9b6a7cac734a8b4138a4e1044eac3404d8326b6c0f939276560687a033fb" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28b0ec9c422ca95ff34a78755cfa6ad4a51371da2a5ace67500cf7ca5f232c58" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "704131571ba93e89d7cd43482277d6632589b18ecf4468f591fbae0a8b101614" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42079295511643151e98d61c38c0acc444e52dd42ab456f7ccfd5152e8ecf21c" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0770833d60a970638e989b3fa9fd2bb1aaadcf88963d1659fd7d9990196ed2d6" + +[[package]] +name = "x86" +version = "0.47.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55b5be8cc34d017d8aabec95bc45a43d0f20e8b2a31a453cabc804fe996f8dca" +dependencies = [ + "bit_field", + "bitflags 1.3.2", + "raw-cpuid", +] + +[[package]] +name = "x86_64" +version = "0.14.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96cb6fd45bfeab6a5055c5bffdb08768bd0c069f1d946debe585bbb380a7c062" +dependencies = [ + "bit_field", + "bitflags 2.4.2", + "rustversion", + "volatile", +] + +[[package]] +name = "zerocopy" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.50", +] diff --git a/td-shim-interface/Cargo.toml b/td-shim-interface/Cargo.toml new file mode 100644 index 00000000..f8fd2564 --- /dev/null +++ b/td-shim-interface/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "td-shim-interface" +version = "0.1.0" +license = "BSD-2-Clause-Patent" +description = "TD-shim metadata data structures and related functions. UEFI Platform Initializaiton data structures and accessors" + +edition = "2018" +homepage = "https://github.com/confidential-containers/td-shim" +repository = "https://github.com/confidential-containers/td-shim" +readme = "README.md" +keywords = ["td-shim", "TDX", "intel"] + +[build-dependencies] +anyhow = "1.0.55" +cc = "1.0" +which = "5.0.0" + +[dependencies] +lazy_static = { version = "1.4.0", features = ["spin_no_std"] } +r-efi = "3.2.0" +scroll = { version = "0.10", default-features = false, features = ["derive"] } +zerocopy = { version = "0.7.31", features = ["derive"] } + +x86 = { version ="0.47.0", optional = true } +# Lock down to 0.44, otherwise it depends on inline asm +x86_64 = { version = "0.14.9", optional = true } + +log = "0.4.13" diff --git a/td-shim-interface/README.md b/td-shim-interface/README.md new file mode 100644 index 00000000..42b56df5 --- /dev/null +++ b/td-shim-interface/README.md @@ -0,0 +1,57 @@ +[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fconfidential-containers%2Ftd-shim.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fconfidential-containers%2Ftd-shim?ref=badge_shield) +# TD-shim - Confidential Containers Shim Firmware + +Hardware virtualization-based containers are designed to launch and run +containerized applications in hardware virtualized environments. While +containers usually run directly as bare-metal applications, using TD or VT as an +isolation layer from the host OS is used as a secure and efficient way of +building multi-tenant Cloud-native infrastructures (e.g. Kubernetes). + +In order to match the short start-up time and resource consumption overhead of +bare-metal containers, runtime architectures for TD- and VT-based containers put +a strong focus on minimizing boot time. They must also launch the container +payload as quickly as possible. Hardware virtualization-based containers +typically run on top of simplified and customized Linux kernels to minimize the +overall guest boot time. + +Simplified kernels typically have no UEFI dependencies and no ACPI ASL +support. This allows guests to boot without firmware dependencies. Current +VT-based container runtimes rely on VMMs that are capable of directly booting +into the guest kernel without loading firmware. + +TD Shim is a simplified [TDX virtual firmware](doc/tdshim_spec.md#vfw) for the +simplified kernel for TD container. This document describes a lightweight +interface between the TD Shim and TD VMM and between the TD Shim and the +simplified kernel. + +## Documents + +* [TD-Shim specification](doc/tdshim_spec.md) + +* Introduction [PDF](doc/td-shim-introduction.pdf) and [conference talk](https://fosdem.org/2023/schedule/event/cc_online_rust/) + +## Feature Introduction + +This td-shim-interface is to support user for creating data structures and functions required for td-shim, such as TdxMetadataDescriptor and TdxMetadataSection. Td-uefi-pi is used for UEFI Platform Initializaiton data structures and accessors. + +The data structure of TD HOB and related crate, such as: +``` +use td_shim_interface::{TD_ACPI_TABLE_HOB_GUID, TD_E820_TABLE_HOB_GUID, TD_PAYLOAD_INFO_HOB_GUID}; +use td_shim_interface::PayloadInfo; +use td_shim_interface::acpi; +use td_shim_interface::td_uefi_pi::{hob, pi, pi::guid} +``` + +This is a Shim Firmware to support [Intel TDX](https://software.intel.com/content/www/us/en/develop/articles/intel-trust-domain-extensions.html). + +The API specification is at [td-shim specification](doc/tdshim_spec.md). + +The secure boot specification for td-shim is at [secure boot specification](doc/secure_boot.md) + +The design is at [td-shim design](doc/design.md). + +The threat model analysis is at [td-shim threat model](doc/threat_model.md). + + +## License +[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fconfidential-containers%2Ftd-shim.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fconfidential-containers%2Ftd-shim?ref=badge_large) diff --git a/td-shim/src/acpi.rs b/td-shim-interface/src/acpi.rs similarity index 100% rename from td-shim/src/acpi.rs rename to td-shim-interface/src/acpi.rs diff --git a/td-uefi-pi/fuzz/Cargo.toml b/td-shim-interface/src/fuzz/Cargo.toml similarity index 100% rename from td-uefi-pi/fuzz/Cargo.toml rename to td-shim-interface/src/fuzz/Cargo.toml diff --git a/td-uefi-pi/fuzz/fuzz_targets/afl_cfv_parser.rs b/td-shim-interface/src/fuzz/fuzz_targets/afl_cfv_parser.rs similarity index 100% rename from td-uefi-pi/fuzz/fuzz_targets/afl_cfv_parser.rs rename to td-shim-interface/src/fuzz/fuzz_targets/afl_cfv_parser.rs diff --git a/td-uefi-pi/fuzz/fuzz_targets/afl_hob_parser.rs b/td-shim-interface/src/fuzz/fuzz_targets/afl_hob_parser.rs similarity index 100% rename from td-uefi-pi/fuzz/fuzz_targets/afl_hob_parser.rs rename to td-shim-interface/src/fuzz/fuzz_targets/afl_hob_parser.rs diff --git a/td-uefi-pi/fuzz/fuzz_targets/afl_payload_parser.rs b/td-shim-interface/src/fuzz/fuzz_targets/afl_payload_parser.rs similarity index 100% rename from td-uefi-pi/fuzz/fuzz_targets/afl_payload_parser.rs rename to td-shim-interface/src/fuzz/fuzz_targets/afl_payload_parser.rs diff --git a/td-uefi-pi/fuzz/fuzz_targets/cfv_parser.rs b/td-shim-interface/src/fuzz/fuzz_targets/cfv_parser.rs similarity index 100% rename from td-uefi-pi/fuzz/fuzz_targets/cfv_parser.rs rename to td-shim-interface/src/fuzz/fuzz_targets/cfv_parser.rs diff --git a/td-uefi-pi/fuzz/fuzz_targets/fuzzlib.rs b/td-shim-interface/src/fuzz/fuzz_targets/fuzzlib.rs similarity index 97% rename from td-uefi-pi/fuzz/fuzz_targets/fuzzlib.rs rename to td-shim-interface/src/fuzz/fuzz_targets/fuzzlib.rs index 7a21fd68..5e455be0 100644 --- a/td-uefi-pi/fuzz/fuzz_targets/fuzzlib.rs +++ b/td-shim-interface/src/fuzz/fuzz_targets/fuzzlib.rs @@ -6,7 +6,7 @@ use core::mem::size_of; use r_efi::efi::Guid; use std::vec::Vec; -use td_uefi_pi::{fv, hob, pi}; +use td_shim_interface::td_uefi_pi::{fv, hob, pi}; const EFI_END_OF_HOB_LIST_OFFSET: usize = 48; diff --git a/td-uefi-pi/fuzz/fuzz_targets/hob_parser.rs b/td-shim-interface/src/fuzz/fuzz_targets/hob_parser.rs similarity index 100% rename from td-uefi-pi/fuzz/fuzz_targets/hob_parser.rs rename to td-shim-interface/src/fuzz/fuzz_targets/hob_parser.rs diff --git a/td-uefi-pi/fuzz/fuzz_targets/payload_parser.rs b/td-shim-interface/src/fuzz/fuzz_targets/payload_parser.rs similarity index 100% rename from td-uefi-pi/fuzz/fuzz_targets/payload_parser.rs rename to td-shim-interface/src/fuzz/fuzz_targets/payload_parser.rs diff --git a/td-uefi-pi/fuzz/seeds/cfv_parser/cfv b/td-shim-interface/src/fuzz/seeds/cfv_parser/cfv similarity index 100% rename from td-uefi-pi/fuzz/seeds/cfv_parser/cfv rename to td-shim-interface/src/fuzz/seeds/cfv_parser/cfv diff --git a/td-uefi-pi/fuzz/seeds/hob_parser/hob_buffer b/td-shim-interface/src/fuzz/seeds/hob_parser/hob_buffer similarity index 100% rename from td-uefi-pi/fuzz/seeds/hob_parser/hob_buffer rename to td-shim-interface/src/fuzz/seeds/hob_parser/hob_buffer diff --git a/td-uefi-pi/fuzz/seeds/payload_parser/fv_buffer b/td-shim-interface/src/fuzz/seeds/payload_parser/fv_buffer similarity index 100% rename from td-uefi-pi/fuzz/seeds/payload_parser/fv_buffer rename to td-shim-interface/src/fuzz/seeds/payload_parser/fv_buffer diff --git a/td-shim-interface/src/lib.rs b/td-shim-interface/src/lib.rs new file mode 100644 index 00000000..2e9fc13c --- /dev/null +++ b/td-shim-interface/src/lib.rs @@ -0,0 +1,134 @@ +// Copyright (c) 2022 Alibaba Cloud +// +// SPDX-License-Identifier: BSD-2-Clause-Patent + +#![no_std] + +use scroll::{Pread, Pwrite}; + +pub mod acpi; +pub mod metadata; +pub mod td_uefi_pi; + +use td_uefi_pi::pi::{self, guid}; + +// This GUID is used for ACPI GUID Extension HOB +// Please refer to: +// https://github.com/confidential-containers/td-shim/blob/main/doc/tdshim_spec.md#acpi-guid-extension-hob +pub const TD_ACPI_TABLE_HOB_GUID: guid::Guid = guid::Guid::from_fields( + 0x6a0c5870, + 0xd4ed, + 0x44f4, + [0xa1, 0x35, 0xdd, 0x23, 0x8b, 0x6f, 0xc, 0x8d], +); + +// This GUID is used for TD Payload Info GUID Extension HOB +// Please refer to: +// https://github.com/confidential-containers/td-shim/blob/main/doc/tdshim_spec.md#td-payload-info-guid-extension-hob +pub const TD_PAYLOAD_INFO_HOB_GUID: guid::Guid = guid::Guid::from_fields( + 0xb96fa412, + 0x461f, + 0x4be3, + [0x8c, 0xd, 0xad, 0x80, 0x5a, 0x49, 0x7a, 0xc0], +); + +// This GUID is used for E820 Memory Map GUID Extension HOB +// Please refer to: +// https://github.com/confidential-containers/td-shim/blob/main/doc/tdshim_spec.md#e820-memory-map-guid-extension-hob +pub const TD_E820_TABLE_HOB_GUID: pi::guid::Guid = pi::guid::Guid::from_fields( + 0x8f8072ea, + 0x3486, + 0x4b47, + [0x86, 0xa7, 0x23, 0x53, 0xb8, 0x8a, 0x87, 0x73], +); + +#[repr(u32)] +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum TdPayloadInfoHobType { + /// Payload Binary is a PE/COFF or ELF executable image as payload. + /// + /// Entrypoint can be found by parsing the image header. This type image does not follow + /// Linux boot protocol. A payload HOB is used to pass data from TdShim to payload. + ExecutablePayload = 0, + + /// Payload Binary is bzImage, follow Linux boot protocol. + /// + /// The first 512 bytes are boot_param. (zero page). The entrypoint is start address of loaded + /// 64bit Linux kernel plus 0x200 + BzImage, + + /// Payload Binary is VMM loaded vmLinux, follow Linux boot protocol. + /// + /// The entrypoint is defined at HOB_PAYLOAD_INFO_TABLE.Entrypoint. + RawVmLinux, + + /// Unknown Image type + UnknownImage = u32::MAX, +} + +impl From<&TdPayloadInfoHobType> for u32 { + fn from(v: &TdPayloadInfoHobType) -> Self { + *v as u32 + } +} + +impl From for TdPayloadInfoHobType { + fn from(v: u32) -> Self { + match v { + 0 => TdPayloadInfoHobType::ExecutablePayload, + 1 => TdPayloadInfoHobType::BzImage, + 2 => TdPayloadInfoHobType::RawVmLinux, + _ => TdPayloadInfoHobType::UnknownImage, + } + } +} + +#[repr(C)] +#[derive(Default, Clone, Copy, Pread, Pwrite)] +pub struct PayloadInfo { + pub image_type: u32, + pub reserved: u32, + pub entry_point: u64, +} + +/// Write three bytes from an integer value into the buffer. +pub fn write_u24(data: u32, buf: &mut [u8; 3]) { + assert!(data <= 0xffffff); + buf[0] = (data & 0xFF) as u8; + buf[1] = ((data >> 8) & 0xFF) as u8; + buf[2] = ((data >> 16) & 0xFF) as u8; +} + +// To protect against speculative attacks, place the LFENCE instruction after the range +// check and branch, but before any code that consumes the checked value. +pub fn speculation_barrier() { + unsafe { core::arch::asm!("lfence") } +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_tdpayload_info_hob_type() { + assert_eq!( + TdPayloadInfoHobType::from(0), + TdPayloadInfoHobType::ExecutablePayload + ); + assert_eq!(TdPayloadInfoHobType::from(1), TdPayloadInfoHobType::BzImage); + assert_eq!( + TdPayloadInfoHobType::from(2), + TdPayloadInfoHobType::RawVmLinux + ); + assert_eq!( + TdPayloadInfoHobType::from(3), + TdPayloadInfoHobType::UnknownImage + ); + } + + #[test] + fn test_write_u24() { + let mut buf: [u8; 3] = [0; 3]; + write_u24(0xffffff, &mut buf); + } +} diff --git a/td-shim/src/metadata.rs b/td-shim-interface/src/metadata.rs similarity index 99% rename from td-shim/src/metadata.rs rename to td-shim-interface/src/metadata.rs index 7a7fb34a..3b0bbabe 100644 --- a/td-shim/src/metadata.rs +++ b/td-shim-interface/src/metadata.rs @@ -4,10 +4,10 @@ extern crate alloc; +use crate::td_uefi_pi::pi::guid::Guid; use alloc::string::String; use core::{ptr::slice_from_raw_parts, str::FromStr}; use scroll::{Pread, Pwrite}; -use td_uefi_pi::pi::guid::Guid; /// TDX Metadata GUID defined in td-shim specification pub const TDX_METADATA_GUID_STR: &str = "E9EAF9F3-168E-44D5-A8EB-7F4D8738F6AE"; diff --git a/td-uefi-pi/Cargo.toml b/td-shim-interface/src/td_uefi_pi/Cargo.toml similarity index 100% rename from td-uefi-pi/Cargo.toml rename to td-shim-interface/src/td_uefi_pi/Cargo.toml diff --git a/td-uefi-pi/src/fv.rs b/td-shim-interface/src/td_uefi_pi/fv.rs similarity index 100% rename from td-uefi-pi/src/fv.rs rename to td-shim-interface/src/td_uefi_pi/fv.rs diff --git a/td-uefi-pi/src/hob.rs b/td-shim-interface/src/td_uefi_pi/hob.rs similarity index 100% rename from td-uefi-pi/src/hob.rs rename to td-shim-interface/src/td_uefi_pi/hob.rs diff --git a/td-uefi-pi/src/lib.rs b/td-shim-interface/src/td_uefi_pi/mod.rs similarity index 99% rename from td-uefi-pi/src/lib.rs rename to td-shim-interface/src/td_uefi_pi/mod.rs index 0aef5ef4..30c350ca 100644 --- a/td-uefi-pi/src/lib.rs +++ b/td-shim-interface/src/td_uefi_pi/mod.rs @@ -21,7 +21,6 @@ //! //! Constants and data structures defined by [UEFI PI Spec] are hosted by [crate::pi], functions //! to access them are hosted by [crate::fv] and [crate::hob]. -#![no_std] pub mod fv; pub mod hob; diff --git a/td-uefi-pi/src/pi/boot_mode.rs b/td-shim-interface/src/td_uefi_pi/pi/boot_mode.rs similarity index 100% rename from td-uefi-pi/src/pi/boot_mode.rs rename to td-shim-interface/src/td_uefi_pi/pi/boot_mode.rs diff --git a/td-uefi-pi/src/pi/fv.rs b/td-shim-interface/src/td_uefi_pi/pi/fv.rs similarity index 100% rename from td-uefi-pi/src/pi/fv.rs rename to td-shim-interface/src/td_uefi_pi/pi/fv.rs diff --git a/td-uefi-pi/src/pi/guid.rs b/td-shim-interface/src/td_uefi_pi/pi/guid.rs similarity index 100% rename from td-uefi-pi/src/pi/guid.rs rename to td-shim-interface/src/td_uefi_pi/pi/guid.rs diff --git a/td-uefi-pi/src/pi/hob.rs b/td-shim-interface/src/td_uefi_pi/pi/hob.rs similarity index 100% rename from td-uefi-pi/src/pi/hob.rs rename to td-shim-interface/src/td_uefi_pi/pi/hob.rs diff --git a/td-uefi-pi/src/pi/mod.rs b/td-shim-interface/src/td_uefi_pi/pi/mod.rs similarity index 100% rename from td-uefi-pi/src/pi/mod.rs rename to td-shim-interface/src/td_uefi_pi/pi/mod.rs diff --git a/td-shim-tools/Cargo.toml b/td-shim-tools/Cargo.toml index a4e7f572..5a55b177 100644 --- a/td-shim-tools/Cargo.toml +++ b/td-shim-tools/Cargo.toml @@ -42,7 +42,7 @@ regex = "1" scroll = { version = "0.10", default-features = false, features = ["derive"]} td-layout = { path = "../td-layout" } td-shim = { path = "../td-shim", default-features = false } -td-uefi-pi = { path = "../td-uefi-pi" } +td-shim-interface = { path = "../td-shim-interface" } cfg-if = "1.0" anyhow = { version = "1.0.68", optional = true } diff --git a/td-shim-tools/src/bin/td-shim-checker/main.rs b/td-shim-tools/src/bin/td-shim-checker/main.rs index 8046171e..13763c78 100644 --- a/td-shim-tools/src/bin/td-shim-checker/main.rs +++ b/td-shim-tools/src/bin/td-shim-checker/main.rs @@ -10,7 +10,7 @@ use log::{error, LevelFilter}; use std::str::FromStr; use std::vec::Vec; use std::{env, io}; -use td_shim::metadata::{TdxMetadataDescriptor, TdxMetadataSection}; +use td_shim_interface::metadata::{TdxMetadataDescriptor, TdxMetadataSection}; use td_shim_tools::loader::TdShimLoader; struct Config { diff --git a/td-shim-tools/src/bin/td-shim-enroll/main.rs b/td-shim-tools/src/bin/td-shim-enroll/main.rs index 3b536a69..8f2a5d05 100644 --- a/td-shim-tools/src/bin/td-shim-enroll/main.rs +++ b/td-shim-tools/src/bin/td-shim-enroll/main.rs @@ -11,9 +11,9 @@ use std::path::PathBuf; use std::str::FromStr; use std::vec::Vec; use std::{env, io, path::Path}; +use td_shim_interface::td_uefi_pi::pi::guid; use td_shim_tools::enroller::{create_key_file, enroll_files, FirmwareRawFile}; use td_shim_tools::InputData; -use td_uefi_pi::pi::guid; const TDSHIM_SB_NAME: &str = "final.sb.bin"; struct Config { diff --git a/td-shim-tools/src/enroller.rs b/td-shim-tools/src/enroller.rs index 50605337..9af2eae7 100644 --- a/td-shim-tools/src/enroller.rs +++ b/td-shim-tools/src/enroller.rs @@ -18,7 +18,7 @@ use td_shim::secure_boot::{ PUBKEY_FILE_STRUCT_VERSION_V1, PUBKEY_HASH_ALGORITHM_SHA384, }; use td_shim::write_u24; -use td_uefi_pi::pi::fv::{ +use td_shim_interface::td_uefi_pi::pi::fv::{ FIRMWARE_FILE_SYSTEM3_GUID, FVH_REVISION, FVH_SIGNATURE, FV_FILETYPE_RAW, }; @@ -298,7 +298,7 @@ mod test { use std::str::FromStr; use super::*; - use td_uefi_pi::pi::guid; + use td_shim_interface::td_uefi_pi::pi::guid; fn read_u24(data: &[u8]) -> u32 { let mut num = data[0] as u32; diff --git a/td-shim-tools/src/linker.rs b/td-shim-tools/src/linker.rs index 357e66e6..0b6a3b49 100644 --- a/td-shim-tools/src/linker.rs +++ b/td-shim-tools/src/linker.rs @@ -20,10 +20,10 @@ use td_shim::fv::{ FvFfsFileHeader, FvFfsSectionHeader, FvHeader, IplFvFfsHeader, IplFvFfsSectionHeader, IplFvHeader, }; -use td_shim::metadata::{TdxMetadataGuid, TdxMetadataPtr}; use td_shim::reset_vector::{ResetVectorHeader, ResetVectorParams}; use td_shim::write_u24; -use td_uefi_pi::pi::fv::{ +use td_shim_interface::metadata::{TdxMetadataGuid, TdxMetadataPtr}; +use td_shim_interface::td_uefi_pi::pi::fv::{ FfsFileHeader, FVH_REVISION, FVH_SIGNATURE, FV_FILETYPE_DXE_CORE, FV_FILETYPE_SECURITY_CORE, SECTION_PE32, }; diff --git a/td-shim-tools/src/loader.rs b/td-shim-tools/src/loader.rs index dca17dbb..9a63945a 100644 --- a/td-shim-tools/src/loader.rs +++ b/td-shim-tools/src/loader.rs @@ -9,7 +9,7 @@ use std::fs; use std::io; use std::io::Read; use std::io::Seek; -use td_shim::metadata::{ +use td_shim_interface::metadata::{ self, TdxMetadataDescriptor, TdxMetadataGuid, TdxMetadataSection, TDX_METADATA_DESCRIPTOR_LEN, TDX_METADATA_GUID_LEN, TDX_METADATA_OFFSET, TDX_METADATA_SECTION_LEN, }; diff --git a/td-shim-tools/src/metadata.rs b/td-shim-tools/src/metadata.rs index 896960bc..ab1c5ad5 100644 --- a/td-shim-tools/src/metadata.rs +++ b/td-shim-tools/src/metadata.rs @@ -7,14 +7,14 @@ use serde::{de, Deserialize}; use std::{mem::size_of, vec::Vec}; use td_layout::build_time::*; use td_layout::runtime::*; -use td_shim::metadata::{ +use td_shim_interface::metadata::{ TdxMetadataDescriptor, TDX_METADATA_GUID, TDX_METADATA_SECTION_TYPE_BFV, TDX_METADATA_SECTION_TYPE_CFV, TDX_METADATA_SECTION_TYPE_PAYLOAD, TDX_METADATA_SECTION_TYPE_PAYLOAD_PARAM, TDX_METADATA_SECTION_TYPE_PERM_MEM, TDX_METADATA_SECTION_TYPE_TD_HOB, TDX_METADATA_SECTION_TYPE_TD_INFO, TDX_METADATA_SECTION_TYPE_TEMP_MEM, TDX_METADATA_SIGNATURE, TDX_METADATA_VERSION, }; -use td_uefi_pi::pi::guid::Guid; +use td_shim_interface::td_uefi_pi::pi::guid::Guid; use crate::linker::PayloadType; @@ -101,7 +101,7 @@ impl MetadataSections { } fn basic_metadata_sections(payload_type: PayloadType) -> MetadataSections { - use td_shim::metadata::TDX_METADATA_ATTRIBUTES_EXTENDMR; + use td_shim_interface::metadata::TDX_METADATA_ATTRIBUTES_EXTENDMR; let mut metadata_sections = MetadataSections::new(); diff --git a/td-shim-tools/src/tee_info_hash.rs b/td-shim-tools/src/tee_info_hash.rs index ef4e11d0..3e7dabc5 100644 --- a/td-shim-tools/src/tee_info_hash.rs +++ b/td-shim-tools/src/tee_info_hash.rs @@ -14,7 +14,7 @@ use std::io::Read; use std::io::Seek; use std::io::SeekFrom; use std::mem::size_of; -use td_shim::metadata::*; +use td_shim_interface::metadata::*; use zeroize::Zeroize; pub const SHA384_DIGEST_SIZE: usize = 0x30; diff --git a/td-shim/Cargo.toml b/td-shim/Cargo.toml index 5f3f429d..f31e2b80 100644 --- a/td-shim/Cargo.toml +++ b/td-shim/Cargo.toml @@ -23,7 +23,7 @@ lazy_static = { version = "1.4.0", features = ["spin_no_std"] } r-efi = "3.2.0" scroll = { version = "0.10", default-features = false, features = ["derive"] } td-layout = { path = "../td-layout" } -td-uefi-pi = { path = "../td-uefi-pi" } +td-shim-interface = { path = "../td-shim-interface" } cc-measurement = { path = "../cc-measurement" } zerocopy = { version = "0.7.31", features = ["derive"] } diff --git a/td-shim/src/bin/td-shim/acpi.rs b/td-shim/src/bin/td-shim/acpi.rs index 980d5182..cab14141 100644 --- a/td-shim/src/bin/td-shim/acpi.rs +++ b/td-shim/src/bin/td-shim/acpi.rs @@ -5,7 +5,7 @@ extern crate alloc; use alloc::vec::Vec; -use td_shim::acpi::{calculate_checksum, Rsdp, Xsdt}; +use td_shim_interface::acpi::{calculate_checksum, Rsdp, Xsdt}; use super::*; diff --git a/td-shim/src/bin/td-shim/main.rs b/td-shim/src/bin/td-shim/main.rs index 3028f791..43ed88c1 100644 --- a/td-shim/src/bin/td-shim/main.rs +++ b/td-shim/src/bin/td-shim/main.rs @@ -30,13 +30,13 @@ use cc_measurement::{log::CcEventLogWriter, EV_EFI_HANDOFF_TABLES2, EV_PLATFORM_ use td_layout::build_time::{self, *}; use td_layout::memslice::{self, SliceType}; use td_layout::RuntimeMemoryLayout; -use td_shim::acpi::{Ccel, GenericSdtHeader}; use td_shim::event_log::{log_hob_list, log_payload_binary, log_payload_parameter}; use td_shim::{ speculation_barrier, PayloadInfo, TdPayloadInfoHobType, TD_ACPI_TABLE_HOB_GUID, TD_PAYLOAD_INFO_HOB_GUID, }; -use td_uefi_pi::{fv, hob, pi}; +use td_shim_interface::acpi::{Ccel, GenericSdtHeader}; +use td_shim_interface::td_uefi_pi::{fv, hob, pi}; use crate::ipl::ExecutablePayloadType; use crate::shim_info::{BootTimeDynamic, BootTimeStatic}; diff --git a/td-shim/src/bin/td-shim/memory.rs b/td-shim/src/bin/td-shim/memory.rs index ed454500..2283b86d 100644 --- a/td-shim/src/bin/td-shim/memory.rs +++ b/td-shim/src/bin/td-shim/memory.rs @@ -8,8 +8,8 @@ use td_layout::memslice::SliceType; use td_layout::{build_time::*, runtime::*, *}; use td_shim::e820::{E820Entry, E820Type}; use td_shim::{PayloadInfo, TdPayloadInfoHobType}; -use td_uefi_pi::hob; -use td_uefi_pi::pi::hob::{ +use td_shim_interface::td_uefi_pi::hob; +use td_shim_interface::td_uefi_pi::pi::hob::{ ResourceDescription, RESOURCE_MEMORY_RESERVED, RESOURCE_MEMORY_UNACCEPTED, RESOURCE_SYSTEM_MEMORY, }; @@ -284,7 +284,7 @@ impl<'a> Memory<'a> { #[cfg(feature = "tdx")] fn accept_memory_resources(resources: &mut Vec) { use td_layout::TD_PAYLOAD_PARTIAL_ACCEPT_MEMORY_SIZE; - use td_uefi_pi::pi; + use td_shim_interface::td_uefi_pi::pi; // The physical address must not exceed the shared mask (the last bit of GPAW). let (index, max_phys_addr) = resources diff --git a/td-shim/src/bin/td-shim/mp.rs b/td-shim/src/bin/td-shim/mp.rs index c7a4fa52..f9465508 100644 --- a/td-shim/src/bin/td-shim/mp.rs +++ b/td-shim/src/bin/td-shim/mp.rs @@ -6,7 +6,7 @@ use core::convert::TryInto; use core::mem::size_of; use zerocopy::{AsBytes, FromBytes, FromZeroes}; -use td_shim::acpi::{self, GenericSdtHeader}; +use td_shim_interface::acpi::{self, GenericSdtHeader}; // 255 vCPUs needs 2278 bytes, refer to create_madt(). const MADT_MAX_SIZE: usize = 0xc00; diff --git a/td-shim/src/bin/td-shim/payload_hob.rs b/td-shim/src/bin/td-shim/payload_hob.rs index 24727fd0..7b474490 100644 --- a/td-shim/src/bin/td-shim/payload_hob.rs +++ b/td-shim/src/bin/td-shim/payload_hob.rs @@ -11,8 +11,8 @@ use td_layout::build_time::*; use td_layout::runtime::*; use td_shim::e820::E820Type; use td_shim::{TD_ACPI_TABLE_HOB_GUID, TD_E820_TABLE_HOB_GUID}; -use td_uefi_pi::pi::hob::ResourceDescription; -use td_uefi_pi::{hob, pi, pi::guid}; +use td_shim_interface::td_uefi_pi::pi::hob::ResourceDescription; +use td_shim_interface::td_uefi_pi::{hob, pi, pi::guid}; #[derive(Debug)] pub enum PayloadHobError { diff --git a/td-shim/src/bin/td-shim/shim_info.rs b/td-shim/src/bin/td-shim/shim_info.rs index 9f0deffe..30e10686 100644 --- a/td-shim/src/bin/td-shim/shim_info.rs +++ b/td-shim/src/bin/td-shim/shim_info.rs @@ -9,14 +9,14 @@ use log::error; use scroll::{Pread, Pwrite}; use td_layout::build_time::{TD_SHIM_FIRMWARE_BASE, TD_SHIM_FIRMWARE_SIZE}; use td_layout::memslice; -use td_shim::metadata::*; use td_shim::speculation_barrier; use td_shim::{ PayloadInfo, TdPayloadInfoHobType, TD_ACPI_TABLE_HOB_GUID, TD_PAYLOAD_INFO_HOB_GUID, }; -use td_uefi_pi::pi::guid::Guid; -use td_uefi_pi::pi::hob::*; -use td_uefi_pi::{fv, hob, pi}; +use td_shim_interface::metadata::*; +use td_shim_interface::td_uefi_pi::pi::guid::Guid; +use td_shim_interface::td_uefi_pi::pi::hob::*; +use td_shim_interface::td_uefi_pi::{fv, hob, pi}; pub struct BootTimeStatic { sections: Vec, diff --git a/td-shim/src/fv.rs b/td-shim/src/fv.rs index c0f960e2..dc2767f1 100644 --- a/td-shim/src/fv.rs +++ b/td-shim/src/fv.rs @@ -8,7 +8,7 @@ use core::ptr::slice_from_raw_parts; use r_efi::efi::Guid; use scroll::{Pread, Pwrite}; -use td_uefi_pi::pi::fv::{ +use td_shim_interface::td_uefi_pi::pi::fv::{ Checksum, CommonSectionHeader, FfsFileHeader, FirmwareVolumeExtHeader, FirmwareVolumeHeader, FvBlockMap, FIRMWARE_FILE_SYSTEM2_GUID, FVH_SIGNATURE, FV_FILETYPE_FFS_PAD, }; diff --git a/td-shim/src/lib.rs b/td-shim/src/lib.rs index 03acda48..b2a2b141 100644 --- a/td-shim/src/lib.rs +++ b/td-shim/src/lib.rs @@ -6,13 +6,11 @@ use scroll::{Pread, Pwrite}; -use td_uefi_pi::pi::{self, guid}; +use td_shim_interface::td_uefi_pi::pi::{self, guid}; -pub mod acpi; pub mod e820; pub mod event_log; pub mod fv; -pub mod metadata; pub mod reset_vector; #[cfg(feature = "secure-boot")] diff --git a/td-shim/src/reset_vector.rs b/td-shim/src/reset_vector.rs index 4da0e187..328de5bf 100644 --- a/td-shim/src/reset_vector.rs +++ b/td-shim/src/reset_vector.rs @@ -8,7 +8,9 @@ use core::ptr::slice_from_raw_parts; use r_efi::efi::Guid; use scroll::{Pread, Pwrite}; use td_layout::build_time::TD_SHIM_RESET_VECTOR_SIZE; -use td_uefi_pi::pi::fv::{CommonSectionHeader, FfsFileHeader, FV_FILETYPE_RAW, SECTION_RAW}; +use td_shim_interface::td_uefi_pi::pi::fv::{ + CommonSectionHeader, FfsFileHeader, FV_FILETYPE_RAW, SECTION_RAW, +}; use crate::write_u24; diff --git a/td-shim/src/secure_boot.rs b/td-shim/src/secure_boot.rs index 0587a73d..50db53e5 100644 --- a/td-shim/src/secure_boot.rs +++ b/td-shim/src/secure_boot.rs @@ -21,7 +21,7 @@ use ring::{ signature::{self, UnparsedPublicKey, VerificationAlgorithm}, }; use scroll::{Pread, Pwrite}; -use td_uefi_pi::{fv, pi}; +use td_shim_interface::td_uefi_pi::{fv, pi}; /// GUID for secure boot trust anchor in the Configuration Firmware Volume (CFV). pub const CFV_FFS_HEADER_TRUST_ANCHOR_GUID: Guid = Guid::from_fields( diff --git a/tests/test-td-payload/Cargo.toml b/tests/test-td-payload/Cargo.toml index 31264841..1fa6cda8 100644 --- a/tests/test-td-payload/Cargo.toml +++ b/tests/test-td-payload/Cargo.toml @@ -13,7 +13,7 @@ r-efi = "3.2.0" linked_list_allocator = "0.10.4" log = "0.4.13" cc-measurement = { path = "../../cc-measurement" } -td-uefi-pi = { path = "../../td-uefi-pi" } +td-shim-interface = { path = "../../td-shim-interface" } tdx-tdcall = { path = "../../tdx-tdcall" , optional = true } td-logger = { path = "../../td-logger" } td-layout = { path = "../../td-layout" } diff --git a/tests/test-td-payload/src/main.rs b/tests/test-td-payload/src/main.rs index 10cb1313..e54305c6 100644 --- a/tests/test-td-payload/src/main.rs +++ b/tests/test-td-payload/src/main.rs @@ -52,7 +52,7 @@ use td_payload as _; use td_payload::print; use td_shim::e820::{E820Entry, E820Type}; use td_shim::{TD_ACPI_TABLE_HOB_GUID, TD_E820_TABLE_HOB_GUID}; -use td_uefi_pi::{fv, hob, pi}; +use td_shim_interface::td_uefi_pi::{fv, hob, pi}; use zerocopy::FromBytes; const E820_TABLE_SIZE: usize = 128; diff --git a/tests/test-td-payload/src/testacpi.rs b/tests/test-td-payload/src/testacpi.rs index 00b0bfb2..0c688f97 100644 --- a/tests/test-td-payload/src/testacpi.rs +++ b/tests/test-td-payload/src/testacpi.rs @@ -12,9 +12,9 @@ use core::ffi::c_void; use core::mem::size_of; use serde::{Deserialize, Serialize}; use td_payload::hob::get_hob; -use td_shim::acpi::GenericSdtHeader; use td_shim::TD_ACPI_TABLE_HOB_GUID; -use td_uefi_pi::hob; +use td_shim_interface::acpi::GenericSdtHeader; +use td_shim_interface::td_uefi_pi::hob; use zerocopy::{AsBytes, FromBytes}; #[derive(Debug, Serialize, Deserialize)] diff --git a/tests/test-td-payload/src/testmemmap.rs b/tests/test-td-payload/src/testmemmap.rs index 3816b484..f7b10a51 100644 --- a/tests/test-td-payload/src/testmemmap.rs +++ b/tests/test-td-payload/src/testmemmap.rs @@ -15,7 +15,7 @@ use serde::{Deserialize, Serialize}; use td_payload::hob::get_hob; use td_shim::e820::{self, E820Entry, E820Type}; use td_shim::TD_E820_TABLE_HOB_GUID; -use td_uefi_pi::hob; +use td_shim_interface::td_uefi_pi::hob; use zerocopy::{AsBytes, FromBytes}; #[derive(Debug, Serialize, Deserialize)] diff --git a/tests/test-td-payload/src/testtrustedboot.rs b/tests/test-td-payload/src/testtrustedboot.rs index 9864eec9..072a6c8f 100644 --- a/tests/test-td-payload/src/testtrustedboot.rs +++ b/tests/test-td-payload/src/testtrustedboot.rs @@ -12,10 +12,10 @@ use core::{convert::TryInto, ffi::c_void, mem::size_of}; use ring::digest; use scroll::Pread; use td_payload::hob::get_hob; -use td_shim::acpi::{Ccel, GenericSdtHeader}; use td_shim::event_log::CCEL_CC_TYPE_TDX; use td_shim::TD_ACPI_TABLE_HOB_GUID; -use td_uefi_pi::hob; +use td_shim_interface::acpi::{Ccel, GenericSdtHeader}; +use td_shim_interface::td_uefi_pi::hob; use tdx_tdcall::tdreport; use zerocopy::{AsBytes, FromBytes};