Goal: distinguish acceptance from completion
Preparing a virtual interrupt in an LR does not mean the guest completed it. Follow the EL1 IRQ vector into handle_guest_irq, read the identifier through IAR, perform EOI and DIR, and return toward ordinary execution. Compare GUEST_ACK, GUEST_EOI, and GUEST_EOI_DIR in order and identify the exact boundary where the same interrupt changes state.
The experiment also uses HVC calls for observation between EL1 and EL2. An HVC log alone is not proof of an IRQ exception; establish the preceding guest vector entry and IAR read. Read handle_guest_irq alongside handle_sync to distinguish guest completion operations from EL2 logging. Event names should guide investigation, not replace examination of the executed control path.
Reading IAR is not merely displaying a number
The guest reads ICC_IAR1_EL1 to obtain the accepted interrupt identifier. In irqNormal it returns forty while the LR changes from Pending to Active. Carry that acknowledged identifier into the later EOI and DIR operations. Blindly writing the originally intended constant would complete the wrong interrupt if the accepted identifier differed.
Active means an interrupt remains in service, not that the LR is free. The admission helper rejects Pending, Active, and combined Pending-and-Active occupancy. Looking only at delivery counts can miss state left behind after the first acceptance. Observe LR state together with handler progress to establish whether reinjection is permitted and to separate acknowledgment from release of the delivery resource.
Split EOI separates priority drop from deactivation
This implementation selects split EOI mode. Writing ICC_EOIR1_EL1 performs the priority-drop part of completion but does not by itself make the virtual interrupt Invalid. The subsequent ICC_DIR_EL1 write deactivates it. In the measured run the LR remains Active after EOI and becomes Invalid after DIR. Do not treat the name EOI as an unconditional synonym for complete release.
An observation HVC between EOI and DIR exposes that distinction. Completion behavior depends on configuration, so keep this explanation attached to the distributed split EOI setup. Copying the same sequence into another operating system or mode without examining its configuration is not justified. Pair each completion operation with the mode under which its meaning is being observed.
Measured trace: three states for one identifier
irqNormal records LR values 0x5080000000000028 at injection, 0x9080000000000028 after acceptance, the same Active value after EOI, and 0x1080000000000028 after DIR. Extracting the top two bits yields one, two, two, and zero: Pending, Active, Active, and Invalid. Identifier forty and other attributes remain. A nonzero final register is not evidence of failure.
GUEST_EOI_DIR records one delivery, and DONE confirms one. The table extracts states from the actual recorded irqNormal execution. Unlike variable timer counter readings, this encoding is an appropriate fixed assertion for the configured experiment. Still decode the state field: selecting a different priority or identifier changes the complete hexadecimal value without changing the lifecycle.
| Log | LR0 | State |
|---|---|---|
| INJECT | 0x5080000000000028 | Pending |
| GUEST_ACK | 0x9080000000000028 | Active |
| GUEST_EOI | 0x9080000000000028 | Still Active |
| GUEST_EOI_DIR | 0x1080000000000028 | Invalid, one delivery |
Do not confuse masked Pending state with loss
irqMasked prepares the virtual interrupt while the guest retains the DAIF IRQ mask. The LR becomes Pending, but the guest handler does not yet run. Acceptance and completion follow unmasking. This is retention until acceptance conditions are satisfied, not disappearance of the request. Observe pending state separately from the ability to enter the handler.
The normal case delivers forty once; boundary and repeated cases exercise admitted identifiers and reinjection after completion. Failure cases reject reserved identifiers or occupied-state reuse. For repetition, establish that the first DIR completed before the second injection. A growing delivery count alone cannot show whether an unfinished request was overwritten. Combine identifier, state, count, and ordering evidence.
Runnable Rust: a completion-state contract
The standalone host Rust program uses a simplified Pending, Active, and Invalid state model. It does not access GIC registers or model every priority and nesting condition. It checks the split EOI contract: masking retains Pending, acceptance creates Active, EOI preserves Active, and deactivation returns Invalid.
Pay particular attention to rejection of injection while Active and rejection of deactivation from Invalid. Transitions have preconditions. Do not infer hardware behavior merely from these functions; compare the contract with the measured LR sequence. Pure state tests can reveal design mistakes early, while QEMU execution establishes vector entry and register interaction. These complementary checks support different parts of the explanation.
#[derive(Debug, PartialEq, Clone, Copy)]
enum State { Invalid, Pending, Active }
fn inject(s: State) -> Result<State, &'static str> {
if s != State::Invalid { return Err("busy"); } Ok(State::Pending)
}
fn acknowledge(s: State, masked: bool) -> State {
if s == State::Pending && !masked { State::Active } else { s }
}
fn eoi(s: State) -> State { s } // split EOI: priority drop only
fn deactivate(s: State) -> Result<State, &'static str> {
if s != State::Active { return Err("not active"); } Ok(State::Invalid)
}
fn main() {
let p = inject(State::Invalid).unwrap();
assert_eq!(acknowledge(p, true), State::Pending);
let a = acknowledge(p, false);
assert_eq!(a, State::Active);
assert_eq!(eoi(a), State::Active);
assert_eq!(inject(a), Err("busy"));
assert_eq!(deactivate(a), Ok(State::Invalid));
assert_eq!(deactivate(State::Invalid), Err("not active"));
println!("Pending -> Active -> Active after EOI -> Invalid after DIR");
}Returning from the exception is part of execution
An IRQ handler must preserve enough state to resume ordinary execution, not merely print a message. Follow the vector assembly saving registers, calling Rust, and returning. Correct IAR and DIR operations cannot compensate for a corrupted return context. Read arrival at DONE together with the interrupt-completion state as evidence that execution continued afterward.
Additional observation HVCs can alter timing, so increasing logging does not automatically preserve identical experimental conditions. Rebuild, update source and ELF identities, and record again after such changes. Establish resumption, processing of another request, and arrival at the stopping condition in sequence. Those observations connect one successful IRQ to continuing guest execution rather than treating handler entry as the whole result.
Exercise: do not assume EOI means release
Decode the state field from all four irqNormal LR observations. Predict whether a new request could be admitted immediately after GUEST_EOI and compare that prediction with the host admission contract. Explain rejection in the state model before attempting an unsafe overwrite in modified machine code. The same identifier can have different lifecycle meanings in Pending and Active states.
Compare irqMasked with irqRepeated to contrast retention and reuse after completion. Submit ordered logs, decoded states, delivery counts, and a later event proving resumption. For an extension, connect the split EOI setup to the guest EOIR and DIR writes in source. Put observation HVCs in a separate column from actual GIC operations to avoid treating explanatory logging as the interrupt itself.