Bug #14429


simplify bhyve vatpic

Added by Patrick Mooney 7 months ago. Updated 6 months ago.

Start date:
Due date:
% Done:


Estimated time:
Gerrit CR:


The vATPIC emulation in bhyve carries a bunch of state in types that are too large and/or expansive for what they represent - using int for booleans, for example. It would be nice to clean this logic up, and make it more readable so that it is easier to deal with for kernel device import/export during a live migration.

As part of this simplification, two apparent bugs in the ATPIC emulation are being fixed:
1. If special-full-nested mode was enabled at any point, it could not be disabled
2. The RR bit in OCW3 gated the ability to to set poll mode (if OCW3_P was set without OCW3_RR, it was ignored)

There have been no reports of either bugs triggering an issue. Considering how minimally the ATPIC is used by modern operating systems, given the presents of the IOAPIC, this does not come as a surprise.

Actions #1

Updated by Electric Monk 7 months ago

  • Gerrit CR set to 1970
Actions #2

Updated by Patrick Mooney 7 months ago

  • Description updated (diff)
Actions #3

Updated by Patrick Mooney 6 months ago

To test this, I ran a variety of guests on a host using the updated bits. All booted and ran normally. While they ran, I dtrace the functions related to ATPIC emulation. I could see the PIC go through the full ICW 1-4 initialization (sometimes more than once, depending on the guest), in addition to interrupts through it, prior to its masking (so the IOAPIC could take over). The os-shipped bhyve tests still work, although none cover the ATPIC at the moment, so no change was expected there. In addition, I booted some propolis-based guests to see if the vanilla-OVMF ROM resulted in any unexpected behavior. That worked fine as well.

Actions #4

Updated by Electric Monk 6 months ago

  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100

git commit 84874e4a9449449560fa7d52a8742eed23733073

commit  84874e4a9449449560fa7d52a8742eed23733073
Author: Patrick Mooney <>
Date:   2022-02-08T17:51:47.000Z

    14429 simplify bhyve vatpic
    Reviewed by: Dan Cross <>
    Approved by: Dan McDonald <>


Also available in: Atom PDF