mirror of
https://github.com/openbsd/src.git
synced 2026-04-30 00:56:33 +00:00
fix timer emulation-related VM hangs
This fixes state machine issues that resulted in hangs with OpenBSD-i386 VMs when using the i8254 hardware timecounter with vmm. This also manifested in incorrect i8254 calibration (wrong CPU speed in dmesg). tested with Debian 12 amd64, i386 Apine Linux 3.23 x86 (with 4GB memory), x86_64 OpenBSD 7.9 beta amd64, i386 ok mlarkin@
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: i8253.c,v 1.45 2025/12/02 02:31:10 dv Exp $ */
|
||||
/* $OpenBSD: i8253.c,v 1.46 2026/04/07 03:21:10 bcook Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2016 Mike Larkin <mlarkin@openbsd.org>
|
||||
*
|
||||
@@ -262,12 +262,14 @@ vcpu_exit_i8253(struct vm_run_params *vrp)
|
||||
ticks % i8253_channel[sel].start;
|
||||
} else
|
||||
i8253_channel[sel].olatch = 0;
|
||||
i8253_channel[sel].last_r = 1;
|
||||
goto ret;
|
||||
} else if (rw != TIMER_16BIT) {
|
||||
log_warnx("%s: i8253 PIT: unsupported counter "
|
||||
"%d rw mode 0x%x selected", __func__,
|
||||
sel, (rw & TIMER_16BIT));
|
||||
}
|
||||
i8253_channel[sel].last_w = 0;
|
||||
i8253_channel[sel].mode = (out_data & 0xe) >> 1;
|
||||
|
||||
goto ret;
|
||||
@@ -293,6 +295,9 @@ vcpu_exit_i8253(struct vm_run_params *vrp)
|
||||
if (i8253_channel[sel].start == 0)
|
||||
i8253_channel[sel].start = 0xffff;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC,
|
||||
&i8253_channel[sel].ts);
|
||||
|
||||
DPRINTF("%s: channel %d reset, mode=%d, "
|
||||
"start=%d\n", __func__,
|
||||
sel, i8253_channel[sel].mode,
|
||||
|
||||
Reference in New Issue
Block a user