From b3d7851f01be04f69c1f14c19905786c1d44a9a1 Mon Sep 17 00:00:00 2001 From: tkchia Date: Thu, 20 Oct 2022 16:26:46 +0000 Subject: [PATCH] [metal] Call invlpg(.) when altering any VA page table entries --- libc/calls/munmap-metal.c | 2 +- libc/intrin/directmap-metal.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libc/calls/munmap-metal.c b/libc/calls/munmap-metal.c index 1b7f9e991..2497e2568 100644 --- a/libc/calls/munmap-metal.c +++ b/libc/calls/munmap-metal.c @@ -27,7 +27,7 @@ noasan int sys_munmap_metal(void *addr, size_t size) { for (i = 0; i < size; i += 4096) { e = __get_virtual(mm, __get_pml4t(), (uint64_t)addr + i, false); if (e) *e = ~(PAGE_V | PAGE_RSRV); - invlpg(e); + invlpg((uint64_t)addr + i); } return 0; } diff --git a/libc/intrin/directmap-metal.c b/libc/intrin/directmap-metal.c index e4e52b5ac..bd3a4afd8 100644 --- a/libc/intrin/directmap-metal.c +++ b/libc/intrin/directmap-metal.c @@ -62,6 +62,7 @@ noasan struct DirectMap sys_mmap_metal(void *paddr, size_t size, int prot, page |= PAGE_V; if (!(prot & PROT_EXEC)) page |= PAGE_XD; *pte = page; + invlpg(addr + i); } else { addr = -1; break;