Skip to content

aarch64: send IDX = -1 for a VGICMaintenance fault without a valid index - #147

Merged
losfair merged 1 commit into
losfair:mainfrom
CommaBot:fix/a64-vgic-maint-invalid-idx
Dec 1, 2026
Merged

losfair merged 1 commit into
losfair:mainfrom
CommaBot:fix/a64-vgic-maint-invalid-idx

Conversation

@CommaBot

@CommaBot CommaBot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Bug

On AArch64, a VGIC maintenance interrupt with EISR == 0 (no list register signalled an EOI, e.g. a GICv2 underflow maintenance with GICH_HCR.UIE) makes handle_vgic_maintenance (crates/fl4-core/src/arch/aarch64/vcpu.rs:339-349) raise Fault::VgicMaintenance { idx_valid: false }. set_mrs_fault (crates/fl4-core/src/faults.rs:188-189) then wrote no message words and the fault IPC had length 0.

seL4 at the pinned commit c98d70ad (src/arch/arm/api/faults.c:46-52, Arch_setMRs_fault) always sends one word, seL4_VGICMaintenance_IDX: the index, or -1 when it is not valid. l4v makeArchFaultMsg agrees (none => [-1] | some idx => [idx]).

Fix

} else if ty == ft::VGICMaintenance {
    return msg::set_mr(s, receiver, buf, 0, if w1 != 0 { w0 } else { u64::MAX });
}

Tests

  • New unit test vcpu::tests::vgic_maintenance_fault_message_has_one_word (--features aarch64): set_fault + ipc::do_ipc_transfer for idx_valid = false / true checks label VGICMaintenance, length 1 and MR0 = -1 / idx. It fails before the fix (idx_valid=false: one message word, left 0, right 1) and passes after.
  • fl4test FL4VCPU0003 (GICv2 branch) asserted the buggy length 0; it now expects length 1 and IDX == (seL4_Word)-1. Not run locally (QEMU AArch64 GICv2 run).
  • cargo test -p fl4-core, cargo test -p fl4-core --features aarch64, cargo test -p fl4-sync, cargo test -p fl4-sim: pass. cargo clippy -p fl4-core --features aarch64 --all-targets: no new warnings (47 before and after). cargo check -p fl4-kernel-aarch64 --target aarch64-unknown-none-softfloat: ok.

Proofs

proofs/ is not touched. The change is inside #[cfg(feature = "aarch64")] with no signature change, so only the AArch64 extraction (proofs/Fl4CoreA64/Funs.lean) changes and re-extracts in the gate / a follow-up PR. Users of that arm to recheck then: the generated Fl4ProofsA64/P2/ProgGenVf11.lean (regenerated by gen_prog.py) and the hand proofs in Fl4ProofsA64/P1/QueueRecv.lean (four -- a64: VgicMaintenance (an if as for VmFault) cases) and QueueXfer.lean / QueueXferFoot.lean (which already treat the arm as one set_mr). The x86_64 extraction is unchanged.

🤖 Generated with Claude Code

When the VGIC maintenance interrupt arrives with EISR == 0 (no list
register signalled an EOI, e.g. a GICv2 underflow with GICH_HCR.UIE),
handle_vgic_maintenance raises the fault with idx_valid = false.
set_mrs_fault then wrote no message words and returned length 0.

seL4 Arch_setMRs_fault (src/arch/arm/api/faults.c:46-52) and l4v
makeArchFaultMsg always send one word, seL4_VGICMaintenance_IDX, set to
the index or to -1 when it is not valid. Do the same.

- crates/fl4-core/src/faults.rs: always set MR0, u64::MAX when !idx_valid.
- vcpu.rs unit test: fault transfer for idx_valid false/true gives label
  VGICMaintenance, length 1 and MR0 = -1 / idx (fails before the fix).
- fl4test FL4VCPU0003 (GICv2 branch) expected the buggy length 0: now
  expects length 1 and IDX == -1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@losfair
losfair merged commit c98a08b into losfair:main Dec 1, 2026
1 check failed
losfair pushed a commit that referenced this pull request Dec 1, 2026
)

* proofs(aarch64): re-extract Fl4CoreA64 after #147 (VGICMaintenance IDX = -1)

Mechanical re-extraction of proofs/Fl4CoreA64/Funs.lean on main (c98a08b)
with pinned Aeneas nightly-2026.11.14-0d21a9e after #147.

Only faults.set_mrs_fault changes (+3/-1 lines): the w1 == 0 branch of
VGICMaintenance now calls msg.set_mr(..., 0, core.num.U64.MAX) instead of
returning ok (0, s). Types.lean, FunsExternal*.lean, and x86_64 Fl4Core
are completely unchanged.

* proofs(aarch64): adapt the A64 proofs to set_mrs_fault's IDX = -1 word (#147)

After #147 the AArch64 extraction's faults.set_mrs_fault writes one message
word (msg.set_mr ... 0 core.num.U64.MAX) in the VGICMaintenance arm when the
fault index is not valid, instead of returning ok (0, s) without a write.

- P2/ProgGenVf11.lean: regenerated with
  `xtask/scripts/gen_prog.py --arch aarch64 Vf syscall.handle_vm_fault_local`
  (not hand-edited); the only change is R.faults.set_mrs_fault's
  invalid-index branch, now `R.msg.set_mr receiver buf 0#u64 core.num.U64.MAX`.
