Starlet: re-sample the ARM IRQ and FIQ lines on interrupt register writes #4

Closed
Yaya48 wants to merge 0 commits from staros/irq-line-resample into master
pull from: staros/irq-line-resample
Owner

For StarOS M3C (decision 42, option A). Review before any merge into master; do not merge without the maintainer's word.

Problem

The Starlet core's IRQ/FIQ lines were set from WiiIPC's flags and masks only at the start of each scheduler slice (Starlet::RunSlice, StarletBootstrapProbe: 4096 cycles). Acknowledging an interrupt (HW_ARMIRQFLAG, write one to clear) or masking it (HW_ARMIRQMASK) left the line asserted until the next slice, so code that acknowledged an interrupt and unmasked IRQ within the same slice took it again with no cause pending. Hollywood's interrupt output is level-sensitive.

Change (d486779f50, 6 files, +81)

  • StarletMemory::AttachInterruptLines(ARMCore*); a write to HW_ARMIRQFLAG or HW_ARMIRQMASK (wide and byte-assembled paths) re-samples the attached core's IRQ and FIQ lines at once.
  • Starlet and StarletBootstrapProbe attach their core (destroyed before the memory).
  • ARMCore::IsIRQLineAsserted / IsFIQLineAsserted for the test.
  • Unchanged: raising a cause still reaches the core at the next slice; timer, alarm, acknowledgement semantics; no new saved state.

Tests

  • New StarletInterrupts.InterruptRegisterWritesResampleTheAttachedCoreLines (ack lowers the line at once; mask/unmask of a latched cause; byte-assembled path; FIQ line). One-off mutant (UpdateInterruptLines doing nothing) makes it fail.
  • tests.exe --gtest_filter=Starlet*: 184 run, 179 PASS, 5 skipped (Ethernet NAT, environment), 0 failed.
  • Probe out/dprobe/d486779f50ec, StarletBootstrapProbe.exe d2c97393…: every StarOS scenario, 32/32 PASS, traces and outputs identical to the bef2c8cf02 probe's (StarOS report lle-20261016T003543Z).
  • The format-patch applied to master rebuilds the branch tree 8569694d.

