A watchdog vdev for x86 (vdev wdt-ib700)

The wdt-ib700 vdev emulates an IB700 watchdog timer for x86 platforms.

For information about how to configure and use this vdev, see the vdev wdt-ib700 reference in the User's Guide “Virtual Device Reference” chapter.

Like the wdt-sp805 vdev that emulates an ARM hardware device, the wdt-ib700 vdev is architecture-specific; it emulates an x86 hardware device, and can be used only on x86 platforms. This vdev is simpler than the ARM one because it has less to do to emulate the x86 IB700 watchdog hardware device.

The wdt-ib700 vdev shares the same fundamental anatomy and behavior as other vdevs. Specifically, it:
  • Defines itself as a data structure (wdt_state).
  • Sets some default values that may or may not be overridden by options input through the VM configuration, including through the common vdev options parsed by the qvm process. An example is the loc option that by default is set to the hardware default location for the IB700 watchdog: 0x441 (vdp->v_block.location = 0x441u;).
  • Uses a control function (wdt_control()) to look after:

    1. startup tasks
    2. the tasks it must perform when it is running
  • Marks the end of its startup with the VDEV_CTRL_OPTIONS_END callback; for such a simple vdev this is sufficient, though more complex vdevs should use the VDEV_CTRL_GUEST_CONFIGURED and VDEV_CTRL_GUEST_STARTING callbacks.
  • Populates its factory structure, specifying the functions to call when triggered by callbacks from the qvm process.
  • Calls the vdev_register_factory() function to register itself in the VM framework.
  • Uses mutexes to protect the integrity of the data when, for example, checking if the guest has written to a vCPU register to prompt the vdev to reset or disable its timer, or when checking the timer state and determining if it should bite the guest.
Note:

In this vdev's factory structure, the vread member is set to NULL, unlike the equivalent member in the wdt-sp805 vdev. The wdt-ib700 vdev doesn't have to handle reads from the guest, and therefore doesn't need a function that calls the guest_cpu_write() function to update the vCPU.

Also, as with the wdt-sp805 vdev, the action taken on a watchdog bite is set by the vdev's action option, and implemented in the wdog_bite() function.