OpenBSD CVS

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


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

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.27 / (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.26: +1 -2 lines
Diff to previous 1.26 (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.26 / (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.25: +3 -3 lines
Diff to previous 1.25 (colored)

I somehow overlooked four more missing void...

Revision 1.25 / (download) - annotate - [select for diffs], Sat Jan 15 23:39:11 2022 UTC (2 years, 4 months ago) by mlarkin
Branch: MAIN
CVS Tags: OPENBSD_7_3_BASE, OPENBSD_7_3, OPENBSD_7_2_BASE, OPENBSD_7_2, OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.24: +1 -6 lines
Diff to previous 1.24 (colored)

vmd: Remove a warning about non-32KHz timebases

Remove a warning that has outlived its usefulness.

From Brian Conway, thanks.

Revision 1.24 / (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_0_BASE, OPENBSD_7_0
Changes since 1.23: +3 -4 lines
Diff to previous 1.23 (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.23 / (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.22: +6 -1 lines
Diff to previous 1.22 (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.22 / (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.21: +29 -3 lines
Diff to previous 1.21 (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.21 / (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.20: +1 -7 lines
Diff to previous 1.20 (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.20 / (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.19: +7 -1 lines
Diff to previous 1.19 (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.19 / (download) - annotate - [select for diffs], Mon May 27 19:21:43 2019 UTC (5 years ago) by jasper
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.18: +2 -2 lines
Diff to previous 1.18 (colored)

only reschedule the periodic interrupt after updating register A
if something changed in register A.

when updating register A we were checking in register B if the
PIE bit was set in order to decide if rtc_reschedule_per needed
to be called. if that bit was changed then the timer rate would
already have been adjusted by rtc_update_regb so the call from
rtc_update_rega is not needed.

this now matches what qemu and other emulators are doing too.

ok mlarkin@

Revision 1.18 / (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_5_BASE, OPENBSD_6_5, OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.17: +2 -2 lines
Diff to previous 1.17 (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.17 / (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.16: +2 -1 lines
Diff to previous 1.16 (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.16 / (download) - annotate - [select for diffs], Wed Feb 28 06:53:25 2018 UTC (6 years, 3 months ago) by pd
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3
Changes since 1.15: +2 -2 lines
Diff to previous 1.15 (colored)

vmd: Fix 100% vmd cpu usage on linux receive / unpause

Use rtc_reschedule_per in mc146818_start instead of re arming the
periodic interrupt without checking if it's enabled in REGB.

reported by Dave Voutila
ok phessler@

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

vmd/vmctl: Add ability to pause / unpause vms

With help from Ashwin Agrawal

ok reyk@ mlarkin@

Revision 1.14 / (download) - annotate - [select for diffs], Mon May 8 09:08:40 2017 UTC (7 years ago) by reyk
Branch: MAIN
Changes since 1.13: +41 -1 lines
Diff to previous 1.13 (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.13 / (download) - annotate - [select for diffs], Tue May 2 09:51:19 2017 UTC (7 years, 1 month ago) by mlarkin
Branch: MAIN
Changes since 1.12: +12 -2 lines
Diff to previous 1.12 (colored)

Resynchronize the guest RTC via vmmci(4) on host resume from zzz/ZZZ
(vmd part)

This feature is for OpenBSD guests only.

ok reyk, kettenis

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: +2 -2 lines
Diff to previous 1.11 (colored)

die whitespace die die die

Revision 1.11 / (download) - annotate - [select for diffs], Sun Mar 26 17:04:03 2017 UTC (7 years, 2 months ago) by kettenis
Branch: MAIN
Changes since 1.10: +2 -2 lines
Diff to previous 1.10 (colored)

With the updated get_input_data() interface, we need to zero-initialize
the stack variable that we use to store the data otherwise the bytes that
aren't touched by get_input_data() may contain garbage.

ok mlarkin@

Revision 1.10 / (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.9: +2 -2 lines
Diff to previous 1.9 (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.9 / (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.8: +7 -13 lines
Diff to previous 1.8 (colored)

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

Revision 1.8 / (download) - annotate - [select for diffs], Thu Mar 23 07:59:41 2017 UTC (7 years, 2 months ago) by mlarkin
Branch: MAIN
Changes since 1.7: +30 -4 lines
Diff to previous 1.7 (colored)

Implement memory size and SMP CPU count NVRAM registers in the emulated
mc146818. This is needed for seabios to boot properly (and construct
a sensible e820 map to send to the guest OS).

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

Various mc146818 emulation fixes - don't block interrupts needlessly, and
set proper return data size (don't clobber high %eax bits). Also apply
a mask on incoming data (from OUT instruction in guest) to avoid
misinterpreting register index values. Found when implementing Linux and
seabios support.

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

Don't identify the MC146818 RTC as operating in binary mode when we are really
operating in BCD mode. Linux assumes the RTC will be in BCD mode by default
and if not, it does a WARN_ON warning about this, and misinterprets the RTC
TOD registers.

Tested with existing vmd/vmm guests with what's in tree.

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: +3 -3 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 17:28:34 2016 UTC (7 years, 9 months ago) by mlarkin
Branch: MAIN
Changes since 1.1: +10 -10 lines
Diff to previous 1.1 (colored)


normalize some function names

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.