diff --git a/flake.nix b/flake.nix index 7f0fa5cd414..01f338b888c 100644 --- a/flake.nix +++ b/flake.nix @@ -64,7 +64,7 @@ includeSystemImages = false; }).androidsdk; rustToolchain = - pkgs.rust-bin.nightly."2023-11-15".default.override { + pkgs.rust-bin.nightly."2024-02-01".default.override { extensions = [ "clippy" "llvm-tools-preview" diff --git a/oak_functions_containers_app/src/native_handler.rs b/oak_functions_containers_app/src/native_handler.rs index 606bc489a03..4a0d2bec4d8 100644 --- a/oak_functions_containers_app/src/native_handler.rs +++ b/oak_functions_containers_app/src/native_handler.rs @@ -34,7 +34,7 @@ struct RequestContext { } thread_local! { - static CONTEXT: RefCell> = RefCell::new(None); + static CONTEXT: RefCell> = const { RefCell::new(None) }; } // Callbacks for the C side. diff --git a/oak_restricted_kernel/src/ghcb.rs b/oak_restricted_kernel/src/ghcb.rs index 2a3c18b2dfd..88db2f3ce49 100644 --- a/oak_restricted_kernel/src/ghcb.rs +++ b/oak_restricted_kernel/src/ghcb.rs @@ -14,6 +14,8 @@ // limitations under the License. // +use core::ptr::addr_of; + use oak_core::sync::OnceCell; use oak_sev_guest::{ ghcb::{Ghcb, GhcbProtocol}, @@ -166,7 +168,7 @@ fn get_identity_mapped_encrypted_page_table<'a>() fn get_ghcb_page() -> Page { // Safety: the reference to a mutable static is safe, as we only use it to // calculate a virtual address and don't dereference it. - let ghcb_pointer = unsafe { &GHCB_WRAPPER as *const GhcbAlignmentWrapper }; + let ghcb_pointer = unsafe { addr_of!(GHCB_WRAPPER) }; let ghcb_address = VirtAddr::from_ptr(ghcb_pointer); Page::::from_start_address(ghcb_address).expect("invalid start address for GHCB page") } diff --git a/oak_sev_guest/src/lib.rs b/oak_sev_guest/src/lib.rs index e82ccf83bd4..2e9663ad7f9 100644 --- a/oak_sev_guest/src/lib.rs +++ b/oak_sev_guest/src/lib.rs @@ -18,7 +18,6 @@ //! manage page state and interact with the hypervisor and the secure processor. #![no_std] -#![feature(offset_of)] use x86_64::{PhysAddr, VirtAddr}; diff --git a/stage0/src/paging.rs b/stage0/src/paging.rs index 4b66883a0fb..35d6b533afb 100644 --- a/stage0/src/paging.rs +++ b/stage0/src/paging.rs @@ -15,6 +15,7 @@ // use alloc::boxed::Box; +use core::ptr::addr_of_mut; use oak_core::sync::OnceCell; use spinning_top::Spinlock; @@ -62,10 +63,10 @@ pub fn init_page_table_refs(encrypted: u64) { // Safety: accessing the mutable statics here is safe since we only do it once // and protect the mutable references with a mutex. This function can only // be called once, since updating `PAGE_TABLE_REFS` twice will panic. - let pml4 = unsafe { &mut PML4 }; - let pdpt = unsafe { &mut PDPT }; - let pd_0 = unsafe { &mut PD_0 }; - let pd_3 = unsafe { &mut PD_3 }; + let pml4 = unsafe { &mut *addr_of_mut!(PML4) }; + let pdpt = unsafe { &mut *addr_of_mut!(PDPT) }; + let pd_0 = unsafe { &mut *addr_of_mut!(PD_0) }; + let pd_3 = unsafe { &mut *addr_of_mut!(PD_3) }; // Set up a new page table that maps the first 2MiB as 4KiB pages, so that we // can share individual 4KiB pages with the hypervisor as needed. We are