diff options
author | Khyber Sen <khyber@google.com> | 2024-03-20 10:59:42 +0000 |
---|---|---|
committer | Khyber Sen <khyber@google.com> | 2024-03-20 10:59:45 +0000 |
commit | e09494bbcbc98fcbda046b3892848fadcd260e31 (patch) | |
tree | 1d29c09c8032516a08888db45ce7d3a77d079c79 | |
parent | 9ebe4679e6a23127ccb01448fbeabd9ecf501624 (diff) | |
download | common-e09494bbcbc98fcbda046b3892848fadcd260e31.tar.gz |
lib: rust_support: Add #[deny(unsafe_op_in_unsafe_fn)]
Test: build.py generic-x86_64-test
Bug: 298705967
Change-Id: I8adebf527b36de7e8ca42a1e6bafa80bf1cc2679
-rw-r--r-- | lib/rust_support/lib.rs | 1 | ||||
-rw-r--r-- | lib/rust_support/vmm.rs | 28 |
2 files changed, 18 insertions, 11 deletions
diff --git a/lib/rust_support/lib.rs b/lib/rust_support/lib.rs index fc99d3d1..c2fd111a 100644 --- a/lib/rust_support/lib.rs +++ b/lib/rust_support/lib.rs @@ -25,6 +25,7 @@ #![no_std] #![feature(c_str_literals)] +#![deny(unsafe_op_in_unsafe_fn)] use alloc::format; use core::ffi::CStr; diff --git a/lib/rust_support/vmm.rs b/lib/rust_support/vmm.rs index 7893d5a7..68d924df 100644 --- a/lib/rust_support/vmm.rs +++ b/lib/rust_support/vmm.rs @@ -43,6 +43,9 @@ pub fn vmm_get_kernel_aspace() -> *mut vmm_aspace_t { unsafe { addr_of_mut!(crate::sys::_kernel_aspace) } } +/// # Safety +/// +/// Same as [`vmm_alloc_physical_etc`]. #[inline] pub unsafe fn vmm_alloc_physical( aspace: *mut vmm_aspace_t, @@ -54,15 +57,18 @@ pub unsafe fn vmm_alloc_physical( vmm_flags: c_uint, arch_mmu_flags: c_uint, ) -> status_t { - vmm_alloc_physical_etc( - aspace, - name, - size, - ptr.cast_mut(), - align_log2, - addr_of!(paddr), - 1, - vmm_flags, - arch_mmu_flags, - ) + // SAFETY: Delegated. + unsafe { + vmm_alloc_physical_etc( + aspace, + name, + size, + ptr.cast_mut(), + align_log2, + addr_of!(paddr), + 1, + vmm_flags, + arch_mmu_flags, + ) + } } |