From e63a17ff749565148f274a1a89a307ae75b56d0d Mon Sep 17 00:00:00 2001 From: Jack Thomson Date: Wed, 22 Jan 2025 12:22:14 +0000 Subject: [PATCH] Call kvmclock_ctrl on GDB pause When we pause for GDB call `KVM_KVMCLOCK_CTRL` to prevent guest softlockup watchdog panic. Signed-off-by: Jack Thomson --- CHANGELOG.md | 3 +++ src/vmm/src/vstate/vcpu/mod.rs | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00e82ee4b19..d6a8e1b2ded 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,9 @@ and this project adheres to `mem_size_mib` and `track_dirty_pages` being mandatory for all `PATCH /machine-config` requests. Now, they can be omitted which leaves these parts of the machine configuration unchanged. +- [#5007](https://github.com/firecracker-microvm/firecracker/pull/5007): Fixed + watchdog softlockup warning on x86_64 guests when a vCPU is paused during GDB + debugging. ## [1.10.1] diff --git a/src/vmm/src/vstate/vcpu/mod.rs b/src/vmm/src/vstate/vcpu/mod.rs index 6a6471193dc..d9aa0abd1a8 100644 --- a/src/vmm/src/vstate/vcpu/mod.rs +++ b/src/vmm/src/vstate/vcpu/mod.rs @@ -319,6 +319,16 @@ impl Vcpu { // If the emulation requests a pause lets do this #[cfg(feature = "gdb")] Ok(VcpuEmulation::Paused) => { + // Calling `KVM_KVMCLOCK_CTRL` to make sure the guest softlockup watchdog + // does not panic on resume, see https://docs.kernel.org/virt/kvm/api.html . + // We do not want to fail if the call is not successful, because depending + // that may be acceptable depending on the workload. + #[cfg(target_arch = "x86_64")] + if let Err(err) = self.kvm_vcpu.fd.kvmclock_ctrl() { + METRICS.vcpu.kvmclock_ctrl_fails.inc(); + warn!("KVM_KVMCLOCK_CTRL call failed {}", err); + } + return StateMachine::next(Self::paused); } // Emulation errors lead to vCPU exit.