arm64: Save/restore FPU state when handling IRQ or syscall

Change-Id: I8b2a36d57f410c0d06ca5ce90d1b997494072c94
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7510
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
This commit is contained in:
milek7 2024-03-07 03:29:12 +01:00 committed by Fredrik Holmqvist
parent b6fd30b0ed
commit 06fae14eb9
2 changed files with 16 additions and 0 deletions

View File

@ -138,6 +138,9 @@ struct iframe {
// exception info
uint64 esr;
uint64 far;
// fpu
struct aarch64_fpu_state fpu;
};

View File

@ -39,6 +39,11 @@
// threads yet.
struct iframe_stack gBootFrameStack;
// In order to avoid store/restore of large FPU state, it is assumed that
// this code and page fault handling doesn't use FPU.
// Instead this is called manually when handling IRQ or syscall.
extern "C" void _fp_save(aarch64_fpu_state *fpu);
extern "C" void _fp_restore(aarch64_fpu_state *fpu);
void
arch_int_enable_io_interrupt(int32 irq)
@ -340,6 +345,8 @@ do_sync_handler(iframe * frame)
}
}
_fp_save(&frame->fpu);
thread_at_kernel_entry(system_time());
enable_interrupts();
@ -362,6 +369,8 @@ do_sync_handler(iframe * frame)
}
}
_fp_restore(&frame->fpu);
return;
}
}
@ -393,11 +402,15 @@ do_irq_handler(iframe * frame)
IFrameScope scope(frame);
_fp_save(&frame->fpu);
InterruptController *ic = InterruptController::Get();
if (ic != NULL)
ic->HandleInterrupt();
after_exception();
_fp_restore(&frame->fpu);
}