Review fix (6c44367b5c, StarOS decision 44)

  • HW_ARMFIQMASK writes re-sample the lines too.
  • Tests: FIQ mask/unmask of a latched cause (wide and byte paths, then an acknowledgement); two pending IRQ sources (acknowledging one keeps IRQ asserted, the last lowers it). Mutant without HW_ARMFIQMASK fails the FIQ test.
  • Lifetime: the attached core is never used after destruction (Shutdown resets m_core then m_memory with nothing between; ~Starlet destroys m_core first; Init attaches after its last failure path; the probe's core is a local declared after its memory). No change needed.
  • tests.exe Starlet*: 186 run, 181 PASS, 5 skipped (Ethernet NAT), 0 failed. Probe 6c44367b5c7a 8d660d45…: the 32 StarOS runs identical to the bef2c8cf02 probe's (report lle-20261016T010928Z).
  • Approved by the maintainer (decision 44); fast-forwarded into master.
For StarOS M3C (decision 42, option A). Review before any merge into `master`; do not merge without the maintainer's word. ## Problem The Starlet core's IRQ/FIQ lines were set from WiiIPC's flags and masks only at the start of each scheduler slice (`Starlet::RunSlice`, `StarletBootstrapProbe`: 4096 cycles). Acknowledging an interrupt (`HW_ARMIRQFLAG`, write one to clear) or masking it (`HW_ARMIRQMASK`) left the line asserted until the next slice, so code that acknowledged an interrupt and unmasked IRQ within the same slice took it again with no cause pending. Hollywood's interrupt output is level-sensitive. ## Change (`d486779f50`, 6 files, +81) - `StarletMemory::AttachInterruptLines(ARMCore*)`; a write to `HW_ARMIRQFLAG` or `HW_ARMIRQMASK` (wide and byte-assembled paths) re-samples the attached core's IRQ and FIQ lines at once. - `Starlet` and `StarletBootstrapProbe` attach their core (destroyed before the memory). - `ARMCore::IsIRQLineAsserted` / `IsFIQLineAsserted` for the test. - Unchanged: raising a cause still reaches the core at the next slice; timer, alarm, acknowledgement semantics; no new saved state. ## Tests - New `StarletInterrupts.InterruptRegisterWritesResampleTheAttachedCoreLines` (ack lowers the line at once; mask/unmask of a latched cause; byte-assembled path; FIQ line). One-off mutant (`UpdateInterruptLines` doing nothing) makes it fail. - `tests.exe --gtest_filter=Starlet*`: 184 run, 179 PASS, 5 skipped (Ethernet NAT, environment), 0 failed. - Probe `out/dprobe/d486779f50ec`, `StarletBootstrapProbe.exe` `d2c97393…`: every StarOS scenario, 32/32 PASS, traces and outputs identical to the `bef2c8cf02` probe's (StarOS report `lle-20261016T003543Z`). - The format-patch applied to `master` rebuilds the branch tree `8569694d`. ## Review fix (`6c44367b5c`, StarOS decision 44) - `HW_ARMFIQMASK` writes re-sample the lines too. - Tests: FIQ mask/unmask of a latched cause (wide and byte paths, then an acknowledgement); two pending IRQ sources (acknowledging one keeps IRQ asserted, the last lowers it). Mutant without `HW_ARMFIQMASK` fails the FIQ test. - Lifetime: the attached core is never used after destruction (`Shutdown` resets `m_core` then `m_memory` with nothing between; `~Starlet` destroys `m_core` first; `Init` attaches after its last failure path; the probe's core is a local declared after its memory). No change needed. - `tests.exe Starlet*`: 186 run, 181 PASS, 5 skipped (Ethernet NAT), 0 failed. Probe `6c44367b5c7a` `8d660d45…`: the 32 StarOS runs identical to the `bef2c8cf02` probe's (report `lle-20261016T010928Z`). - Approved by the maintainer (decision 44); fast-forwarded into `master`.
Yaya48 added 1 commit 2026-10-16 02:38:06 +02:00
The core's IRQ and FIQ lines were set from WiiIPC's flags and masks only at
the start of each scheduler slice (Starlet::RunSlice, StarletBootstrapProbe).
Acknowledging an interrupt (HW_ARMIRQFLAG, write one to clear) or masking it
(HW_ARMIRQMASK) left the line asserted until the next slice, so code that
acknowledged an interrupt and unmasked IRQ within the same slice took it
again with no cause pending. Hollywood's interrupt output is level-sensitive.

StarletMemory now re-samples the lines of the core attached with
AttachInterruptLines on every write to those two registers, on both its
wide and byte-assembled write paths; Starlet and StarletBootstrapProbe
attach theirs. Raising a cause still reaches the core at the next slice, as
before. ARMCore exposes IsIRQLineAsserted and IsFIQLineAsserted for the
unit test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Yaya48 added 1 commit 2026-10-16 03:12:08 +02:00
Review of d486779f50 (StarOS decision 44):
- A write to HW_ARMFIQMASK re-samples the attached core's IRQ and FIQ lines,
  as writes to HW_ARMIRQFLAG and HW_ARMIRQMASK do.
- Tests: FIQ masking and unmasking of a latched cause (wide and
  byte-assembled writes, then an acknowledgement); two pending IRQ sources,
  where acknowledging one keeps the line asserted and acknowledging the
  last lowers it.

The attached core cannot be used after it is destroyed: Starlet::Shutdown
resets m_core then m_memory with nothing in between, ~Starlet destroys
m_core (declared after m_memory) first, Init attaches only after the last
path that can fail, StarletMemory::Reset keeps the core, which is still
alive, and the probe's core is a local declared after its memory.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Yaya48 closed this pull request 2026-10-16 03:12:24 +02:00
Yaya48 deleted branch staros/irq-line-resample 2026-10-16 03:12:24 +02:00

Pull request closed

This pull request cannot be reopened because the branch was deleted.
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Yaya48/dolphin#4