diff --git a/kernel/src/sev/secrets_page.rs b/kernel/src/sev/secrets_page.rs index 7ad773ff19..afe24762f9 100644 --- a/kernel/src/sev/secrets_page.rs +++ b/kernel/src/sev/secrets_page.rs @@ -5,13 +5,12 @@ // Author: Joerg Roedel use crate::address::VirtAddr; +use crate::error::SvsmError; use crate::locking::{RWLock, ReadLockGuard, WriteLockGuard}; +use crate::mm::GlobalBox; use crate::sev::vmsa::VMPL_MAX; use crate::types::GUEST_VMPL; -extern crate alloc; -use alloc::boxed::Box; - pub const VMPCK_SIZE: usize = 32; #[derive(Copy, Clone, Debug)] @@ -73,13 +72,13 @@ impl SecretsPage { } } - pub fn copy_for_vmpl(&self, vmpl: usize) -> Box { - let mut sp = Box::new(*self); + pub fn copy_for_vmpl(&self, vmpl: usize) -> Result, SvsmError> { + let mut sp = GlobalBox::try_new(*self)?; for idx in 0..vmpl { sp.clear_vmpck(idx); } - sp + Ok(sp) } pub fn set_svsm_data(&mut self, base: u64, size: u64, caa_addr: u64) { diff --git a/kernel/src/svsm.rs b/kernel/src/svsm.rs index da5c70243b..57eb159516 100755 --- a/kernel/src/svsm.rs +++ b/kernel/src/svsm.rs @@ -125,7 +125,7 @@ fn copy_secrets_page_to_fw(fw_addr: PhysAddr, caa_addr: PhysAddr) -> Result<(), zero_mem_region(start, start + PAGE_SIZE); // Copy secrets page - let mut fw_secrets_page = secrets_page().copy_for_vmpl(GUEST_VMPL); + let mut fw_secrets_page = secrets_page().copy_for_vmpl(GUEST_VMPL)?; let &li = &*LAUNCH_INFO;