diff --git a/kernel/trampoline.S b/kernel/trampoline.S index 7fb0b36..d7308cc 100644 --- a/kernel/trampoline.S +++ b/kernel/trampoline.S @@ -80,10 +80,18 @@ uservec: # load the address of usertrap(), from p->trapframe->kernel_trap ld t0, 16(a0) - # load the kernel page table, from p->trapframe->kernel_satp + + # fetch the kernel page table address, from p->trapframe->kernel_satp. ld t1, 0(a0) + + # wait for any previous memory operations to complete, so that + # they use the user page table. sfence.vma zero, zero + + # install the kernel page table. csrw satp, t1 + + # flush now-stale user entries from the TLB. sfence.vma zero, zero # jump to usertrap(), which does not return