From c70ec3491016fe20f867aa982b9a858d7df45256 Mon Sep 17 00:00:00 2001 From: Peter Fang Date: Mon, 22 Jul 2024 20:58:07 -0700 Subject: [PATCH] platform: tdp: Implement validate_page_range() On TDP platforms, validate_page_range() means page acceptance. Use the tdx-tdcall crate for this TDCALL operation. Signed-off-by: Peter Fang --- kernel/src/platform/tdp.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kernel/src/platform/tdp.rs b/kernel/src/platform/tdp.rs index a6ed5c9c2..41d3f76a0 100644 --- a/kernel/src/platform/tdp.rs +++ b/kernel/src/platform/tdp.rs @@ -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> = ImmutAfterInitCell::uninit(); @@ -98,10 +99,11 @@ impl SvsmPlatform for TdpPlatform { fn validate_page_range( &self, - _region: MemoryRegion, - _paddr: PhysAddr, + region: MemoryRegion, + 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) -> Result<(), SvsmError> {