From ea95a6654c3f921849f3541aa856a8806ebf571e Mon Sep 17 00:00:00 2001 From: Robert Morris Date: Fri, 26 Jul 2019 04:53:46 -0400 Subject: [PATCH] trampin -> uservec trampout -> userret --- kernel/kernel.ld | 2 +- kernel/proc.c | 4 ++-- kernel/proc.h | 4 ++-- kernel/trampoline.S | 17 +++++++++-------- kernel/trap.c | 4 ++-- kernel/vm.c | 4 ++-- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/kernel/kernel.ld b/kernel/kernel.ld index dec8e4f..0b5e76b 100644 --- a/kernel/kernel.ld +++ b/kernel/kernel.ld @@ -12,7 +12,7 @@ SECTIONS { *(.text) . = ALIGN(0x1000); - *(trampoline) + *(trampsec) } . = ALIGN(0x1000); diff --git a/kernel/proc.c b/kernel/proc.c index 48b006f..0dcae00 100644 --- a/kernel/proc.c +++ b/kernel/proc.c @@ -18,7 +18,7 @@ struct spinlock pid_lock; extern void forkret(void); static void wakeup1(struct proc *chan); -extern char trampout[]; // trampoline.S +extern char trampoline[]; // trampoline.S void procinit(void) @@ -159,7 +159,7 @@ proc_pagetable(struct proc *p) // only the supervisor uses it, on the way // to/from user space, so not PTE_U. mappages(pagetable, TRAMPOLINE, PGSIZE, - (uint64)trampout, PTE_R | PTE_X); + (uint64)trampoline, PTE_R | PTE_X); // map the trapframe just below TRAMPOLINE, for trampoline.S. mappages(pagetable, TRAPFRAME, PGSIZE, diff --git a/kernel/proc.h b/kernel/proc.h index d515043..655d79f 100644 --- a/kernel/proc.h +++ b/kernel/proc.h @@ -32,10 +32,10 @@ extern struct cpu cpus[NCPU]; // sits in a page by itself just under the trampoline page in the // user page table. not specially mapped in the kernel page table. // the sscratch register points here. -// trampin in trampoline.S saves user registers in the trapframe, +// uservec in trampoline.S saves user registers in the trapframe, // then initializes registers from the trapframe's // kernel_sp, kernel_hartid, kernel_satp, and jumps to kernel_trap. -// usertrapret() and trampout in trampoline.S set up +// usertrapret() and userret in trampoline.S set up // the trapframe's kernel_*, restore user registers from the // trapframe, switch to the user page table, and enter user space. // the trapframe includes callee-saved user registers like s0-s11 because the diff --git a/kernel/trampoline.S b/kernel/trampoline.S index d4066c9..bc31974 100644 --- a/kernel/trampoline.S +++ b/kernel/trampoline.S @@ -5,14 +5,15 @@ # in user and kernel space so that it continues # to work when it switches page tables. # - # kernel.ld causes trampout to be aligned + # kernel.ld causes userret to be aligned # to a page boundary. # -.globl usertrap - .section trampoline -.globl trampout -trampout: - # trampout(trapframe, pagetable) + .section trampsec +.globl trampoline +trampoline: +.globl userret +userret: + # userret(trapframe, pagetable) # switch from kernel to user. # usertrapret() calls here. # a0: p->tf in user page table @@ -67,8 +68,8 @@ trampout: sret .align 4 -.globl trampin -trampin: +.globl uservec +uservec: # # trap.c set stvec to point here, so # user interrupts and exceptions start here, diff --git a/kernel/trap.c b/kernel/trap.c index ef2b618..ad2d0f8 100644 --- a/kernel/trap.c +++ b/kernel/trap.c @@ -9,7 +9,7 @@ struct spinlock tickslock; uint ticks; -extern char trampout[], trampin[]; +extern char trampoline[], uservec[]; // in kernelvec.S, calls kerneltrap(). void kernelvec(); @@ -96,7 +96,7 @@ usertrapret(void) intr_off(); // send interrupts and exceptions to trampoline.S - w_stvec(TRAMPOLINE + (trampin - trampout)); + w_stvec(TRAMPOLINE + (uservec - trampoline)); // set up values that trampoline.S will need when // the process next re-enters the kernel. diff --git a/kernel/vm.c b/kernel/vm.c index 33469d1..a1c36ba 100644 --- a/kernel/vm.c +++ b/kernel/vm.c @@ -13,7 +13,7 @@ pagetable_t kernel_pagetable; extern char etext[]; // kernel.ld sets this to end of kernel code. -extern char trampout[]; // trampoline.S +extern char trampoline[]; // trampoline.S /* * create a direct-map page table for the kernel and @@ -46,7 +46,7 @@ kvminit() // map the trampoline for trap entry/exit to // the highest virtual address in the kernel. - kvmmap(TRAMPOLINE, (uint64)trampout, PGSIZE, PTE_R | PTE_X); + kvmmap(TRAMPOLINE, (uint64)trampoline, PGSIZE, PTE_R | PTE_X); } // Switch h/w page table register to the kernel's page table,