OpenBSD CVS

CVS log for src/usr.sbin/vmd/i8253.c


[BACK] Up to [local] / src / usr.sbin / vmd

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.39 / (download) - annotate - [select for diffs], Fri Feb 9 14:35:47 2024 UTC (3 months, 3 weeks ago) by dv
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, HEAD
Changes since 1.38: +3 -3 lines
Diff to previous 1.38 (colored)

Tuck vmd's i8253 reset debug logs behind DPRINTF.

It's super chatty and pollutes verbose logging.

Revision 1.38 / (download) - annotate - [select for diffs], Wed Oct 25 12:44:28 2023 UTC (7 months, 1 week ago) by dv
Branch: MAIN
Changes since 1.37: +1 -2 lines
Diff to previous 1.37 (colored)

vmd(8): stop toggling irq deassert for edge triggered devs.

For edge-triggered devices, there's no need to deassert an irq given
how vmd(8) emulates a pic.  Deassertion grabs a lock and can trigger
the ioctl for toggling pending interrupts causing a race condition.
This results in a storm of vm-exits and guest vcpu becoming
unresponsive.

The original sign of this issue is guest "pauses" when pasting text
into a serial console connection in something like xterm(1).

Tested by mbuhl@, cheloha@, sashan@, kn@, and mlarkin@.

"go for it", mlarkin@

Revision 1.37 / (download) - annotate - [select for diffs], Fri Apr 14 15:31:17 2023 UTC (13 months, 2 weeks ago) by tb
Branch: MAIN
CVS Tags: OPENBSD_7_4_BASE, OPENBSD_7_4
Changes since 1.36: +3 -3 lines
Diff to previous 1.36 (colored)

Add two missing void to appease clang 15

There is another thing clang 15 is whining about - this will be resolved
in upcoming work by dv.

ok dv

Revision 1.36 / (download) - annotate - [select for diffs], Thu Nov 10 18:58:02 2022 UTC (18 months, 3 weeks ago) by mbuhl
Branch: MAIN
CVS Tags: OPENBSD_7_3_BASE, OPENBSD_7_3
Changes since 1.35: +2 -2 lines
Diff to previous 1.35 (colored)

Initialize data before passing it to get_input_data.  Strictly
speaking this is not necessary as all used bits of the uint32_t are
zeroed.
ok mlarkin

Revision 1.35 / (download) - annotate - [select for diffs], Fri Sep 2 21:33:51 2022 UTC (20 months, 4 weeks ago) by cheloha
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2
Changes since 1.34: +2 -2 lines
Diff to previous 1.34 (colored)

vmd(8): compute i8254 read-back command latch from singular timestamp

The intent of the i8254 read-back command is (most likely) to permit
simultaneously latching two or three counters at once along with their
statuses.

To simulate this, we should compute olatch from one timestamp per
read-back command, not one timestamp per counter.

Improved with a tweak by dv@.

Link: https://marc.info/?l=openbsd-tech&m=166213670605453&w=2

ok dv@ mlarkin@

Revision 1.34 / (download) - annotate - [select for diffs], Wed Jun 16 16:55:02 2021 UTC (2 years, 11 months ago) by dv
Branch: MAIN
CVS Tags: OPENBSD_7_1_BASE, OPENBSD_7_1, OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.33: +1 -2 lines
Diff to previous 1.33 (colored)

cleanup vmd(8) includes and header files

Lots of organic growth other the years lead to unnecessary includes
(proc.h everywhere) and odd dependencies between header files. This
cleans things up a bit to help with upcoming cleanup around dhcp
code.

No functional change.

"go for it" mlarkin@

Revision 1.33 / (download) - annotate - [select for diffs], Mon Mar 29 13:09:41 2021 UTC (3 years, 2 months ago) by dv
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.32: +6 -1 lines
Diff to previous 1.32 (colored)

Cleanly teardown and restore emulated device state on vm send/receive.

This cleans up events on a pause or resume, but also fixes an issue
where the vm_pipe event channels are not properly reinitialized on a
received guest leading to broken serial console.

OK pd@, mlarkin@

Revision 1.32 / (download) - annotate - [select for diffs], Sun Jun 28 16:52:45 2020 UTC (3 years, 11 months ago) by pd
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8
Changes since 1.31: +35 -2 lines
Diff to previous 1.31 (colored)

vmd(8): Eliminate libevent state corruption

