Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions crates/fl4-arch-aarch64/src/arch.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! `fl4_core::machine::Arch` on AArch64 hardware. Every operation runs at
//! once: kernel entries run under the serial gate, or are local paths
//! beside it whose operations concern their own core (DESIGN.md §7).
use crate::{gic, percpu, serial, smp, timer};
use crate::{cpu, gic, percpu, serial, smp, timer};
use core::sync::atomic::{AtomicBool, Ordering};
use fl4_core::layout::irq;
use fl4_core::machine::Arch;
Expand Down Expand Up @@ -43,12 +43,16 @@ fn eoi_value(irq: u64) -> u64 {
}
}

/// Take the highest pending interrupt, leaving the remote-call SGI
/// pending: it is serviced on the way into the kernel, never by a
/// preemption point. Returns the interrupt's IRQ, or `NO_IRQ`.
fn irq_serviced_on_entry(id: u64) -> bool {
id == irq::REMOTE_CALL_ID || ((id == irq::VGIC_MAINT_ID || id == irq::TIMER_ID) && cpu::has_el2())
}

/// Take the highest pending interrupt and return its IRQ, or `NO_IRQ`.
/// Preemption points leave the remote-call SGI and, when the kernel owns
/// EL2, the VGIC maintenance and virtual timer PPIs pending for kernel entry.
pub fn poll_irq() -> u64 {
let hp = gic::highest_pending();
if gic::is_spurious(hp) || hp == irq::REMOTE_CALL_ID {
if gic::is_spurious(hp) || irq_serviced_on_entry(gic::raw_id(hp)) {
return fl4_core::syscall::NO_IRQ;
}
let raw = gic::ack();
Expand All @@ -61,8 +65,9 @@ pub fn poll_irq() -> u64 {
gic::eoi(raw);
return fl4_core::syscall::NO_IRQ;
}
if id == irq::REMOTE_CALL_ID {
// Raced with a new remote call: it is serviced on entry anyway.
if irq_serviced_on_entry(id) {
// The pending IRQ changed before acknowledge. End it without
// masking so a level-triggered PPI can reassert for entry.
gic::eoi(raw);
return fl4_core::syscall::NO_IRQ;
}
Expand Down
Loading