From: ssnf Subject: [PATCH 1/6] vmd: store i8253 modes in register representation To: tech@openbsd.org Cc: ssnf Date: Sat, 22 Aug 2026 19:02:42 +0000 TIMER_* constants contain the mode bits in their PIT control-word representation. i8253_channel[].mode currently stores those bits shifted down, but later comparisons are made directly with the TIMER_* constants. Store the mode in the same representation as the TIMER_* constants and stop shifting it when constructing read-back status. --- usr.sbin/vmd/i8253.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/vmd/i8253.c b/usr.sbin/vmd/i8253.c index 00b0945da33..2e6c605b12d 100644 --- a/usr.sbin/vmd/i8253.c +++ b/usr.sbin/vmd/i8253.c @@ -270,7 +270,7 @@ vcpu_exit_i8253(struct vm_run_params *vrp) sel, (rw & TIMER_16BIT)); } i8253_channel[sel].last_w = 0; - i8253_channel[sel].mode = (out_data & 0xe) >> 1; + i8253_channel[sel].mode = out_data & 0xe; goto ret; } else { @@ -308,7 +308,7 @@ vcpu_exit_i8253(struct vm_run_params *vrp) } else { if (i8253_channel[sel].rbs) { i8253_channel[sel].rbs = 0; - data = i8253_channel[sel].mode << 1; + data = i8253_channel[sel].mode; data |= TIMER_16BIT; set_return_data(vei, data); goto ret; -- 2.51.0