From b8fee118227181ffbabfcad6835720641912b0dd Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Fri, 29 Oct 2021 09:56:18 +0100 Subject: [PATCH] vmm: Place SGX EPC region between RAM and device area Increase the start of the device area to accomodate the SGX EPC area. Signed-off-by: Rob Bradford --- vmm/src/memory_manager.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/vmm/src/memory_manager.rs b/vmm/src/memory_manager.rs index 506b175b4..f0254349d 100644 --- a/vmm/src/memory_manager.rs +++ b/vmm/src/memory_manager.rs @@ -1622,15 +1622,12 @@ impl MemoryManager { epc_region_size += epc_section.size; } - // Now that we know about the total size for the EPC region, we can - // proceed with the allocation of the entire range. The EPC region - // must be 4kiB aligned. - let epc_region_start = self - .allocator - .lock() - .unwrap() - .allocate_mmio_addresses(None, epc_region_size as GuestUsize, Some(0x1000)) - .ok_or(Error::SgxEpcRangeAllocation)?; + // Place the SGX EPC region on a 4k boundary between the RAM and the device area + let epc_region_start = + GuestAddress(((self.start_of_device_area.0 + 0xfff) / 0x1000) * 0x1000); + self.start_of_device_area = epc_region_start + .checked_add(epc_region_size) + .ok_or(Error::GuestAddressOverFlow)?; let mut sgx_epc_region = SgxEpcRegion::new(epc_region_start, epc_region_size as GuestUsize);