mirror of
https://github.com/hexagonal-sun/moss-kernel.git
synced 2026-01-30 09:01:44 -05:00
arch: arm64: detect kernel stack overflow condition
Currently, when a kernel stack overflow occures, the exception handler blindly attempts to write the current context to the stack. If the SP isn't valid this causes another fault, and so on - locking up the system. This commit re-arranges the stack layout, performs SP validation before usage and switches to an emergency stack when SP isn't valid. This allows the handler to run and panic gracefully. Fixes: #98
This commit is contained in:
committed by
Ashwin Naren
parent
57e0aa364c
commit
d8bcc015de
@@ -152,7 +152,7 @@ impl<K: MemKind, T> Address<K, T> {
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn add_bytes(self, n: usize) -> Self {
|
||||
pub const fn add_bytes(self, n: usize) -> Self {
|
||||
Self::from_value(self.value() + n)
|
||||
}
|
||||
|
||||
|
||||
@@ -64,8 +64,8 @@ impl<T: MemKind> MemoryRegion<T> {
|
||||
/// Create a memory region from a start and end address.
|
||||
///
|
||||
/// The size is calculated as `end - start`. No alignment is enforced.
|
||||
pub fn from_start_end_address(start: Address<T, ()>, end: Address<T, ()>) -> Self {
|
||||
assert!(end >= start);
|
||||
pub const fn from_start_end_address(start: Address<T, ()>, end: Address<T, ()>) -> Self {
|
||||
assert!(end.value() >= start.value());
|
||||
|
||||
Self {
|
||||
address: start,
|
||||
|
||||
Reference in New Issue
Block a user