vmm: vmm_changemmuflags

This commit is contained in:
Matheus
2024-08-21 21:33:29 -03:00
parent 8afbc8911c
commit dd75dc2d87
4 changed files with 167 additions and 36 deletions
+13 -1
View File
@@ -167,7 +167,7 @@ void *arch_mmu_getphysical(pagetableptr_t table, void *vaddr) {
bool arch_mmu_ispresent(pagetableptr_t table, void *vaddr) {
uint64_t *entry = get_page(table, vaddr);
return entry == NULL ? false : *entry & ARCH_MMU_FLAGS_READ;
return entry == NULL ? false : *entry;
}
bool arch_mmu_iswritable(pagetableptr_t table, void *vaddr) {
@@ -182,6 +182,18 @@ bool arch_mmu_isdirty(pagetableptr_t table, void *vaddr) {
return entry == NULL ? false : *entry & ARCH_MMU_FLAGS_DIRTY;
}
#define FLAGS_MASK (ARCH_MMU_FLAGS_WRITE | ARCH_MMU_FLAGS_READ | ARCH_MMU_FLAGS_NOEXEC | ARCH_MMU_FLAGS_USER)
bool arch_mmu_getflags(pagetableptr_t table, void *vaddr, mmuflags_t *mmuflagsp) {
uint64_t *entry = get_page(table, vaddr);
if (entry == NULL)
return false;
*mmuflagsp = *entry & FLAGS_MASK;
return true;
}
void arch_mmu_switch(pagetableptr_t table) {
asm volatile("mov %%rax, %%cr3" : : "a"(table));
}