Index | Thread | Search

From:
ssnf <ssnf@ssnf.xyz>
Subject:
[PATCH 4/6] vmd: reset i8253 input latch on new counter writes
To:
tech@openbsd.org
Cc:
ssnf <ssnf@ssnf.xyz>
Date:
Sat, 22 Aug 2026 19:02:45 +0000

Download raw body.

Thread
A new LSB/MSB counter write must replace the previous programmed
value.

The first byte is currently OR'ed into ilatch, leaving bits from
the previous divisor set and potentially programming the wrong
count.
---
 usr.sbin/vmd/i8253.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr.sbin/vmd/i8253.c b/usr.sbin/vmd/i8253.c
index 917def18b75..3723bcde639 100644
--- a/usr.sbin/vmd/i8253.c
+++ b/usr.sbin/vmd/i8253.c
@@ -287,7 +287,7 @@ vcpu_exit_i8253(struct vm_run_params *vrp)
 
 		if (vei->vei.vei_dir == VEI_DIR_OUT) { /* OUT instruction */
 			if (i8253_channel[sel].last_w == 0) {
-				i8253_channel[sel].ilatch |= (out_data & 0xff);
+				i8253_channel[sel].ilatch = out_data & 0xff;
 				i8253_channel[sel].last_w = 1;
 			} else {
 				i8253_channel[sel].ilatch |=
-- 
2.51.0