From 60435b9f76b0f8fce41135346554f1fdf5888e54 Mon Sep 17 00:00:00 2001 From: Ernesto Ocampo Date: Tue, 9 Apr 2024 13:37:56 +0000 Subject: [PATCH] Build oak_sev_guest and sev_serial with Bazel Change-Id: Iee7c8d75aff667b8f1db68883091216d94230a7a --- Cargo.bazel.lock | 47 +++++++ WORKSPACE | 2 + cargo-bazel-lock.json | 290 +++++++++++++++++++++++++++++++++++++++++- oak_sev_guest/BUILD | 39 ++++++ sev_serial/BUILD | 31 +++++ 5 files changed, 408 insertions(+), 1 deletion(-) create mode 100644 oak_sev_guest/BUILD create mode 100644 sev_serial/BUILD diff --git a/Cargo.bazel.lock b/Cargo.bazel.lock index d95311e75a3..36370d7a71b 100644 --- a/Cargo.bazel.lock +++ b/Cargo.bazel.lock @@ -87,6 +87,12 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +[[package]] +name = "bit_field" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61" + [[package]] name = "bitflags" version = "2.5.0" @@ -349,11 +355,13 @@ dependencies = [ "serde", "serde_json", "sha2", + "snafu", "spinning_top", "static_assertions", "strum", "time", "x509-cert", + "x86_64", "zerocopy", "zeroize", ] @@ -1132,6 +1140,27 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +[[package]] +name = "snafu" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75976f4748ab44f6e5332102be424e7c2dc18daeaf7e725f2040c3ebb133512e" +dependencies = [ + "snafu-derive", +] + +[[package]] +name = "snafu-derive" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4b19911debfb8c2fb1107bc6cb2d61868aaf53a988449213959bb1b5b1ed95f" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "spin" version = "0.5.2" @@ -1272,6 +1301,12 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "volatile" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "442887c63f2c839b346c192d047a7c87e73d0689c9157b00b53dcc27dd5ea793" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -1377,6 +1412,18 @@ dependencies = [ "spki", ] +[[package]] +name = "x86_64" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bc79523af8abf92fb1a970c3e086c5a343f6bcc1a0eb890f575cbb3b45743df" +dependencies = [ + "bit_field", + "bitflags", + "rustversion", + "volatile", +] + [[package]] name = "zerocopy" version = "0.7.32" diff --git a/WORKSPACE b/WORKSPACE index db38c709d02..14dbaa677b0 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -454,6 +454,7 @@ crates_repository( default_features = False, version = "*", ), + "snafu": crate.spec(version = "*"), "spinning_top": crate.spec(version = "*"), "static_assertions": crate.spec(version = "*"), "strum": crate.spec( @@ -474,6 +475,7 @@ crates_repository( features = ["pem"], version = "0.2.5", ), + "x86_64": crate.spec(version = "*"), "zerocopy": crate.spec( default_features = False, features = ["derive"], diff --git a/cargo-bazel-lock.json b/cargo-bazel-lock.json index 82dc3911d01..87b639078ce 100644 --- a/cargo-bazel-lock.json +++ b/cargo-bazel-lock.json @@ -1,5 +1,5 @@ { - "checksum": "f54fb811f525992881af16b92e3ff01179325e0e0b58d2629086625e10d0cae7", + "checksum": "967533bb81a653f366fc2502c26407b5044c39ae8aea4a3f336d1ed582cfa00b", "crates": { "aead 0.5.2": { "name": "aead", @@ -561,6 +561,45 @@ ], "license_file": "LICENSE-APACHE" }, + "bit_field 0.10.2": { + "name": "bit_field", + "version": "0.10.2", + "package_url": "https://github.com/phil-opp/rust-bit-field", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/bit_field/0.10.2/download", + "sha256": "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61" + } + }, + "targets": [ + { + "Library": { + "crate_name": "bit_field", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": false, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "bit_field", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2015", + "version": "0.10.2" + }, + "license": "Apache-2.0/MIT", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, "bitflags 2.5.0": { "name": "bitflags", "version": "2.5.0", @@ -2101,6 +2140,10 @@ "id": "sha2 0.10.8", "target": "sha2" }, + { + "id": "snafu 0.8.2", + "target": "snafu" + }, { "id": "spinning_top 0.3.0", "target": "spinning_top" @@ -2121,6 +2164,10 @@ "id": "x509-cert 0.2.5", "target": "x509_cert" }, + { + "id": "x86_64 0.15.1", + "target": "x86_64" + }, { "id": "zerocopy 0.7.32", "target": "zerocopy" @@ -7032,6 +7079,129 @@ ], "license_file": "LICENSE-APACHE" }, + "snafu 0.8.2": { + "name": "snafu", + "version": "0.8.2", + "package_url": "https://github.com/shepmaster/snafu", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/snafu/0.8.2/download", + "sha256": "75976f4748ab44f6e5332102be424e7c2dc18daeaf7e725f2040c3ebb133512e" + } + }, + "targets": [ + { + "Library": { + "crate_name": "snafu", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": false, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "snafu", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "default", + "rust_1_61", + "rust_1_65", + "std" + ], + "selects": {} + }, + "edition": "2018", + "proc_macro_deps": { + "common": [ + { + "id": "snafu-derive 0.8.2", + "target": "snafu_derive" + } + ], + "selects": {} + }, + "version": "0.8.2" + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, + "snafu-derive 0.8.2": { + "name": "snafu-derive", + "version": "0.8.2", + "package_url": "https://github.com/shepmaster/snafu", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/snafu-derive/0.8.2/download", + "sha256": "b4b19911debfb8c2fb1107bc6cb2d61868aaf53a988449213959bb1b5b1ed95f" + } + }, + "targets": [ + { + "ProcMacro": { + "crate_name": "snafu_derive", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": false, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "snafu_derive", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "rust_1_61" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "heck 0.4.1", + "target": "heck" + }, + { + "id": "proc-macro2 1.0.79", + "target": "proc_macro2" + }, + { + "id": "quote 1.0.35", + "target": "quote" + }, + { + "id": "syn 2.0.58", + "target": "syn" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "0.8.2" + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, "spin 0.5.2": { "name": "spin", "version": "0.5.2", @@ -7872,6 +8042,45 @@ ], "license_file": "LICENSE-APACHE" }, + "volatile 0.4.6": { + "name": "volatile", + "version": "0.4.6", + "package_url": "https://github.com/rust-osdev/volatile", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/volatile/0.4.6/download", + "sha256": "442887c63f2c839b346c192d047a7c87e73d0689c9157b00b53dcc27dd5ea793" + } + }, + "targets": [ + { + "Library": { + "crate_name": "volatile", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": false, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "volatile", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2015", + "version": "0.4.6" + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, "wasi 0.11.0+wasi-snapshot-preview1": { "name": "wasi", "version": "0.11.0+wasi-snapshot-preview1", @@ -8683,6 +8892,83 @@ ], "license_file": "LICENSE-APACHE" }, + "x86_64 0.15.1": { + "name": "x86_64", + "version": "0.15.1", + "package_url": "https://github.com/rust-osdev/x86_64", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/x86_64/0.15.1/download", + "sha256": "4bc79523af8abf92fb1a970c3e086c5a343f6bcc1a0eb890f575cbb3b45743df" + } + }, + "targets": [ + { + "Library": { + "crate_name": "x86_64", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": false, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "x86_64", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "abi_x86_interrupt", + "asm_const", + "const_fn", + "default", + "instructions", + "nightly", + "step_trait" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "bit_field 0.10.2", + "target": "bit_field" + }, + { + "id": "bitflags 2.5.0", + "target": "bitflags" + }, + { + "id": "volatile 0.4.6", + "target": "volatile" + } + ], + "selects": {} + }, + "edition": "2018", + "proc_macro_deps": { + "common": [ + { + "id": "rustversion 1.0.14", + "target": "rustversion" + } + ], + "selects": {} + }, + "version": "0.15.1" + }, + "license": "MIT/Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, "zerocopy 0.7.32": { "name": "zerocopy", "version": "0.7.32", @@ -8992,11 +9278,13 @@ "serde 1.0.197", "serde_json 1.0.115", "sha2 0.10.8", + "snafu 0.8.2", "spinning_top 0.3.0", "static_assertions 1.1.0", "strum 0.26.2", "time 0.3.34", "x509-cert 0.2.5", + "x86_64 0.15.1", "zerocopy 0.7.32", "zeroize 1.7.0" ], diff --git a/oak_sev_guest/BUILD b/oak_sev_guest/BUILD new file mode 100644 index 00000000000..d813d5bea41 --- /dev/null +++ b/oak_sev_guest/BUILD @@ -0,0 +1,39 @@ +# +# Copyright 2024 The Project Oak Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package( + default_visibility = ["//visibility:public"], + licenses = ["notice"], +) + +rust_library( + name = "oak_sev_guest", + srcs = glob(["src/**"]), + deps = [ + "//oak_sev_snp_attestation_report", + "@oak_crates_index//:aes-gcm", + "@oak_crates_index//:bitflags", + "@oak_crates_index//:lock_api", + "@oak_crates_index//:snafu", + "@oak_crates_index//:spinning_top", + "@oak_crates_index//:static_assertions", + "@oak_crates_index//:strum", + "@oak_crates_index//:x86_64", + "@oak_crates_index//:zerocopy", + ], +) diff --git a/sev_serial/BUILD b/sev_serial/BUILD new file mode 100644 index 00000000000..cd72812d0e0 --- /dev/null +++ b/sev_serial/BUILD @@ -0,0 +1,31 @@ +# +# Copyright 2024 The Project Oak Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package( + default_visibility = ["//visibility:public"], + licenses = ["notice"], +) + +rust_library( + name = "sev_serial", + srcs = glob(["src/**"]), + deps = [ + "//oak_sev_guest", + "@oak_crates_index//:x86_64", + ], +)