Skip to content

Commit 0d5942b

Browse files
committed
fix: reset timer_stop flag before spawning timer thread
During evolve(), the guest init sequence halts via OutBAction::Halt, which sets timer_stop=true. When the guest later configures a timer via PvTimerConfig, the timer thread inherits the already-true stop flag and exits immediately without ever firing. Reset the flag to false right before spawning the timer thread in both KVM and MSHV backends. WHP was not affected because it creates a fresh AtomicBool each time. Signed-off-by: danbugs <danilochiarlone@gmail.com>
1 parent 6b482c9 commit 0d5942b

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

src/hyperlight_host/src/hypervisor/virtual_machine/kvm.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@ impl VirtualMachine for KvmVm {
260260
if let Ok(bytes) = data[..4].try_into() {
261261
let period_us = u32::from_le_bytes(bytes) as u64;
262262
if period_us > 0 && self.timer_thread.is_none() {
263+
// Reset the stop flag — a previous halt (e.g. the
264+
// init halt during evolve()) may have set it.
265+
self.timer_stop.store(false, Ordering::Relaxed);
263266
let eventfd = self.timer_irq_eventfd.try_clone().map_err(|e| {
264267
RunVcpuError::Unknown(HypervisorError::KvmError(e.into()))
265268
})?;

src/hyperlight_host/src/hypervisor/virtual_machine/mshv.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,9 @@ impl MshvVm {
639639
if data.len() >= 4 {
640640
let period_us = u32::from_le_bytes([data[0], data[1], data[2], data[3]]);
641641
if period_us > 0 && self.timer_thread.is_none() {
642+
// Reset the stop flag — a previous halt (e.g. the
643+
// init halt during evolve()) may have set it.
644+
self.timer_stop.store(false, Ordering::Relaxed);
642645
// Re-enable LAPIC if the guest disabled it (via WRMSR
643646
// to MSR 0x1B clearing bit 11). Some guests clear
644647
// the global APIC enable when no I/O APIC is detected.

0 commit comments

Comments
 (0)