From 50d22f83ef134b3e809669b2e72cddaaca7ebdd8 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sun, 9 Aug 2009 17:39:05 +0000 Subject: [PATCH] The reference of the currently active translation map shouldn't be released until the data it protects isn't in active use anymore. Previously it would release the translation map and therefore the page directory reference while the page dir was still set on the CPU, as only the actual call to i386_context_switch() will replace the page directory in the control register. This didn't cause any harm though, as during the context switch interrupts are disabled and therefore the page directory would only be deferred_delete()ed and not directly freed/overwritten. Still this is logically more correct. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32216 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/arch/x86/arch_thread.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/system/kernel/arch/x86/arch_thread.cpp b/src/system/kernel/arch/x86/arch_thread.cpp index 979a82a1ff..05946189aa 100644 --- a/src/system/kernel/arch/x86/arch_thread.cpp +++ b/src/system/kernel/arch/x86/arch_thread.cpp @@ -384,17 +384,21 @@ arch_thread_context_switch(struct thread *from, struct thread *to) atomic_or(&toMap->active_on_cpus, (uint32)1 << cpu); // assign the new map to the CPU - activeMap->RemoveReference(); toMap->AddReference(); cpuData->arch.active_translation_map = toMap; // get the new page directory newPageDirectory = (addr_t)toMap->pgdir_phys; - } else + } else { + activeMap = NULL; newPageDirectory = 0; + } gX86SwapFPUFunc(from->arch_info.fpu_state, to->arch_info.fpu_state); i386_context_switch(&from->arch_info, &to->arch_info, newPageDirectory); + + if (activeMap != NULL) + activeMap->RemoveReference(); }