From a950021011e41b7d4fd285dde278cf9b06f89574 Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Wed, 20 Mar 2024 18:08:57 +0100 Subject: MMU: Fixed massive problem in assumption of RAM layout This caused certain addreses which where not RAM memory to be assigned to virtual addresses incorrectly. This caused a significant slowdown when running it with KVM due to constantly having to exit the VM if the OS writes to memory that is not RAM. This fix increased the performance of KVM significantly and improved TCG performance. --- kernel/process.s | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'kernel/process.s') diff --git a/kernel/process.s b/kernel/process.s index caef941..934d627 100644 --- a/kernel/process.s +++ b/kernel/process.s @@ -128,15 +128,13 @@ switch_to_task: mov eax,[esi+TCB.CR3] # eax = address of page directory for next task mov ebx,[esi+TCB.ESP0] # ebx = address for the top of the next task's kernel stack # mov [TSS.ESP0],ebx # Adjust the ESP0 field in the TSS (used by CPU for for CPL=3 -> CPL=0 privilege level changes) -# mov ecx,cr3 # ecx = previous task's virtual address space + mov ecx,cr3 # ecx = previous task's virtual address space -# FIXME: This branch gets a from the assembler, something about "relaxed branches". -# this branch would probably not be used anyway but should be checked on later anyway. -# cmp eax,ecx # Does the virtual address space need to being changed? + cmp eax,ecx # Does the virtual address space need to being changed? -# je .doneVAS # no, virtual address space is the same, so don't reload it and cause TLB flushes + je .doneVAS # no, virtual address space is the same, so don't reload it and cause TLB flushes mov cr3,eax # yes, load the next task's virtual address space -#.doneVAS: +.doneVAS: pop ebp pop edi -- cgit v1.2.3