]> git.lizzy.rs Git - plan9front.git/commitdiff
pc64: avoid getcr3() in mmuflushtlb()
authorcinap_lenrek <cinap_lenrek@felloff.net>
Wed, 12 May 2021 20:40:51 +0000 (22:40 +0200)
committercinap_lenrek <cinap_lenrek@felloff.net>
Wed, 12 May 2021 20:40:51 +0000 (22:40 +0200)
it turns out that calculating physical address of pml4 is faster
than reading the machine register, so pass it explicitely.

sys/src/9/pc64/fns.h
sys/src/9/pc64/main.c
sys/src/9/pc64/mmu.c

index 01a1959d3e6c4f6a2f0ef84975a795deedbcd73c..75764f06dff4e1f41ce1030f5950c8f9dddc4f51 100644 (file)
@@ -96,7 +96,7 @@ void  meminit(void);
 void   meminit0(void);
 void   memreserve(uintptr, uintptr);
 void   mfence(void);
-#define mmuflushtlb() putcr3(getcr3())
+#define mmuflushtlb(pml4) putcr3(pml4)
 void   mmuinit(void);
 uintptr        *mmuwalk(uintptr*, uintptr, int, int);
 char*  mtrr(uvlong, uvlong, char *);
index 17a766137cf6e8063964a7616330db449971eba6..78cd8ef4c30c1338ede5af3de369a3e9f8cb44af 100644 (file)
@@ -239,7 +239,7 @@ rebootjump(uintptr entry, uintptr code, ulong size)
        if((pte = mmuwalk(m->pml4, REBOOTADDR, 0, 0)) != nil)
                *pte &= ~PTENOEXEC;
 
-       mmuflushtlb();
+       mmuflushtlb(PADDR(m->pml4));
 
        /* setup reboot trampoline function */
        f = (void*)REBOOTADDR;
@@ -350,5 +350,5 @@ procsave(Proc *p)
         * You might think it would be a win not to do this in that case,
         * especially on VMware, but it turns out not to matter.
         */
-       mmuflushtlb();
+       mmuflushtlb(PADDR(m->pml4));
 }
index 23a39f6d8e317d8febbc7f84a348b2de91c4d2f3..1f6560bfead0c81c56f6a1ad65ec2e37fe808dbe 100644 (file)
@@ -67,7 +67,7 @@ taskswitch(uintptr stack)
        tss->rsp1[1] = stack >> 32;
        tss->rsp2[0] = (u32int)stack;
        tss->rsp2[1] = stack >> 32;
-       mmuflushtlb();
+       mmuflushtlb(PADDR(m->pml4));
 }
 
 static void kernelro(void);