From 579feaa64fc018b7e4a877e9895b3a01dba7402f Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Wed, 12 Aug 2015 20:58:08 +0200 Subject: [PATCH] set new page table entry before we flush the TLB --- hermit/arch/x86/mm/page.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hermit/arch/x86/mm/page.c b/hermit/arch/x86/mm/page.c index c3f68b405..4ee0ae7d1 100644 --- a/hermit/arch/x86/mm/page.c +++ b/hermit/arch/x86/mm/page.c @@ -152,12 +152,19 @@ int page_map(size_t viraddr, size_t phyaddr, size_t npages, size_t bits) } } else { /* PGT */ + int8_t flush = 0; + + /* do we have to flush the TLB? */ if (self[lvl][vpn] & PG_PRESENT) + flush = 1; + + self[lvl][vpn] = phyaddr | bits | PG_PRESENT; + + if (flush) /* There's already a page mapped at this address. * We have to flush a single TLB entry. */ tlb_flush_one_page(vpn << PAGE_BITS); - self[lvl][vpn] = phyaddr | bits | PG_PRESENT; phyaddr += PAGE_SIZE; } }