[WIP] virtio: detect PIIX4 and attempt to power off via PIIX4 (broken) #500
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is attempt 1 of 2 to solve #499 (attempt 2 is at #501)
Summary:
This is my failed attempt to resolve #499 . It will detect the PIIX4 on GCE and attempt to power off if you exit the mirage unikernel (e.g. raise an uncaught exception right after you start), but it hangs instead of powering off because it's not a correct implementation.
Discussion:
Detecting the PIIX4 on the PCI bus works; it requires a simple change to the
pci_enumerate
function to list "functions" of PCI devices. The part where it tries to actually instruct the PIIX4 to power off is completely broken though.I'm at the limits of my understanding of low-level x86 architecture, but will post this anyway in the event that someone with more expertise can determine if this is 90% of the way there and make use of it.
The specific problem is the base address that PCI enumeration probes for the PIIX4 device is 0, which obviously can't be used to inw/outw the device. I tried to learn the from this Linux kernel code but it became too challlenging for me to reason about.