libevent functions for com, pic and rtc are now only called on event_thread.
vcpu exit handlers send messages on a dev pipe and callbacks on these events do
the event management (event_add, evtimer_add, etc).  Previously, libevent state
was mutated by two threads, event_thread, that runs all the callbacks and the
vcpu thread when running exit handlers.  This could have lead to libevent state
corruption.

Patch from Dave Voutila <dave@sisu.io>

ok claudio@
tested by abieber@ and brynet@

Revision 1.31 / (download) - annotate - [select for diffs], Sat Nov 30 00:51:29 2019 UTC (4 years, 6 months ago) by mlarkin
Branch: MAIN
CVS Tags: OPENBSD_6_7_BASE, OPENBSD_6_7
Changes since 1.30: +1 -6 lines
Diff to previous 1.30 (colored)

Revert previous - the stability was not as improved as we had thought and
we ended up accidentally breaking vmctl. This will need more thought.

ok ori@

Revision 1.30 / (download) - annotate - [select for diffs], Fri Nov 29 00:51:27 2019 UTC (4 years, 6 months ago) by mlarkin
Branch: MAIN
Changes since 1.29: +6 -1 lines
Diff to previous 1.29 (colored)

Fix at least one cause of VMs spinning at 100% host CPU

After debugging with ori@, it looks like an event ends up on the wrong
libevent queue, and we end continually de-queueing and re-queueing the
event continually. While it's unclear exactly why this happened, a clue
on libevent's github issues page for the same problem pointed us to using
a different event base for the device events. This seems to have unstuck
ori@'s problematic VM, and I have also seen no more hangs after this.

We have not completely separated the queues; ori@ will work on setting
new libevent bases for those later. But those events are pretty
frequency.

with help from and ok ori@

Revision 1.29 / (download) - annotate - [select for diffs], Mon Dec 10 21:24:22 2018 UTC (5 years, 5 months ago) by claudio
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE, OPENBSD_6_6, OPENBSD_6_5_BASE, OPENBSD_6_5
Changes since 1.28: +2 -2 lines
Diff to previous 1.28 (colored)

No need to \n in log_debug. Part of a larger diff.
OK mlarkin@ ccardenas@

Revision 1.28 / (download) - annotate - [select for diffs], Thu Jul 12 10:15:44 2018 UTC (5 years, 10 months ago) by mlarkin
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.27: +3 -3 lines
Diff to previous 1.27 (colored)

vmm(8)/vmm(4): send a copy of the guest register state to vmd on exit,
avoiding multiple readregs ioctls back to vmm in case register content
is needed subsequently.

ok phessler

Revision 1.27 / (download) - annotate - [select for diffs], Mon Jul 9 16:11:37 2018 UTC (5 years, 10 months ago) by mlarkin
Branch: MAIN
Changes since 1.26: +2 -1 lines
Diff to previous 1.26 (colored)

vmd(8): deassert interrupt pins in the PIC at the right times. Helps fix
situations where vmd gets stuck at 100% cpu usage because the guest VM
is constantly trying to ack interrupts that already occurred.

tested by phessler on a VM that used to exhibit the issue.

ok phessler

Revision 1.26 / (download) - annotate - [select for diffs], Tue Jun 19 17:12:34 2018 UTC (5 years, 11 months ago) by reyk
Branch: MAIN
Changes since 1.25: +2 -2 lines
Diff to previous 1.25 (colored)

knf

Revision 1.25 / (download) - annotate - [select for diffs], Wed May 23 02:19:34 2018 UTC (6 years ago) by mlarkin
Branch: MAIN
Changes since 1.24: +3 -15 lines
Diff to previous 1.24 (colored)

vmd(8): revert r1.23 (unlatched PIT reads), this made time go too fast on
some machines. Will investigate and commit a proper fix later.

Revision 1.24 / (download) - annotate - [select for diffs], Fri Apr 27 08:57:13 2018 UTC (6 years, 1 month ago) by mlarkin
Branch: MAIN
Changes since 1.23: +28 -9 lines
Diff to previous 1.23 (colored)

vmd(8): allow counter state readback via misc port for square wave mode

Revision 1.23 / (download) - annotate - [select for diffs], Fri Apr 27 06:44:43 2018 UTC (6 years, 1 month ago) by mlarkin
Branch: MAIN
Changes since 1.22: +15 -3 lines
Diff to previous 1.22 (colored)

vmd(8): allow unlatch PIT reads

ok ccardenas

