Skip to content

Commit

Permalink
platform: tdp: Implement validate_page_range()
Browse files Browse the repository at this point in the history
On TDP platforms, validate_page_range() means page acceptance. Use the
tdx-tdcall crate for this TDCALL operation.

Signed-off-by: Peter Fang <[email protected]>
  • Loading branch information
peterfang committed Aug 21, 2024
1 parent deebe09 commit 01a984d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions kernel/src/platform/tdp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::svsm_console::SvsmTdIOPort;
use crate::types::PageSize;
use crate::utils::immut_after_init::ImmutAfterInitCell;
use crate::utils::MemoryRegion;
use tdx_tdcall::tdx::td_accept_memory;

static CONSOLE_IO: SvsmTdIOPort = SvsmTdIOPort::new();
static CONSOLE_SERIAL: ImmutAfterInitCell<SerialPort<'_>> = ImmutAfterInitCell::uninit();
Expand Down Expand Up @@ -85,10 +86,11 @@ impl SvsmPlatform for TdpPlatform {

fn validate_page_range(
&self,
_region: MemoryRegion<VirtAddr>,
_paddr: PhysAddr,
region: MemoryRegion<VirtAddr>,
paddr: PhysAddr,
) -> Result<(), SvsmError> {
Err(SvsmError::Tdx)
td_accept_memory(paddr.into(), region.len().try_into().unwrap());
Ok(())
}

fn invalidate_page_range(&self, _region: MemoryRegion<VirtAddr>) -> Result<(), SvsmError> {
Expand Down

0 comments on commit 01a984d

Please sign in to comment.