Skip to content

Commit

Permalink
[fix] enable IRQ in boot_el2.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
hky1999 committed Nov 19, 2024
1 parent 44a5351 commit 9422e20
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions modules/axhal/src/irq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ pub(crate) fn register_handler_common(irq_num: usize, handler: IrqHandler) -> bo
false
}

/// Core IRQ handling routine, registered at [`IRQ`],
/// which dispatches IRQs to registered handlers.
///
/// Note: this function is denoted as public here because it'll be called by the
/// hypervisor for hypervisor reserved IRQ handling.
#[register_trap_handler(IRQ)]
pub fn handler_irq(irq_num: usize) -> bool {
let guard = kernel_guard::NoPreempt::new();
Expand Down
13 changes: 12 additions & 1 deletion modules/axhal/src/platform/aarch64_common/boot_el2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,18 @@ unsafe fn switch_to_el2() {

unsafe fn init_mmu_el2() {
// Set EL1 to 64bit.
HCR_EL2.write(HCR_EL2::RW::EL1IsAarch64);
// Enable `IMO` and `FMO` to make sure that:
// * Physical IRQ interrupts are taken to EL2;
// * Virtual IRQ interrupts are enabled;
// * Physical FIQ interrupts are taken to EL2;
// * Virtual FIQ interrupts are enabled.
HCR_EL2.modify(
HCR_EL2::VM::Enable
+ HCR_EL2::RW::EL1IsAarch64
+ HCR_EL2::IMO::EnableVirtualIRQ // Physical IRQ Routing.
+ HCR_EL2::FMO::EnableVirtualFIQ // Physical FIQ Routing.
+ HCR_EL2::TSC::EnableTrapEl1SmcToEl2,
);

// Device-nGnRE memory
let attr0 = MAIR_EL2::Attr0_Device::nonGathering_nonReordering_EarlyWriteAck;
Expand Down

0 comments on commit 9422e20

Please sign in to comment.