Skip to content

chipset: PIC poll-mode read does not re-sync outputs; the next INTA panics with "pic1 ready was set" #1062

Closed

Description

@q5438722

Summary

A poll-mode read of a PIC command port (OCW3 with P = 1) acknowledges the highest-priority pending IRQ, but DualPic::io_read never calls sync_outputs() afterwards. io_write, set_irq, acknowledge_interrupt and reset all do. As a result, the cascade line (primary IRQ2) and ready keep stale levels. After a poll of the secondary, the next INTA cascades into a secondary with nothing pending and panics. A guest can trigger this with two port accesses.

Repro

pic_poll_read_sync.txt

Add the attached pic_poll_read_sync.rs (.txt) to vm/devices/chipset/tests/ and run:

cargo test -p chipset --test pic_poll_read_sync
  1. Initialize both PICs (ICW1–ICW4).
  2. set_irq(8, true): IRQ8 is pending and ready goes high.
  3. Write 0x0c (OCW3, poll) to port 0xa0, then read 0xa0. It returns 0x80: the secondary acknowledged IR0.
  4. acknowledge_interrupt(), since ready is still high.

Expected

After step 3 nothing is pending, so IRQ2 and ready go low. On an 8259A, a cascaded slave with no request answers INTA with its IR7 (spurious) vector.

Actual

thread 'secondary_poll_then_inta_does_not_panic' panicked at vm/devices/chipset/src/pic/mod.rs:113:17:
pic1 ready was set

poll_read_resyncs_outputs also fails: ready is still high after the poll acknowledged the only pending IRQ.

Root cause

sync_outputs() derives primary IRQ2 from the secondary's state and ready from the primary's state. io_read (pic/mod.rs:166) skips it, which breaks the invariant behind assert!(requested, "pic1 ready was set"): IRQ2 high ⇒ the secondary has a request. A poll of the primary leaves ready high in the same way, and the next INTA then returns a spurious interrupt.

Impact

A guest can panic the VMM with two PIO accesses while any IRQ 8–15 (e.g. the RTC) is pending. Poll mode is rare in modern OSes.

Suggested fix

--- a/vm/devices/chipset/src/pic/mod.rs
+++ b/vm/devices/chipset/src/pic/mod.rs
@@ -176,6 +176,9 @@ fn io_read(&mut self, io_port: u16, data: &mut [u8]) -> IoResult {
             SECONDARY_PIC_ELCR_PORT => self.pics[1].elcr,
             _ => return IoResult::Err(IoError::InvalidRegister),
         };
+        // A poll-mode command read acknowledges an interrupt, so the cascade
+        // line and the ready output may need to change.
+        self.sync_outputs();
         IoResult::Ok
     }
 

Activity

  1. ppenna commented on Nov 11, 2026

    @ppenna
    Contributor

    Closing: this is an OpenVMM bug outside NVX, and upstream fixed it in microsoft/openvmm#4838, chipset: synchronize PIC outputs after poll reads, merged on 2026-11-01. NVX's OpenVMM pin, 58d3c3b1d, includes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions