Skip to content

Commit 9df5cc4

Browse files
committed
Kernel/aarch64: Only enable interrupts in trap handler if they were on
1 parent 0f9c713 commit 9df5cc4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Kernel/Arch/aarch64/Interrupts.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ extern "C" void exception_common(Kernel::TrapFrame* trap_frame)
9292
// stay consistent with the user‑mode debugger’s behavior.
9393
trap_frame->regs->set_ip(trap_frame->regs->ip() + 4);
9494
}
95-
Processor::enable_interrupts();
95+
96+
// Only enable interrupts if they were enabled when the exception happened
97+
// (spsr_el1.I specifiers an interrupt mask, so it's 0 if interrupts were enabled).
98+
if (bit_cast<Aarch64::SPSR_EL1>(trap_frame->regs->spsr_el1).I == 0)
99+
Processor::enable_interrupts();
96100

97101
if (Aarch64::exception_class_is_data_abort(esr_el1.EC) || Aarch64::exception_class_is_instruction_abort(esr_el1.EC)) {
98102
auto page_fault_or_error = page_fault_from_exception_syndrome_register(VirtualAddress(fault_address), esr_el1);

0 commit comments

Comments
 (0)