History log of /openbsd/usr.sbin/vmd/mc146818.c (Results 1 – 25 of 29)
Revision Date Author Comments
# c4fd4c5b 10-Jul-2024 dv <dv@openbsd.org>

Split vmd into mi/md parts.

Makes as much of the core of vmd mi, pushing x86-isms into separate
compilation units. Adds build logic for arm64, but no emulation
yet. (You can build vmd, but it won't

Split vmd into mi/md parts.

Makes as much of the core of vmd mi, pushing x86-isms into separate
compilation units. Adds build logic for arm64, but no emulation
yet. (You can build vmd, but it won't have a vmm device to connect
to.)

Some more cleanup probably needed around interrupt controller
abstraction, but that can come as we implement more than the i8259.

ok mlarkin@

show more ...


# ba66f564 09-Jul-2024 dv <dv@openbsd.org>

vmd/vmm: move vm_run_params into mi header.

To prepare for mi/md splitting vmd, need to fixup the dev/vmm/vmm.h
mi header. Move the vm_run_params struct and clean up the includes
in vmd.

"sure", ml

vmd/vmm: move vm_run_params into mi header.

To prepare for mi/md splitting vmd, need to fixup the dev/vmm/vmm.h
mi header. Move the vm_run_params struct and clean up the includes
in vmd.

"sure", mlarkin@

show more ...


# 9bd123e2 25-Oct-2023 dv <dv@openbsd.org>

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

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@

show more ...


# 1999429c 18-Apr-2023 tb <tb@openbsd.org>

I somehow overlooked four more missing void...


# 418ce7a9 15-Jan-2022 mlarkin <mlarkin@openbsd.org>

vmd: Remove a warning about non-32KHz timebases

Remove a warning that has outlived its usefulness.

From Brian Conway, thanks.


# 6eb4c859 16-Jun-2021 dv <dv@openbsd.org>

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 bi

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@

show more ...


# bc11ef5c 29-Mar-2021 dv <dv@openbsd.org>

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 reinitial

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@

show more ...


# 08fd0ce3 28-Jun-2020 pd <pd@openbsd.org>

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

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@

show more ...


# 9d3767a2 30-Nov-2019 mlarkin <mlarkin@openbsd.org>

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@


# ee8a1797 29-Nov-2019 mlarkin <mlarkin@openbsd.org>

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

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@

show more ...


# a50a4aa6 27-May-2019 jasper <jasper@openbsd.org>

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

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@

show more ...


# 02ee787f 12-Jul-2018 mlarkin <mlarkin@openbsd.org>

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


# 7b36e131 09-Jul-2018 mlarkin <mlarkin@openbsd.org>

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 occ

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

show more ...


# e605192a 28-Feb-2018 pd <pd@openbsd.org>

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 Dav

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@

show more ...


# 52e954a3 09-Jul-2017 pd <pd@openbsd.org>

vmd/vmctl: Add ability to pause / unpause vms

With help from Ashwin Agrawal

ok reyk@ mlarkin@


# 149417b6 08-May-2017 reyk <reyk@openbsd.org>

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

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@

show more ...


# e82d5294 02-May-2017 mlarkin <mlarkin@openbsd.org>

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


# f9eeb76b 27-Mar-2017 deraadt <deraadt@openbsd.org>

die whitespace die die die


# 41b1eddd 26-Mar-2017 kettenis <kettenis@openbsd.org>

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 garbag

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@

show more ...


# b966d91a 25-Mar-2017 mlarkin <mlarkin@openbsd.org>

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


# 46635426 25-Mar-2017 mlarkin <mlarkin@openbsd.org>

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


# 909b2594 23-Mar-2017 mlarkin <mlarkin@openbsd.org>

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).


# c089a9ad 23-Mar-2017 mlarkin <mlarkin@openbsd.org>

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

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.

show more ...


# bfcb3828 19-Mar-2017 mlarkin <mlarkin@openbsd.org>

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

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.

show more ...


# 24c50ede 17-Jan-2017 krw <krw@openbsd.org>

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


12