Up to [local] / src / usr.sbin / vmd
Request diff between arbitrary revisions
Default branch: MAIN
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
CVS Tags: OPENBSD_7_5_BASE,
OPENBSD_7_5,
HEAD
Changes since 1.37: +1 -3 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], Tue Apr 18 10:27:38 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)
I somehow overlooked four more missing void...
Revision 1.36 / (download) - annotate - [select for diffs], Mon Mar 13 18:09:41 2023 UTC (14 months, 2 weeks ago) by dv
Branch: MAIN
CVS Tags: OPENBSD_7_3_BASE,
OPENBSD_7_3
Changes since 1.35: +7 -8 lines
Diff to previous 1.35 (colored)
vmd(8): backout ns8250 changes. This backs out commit h1IJwTVsYWfnRKWy which intended to fix interrupt issues on slower host hardware. Unfortunately, this causes a race condition on much faster host hardware. It still requires investigation. With an "I told you so" about touching ns8250 from mlarkin@
Revision 1.35 / (download) - annotate - [select for diffs], Mon Jan 30 21:43:12 2023 UTC (16 months ago) by dv
Branch: MAIN
Changes since 1.34: +8 -7 lines
Diff to previous 1.34 (colored)
vmd(8): fix an interrupt storm in ns8250. On slower hosts, such as those in a nested virtualization scenario of OpenBSD guest inside OpenBSD atop Linux KVM, ns8250 can cause a race between the kevent firing and the vcpu being kicked by an assert/deassert of the irq. The end user experiences a "stuck" serial console and the host will see a vmd process peg the cpu. This change only toggles the irq if we were in a position of being ready to receive data on the device so while the kevent might continuously fire, the vcpu will not be kicked repeatedly. OK mlarkin@
Revision 1.34 / (download) - annotate - [select for diffs], Wed Dec 28 21:30:19 2022 UTC (17 months ago) by jmc
Branch: MAIN
Changes since 1.33: +2 -2 lines
Diff to previous 1.33 (colored)
spelling fixes; from paul tagliamonte any parts of his diff not taken are noted on tech
Revision 1.33 / (download) - annotate - [select for diffs], Mon Dec 19 20:27:26 2022 UTC (17 months, 1 week ago) by dv
Branch: MAIN
Changes since 1.32: +2 -2 lines
Diff to previous 1.32 (colored)
Silence vmd ns8250 log noise about reading com1 before ready. ok marlkin@
Revision 1.32 / (download) - annotate - [select for diffs], Fri Jul 16 16:21:22 2021 UTC (2 years, 10 months ago) by dv
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE,
OPENBSD_7_2,
OPENBSD_7_1_BASE,
OPENBSD_7_1,
OPENBSD_7_0_BASE,
OPENBSD_7_0
Changes since 1.31: +8 -37 lines
Diff to previous 1.31 (colored)
vmd(8): simplify vcpu logic, removing uart & vionet reads Remove legacy state handling on the ns8250 and virtio network devices originally put in place before using libevent for async device events. The vcpu thread doesn't need to process device data as it is handled by the libevent thread. This has the benefit of simplifying some of the message passing between threads introduced to the ns8250 uart since both the vcpu and libevent threads were processing read events. No functional change intended. Tested by many, including abieber@, weerd@, Mischa Peters, and Matthias Schmidt. (Thanks.) OK mlarkin@
Revision 1.31 / (download) - annotate - [select for diffs], Wed Jun 16 16:55:02 2021 UTC (2 years, 11 months ago) by dv
Branch: MAIN
Changes since 1.30: +2 -3 lines
Diff to previous 1.30 (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.30 / (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.29: +9 -3 lines
Diff to previous 1.29 (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.29 / (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.28: +49 -9 lines
Diff to previous 1.28 (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.28 / (download) - annotate - [select for diffs], Sun Jun 21 20:36:07 2020 UTC (3 years, 11 months ago) by pd
Branch: MAIN
Changes since 1.27: +16 -16 lines
Diff to previous 1.27 (colored)
vmd(8): fix ns8250 lockup due to race condition Inject a pending interrupt even if the rcv_pending flag is set to avoid the endless EV_READ loop where a byte lingers read to be read but the vcpu never gets the interrupt to read it. (e.g. the result of spamming RETURN via the serial console) Also, protect com ratelimit handler with mutexes to avoid corruption of the device state. These changes help preventing linux vm crashes when the return key is held on boot. Discovered by and patch from Dave Voutila <dave@sisu.io> ok tb@
Revision 1.27 / (download) - annotate - [select for diffs], Tue Jun 16 08:46:03 2020 UTC (3 years, 11 months ago) by pd
Branch: MAIN
Changes since 1.26: +9 -17 lines
Diff to previous 1.26 (colored)
vmd(8): backout previous commit to ns8250.c as it reintroduced the bug where the vm would get stuck if disconnected from console and get unstuck once console is attached. Spotted by tb@
Revision 1.26 / (download) - annotate - [select for diffs], Tue Jun 16 06:23:51 2020 UTC (3 years, 11 months ago) by pd
Branch: MAIN
Changes since 1.25: +17 -9 lines
Diff to previous 1.25 (colored)
vmd(8): fix ns8250 lockup due to race condition Inject pending interrupt if com has receive pending. This was previously accidently checked in with an unrelated change by Mike Larkin and was backed out as it didn't fix the intended problem. Also, protect com ratelimit handler with mutexes to avoid corruption of the device state. These changes help preventing linux vm crashes when the return key is held on boot. Discovered by and patch from Dave Voutila <dave@sisu.io>
Revision 1.25 / (download) - annotate - [select for diffs], Wed Dec 11 06:45:16 2019 UTC (4 years, 5 months ago) by pd
Branch: MAIN
CVS Tags: OPENBSD_6_7_BASE,
OPENBSD_6_7
Changes since 1.24: +17 -2 lines
Diff to previous 1.24 (colored)
vmd: proper concurrency control when pausing a vm Removes an XXX which slept for 1s waiting for the vcpu thread to reach HLT and pause. We now define a paused and unpaused condition so that a call to pause_vm() / vmctl pause blocks till the vm really reaches a paused state. Also, detach events for devices from event loop when pausing and add them back when unpausing. This is because some callbacks call pthread_mutex_lock and if the vm is paused, it would block also causing the libevent thread to block. This would mean that we would not be able to process any IMSGs received from vmm (parent process) including a message to unpause. ok mlarkin@
Revision 1.24 / (download) - annotate - [select for diffs], Sun Dec 8 20:14:59 2019 UTC (4 years, 5 months ago) by tb
Branch: MAIN
Changes since 1.23: +15 -27 lines
Diff to previous 1.23 (colored)
Fully reinstate revision 1.21. Apparently, revision 1.22 (part of the "Fix at least one cause of VMs spinning at 100% host CPU" commit) accidentally included some pieces of a different WIP. These pieces remained in the tree after the revert and caused vmd to busy loop after attaching to and detaching from a VM's console. "please commit" mlarkin
Revision 1.23 / (download) - annotate - [select for diffs], Sat Nov 30 00:51:29 2019 UTC (4 years, 6 months ago) by mlarkin
Branch: MAIN
Changes since 1.22: +1 -8 lines
Diff to previous 1.22 (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.22 / (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.21: +34 -15 lines
Diff to previous 1.21 (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.21 / (download) - annotate - [select for diffs], Tue May 28 07:36:37 2019 UTC (5 years ago) by mlarkin
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE,
OPENBSD_6_6
Changes since 1.20: +5 -3 lines
Diff to previous 1.20 (colored)
Make vmd(8)'s ns8250 emulation more correct Remove the scratch register (8250s don't have this), and reorganize some constants to be able to more easily support more than one serial port in the future. ok deraadt Diff from Katherine Rohl, thanks!
Revision 1.20 / (download) - annotate - [select for diffs], Mon Mar 11 17:08:52 2019 UTC (5 years, 2 months ago) by anton
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE,
OPENBSD_6_5
Changes since 1.19: +25 -3 lines
Diff to previous 1.19 (colored)
Do not unconditionally wait for read events on the pty associated with a vm console. Instead, wait for the controlling end of the pty to become writeable, which implies that the slave end is connected. A recent change to the kqueue pty implementation caused vmd to hammer the log due to constantly hitting EOF while reading from the pty since the slave end was disconnected. Issue found the hard way by mlarkin@ and tb@ ok mlarkin@
Revision 1.19 / (download) - annotate - [select for diffs], Thu Oct 4 16:21:59 2018 UTC (5 years, 7 months ago) by mlarkin
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE,
OPENBSD_6_4
Changes since 1.18: +5 -4 lines
Diff to previous 1.18 (colored)
vmd(8): don't forget to set TXRDY in the case when the rate limiter isn't going to be used. Issue caused by yesterday's commit, affected certain guests' consoles after interrupts had been enabled. spotted by bluhm@, thanks.
Revision 1.18 / (download) - annotate - [select for diffs], Wed Oct 3 20:13:33 2018 UTC (5 years, 7 months ago) by mlarkin
Branch: MAIN
Changes since 1.17: +4 -3 lines
Diff to previous 1.17 (colored)
vmd(8): avoid a divide by zero when the user specified a low baud rate Low baud rates would result in a 0 "rate limiter pause count" in the serial port output code. This pause counter is used to implement a delay in what otherwise is an instantaneous serial port output path, and is needed by some guest OS kernels. This fix only enables the rate limiter pause if the count is > 0 ("pause after 0 characters" makes no sense anyway). Note that this will result in skipping the limiter on unusually low baud rates, but since nobody is using a low baud rate console in vmd, I don't think this is going to be a problem. ok pd
Revision 1.17 / (download) - annotate - [select for diffs], Thu Jul 12 10:15:44 2018 UTC (5 years, 10 months ago) by mlarkin
Branch: MAIN
Changes since 1.16: +10 -10 lines
Diff to previous 1.16 (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.16 / (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.15: +3 -6 lines
Diff to previous 1.15 (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.15 / (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.14: +3 -2 lines
Diff to previous 1.14 (colored)
knf
Revision 1.14 / (download) - annotate - [select for diffs], Mon Jan 8 18:21:22 2018 UTC (6 years, 4 months ago) by anton
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE,
OPENBSD_6_3
Changes since 1.13: +2 -2 lines
Diff to previous 1.13 (colored)
Fix typo in comment; ok mpi@
Revision 1.13 / (download) - annotate - [select for diffs], Mon Jan 8 11:58:27 2018 UTC (6 years, 4 months ago) by mpi
Branch: MAIN
Changes since 1.12: +34 -6 lines
Diff to previous 1.12 (colored)
Enable TIOCUCNTL to be able to set ns8250's break detected condition. It is now possible to send BREAK commands to vmd(8) independently of the serial terminal emulator. Happy virtual ddb(4) hacking! No objection from mlarkin@, ok nicm@, ccardenas@, deraadt@
Revision 1.12 / (download) - annotate - [select for diffs], Fri Sep 15 02:35:39 2017 UTC (6 years, 8 months ago) by mlarkin
Branch: MAIN
CVS Tags: OPENBSD_6_2_BASE,
OPENBSD_6_2
Changes since 1.11: +4 -10 lines
Diff to previous 1.11 (colored)
vmd: emulate UART scratch register, seems to be required by GRUB and doesn't seem to cause any side effects with other guest types.
Revision 1.11 / (download) - annotate - [select for diffs], Mon Aug 14 19:46:44 2017 UTC (6 years, 9 months ago) by jasper
Branch: MAIN
Changes since 1.10: +2 -2 lines
Diff to previous 1.10 (colored)
whitespace and fix a comment typo
Revision 1.10 / (download) - annotate - [select for diffs], Sat Jul 15 05:05:36 2017 UTC (6 years, 10 months ago) by pd
Branch: MAIN
Changes since 1.9: +8 -1 lines
Diff to previous 1.9 (colored)
Add vmctl send and vmctl receive ok reyk@ and mlarkin@
Revision 1.9 / (download) - annotate - [select for diffs], Wed Jun 7 14:53:28 2017 UTC (6 years, 11 months ago) by mlarkin
Branch: MAIN
Changes since 1.8: +106 -15 lines
Diff to previous 1.8 (colored)
vmd: Implement simulated baudrate support in the ns8250 module. The previous version was allowing an output rate that is "too fast", and linux guests would give up after 512 characters TXed ("too much work for irq4"). This diff calculates the approximate rate we can sustain at the current programmed baud rate and limits the output to that rate by inserting a HZ delay after a specified number of characters have been transmitted. This fixes the linux guest console issue. Note that the console now outputs at more or less the selected baud rate, instead of nearly instantaneously as before - if you selected 9600 in your guest VMs before, you might want to change that to 115200 now for a better console experience. krw@ "seems like a good idea to me"
Revision 1.8 / (download) - annotate - [select for diffs], Mon May 8 09:08:40 2017 UTC (7 years ago) by reyk
Branch: MAIN
Changes since 1.7: +40 -1 lines
Diff to previous 1.7 (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.7 / (download) - annotate - [select for diffs], Tue Mar 21 03:29:57 2017 UTC (7 years, 2 months ago) by mlarkin
Branch: MAIN
CVS Tags: OPENBSD_6_1_BASE,
OPENBSD_6_1
Changes since 1.6: +16 -13 lines
Diff to previous 1.6 (colored)
Fix two errors in NS8250 (UART) emulation. The first error zeroed out the high bits of %eax on reading register data from the emulated UART ports. The second error didn't properly assert the TXRDY bit during init - this bit was only set after the first character was sent. Both these bugs caused seabios to not be able to output any data. Found during the recent effort to get Linux guests booting.
Revision 1.6 / (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.5: +2 -2 lines
Diff to previous 1.5 (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.5 / (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.4: +1 -0 lines
Diff to previous 1.4 (colored)
add RCS tags
Revision 1.4 / (download) - annotate - [select for diffs], Sat Sep 3 11:36:08 2016 UTC (7 years, 8 months ago) by mlarkin
Branch: MAIN
Changes since 1.3: +0 -8 lines
Diff to previous 1.3 (colored)
fix some wrong interrupt code that doesn't fit with the new model ok stefan@
Revision 1.3 / (download) - annotate - [select for diffs], Fri Sep 2 17:10:08 2016 UTC (7 years, 9 months ago) by stefan
Branch: MAIN
Changes since 1.2: +153 -77 lines
Diff to previous 1.2 (colored)
Process incoming com data asynchronously to running VCPU This registers a handler with libevent that is triggered on incoming data on the com port. ok mlarkin@
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: +24 -24 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