Revision 1.22 / (download) - annotate - [select for diffs], Thu Apr 26 18:19:37 2018 UTC (6 years, 1 month ago) by mlarkin
Branch: MAIN
Changes since 1.21: +11 -10 lines
Diff to previous 1.21 (colored)

vmd(8): fix some bugs in PIT mode setting

PIT modes are now properly handled, including INTTC mode. This fixes some
bootloader timeouts.

ok brynet

Revision 1.21 / (download) - annotate - [select for diffs], Thu Apr 26 17:21:50 2018 UTC (6 years, 1 month ago) by mlarkin
Branch: MAIN
Changes since 1.20: +7 -4 lines
Diff to previous 1.20 (colored)

vmd(8): some more long lines that got missed last time

Revision 1.20 / (download) - annotate - [select for diffs], Thu Apr 26 17:10:09 2018 UTC (6 years, 1 month ago) by mlarkin
Branch: MAIN
Changes since 1.19: +44 -3 lines
Diff to previous 1.19 (colored)

vmd(8): handle PIT channel 2 status readback via port 0x61

Allow PIT channel 2 status (fired/counting) readback via port 0x61
bit 5.

ok guenther@

Revision 1.19 / (download) - annotate - [select for diffs], Thu Apr 26 16:56:13 2018 UTC (6 years, 1 month ago) by mlarkin
Branch: MAIN
Changes since 1.18: +5 -3 lines
Diff to previous 1.18 (colored)

vmd(8): wrap some long lines

Revision 1.18 / (download) - annotate - [select for diffs], Tue Apr 17 14:34:09 2018 UTC (6 years, 1 month ago) by cheloha
Branch: MAIN
Changes since 1.17: +22 -85 lines
Diff to previous 1.17 (colored)

Drive i8253 with CLOCK_MONOTONIC.

Ensures that the olatch decrements uniformly, independent of system
wall clock jumps.

While here, roll the olatch computation in i8253_do_readback() into
a loop, and leverage the timespec macros in sys/time.h.  Both make the
code a lot more readable.

ok mlarkin@

Revision 1.17 / (download) - annotate - [select for diffs], Mon Aug 14 19:46:44 2017 UTC (6 years, 9 months ago) by jasper
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3, OPENBSD_6_2_BASE, OPENBSD_6_2
Changes since 1.16: +2 -2 lines
Diff to previous 1.16 (colored)

whitespace and fix a comment typo

Revision 1.16 / (download) - annotate - [select for diffs], Sun Jul 9 00:51:40 2017 UTC (6 years, 10 months ago) by pd
Branch: MAIN
Changes since 1.15: +22 -14 lines
Diff to previous 1.15 (colored)

vmd/vmctl: Add ability to pause / unpause vms

With help from Ashwin Agrawal

ok reyk@ mlarkin@

Revision 1.15 / (download) - annotate - [select for diffs], Mon May 8 09:08:40 2017 UTC (7 years ago) by reyk
Branch: MAIN
Changes since 1.14: +46 -1 lines
Diff to previous 1.14 (colored)

Adds functions to read and write state of devices in vmd.

This is required for implementing vmctl send and vmctl receive.  vmctl
send / receive are two new options that will support snapshotting VMs
and migrating VMs from one host to another. The atomicio files are
copied from usr.bin/ssh.

Patch from Pratik Vyas; this project was undertaken at San Jose State
University along with his three teammates, Ashwin, Harshada and Siri
with mlarkin@ as the advisor.

OK mlarkin@

Revision 1.14 / (download) - annotate - [select for diffs], Fri Apr 28 08:14:48 2017 UTC (7 years, 1 month ago) by mlarkin
Branch: MAIN
Changes since 1.13: +79 -81 lines
Diff to previous 1.13 (colored)

rename i8253 "counter" to "channel", a better name for what we are
emulating

Revision 1.13 / (download) - annotate - [select for diffs], Sat Apr 8 19:06:04 2017 UTC (7 years, 1 month ago) by mlarkin
Branch: MAIN
Changes since 1.12: +76 -29 lines
Diff to previous 1.12 (colored)

implement channels 1 and 2 of the legacy PIT.

ok otto, deraadt

