aboutsummaryrefslogtreecommitdiff
path: root/src/vmem.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-10-30 00:57:33 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2024-10-30 00:57:33 +0200
commit44a73ecab6e91519627786a5101cd4f1a2f2b0d7 (patch)
treef5c811050a4d5ee832f5883c4d0c27efddd60817 /src/vmem.c
parent5976ad390a15726c3ddfacf8c8b282c8350f9554 (diff)
downloadkmi-44a73ecab6e91519627786a5101cd4f1a2f2b0d7.tar.gz
kmi-44a73ecab6e91519627786a5101cd4f1a2f2b0d7.zip
most of the way to passing tests
Diffstat (limited to 'src/vmem.c')
-rw-r--r--src/vmem.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/vmem.c b/src/vmem.c
index f4f1bf7..bd0cd7c 100644
--- a/src/vmem.c
+++ b/src/vmem.c
@@ -9,6 +9,7 @@
#include <kmi/regions.h>
#include <kmi/assert.h>
#include <kmi/string.h>
+#include <kmi/panic.h>
#include <kmi/debug.h>
#include <kmi/bits.h>
#include <kmi/vmem.h>
@@ -408,3 +409,25 @@ vmflags_t sanitize_uvflags(vmflags_t flags)
{
return (flags & (VM_R | VM_W | VM_X)) | VM_V | VM_U;
}
+
+void handle_pagefault(vm_t addr)
+{
+ struct tcb *t = cur_tcb();
+ struct tcb *p = get_cproc(t);
+
+ size_t ref = __page(addr);
+
+ struct mem_region *m = find_closest_used_region(&p->uvmem.region, addr);
+ if (!m || (ref < m->start || ref > m->end) || !is_region_used(m)) {
+ error("cannot handle actual page fault just yet :(\n");
+ kernel_panic(NULL, NULL, 0);
+ return;
+ }
+
+ /* this is a valid address so presumably the proc virtual memory has
+ * some changes that haven't been reflected over in our rpc virtual
+ * memory so make them visible */
+ clone_uvmem(p->proc.vmem, t->rpc.vmem);
+ flush_tlb_all();
+ return;
+}