VMM: Clean up per-cpu VMCS state
[akaros.git] / kern / arch / riscv / env.c
index da3032b..2b7d32d 100644 (file)
@@ -4,8 +4,7 @@
 #include <arch/arch.h>
 #include <pmap.h>
 
-void
-save_fp_state(ancillary_state_t* silly)
+void save_fp_state(ancillary_state_t* silly)
 {
        uintptr_t sr = enable_fp();
        uint32_t fsr = read_fsr();
@@ -47,8 +46,7 @@ save_fp_state(ancillary_state_t* silly)
        mtpcr(PCR_SR, sr);
 }
 
-void
-restore_fp_state(ancillary_state_t* silly)
+void restore_fp_state(ancillary_state_t* silly)
 {
        uintptr_t sr = enable_fp();
        uint32_t fsr = silly->fsr;
@@ -137,7 +135,7 @@ user_mem_walk_recursive(env_t* e, uintptr_t start, size_t len,
                        if(pt_callback != NULL && (ret = pt_callback(e, pte, (void*)pgaddr, arg)))
                                goto out;
                }
-               else if(callback != NULL && !PAGE_UNMAPPED(*pte))
+               else if(callback != NULL)
                        if((ret = callback(e, pte, (void*)pgaddr, arg)))
                                goto out;
        }
@@ -159,6 +157,8 @@ env_pagetable_free(env_t* e)
 {
        int pt_free(env_t* e, pte_t* pte, void* va, void* arg)
        {
+               if (!PAGE_PRESENT(pte))
+                       return 0;
                page_decref(pa2page(PTD_ADDR(*pte)));
                return 0;
        }