MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / tdx_init_memory_region

Method tdx_init_memory_region

hypervisor/src/kvm/mod.rs:1376–1402  ·  view source on GitHub ↗
(
        &self,
        host_address: *mut u8,
        guest_address: u64,
        size: usize,
        measure: bool,
    )

Source from the content-addressed store, hash-verified

1374 /// `host_address` must be valid for `size` bytes
1375 #[cfg(feature = "tdx")]
1376 unsafe fn tdx_init_memory_region(
1377 &self,
1378 host_address: *mut u8,
1379 guest_address: u64,
1380 size: usize,
1381 measure: bool,
1382 ) -> vm::Result<()> {
1383 #[repr(C)]
1384 struct TdxInitMemRegion {
1385 host_address: u64,
1386 guest_address: u64,
1387 pages: u64,
1388 }
1389 let data = TdxInitMemRegion {
1390 host_address: host_address as _,
1391 guest_address,
1392 pages: (size / 4096).try_into().unwrap(),
1393 };
1394
1395 tdx_command(
1396 &self.fd.as_raw_fd(),
1397 TdxCommand::InitMemRegion,
1398 u32::from(measure),
1399 (&raw const data).cast(),
1400 )
1401 .map_err(vm::HypervisorVmError::InitMemRegionTdx)
1402 }
1403
1404 /// Downcast to the underlying KvmVm type
1405 fn as_any(&self) -> &dyn Any {

Callers

nothing calls this directly

Calls 3

tdx_commandFunction · 0.85
try_intoMethod · 0.80
as_raw_fdMethod · 0.45

Tested by

no test coverage detected