vmbase: Move handle_*_fault() to crate::exceptions
Move the functions out of vmbase::memory::shared.
Fix the visibility of the corresponding MemoryTracker methods.
Note: no functional change intended.
Test: m pvmfw_bin rialto_bin
Bug: 377276983
Change-Id: I56f273e5ca5d8d544248aa4c695c9d535b6c8b0a
diff --git a/libs/libvmbase/src/exceptions.rs b/libs/libvmbase/src/exceptions.rs
index 11fcd93..b04cb16 100644
--- a/libs/libvmbase/src/exceptions.rs
+++ b/libs/libvmbase/src/exceptions.rs
@@ -17,11 +17,12 @@
use crate::{
eprintln,
layout::UART_PAGE_ADDR,
- memory::{page_4kb_of, MemoryTrackerError},
+ memory::{page_4kb_of, MemoryTrackerError, MEMORY},
read_sysreg,
};
use aarch64_paging::paging::VirtualAddress;
use core::fmt;
+use core::result;
/// Represents an error that can occur while handling an exception.
#[derive(Debug)]
@@ -136,3 +137,19 @@
self.esr == Esr::DataAbortSyncExternalAbort && page_4kb_of(self.far.0) == UART_PAGE_ADDR
}
}
+
+/// Handles a translation fault with the given fault address register (FAR).
+#[inline]
+pub fn handle_translation_fault(far: VirtualAddress) -> result::Result<(), HandleExceptionError> {
+ let mut guard = MEMORY.try_lock().ok_or(HandleExceptionError::PageTableUnavailable)?;
+ let memory = guard.as_mut().ok_or(HandleExceptionError::PageTableNotInitialized)?;
+ Ok(memory.handle_mmio_fault(far)?)
+}
+
+/// Handles a permission fault with the given fault address register (FAR).
+#[inline]
+pub fn handle_permission_fault(far: VirtualAddress) -> result::Result<(), HandleExceptionError> {
+ let mut guard = MEMORY.try_lock().ok_or(HandleExceptionError::PageTableUnavailable)?;
+ let memory = guard.as_mut().ok_or(HandleExceptionError::PageTableNotInitialized)?;
+ Ok(memory.handle_permission_fault(far)?)
+}