x86_64: pmap: implement pmap_flush and pmap_remove_range

This commit is contained in:
2026-04-30 18:59:46 +01:00
parent d5c7a9f030
commit 5654c02f36
2 changed files with 21 additions and 0 deletions
+12
View File
@@ -321,6 +321,10 @@ static kern_status_t do_pmap_remove(
virt_addr_t pv,
enum page_size size)
{
if (pmap == PMAP_INVALID) {
return KERN_OK;
}
unsigned int pml4t_index = BAD_INDEX, pdpt_index = BAD_INDEX,
pd_index = BAD_INDEX, pt_index = BAD_INDEX;
@@ -622,5 +626,13 @@ kern_status_t pmap_remove(pmap_t pmap, virt_addr_t p)
kern_status_t pmap_remove_range(pmap_t pmap, virt_addr_t p, size_t len)
{
if (pmap == PMAP_INVALID) {
return KERN_OK;
}
for (size_t i = p; i < p + len; i += VM_PAGE_SIZE) {
pmap_remove(pmap, i);
}
return KERN_OK;
}
+9
View File
@@ -1,3 +1,11 @@
.global pmap_flush
.type pmap_flush, @function
pmap_flush:
mov %cr3, %rax
mov %rax, %cr3
ret
.global pmap_switch
.type pmap_switch, @function
@@ -6,6 +14,7 @@ pmap_switch:
mov %rdi, %cr3
ret
.global gigabyte_pages
.type gigabyte_pages, @function