From af69128800d88c69a9d195d4bb34f600013cdab6 Mon Sep 17 00:00:00 2001 From: Matheus Date: Mon, 10 Oct 2022 10:43:14 -0300 Subject: [PATCH] mmu: fix deadlock --- src/arch/x86_64/mmu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/arch/x86_64/mmu.c b/src/arch/x86_64/mmu.c index 457fce98..b633b15c 100644 --- a/src/arch/x86_64/mmu.c +++ b/src/arch/x86_64/mmu.c @@ -31,7 +31,7 @@ void arch_mmu_switchcontext(arch_mmu_tableptr context){ } void* inv = NULL; - +int invlock; semaphore_t sem; void arch_mmu_invalidateipi(){ @@ -40,6 +40,7 @@ void arch_mmu_invalidateipi(){ } static void invalidate(void* addr){ + spinlock_acquire(&invlock); asm("invlpg (%%rax)" : : "a"(addr)); sem.count = -arch_smp_cpucount(); if(!sem.count) return; @@ -47,6 +48,7 @@ static void invalidate(void* addr){ inv = addr; arch_smp_sendipi(0, VECTOR_MMUINVAL, IPI_CPU_ALLBUTSELF); while(!sem_tryacquire(&sem)) asm("pause"); + spinlock_release(&invlock); }