#include <lunaix/hart_state.h>
#include <lunaix/failsafe.h>
-#include <sys/mm/mm_defs.h>
+#include <asm/mm_defs.h>
#include <klibc/string.h>
context->fault_refva = refva;
}
-static bool
+static void
__prepare_fault_context(struct fault_context* fault)
{
- if (!__arch_prepare_fault_context(fault)) {
- return false;
- }
-
- __gather_memaccess_info(fault);
-
pte_t* fault_ptep = fault->fault_ptep;
ptr_t fault_va = fault->fault_va;
pte_t fault_pte = *fault_ptep;
fault->resolving = pte_mkloaded(fault_pte);
fault->kernel_vmfault = kernel_vmfault;
fault->kernel_access = kernel_context(fault->hstate);
-
- return true;
}
static inline void
}
-static void noret
-__fail_to_resolve(struct fault_context* fault)
+void noret
+fault_resolving_failed(struct fault_context* fault)
{
if (fault->prealloc) {
leaflet_return(fault->prealloc);
return !!(fault->resolve_type & RESOLVE_OK);
}
-void
-intr_routine_page_fault(const struct hart_state* hstate)
+bool
+handle_page_fault(struct fault_context* fault)
{
- if (hstate->depth > 10) {
- // Too many nested fault! we must messed up something
- // XXX should we failed silently?
- spin();
- }
-
- struct fault_context fault = { .hstate = hstate };
-
- if (!__prepare_fault_context(&fault)) {
- __fail_to_resolve(&fault);
- }
+ __gather_memaccess_info(fault);
+ __prepare_fault_context(fault);
- fault_prealloc_page(&fault);
+ fault_prealloc_page(fault);
- if (!__try_resolve_fault(&fault)) {
- __fail_to_resolve(&fault);
+ if (!__try_resolve_fault(fault)) {
+ return false;
}
- if ((fault.resolve_type & NO_PREALLOC)) {
- if (fault.prealloc) {
- leaflet_return(fault.prealloc);
+ if ((fault->resolve_type & NO_PREALLOC)) {
+ if (fault->prealloc) {
+ leaflet_return(fault->prealloc);
}
}
- tlb_flush_kernel(fault.fault_va);
-}
\ No newline at end of file
+ tlb_flush_kernel(fault->fault_va);
+ return true;
+}