X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_paging.c;h=b4ba9ee1b0f7627b85480a01fbf72228d0d67709;hb=82b8b87c344fcd1eab22e3f3be5ad54cbb3f8f68;hp=dc7aa97046242c7dbd3e379b7ce5d80c2466e593;hpb=266af4b5b19da7bee8e7445288c7c1cb3ee194c7;p=palacios.git diff --git a/palacios/src/palacios/vmm_paging.c b/palacios/src/palacios/vmm_paging.c index dc7aa97..b4ba9ee 100644 --- a/palacios/src/palacios/vmm_paging.c +++ b/palacios/src/palacios/vmm_paging.c @@ -46,7 +46,7 @@ static pt_entry_type_t pte64_lookup(pte64_t * pt, addr_t addr, addr_t * entry); -#ifndef DEBUG_SHADOW_PAGING +#ifndef CONFIG_DEBUG_SHADOW_PAGING #undef PrintDebug #define PrintDebug(fmt, args...) #endif @@ -59,29 +59,90 @@ void delete_page_tables_32(pde32_t * pde) { if (pde == NULL) { return; } - PrintDebug("Deleting Page Tables -- PDE (%p)\n", pde); - for (i = 0; (i < MAX_PDE32_ENTRIES); i++) { - if (pde[i].present) { - // We double cast, first to an addr_t to handle 64 bit issues, then to the pointer - - pte32_t * pte = (pte32_t *)((addr_t)(uint_t)(pde[i].pt_base_addr << PAGE_POWER)); + PrintDebug("Deleting Page Tables (32) -- PDE (%p)\n", pde); + for (i = 0; i < MAX_PDE32_ENTRIES; i++) { + if ((pde[i].present == 1) && (pde[i].large_page == 0)) { + // We double cast, first to an addr_t to handle 64 bit issues, then to the pointer - V3_FreePage(pte); + PrintDebug("Deleting PT Page %d (%p)\n", i, (void *)(addr_t)BASE_TO_PAGE_ADDR_4KB(pde[i].pt_base_addr)); + V3_FreePage((void *)(addr_t)BASE_TO_PAGE_ADDR_4KB(pde[i].pt_base_addr)); } } - V3_FreePage(V3_PAddr(pde)); } -void delete_page_tables_32PAE(pdpe32pae_t * pdpe) { - PrintError("Unimplemented function\n"); +void delete_page_tables_32pae(pdpe32pae_t * pdpe) { + int i, j; + + if (pdpe == NULL) { + return; + } + + PrintDebug("Deleting Page Tables (32 PAE) -- PDPE (%p)\n", pdpe); + + for (i = 0; i < MAX_PDPE32PAE_ENTRIES; i++) { + if (pdpe[i].present == 0) { + continue; + } + + pde32pae_t * pde = (pde32pae_t *)V3_VAddr((void *)(addr_t)BASE_TO_PAGE_ADDR_4KB(pdpe[i].pd_base_addr)); + + for (j = 0; j < MAX_PDE32PAE_ENTRIES; j++) { + + if ((pde[j].present == 0) || (pde[j].large_page == 1)) { + continue; + } + + V3_FreePage((void *)(addr_t)BASE_TO_PAGE_ADDR_4KB(pde[j].pt_base_addr)); + } + + V3_FreePage(V3_PAddr(pde)); + } + + V3_FreePage(V3_PAddr(pdpe)); } void delete_page_tables_64(pml4e64_t * pml4) { - PrintError("Unimplemented function\n"); + int i, j, k; + + if (pml4 == NULL) { + return; + } + + PrintDebug("Deleting Page Tables (64) -- PML4 (%p)\n", pml4); + + for (i = 0; i < MAX_PML4E64_ENTRIES; i++) { + if (pml4[i].present == 0) { + continue; + } + + pdpe64_t * pdpe = (pdpe64_t *)V3_VAddr((void *)(addr_t)BASE_TO_PAGE_ADDR_4KB(pml4[i].pdp_base_addr)); + + for (j = 0; j < MAX_PDPE64_ENTRIES; j++) { + if ((pdpe[j].present == 0) || (pdpe[j].large_page == 1)) { + continue; + } + + pde64_t * pde = (pde64_t *)V3_VAddr((void *)(addr_t)BASE_TO_PAGE_ADDR_4KB(pdpe[j].pd_base_addr)); + + for (k = 0; k < MAX_PDE64_ENTRIES; k++) { + if ((pde[k].present == 0) || (pde[k].large_page == 1)) { + continue; + } + + V3_FreePage((void *)(addr_t)BASE_TO_PAGE_ADDR_4KB(pde[k].pt_base_addr)); + } + + V3_FreePage(V3_PAddr(pde)); + } + + V3_FreePage(V3_PAddr(pdpe)); + } + + V3_FreePage(V3_PAddr(pml4)); }