feat: msync(2)
[lunaix-os.git] / lunaix-os / kernel / mm / dmm.c
index 44f0f9e897d2d176a65c260f38744fb3aa3a4c6a..4bf0439172c67684932b4285d098e8cd7590b03f 100644 (file)
@@ -24,8 +24,6 @@
 #include <lunaix/spike.h>
 #include <lunaix/syscall.h>
 
-extern void __kernel_heap_start;
-
 __DEFINE_LXSYSCALL1(int, sbrk, size_t, size)
 {
     heap_context_t* uheap = &__current->mm.u_heap;
@@ -52,13 +50,11 @@ dmm_init(heap_context_t* heap)
     heap->brk = heap->start;
     mutex_init(&heap->lock);
 
-    int perm = PG_ALLOW_USER;
-    if (heap->brk >= &__kernel_heap_start) {
-        perm = 0;
-    }
-
-    return vmm_set_mapping(
-             PD_REFERENCED, heap->brk, 0, PG_WRITE | perm, VMAP_NULL) != NULL;
+    return vmm_set_mapping(VMS_SELF,
+                           heap->brk,
+                           0,
+                           PG_WRITE | PG_ALLOW_USER,
+                           VMAP_NULL) != NULL;
 }
 
 int
@@ -90,7 +86,7 @@ lxsbrk(heap_context_t* heap, size_t size, int user)
     if (diff) {
         // if next do require new pages to be mapped
         for (size_t i = 0; i < diff; i += PG_SIZE) {
-            vmm_set_mapping(PD_REFERENCED,
+            vmm_set_mapping(VMS_SELF,
                             PG_ALIGN(current_brk) + PG_SIZE + i,
                             0,
                             PG_WRITE | user,