From ff20f183647c602bf5e5028d99959e5547a7dd84 Mon Sep 17 00:00:00 2001 From: CMGS Date: Tue, 31 Mar 2026 06:12:21 +0000 Subject: [PATCH] vmm: restore KVM clock before resuming vCPUs Reorder resume() to: set_clock, device_manager.resume, cpu_manager.resume. This matches the inverse of pause() which correctly saves the clock before pausing vCPUs. Signed-off-by: CMGS --- vmm/src/vm.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index 430c9bdc7..c1e21a5ac 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -3111,7 +3111,8 @@ impl Pausable for Vm { .valid_transition(new_state) .map_err(|e| MigratableError::Resume(anyhow!("Invalid transition: {e:?}")))?; - self.cpu_manager.lock().unwrap().resume()?; + // Restore KVM clock BEFORE vCPUs start running, so they see correct + // TSC/kvmclock from the first instruction after resume. #[cfg(target_arch = "x86_64")] { if let Some(clock) = &self.saved_clock { @@ -3128,6 +3129,7 @@ impl Pausable for Vm { } self.device_manager.lock().unwrap().resume()?; + self.cpu_manager.lock().unwrap().resume()?; // And we're back to the Running state. self.state = new_state;