From f063346de303a19cb3add35aafe4b3ffc24adf6c Mon Sep 17 00:00:00 2001 From: Bo Chen Date: Thu, 22 Jul 2021 09:43:19 -0700 Subject: [PATCH] vmm: Create guest memory regions without dirty-pages-log by default With the support of dynamically turning on/off dirty-pages-log during live-migration (only for guest RAM regions), we now can create guest memory regions without dirty-pages-log by default both for guest RAM regions and other regions backed by file/device. Signed-off-by: Bo Chen --- vmm/src/device_manager.rs | 5 +---- vmm/src/memory_manager.rs | 24 ++---------------------- vmm/src/vm.rs | 4 ---- 3 files changed, 3 insertions(+), 30 deletions(-) diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 38a505e22..05e654453 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -2233,9 +2233,7 @@ impl DeviceManager { .memory_manager .lock() .unwrap() - .create_userspace_mapping( - cache_base, cache_size, host_addr, false, false, false, - ) + .create_userspace_mapping(cache_base, cache_size, host_addr, false, false) .map_err(DeviceManagerError::MemoryManager)?; let region_list = vec![VirtioSharedMemory { @@ -2427,7 +2425,6 @@ impl DeviceManager { host_addr, pmem_cfg.mergeable, false, - false, ) .map_err(DeviceManagerError::MemoryManager)?; diff --git a/vmm/src/memory_manager.rs b/vmm/src/memory_manager.rs index 01568960d..e54ade705 100644 --- a/vmm/src/memory_manager.rs +++ b/vmm/src/memory_manager.rs @@ -139,7 +139,6 @@ pub struct MemoryManager { user_provided_zones: bool, snapshot_memory_regions: Vec, memory_zones: MemoryZones, - log_dirty: bool, // Enable dirty logging for created RAM regions // Keep track of calls to create_userspace_mapping() for guest RAM. // This is useful for getting the dirty pages as we need to know the @@ -510,7 +509,6 @@ impl MemoryManager { config: &MemoryConfig, prefault: bool, phys_bits: u8, - #[cfg(feature = "tdx")] tdx_enabled: bool, ) -> Result>, Error> { let user_provided_zones = config.size == 0; let mut allow_mem_hotplug: bool = false; @@ -749,11 +747,6 @@ impl MemoryManager { .allocate_mmio_addresses(None, MEMORY_MANAGER_ACPI_SIZE as u64, None) .ok_or(Error::AllocateMmioAddress)?; - #[cfg(not(feature = "tdx"))] - let log_dirty = true; - #[cfg(feature = "tdx")] - let log_dirty = !tdx_enabled; // Cannot log dirty pages on a TD - let memory_manager = Arc::new(Mutex::new(MemoryManager { boot_guest_memory, guest_memory: guest_memory.clone(), @@ -781,7 +774,6 @@ impl MemoryManager { guest_ram_mappings: Vec::new(), #[cfg(feature = "acpi")] acpi_address, - log_dirty, })); for region in guest_memory.memory().iter() { @@ -792,7 +784,6 @@ impl MemoryManager { region.as_ptr() as u64, config.mergeable, false, - log_dirty, )?; mm.guest_ram_mappings.push(GuestRamMapping { gpa: region.start_addr().raw_value(), @@ -809,7 +800,6 @@ impl MemoryManager { region.as_ptr() as u64, config.mergeable, false, - log_dirty, )?; mm.guest_ram_mappings.push(GuestRamMapping { @@ -845,14 +835,7 @@ impl MemoryManager { prefault: bool, phys_bits: u8, ) -> Result>, Error> { - let mm = MemoryManager::new( - vm, - config, - prefault, - phys_bits, - #[cfg(feature = "tdx")] - false, - )?; + let mm = MemoryManager::new(vm, config, prefault, phys_bits)?; if let Some(source_url) = source_url { let vm_snapshot_path = url_to_path(source_url).map_err(Error::Restore)?; @@ -1118,7 +1101,6 @@ impl MemoryManager { region.as_ptr() as u64, self.mergeable, false, - self.log_dirty, )?; self.guest_ram_mappings.push(GuestRamMapping { gpa: region.start_addr().raw_value(), @@ -1210,7 +1192,6 @@ impl MemoryManager { userspace_addr: u64, mergeable: bool, readonly: bool, - log_dirty: bool, ) -> Result { let slot = self.allocate_memory_slot(); let mem_region = self.vm.make_user_memory_region( @@ -1219,7 +1200,7 @@ impl MemoryManager { memory_size, userspace_addr, readonly, - log_dirty, + false, // Always create memory regions without dirty pages log ); self.vm @@ -1455,7 +1436,6 @@ impl MemoryManager { host_addr, false, false, - false, )?; sgx_epc_region.insert( diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index 792c96468..1dd4e6199 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -765,8 +765,6 @@ impl Vm { &config.lock().unwrap().memory.clone(), false, phys_bits, - #[cfg(feature = "tdx")] - tdx_enabled, ) .map_err(Error::MemoryManager)?; @@ -887,8 +885,6 @@ impl Vm { &config.lock().unwrap().memory.clone(), false, phys_bits, - #[cfg(feature = "tdx")] - false, ) .map_err(Error::MemoryManager)?;