Revision 1.12 / (download) - annotate - [select for diffs], Mon Mar 27 00:28:04 2017 UTC (7 years, 2 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.11: +1 -2 lines
Diff to previous 1.11 (colored)

die whitespace die die die

Revision 1.11 / (download) - annotate - [select for diffs], Sat Mar 25 22:36:53 2017 UTC (7 years, 2 months ago) by mlarkin
Branch: MAIN
Changes since 1.10: +2 -2 lines
Diff to previous 1.10 (colored)

Last bits needed to get seabios + alpine linux working. This is enough
to get started and let more people help finding and fixing bugs.

ok kettenis, deraadt

Revision 1.10 / (download) - annotate - [select for diffs], Sat Mar 25 07:46:24 2017 UTC (7 years, 2 months ago) by mlarkin
Branch: MAIN
Changes since 1.9: +2 -2 lines
Diff to previous 1.9 (colored)

Introduce a new function to obtain properly sized input data, and convert
i8253/i8259/mc146818 emulation to use this.

Revision 1.9 / (download) - annotate - [select for diffs], Fri Mar 24 11:08:43 2017 UTC (7 years, 2 months ago) by reyk
Branch: MAIN
Changes since 1.8: +1 -1 lines
Diff to previous 1.8 (colored)

Backout mlarkin's previous commit while he is away:
The newly-used function get_input_data() is missing and broke the tree.

Revision 1.8 / (download) - annotate - [select for diffs], Fri Mar 24 09:11:49 2017 UTC (7 years, 2 months ago) by mlarkin
Branch: MAIN
Changes since 1.7: +2 -2 lines
Diff to previous 1.7 (colored)

Last bits of cleanup for linux/seabios support in i8253/i8259 emulation
code.

Revision 1.7 / (download) - annotate - [select for diffs], Thu Mar 23 07:02:47 2017 UTC (7 years, 2 months ago) by mlarkin
Branch: MAIN
Changes since 1.6: +79 -19 lines
Diff to previous 1.6 (colored)

Various i8253/i8254 implementation improvements - Fix an error that used
the wrong i/o latch index on reads (resulting in erratic counter values
possibly being read). Also do proper return size setting (don't clobber
%eax high bits).

This diff also implements counter readback mode, which is used in seabios.

Revision 1.6 / (download) - annotate - [select for diffs], Sun Mar 19 23:03:44 2017 UTC (7 years, 2 months ago) by mlarkin
Branch: MAIN
Changes since 1.5: +5 -12 lines
Diff to previous 1.5 (colored)

Emulated i8253 should not start out in TIMER_RATEGEN mode on boot
automatically. This worked for OpenBSD guests but breaks seabios as soon
as the first interrupt fires since it has not programmed the PIT to do
anything yet. And OpenBSD reprograms the clock to rategen mode as soon
as it boots anyway, so this still works with vmctl(8)'s -k option, as
well as the faux-bootloader implemented in vmd(8)

Revision 1.5 / (download) - annotate - [select for diffs], Tue Jan 17 21:51:01 2017 UTC (7 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.4: +2 -2 lines
Diff to previous 1.4 (colored)

Nuke some whitespace that keeps poking me in the eye as I try to
steal code.

Revision 1.4 / (download) - annotate - [select for diffs], Wed Oct 26 05:26:36 2016 UTC (7 years, 7 months ago) by mlarkin
Branch: MAIN
Changes since 1.3: +2 -2 lines
Diff to previous 1.3 (colored)


vmd(8)/vmctl(8) for i386. Some ugliness in #ifdef __i386__ areas will be
fixed in tree, but the changes required were pretty minimal.

Note that i386 hosts are still presently limited to running i386 guests.

ok deraadt, stefan, jca

Revision 1.3 / (download) - annotate - [select for diffs], Mon Oct 3 06:00:17 2016 UTC (7 years, 8 months ago) by mlarkin
Branch: MAIN
Changes since 1.2: +1 -0 lines
Diff to previous 1.2 (colored)


add RCS tags

Revision 1.2 / (download) - annotate - [select for diffs], Thu Sep 1 16:40:06 2016 UTC (7 years, 9 months ago) by mlarkin
Branch: MAIN
Changes since 1.1: +2 -2 lines
Diff to previous 1.1 (colored)


change some log_warn to log_warnx and convert some integer literals to
enumerand values

Revision 1.1 / (download) - annotate - [select for diffs], Thu Sep 1 14:48:09 2016 UTC (7 years, 9 months ago) by mlarkin
Branch: MAIN


Add a set of emulated legacy devices (PIT, PIC, RTC)

discussed with stefan and deraadt

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.