]> Zhao Yanbai Git Server - minix.git/commitdiff
vm: restartability improvements (#2) 22/3122/1
authorBen Gras <ben@minix3.org>
Fri, 16 Jan 2015 15:42:28 +0000 (16:42 +0100)
committerDavid van Moolenbroek <david@minix3.org>
Thu, 17 Sep 2015 13:42:18 +0000 (13:42 +0000)
also allocate vm pagetables dynamic-only.

further improves restart survivability.

Change-Id: Iac44845d9bd434408b23755274fa890a7b851373

minix/servers/vm/pagetable.c

index 66dd9da0f29a5f9d4b9589eb5180920be368159b..695656cb2376685c24b6d53fd1155d55ecf8af13 100644 (file)
@@ -856,11 +856,6 @@ int pt_writemap(struct vmproc * vmp,
                 */
                assert(pt->pt_pt[pde]);
 
-#if SANITYCHECKS
-               /* We don't expect to overwrite a page. */
-               if(!(writemapflags & (WMF_OVERWRITE|WMF_VERIFY)))
-                       assert(!(pt->pt_pt[pde][pte] & ARCH_VM_PTE_PRESENT));
-#endif
                if(writemapflags & (WMF_WRITEFLAGSONLY|WMF_FREE)) {
 #if defined(__i386__)
                        physaddr = pt->pt_pt[pde][pte] & ARCH_VM_ADDR_MASK;
@@ -1072,12 +1067,28 @@ void pt_allocate_kernel_mapped_pagetables(void)
        }
 }
 
+static void pt_copy(pt_t *dst, pt_t *src)
+{
+       int pde;
+       for(pde=0; pde < kern_start_pde; pde++) {
+               if(!(src->pt_dir[pde] & ARCH_VM_PDE_PRESENT)) {
+                       continue;
+               }
+               assert(!(src->pt_dir[pde] & ARCH_VM_BIGPAGE));
+               if(!src->pt_pt[pde]) { panic("pde %d empty\n", pde); }
+               if(pt_ptalloc(dst, pde, 0) != OK)
+                       panic("pt_ptalloc failed");
+               memcpy(dst->pt_pt[pde], src->pt_pt[pde],
+                       ARCH_VM_PT_ENTRIES * sizeof(*dst->pt_pt[pde]));
+       }
+}
+
 /*===========================================================================*
  *                              pt_init                                      *
  *===========================================================================*/
 void pt_init(void)
 {
-        pt_t *newpt;
+        pt_t *newpt, newpt_dyn;
         int s, r, p;
        phys_bytes phys;
        vir_bytes sparepages_mem;
@@ -1307,6 +1318,9 @@ void pt_init(void)
         * pages though, as the physical addresses will change on liveupdate. So we
         * re-do part of the initialization now with purely dynamically allocated
         * memory. First throw out the static pool.
+        *
+        * Then allocate the kernel-shared-pagetables and VM pagetables with dynamic
+        * memory.
         */
 
        alloc_cycle();                          /* Make sure allocating works */
@@ -1321,6 +1335,20 @@ void pt_init(void)
                panic("VMCTL_FLUSHTLB failed");
        }
 
+       /* Recreate VM page table with dynamic-only allocations */
+       memset(&newpt_dyn, 0, sizeof(newpt_dyn));
+       pt_new(&newpt_dyn);
+       pt_copy(&newpt_dyn, newpt);
+       memcpy(newpt, &newpt_dyn, sizeof(*newpt));
+
+       pt_bind(newpt, &vmproc[VM_PROC_NR]);    /* Recalculate */
+       pt_mapkernel(newpt);                    /* Rewrite pagetable info */
+
+       /* Flush TLB just in case any of those mappings have been touched */
+       if((sys_vmctl(SELF, VMCTL_FLUSHTLB, 0)) != OK) {
+               panic("VMCTL_FLUSHTLB failed");
+       }
+
         /* All OK. */
         return;
 }