diff --git a/BUILD b/BUILD index 4546bd6..c0fcdb4 100644 --- a/BUILD +++ b/BUILD @@ -6,7 +6,6 @@ rust_library( name = "sbi-rs", srcs = glob(["src/**/*.rs"]), crate_root = "src/sbi.rs", - proc_macro_deps = ["@sbi-index//:enum_dispatch"], deps = [ "@sbi-index//:arrayvec", "@sbi-index//:flagset", diff --git a/bazel-locks/Sbi-Cargo.Bazel.lock b/bazel-locks/Sbi-Cargo.Bazel.lock index 4014115..77fcf51 100644 --- a/bazel-locks/Sbi-Cargo.Bazel.lock +++ b/bazel-locks/Sbi-Cargo.Bazel.lock @@ -13,72 +13,18 @@ name = "direct-cargo-bazel-deps" version = "0.0.1" dependencies = [ "arrayvec", - "enum_dispatch", "flagset", "static_assertions", ] -[[package]] -name = "enum_dispatch" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11f36e95862220b211a6e2aa5eca09b4fa391b13cd52ceb8035a24bf65a79de2" -dependencies = [ - "once_cell", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "flagset" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cda653ca797810c02f7ca4b804b40b8b95ae046eb989d356bce17919a8c25499" -[[package]] -name = "once_cell" -version = "1.17.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" - -[[package]] -name = "proc-macro2" -version = "1.0.51" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" -dependencies = [ - "proc-macro2", -] - [[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "syn" -version = "1.0.107" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "unicode-ident" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" diff --git a/bazel-locks/sbi-cargo-bazel-lock.json b/bazel-locks/sbi-cargo-bazel-lock.json index 51a7fb4..1d9dfb6 100644 --- a/bazel-locks/sbi-cargo-bazel-lock.json +++ b/bazel-locks/sbi-cargo-bazel-lock.json @@ -1,12 +1,12 @@ { - "checksum": "1b6651df522b517e333acc6d66b328ff329e9411fc325f277ab58a21d0126510", + "checksum": "9c177b2577d39ea15a9ab93a7ff0f3e2cf438f1a2af95c296182789db8634e67", "crates": { "arrayvec 0.7.2": { "name": "arrayvec", "version": "0.7.2", "repository": { "Http": { - "url": "https://crates.io/api/v1/crates/arrayvec/0.7.2/download", + "url": "https://static.crates.io/crates/arrayvec/0.7.2/download", "sha256": "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" } }, @@ -69,76 +69,16 @@ "selects": {} }, "edition": "2018", - "proc_macro_deps": { - "common": [ - { - "id": "enum_dispatch 0.3.11", - "target": "enum_dispatch" - } - ], - "selects": {} - }, "version": "0.0.1" }, "license": null }, - "enum_dispatch 0.3.11": { - "name": "enum_dispatch", - "version": "0.3.11", - "repository": { - "Http": { - "url": "https://crates.io/api/v1/crates/enum_dispatch/0.3.11/download", - "sha256": "11f36e95862220b211a6e2aa5eca09b4fa391b13cd52ceb8035a24bf65a79de2" - } - }, - "targets": [ - { - "ProcMacro": { - "crate_name": "enum_dispatch", - "crate_root": "src/lib.rs", - "srcs": [ - "**/*.rs" - ] - } - } - ], - "library_target_name": "enum_dispatch", - "common_attrs": { - "compile_data_glob": [ - "**" - ], - "deps": { - "common": [ - { - "id": "once_cell 1.17.1", - "target": "once_cell" - }, - { - "id": "proc-macro2 1.0.51", - "target": "proc_macro2" - }, - { - "id": "quote 1.0.23", - "target": "quote" - }, - { - "id": "syn 1.0.107", - "target": "syn" - } - ], - "selects": {} - }, - "edition": "2018", - "version": "0.3.11" - }, - "license": "MIT OR Apache-2.0" - }, "flagset 0.4.3": { "name": "flagset", "version": "0.4.3", "repository": { "Http": { - "url": "https://crates.io/api/v1/crates/flagset/0.4.3/download", + "url": "https://static.crates.io/crates/flagset/0.4.3/download", "sha256": "cda653ca797810c02f7ca4b804b40b8b95ae046eb989d356bce17919a8c25499" } }, @@ -163,170 +103,12 @@ }, "license": "Apache-2.0" }, - "once_cell 1.17.1": { - "name": "once_cell", - "version": "1.17.1", - "repository": { - "Http": { - "url": "https://crates.io/api/v1/crates/once_cell/1.17.1/download", - "sha256": "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" - } - }, - "targets": [ - { - "Library": { - "crate_name": "once_cell", - "crate_root": "src/lib.rs", - "srcs": [ - "**/*.rs" - ] - } - } - ], - "library_target_name": "once_cell", - "common_attrs": { - "compile_data_glob": [ - "**" - ], - "crate_features": [ - "alloc", - "default", - "race", - "std" - ], - "edition": "2021", - "version": "1.17.1" - }, - "license": "MIT OR Apache-2.0" - }, - "proc-macro2 1.0.51": { - "name": "proc-macro2", - "version": "1.0.51", - "repository": { - "Http": { - "url": "https://crates.io/api/v1/crates/proc-macro2/1.0.51/download", - "sha256": "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" - } - }, - "targets": [ - { - "Library": { - "crate_name": "proc_macro2", - "crate_root": "src/lib.rs", - "srcs": [ - "**/*.rs" - ] - } - }, - { - "BuildScript": { - "crate_name": "build_script_build", - "crate_root": "build.rs", - "srcs": [ - "**/*.rs" - ] - } - } - ], - "library_target_name": "proc_macro2", - "common_attrs": { - "compile_data_glob": [ - "**" - ], - "crate_features": [ - "default", - "proc-macro" - ], - "deps": { - "common": [ - { - "id": "proc-macro2 1.0.51", - "target": "build_script_build" - }, - { - "id": "unicode-ident 1.0.6", - "target": "unicode_ident" - } - ], - "selects": {} - }, - "edition": "2018", - "version": "1.0.51" - }, - "build_script_attrs": { - "data_glob": [ - "**" - ] - }, - "license": "MIT OR Apache-2.0" - }, - "quote 1.0.23": { - "name": "quote", - "version": "1.0.23", - "repository": { - "Http": { - "url": "https://crates.io/api/v1/crates/quote/1.0.23/download", - "sha256": "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" - } - }, - "targets": [ - { - "Library": { - "crate_name": "quote", - "crate_root": "src/lib.rs", - "srcs": [ - "**/*.rs" - ] - } - }, - { - "BuildScript": { - "crate_name": "build_script_build", - "crate_root": "build.rs", - "srcs": [ - "**/*.rs" - ] - } - } - ], - "library_target_name": "quote", - "common_attrs": { - "compile_data_glob": [ - "**" - ], - "crate_features": [ - "default", - "proc-macro" - ], - "deps": { - "common": [ - { - "id": "proc-macro2 1.0.51", - "target": "proc_macro2" - }, - { - "id": "quote 1.0.23", - "target": "build_script_build" - } - ], - "selects": {} - }, - "edition": "2018", - "version": "1.0.23" - }, - "build_script_attrs": { - "data_glob": [ - "**" - ] - }, - "license": "MIT OR Apache-2.0" - }, "static_assertions 1.1.0": { "name": "static_assertions", "version": "1.1.0", "repository": { "Http": { - "url": "https://crates.io/api/v1/crates/static_assertions/1.1.0/download", + "url": "https://static.crates.io/crates/static_assertions/1.1.0/download", "sha256": "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" } }, @@ -350,111 +132,6 @@ "version": "1.1.0" }, "license": "MIT OR Apache-2.0" - }, - "syn 1.0.107": { - "name": "syn", - "version": "1.0.107", - "repository": { - "Http": { - "url": "https://crates.io/api/v1/crates/syn/1.0.107/download", - "sha256": "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" - } - }, - "targets": [ - { - "Library": { - "crate_name": "syn", - "crate_root": "src/lib.rs", - "srcs": [ - "**/*.rs" - ] - } - }, - { - "BuildScript": { - "crate_name": "build_script_build", - "crate_root": "build.rs", - "srcs": [ - "**/*.rs" - ] - } - } - ], - "library_target_name": "syn", - "common_attrs": { - "compile_data_glob": [ - "**" - ], - "crate_features": [ - "clone-impls", - "default", - "derive", - "full", - "parsing", - "printing", - "proc-macro", - "quote" - ], - "deps": { - "common": [ - { - "id": "proc-macro2 1.0.51", - "target": "proc_macro2" - }, - { - "id": "quote 1.0.23", - "target": "quote" - }, - { - "id": "syn 1.0.107", - "target": "build_script_build" - }, - { - "id": "unicode-ident 1.0.6", - "target": "unicode_ident" - } - ], - "selects": {} - }, - "edition": "2018", - "version": "1.0.107" - }, - "build_script_attrs": { - "data_glob": [ - "**" - ] - }, - "license": "MIT OR Apache-2.0" - }, - "unicode-ident 1.0.6": { - "name": "unicode-ident", - "version": "1.0.6", - "repository": { - "Http": { - "url": "https://crates.io/api/v1/crates/unicode-ident/1.0.6/download", - "sha256": "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" - } - }, - "targets": [ - { - "Library": { - "crate_name": "unicode_ident", - "crate_root": "src/lib.rs", - "srcs": [ - "**/*.rs" - ] - } - } - ], - "library_target_name": "unicode_ident", - "common_attrs": { - "compile_data_glob": [ - "**" - ], - "edition": "2018", - "version": "1.0.6" - }, - "license": "(MIT OR Apache-2.0) AND Unicode-DFS-2016" } }, "binary_crates": [], diff --git a/deps.bzl b/deps.bzl index f397675..54d0382 100644 --- a/deps.bzl +++ b/deps.bzl @@ -15,9 +15,6 @@ def sbi_dependencies(): version = "0.7.2", default_features = False, ), - "enum_dispatch": crate.spec( - version = "0.3.8", - ), "flagset": crate.spec( version = "0.4.3", ), diff --git a/src/api/attestation.rs b/src/api/attestation.rs index 868413f..560924a 100644 --- a/src/api/attestation.rs +++ b/src/api/attestation.rs @@ -21,7 +21,7 @@ pub fn get_capabilities() -> Result { }); // Safety: &caps is the single reference to a variable defined in this scope. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(caps) } @@ -34,9 +34,9 @@ pub fn get_capabilities() -> Result { /// /// * `cert_request` - The [Certificate Signing Request](https://datatracker.ietf.org/doc/html/rfc2986) buffer. /// * `request_data` - A data blob that will be included in the generated -/// certificate, as [UserNotice](https://datatracker.ietf.org/doc/html/rfc2986) -/// X.509 certificate extension. This is typically used to -/// pass a cryptographic nonce. +/// certificate, as [UserNotice](https://datatracker.ietf.org/doc/html/rfc2986) +/// X.509 certificate extension. This is typically used to +/// pass a cryptographic nonce. /// * `evidence_format` - The format of the attestation evidence as defined by [`EvidenceFormat`](crate::EvidenceFormat). pub fn get_evidence( cert_request: &[u8], @@ -90,7 +90,7 @@ pub fn extend_measurement(digest: &[u8], index: usize) -> Result<()> { // Safety: ExtendMeasurement only reads the pages pointed to by `digest`. // This is safe because they're owned by the borrowed slice passed as an // argument to this function. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } diff --git a/src/api/cove_guest.rs b/src/api/cove_guest.rs index 02c80e2..5b2bf35 100644 --- a/src/api/cove_guest.rs +++ b/src/api/cove_guest.rs @@ -13,7 +13,7 @@ pub fn add_emulated_mmio_region(addr: u64, len: u64) -> Result<()> { // Safety: AddMmioRegion does not directly access our memory. The specified range of // address space must have been previously inaccessible for the call to succeed, after which // accesses to that range have well-defined behavior. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -24,7 +24,7 @@ pub fn remove_emulated_mmio_region(addr: u64, len: u64) -> Result<()> { // Safety: RemoveMmioRegion does not directly access the memory. The specified range of // address space must have been previously registered for MMIO using `AddMmioRegion` for // this call to succeed. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -38,7 +38,7 @@ pub fn remove_emulated_mmio_region(addr: u64, len: u64) -> Result<()> { /// the host. pub unsafe fn share_memory(addr: u64, len: u64) -> Result<()> { let msg = SbiMessage::CoveGuest(ShareMemory { addr, len }); - ecall_send(&msg)?; + ecall_send::<()>(&msg)?; Ok(()) } @@ -52,7 +52,7 @@ pub unsafe fn share_memory(addr: u64, len: u64) -> Result<()> { /// confidential to the calling VM. pub unsafe fn unshare_memory(addr: u64, len: u64) -> Result<()> { let msg = SbiMessage::CoveGuest(UnshareMemory { addr, len }); - ecall_send(&msg)?; + ecall_send::<()>(&msg)?; Ok(()) } @@ -60,7 +60,7 @@ pub unsafe fn unshare_memory(addr: u64, len: u64) -> Result<()> { pub fn allow_external_interrupt(id: u64) -> Result<()> { let msg = SbiMessage::CoveGuest(AllowExternalInterrupt { id: id as i64 }); // Safety: AllowExternalInterrupt doesn't access our memory. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -68,7 +68,7 @@ pub fn allow_external_interrupt(id: u64) -> Result<()> { pub fn allow_all_external_interrupts() -> Result<()> { let msg = SbiMessage::CoveGuest(AllowExternalInterrupt { id: -1 }); // Safety: AllowExternalInterrupt doesn't access our memory. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -76,7 +76,7 @@ pub fn allow_all_external_interrupts() -> Result<()> { pub fn deny_external_interrupt(id: u64) -> Result<()> { let msg = SbiMessage::CoveGuest(DenyExternalInterrupt { id: id as i64 }); // Safety: DenyExternalInterrupt doesn't access our memory. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -84,6 +84,6 @@ pub fn deny_external_interrupt(id: u64) -> Result<()> { pub fn deny_all_external_interrupts() -> Result<()> { let msg = SbiMessage::CoveGuest(DenyExternalInterrupt { id: -1 }); // Safety: DenyExternalInterrupt doesn't access our memory. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } diff --git a/src/api/cove_host.rs b/src/api/cove_host.rs index 15929c7..913ad3e 100644 --- a/src/api/cove_host.rs +++ b/src/api/cove_host.rs @@ -17,7 +17,7 @@ pub struct TsmShmemAreaRef<'a> { _lifetime: PhantomData<&'a NaclShmem>, } -impl<'a> TsmShmemAreaRef<'a> { +impl TsmShmemAreaRef<'_> { /// Creates a new `TsmShmemAreaRef` from a raw pointer to a `NaclShmem`. /// /// # Safety @@ -81,7 +81,7 @@ fn _assert_scratch_size() { pub fn tsm_initiate_fence() -> Result<()> { let msg = SbiMessage::CoveHost(TsmInitiateFence); // Safety: TsmInitiateFence doesn't read or write any memory we have access to. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -89,7 +89,7 @@ pub fn tsm_initiate_fence() -> Result<()> { pub fn tsm_local_fence() -> Result<()> { let msg = SbiMessage::CoveHost(TsmLocalFence); // Safety: TsmLocalFence doesn't read or write any memory we have access to. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -97,7 +97,7 @@ pub fn tsm_local_fence() -> Result<()> { pub fn tvm_initiate_fence(vmid: u64) -> Result<()> { let msg = SbiMessage::CoveHost(TvmInitiateFence { guest_id: vmid }); // Safety: TvmInitiateFence doesn't read or write any memory we have access to. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -133,7 +133,7 @@ pub unsafe fn convert_pages(addr: u64, num_pages: u64) -> Result<()> { }); // Safety: The passed-in pages are unmapped and we do not access them again until they're // reclaimed. - ecall_send(&msg)?; + ecall_send::<()>(&msg)?; Ok(()) } @@ -145,7 +145,7 @@ pub fn reclaim_pages(addr: u64, num_pages: u64) -> Result<()> { }); // Safety: The referenced pages are made accessible again, which is safe since we haven't // done anything with them since they were converted. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -154,10 +154,10 @@ pub fn reclaim_pages(addr: u64, num_pages: u64) -> Result<()> { /// # Params: /// /// - tvm_page_directory_addr: The base physical address of the 16kB confidential memory region that -/// should be used for the TVM's page directory. Must be 16kB-aligned. +/// should be used for the TVM's page directory. Must be 16kB-aligned. /// /// - tvm_state_addr: The base physical address of the confidential memory region to be used to hold -/// the TVM's global state. Must be page-aligned and `TsmInfo::tvm_state_pages` pages in length. +/// the TVM's global state. Must be page-aligned and `TsmInfo::tvm_state_pages` pages in length. pub fn tvm_create(tvm_page_directory_addr: u64, tvm_state_addr: u64) -> Result { let tvm_create_params = TvmCreateParams { tvm_page_directory_addr, @@ -181,7 +181,7 @@ pub fn tvm_finalize(vmid: u64, entry_sepc: u64, entry_arg: u64) -> Result<()> { entry_arg, }); // Safety: `Finalize` doesn't touch memory. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -189,7 +189,7 @@ pub fn tvm_finalize(vmid: u64, entry_sepc: u64, entry_arg: u64) -> Result<()> { pub fn tvm_destroy(vmid: u64) -> Result<()> { let msg = SbiMessage::CoveHost(TvmDestroy { guest_id: vmid }); // Safety: destroying a VM doesn't write to memory that's accessible from the host. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -212,7 +212,7 @@ pub fn add_page_table_pages(vmid: u64, page_addr: u64, num_pages: u64) -> Result }); // Safety: `AddPageTablePages` only accesses pages that have been previously converted. Passing // non-converted memory will result in a failure and not touch the memory. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -229,7 +229,7 @@ pub fn add_vcpu(vmid: u64, vcpu_id: u64, state_page_addr: u64) -> Result<()> { }); // Safety: TvmCpuCreate only accesses pages that have been converted and thus must already be // inaccessible to the calling program. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -241,7 +241,7 @@ pub fn add_memory_region(vmid: u64, guest_addr: u64, len: u64) -> Result<()> { len, }); // Safety: `TvmAddMemoryRegion` doesn't access our memory at all. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -273,7 +273,7 @@ pub fn add_measured_pages( // Safety: `TvmAddMeasuredPages` only writes pages that have already been converted, and only // reads the pages pointed to by `src_addr`. This is safe because those pages are owned by the // borrowed slice and safe to read from. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -294,7 +294,7 @@ pub fn add_zero_pages( guest_addr, }); // Safety: `TvmAddZeroPages` only touches pages that we've already converted. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -318,7 +318,7 @@ pub unsafe fn add_shared_pages( num_pages, guest_addr, }); - ecall_send(&msg)?; + ecall_send::<()>(&msg)?; Ok(()) } @@ -330,7 +330,7 @@ pub fn block_pages(vmid: u64, guest_addr: u64, len: u64) -> Result<()> { len, }); // Safety: The pages belong to the guest's address space. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -343,7 +343,7 @@ pub fn unblock_pages(vmid: u64, guest_addr: u64, len: u64) -> Result<()> { len, }); // Safety: The pages belong to the guest's address space. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -355,7 +355,7 @@ pub fn promote_page(vmid: u64, guest_addr: u64, page_type: TsmPageType) -> Resul page_type, }); // Safety: The pages belong to the guest's address space. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -367,7 +367,7 @@ pub fn demote_page(vmid: u64, guest_addr: u64, page_type: TsmPageType) -> Result page_type, }); // Safety: The pages belong to the guest's address space. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -379,6 +379,6 @@ pub fn remove_pages(vmid: u64, guest_addr: u64, len: u64) -> Result<()> { len, }); // Safety: The pages belong to the guest's address space. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } diff --git a/src/api/cove_interrupt.rs b/src/api/cove_interrupt.rs index 1293bf6..9dc8cd8 100644 --- a/src/api/cove_interrupt.rs +++ b/src/api/cove_interrupt.rs @@ -15,7 +15,7 @@ pub fn tvm_aia_init(tvm_id: u64, tvm_aia_params: TvmAiaParams) -> Result<()> { }); // Safety: `TvmConfigureAia` will only read up to `len` bytes of the `TvmAiaParams` structure // we passed in. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -27,7 +27,7 @@ pub fn set_vcpu_imsic_addr(tvm_id: u64, vcpu_id: u64, imsic_addr: u64) -> Result imsic_addr, }); // Safety: `TvmCpuSetImsicAddr` doesn't touch host memory in any way. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -39,7 +39,7 @@ pub fn set_vcpu_imsic_addr(tvm_id: u64, vcpu_id: u64, imsic_addr: u64) -> Result pub unsafe fn convert_imsic(imsic_addr: u64) -> Result<()> { let msg = SbiMessage::CoveInterrupt(TsmConvertImsic { imsic_addr }); // The caller must guarantee that they won't access the page at `imsic_addr`. - ecall_send(&msg)?; + ecall_send::<()>(&msg)?; Ok(()) } @@ -49,7 +49,7 @@ pub fn reclaim_imsic(imsic_addr: u64) -> Result<()> { let msg = SbiMessage::CoveInterrupt(TsmReclaimImsic { imsic_addr }); // Safety: The referenced page is made available again, which is safe since it hasn't been // accessible since conversion. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -62,7 +62,7 @@ pub fn bind_vcpu_imsic(tvm_id: u64, vcpu_id: u64, imsic_mask: u64) -> Result<()> imsic_mask, }); // Safety: The specified guest interrupt files must have already been inaccessible. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -72,7 +72,7 @@ pub fn bind_vcpu_imsic(tvm_id: u64, vcpu_id: u64, imsic_mask: u64) -> Result<()> pub fn unbind_vcpu_imsic_begin(tvm_id: u64, vcpu_id: u64) -> Result<()> { let msg = SbiMessage::CoveInterrupt(TvmCpuUnbindImsicBegin { tvm_id, vcpu_id }); // Safety: Does not access host memory. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -82,7 +82,7 @@ pub fn unbind_vcpu_imsic_begin(tvm_id: u64, vcpu_id: u64) -> Result<()> { pub fn unbind_vcpu_imsic_end(tvm_id: u64, vcpu_id: u64) -> Result<()> { let msg = SbiMessage::CoveInterrupt(TvmCpuUnbindImsicEnd { tvm_id, vcpu_id }); // Safety: Does not access host memory. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -95,7 +95,7 @@ pub fn inject_external_interrupt(tvm_id: u64, vcpu_id: u64, interrupt_id: u64) - interrupt_id, }); // Safety: Does not access host memory. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -110,7 +110,7 @@ pub fn rebind_vcpu_imsic_begin(tvm_id: u64, vcpu_id: u64, imsic_mask: u64) -> Re imsic_mask, }); // Safety: The specified guest interrupt files must have already been inaccessible. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -120,7 +120,7 @@ pub fn rebind_vcpu_imsic_begin(tvm_id: u64, vcpu_id: u64, imsic_mask: u64) -> Re pub fn rebind_vcpu_imsic_clone(tvm_id: u64, vcpu_id: u64) -> Result<()> { let msg = SbiMessage::CoveInterrupt(TvmCpuRebindImsicClone { tvm_id, vcpu_id }); // Safety: Does not access host memory. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -129,6 +129,6 @@ pub fn rebind_vcpu_imsic_clone(tvm_id: u64, vcpu_id: u64) -> Result<()> { pub fn rebind_vcpu_imsic_end(tvm_id: u64, vcpu_id: u64) -> Result<()> { let msg = SbiMessage::CoveInterrupt(TvmCpuRebindImsicEnd { tvm_id, vcpu_id }); // Safety: Does not access host memory. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } diff --git a/src/api/debug_console.rs b/src/api/debug_console.rs index 7d972f2..7cc5155 100644 --- a/src/api/debug_console.rs +++ b/src/api/debug_console.rs @@ -12,7 +12,7 @@ pub fn console_puts(chars: &[u8]) -> Result<()> { }); // Safety: The sbi implementation is trusted not to write memory when printing to the console. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } diff --git a/src/api/nacl.rs b/src/api/nacl.rs index dac5fa0..8dc142d 100644 --- a/src/api/nacl.rs +++ b/src/api/nacl.rs @@ -21,7 +21,7 @@ pub unsafe fn register_shmem(shmem_ptr: *mut NaclShmem) -> Result<()> { let msg = SbiMessage::Nacl(SetShmem { shmem_addr: shmem_ptr as u64, }); - ecall_send(&msg)?; + ecall_send::<()>(&msg)?; Ok(()) } @@ -31,6 +31,6 @@ pub fn unregister_shmem() -> Result<()> { shmem_addr: u64::MAX, }); // Safety: Doesn't access host memory. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } diff --git a/src/api/pmu.rs b/src/api/pmu.rs index daff8eb..5bda5ed 100644 --- a/src/api/pmu.rs +++ b/src/api/pmu.rs @@ -56,7 +56,7 @@ pub fn start_counters( initial_value, }); // Safety: PmuFunction does not touch memory. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -72,7 +72,7 @@ pub fn stop_counters( stop_flags, }); // Safety: PmuFunction does not touch memory. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } diff --git a/src/api/reset.rs b/src/api/reset.rs index 32ea2aa..028c78f 100644 --- a/src/api/reset.rs +++ b/src/api/reset.rs @@ -10,7 +10,7 @@ use crate::{ResetReason, ResetType}; pub fn reset(reset_type: ResetType, reason: ResetReason) -> Result<()> { let msg = SbiMessage::Reset(ResetFunction::Reset { reset_type, reason }); // Safety: Reset terminates this VM. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } @@ -18,6 +18,6 @@ pub fn reset(reset_type: ResetType, reason: ResetReason) -> Result<()> { pub fn shutdown() -> Result<()> { let msg = SbiMessage::Reset(ResetFunction::shutdown()); // Safety: This ecall doesn't touch memory and will never return. - unsafe { ecall_send(&msg) }?; + unsafe { ecall_send::<()>(&msg) }?; Ok(()) } diff --git a/src/api/salus.rs b/src/api/salus.rs index 4cb730b..80a7758 100644 --- a/src/api/salus.rs +++ b/src/api/salus.rs @@ -20,6 +20,6 @@ pub unsafe fn test_memcpy(to: *mut u8, from: *const u8, len: u64) -> Result<()> len, }); let msg = SalusSbiMessage::SalusTest(function).into(); - ecall_send(&msg)?; + ecall_send::<()>(&msg)?; Ok(()) } diff --git a/src/api/state.rs b/src/api/state.rs index 8578e3b..ba9375d 100644 --- a/src/api/state.rs +++ b/src/api/state.rs @@ -19,6 +19,6 @@ pub unsafe fn hart_start(hart_id: u64, start_addr: u64, opaque: u64) -> Result<( }); // Safety: Passes one pointer to SBI, that pointer is guaranteed by the linker to be the // code to start secondary CPUs. - ecall_send(&msg)?; + ecall_send::<()>(&msg)?; Ok(()) } diff --git a/src/cove_host.rs b/src/cove_host.rs index ffeef4b..fef256a 100644 --- a/src/cove_host.rs +++ b/src/cove_host.rs @@ -351,6 +351,7 @@ pub enum CoveHostFunction { /// - The page is currently marked present in the TVM’s page table. /// - The page is in either the “Mapped” state and uniquely owned by the TVM, or in /// the “Shared” state and owned by the host. + /// /// After verifying these pre-conditions are met, the TSM: /// - Invalidates the page. /// - Places the page in the “Blocked” state (if “Mapped”) or “BlockedShared” state @@ -379,6 +380,7 @@ pub enum CoveHostFunction { /// - The page is currently marked invalid in the TVM’s page table. /// - The page is in either the “Blocked” state and uniquely owned by the TVM, or in /// the “BlockedShared” state and owned by the host. + /// /// After verifying these pre-conditions are met, the TSM: /// - Marks the page as present. /// - Places the page in the “Mapped” state (if “Blocked”) or “Shared” state