- P1/QueueXfer.lean (faults.set_mrs_fault.xs), P1/QueueXferFoot.lean
  (faults.set_mrs_fault.xsf), P1/MdbXferL.lean (faults.set_mrs_fault.gx):
  the VGICMaintenance invalid-index case is now discharged by the same
  one-`set_mr` step as the valid-index case (set_mr_last / set_mr_lastF / gml)
  instead of the `ok` step.

No theorem statement changes; no generator or kernel changes.
Fl4ProofsA64 root build: 0 errors, 0 sorry; #print axioms on the changed
declarations: propext, Classical.choice, Quot.sound only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
losfair pushed a commit that referenced this pull request Dec 1, 2026
… the CDT and IPC-buffer history (DESIGN §9 item 4) (#149)

DESIGN §9 item 4, both halves, for AArch64. One commit on `main` @ `c98a08b1c` (after #146 and #147): 34 files, +9216 / −199. No Rust changes (nothing under `crates/`). No x86 statement changes.

**Half 1 (the history along an execution).** A replay record `InvR` beside `InvH`; P1's MDB tree facts hold of the replayed history (`MdbSH`) along every execution of the local-path family, every slot's edit being one of P1's (`SlotWireP`). The top family is `fl4LocPBL` (`DelLkA`): the Delete-with-PTE start needs the CDT facts only at its own locked slots (`CdtAtL`), discharged from the history, so the all-slot `MdbLk` / `NullLk` [J] is gone. The IPC-buffer words are gate-owned, so `BufSH` is kept along an execution and gives the PTE slots' `bufU`. Boot corollaries at w0/w1 (`w0_serial_mdbL`, `w1_serial_mdbL`).

**Half 2 (the gate and the locks themselves).** `proofs/Fl4P2Base/GateImpl.lean` hand-transcribes fl4-sync's gate (`try_enter_local`, `leave_local`, `acquire`, the serial body, `release`) and fl4-store's lock table (`try_lock_object`, `unlock_held`), plus hardware writes, as `ICfg` / `IStepG` / `IStepL` / `IStepHw` (listed in `TRUSTED` with its modelling choices). `impl_sim` matches every runtime step by zero or one gate-model step (`StepR`: a `Serial.Step`, or a racy speculative read returning another value; on gate- or core-class words a value of the current class), keeping `Rel` and the lock invariant `LkInv`; hardware writes during a pending serial body are deferred and replayed after the model's `serial` at the release's decisive store. Racy reads are covered by weak safety `SafeW` from the same per-path certificates. `impl_execPA` / `serializable_implPA` (`GateExecA`): every runtime execution from boot is an FL4 execution, and where no local path runs and no body is pending its memory is the serial run of the completed entries; `w0_serializable_impl` / `w1_serializable_impl` (`GateBootA`) at the boot witnesses for `fl4LocPBL`.

**Premises and hypotheses.**
- Named premises added: [P] MM-SB, MM-DRF, MM-RACY, IPI (the transcription's step granularity, stated in `GateImpl`'s docstring; no Lean hypothesis carries them). `IHwPA` is `HwStepPA`'s existing [P] moved to the runtime. No [W].
- Theorem hypotheses left to the serial-kernel side: `hSer` / `hSerB` (serial entries keep `MdbSH` / `BufSH`; AArch64 P1 / S1A) and `BufSH` at w0/w1 (S1A / Boot).
- Not yet proved: the Half 1 history facts along the weak executions `ExecPAR` (proved along `ExecPA`).

**Merge with #146.** Text conflicts only: `proofs/Fl4ProofsA64.lean` (union of imports, no duplicates) and `DESIGN.md` §9 status (main's `w1_sysL` kept; this PR's item-4 bullets added; the "Not yet proved" bullet reconciled: `SysL` at w1 is no longer listed). No proof conflicts. Existing declarations: 0 statement changes against the pre-rebase branch.

**Checks.**
- `Fl4ProofsA64` root build on this tree: 0 errors, 0 sorry, "Build completed successfully (5755 jobs)". Module builds of every changed module and its users (the gate files, the A64 P2 files of this PR, and the x86 `Fl4Proofs.P2` re-export modules): 0 errors, 0 sorry (5548 jobs).
- Axioms: sweep of all 18882 constants under `Fl4ProofsA64.P2` and `Fl4Proofs.P2` (`Fl4P2Base`): 0 outside propext / Classical.choice / Quot.sound; plus 109 `#print axioms` on the gate files' and `GateBootA`'s theorems: 68 `[propext, Classical.choice, Quot.sound]`, 21 `[propext]`, 3 `[propext, Quot.sound]`, 17 none, 0 `sorryAx`.
- No sorry / admit / native_decide / bv_decide / axiom / maxHeartbeats in the diff; every new module is imported from `Fl4ProofsA64`.
- `python3 xtask/scripts/port_p2_a64.py --check proofs`: exit 0.
- No x86 root build: the x86 users of `Fl4P2Base` are the unchanged re-export modules `Fl4Proofs.P2.Serial` / `SerialHw` / `SafeCert` / `SerialSafe`, built as modules.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants