Created
December 1, 2016 17:19
-
-
Save heatd/f64e4c68cd3e5e2c73ac320c03a346d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void paging_map_all_phys(size_t bytes) | |
{ | |
uintptr_t virt = 0xffffea0000000000; | |
decomposed_addr_t decAddr; | |
memcpy(&decAddr, &virt, sizeof(decomposed_addr_t)); | |
uint64_t* entry = ¤t_pml4->entries[decAddr.pml4]; | |
PML3* pml3 = NULL; | |
/* If its present, use that pml3 */ | |
if(*entry & 1) { | |
pml3 = (PML3*)(*entry & 0x0FFFFFFFFFFFF000); | |
} | |
else { /* Else create one */ | |
pml3 = (PML3*)&pdptphysical_map; | |
memset(pml3, 0, sizeof(PML3)); | |
*entry = make_pml4e((uint64_t)pml3, 0, 0, 0, 0, 1, 1); | |
} | |
for(size_t i = 0; i < 512; i++) | |
{ | |
entry = &pml3->entries[i]; | |
*entry = make_pml3e(i * 0x40000000, 1, 0, 1, 0, 0, 0, 1, 1); | |
*entry |= (1 << 7); | |
__native_tlb_invalidate_page((void*)(virt + i * 0x40000000)); | |
} | |
asm volatile("mov %cr3, %rax;mov %rax, %cr3"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment