-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sev/secrets_page: replace Box with GlobalBox
Use the new fallible-allocation-aware GlobalBox type when allocating a new secrets page for the given VPML. Signed-off-by: Carlos López <[email protected]>
- Loading branch information
Showing
2 changed files
with
6 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,12 @@ | |
// Author: Joerg Roedel <[email protected]> | ||
|
||
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<SecretsPage> { | ||
let mut sp = Box::new(*self); | ||
pub fn copy_for_vmpl(&self, vmpl: usize) -> Result<GlobalBox<SecretsPage>, 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) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters