summaryrefslogtreecommitdiffstats
path: root/sys/riscv
diff options
context:
space:
mode:
authorbr <br@FreeBSD.org>2016-02-17 13:43:43 +0000
committerbr <br@FreeBSD.org>2016-02-17 13:43:43 +0000
commit97821f014d479d772247a29ca66c704f0a6b4c44 (patch)
treecbf813dc76885d1d8f72cda73a6a2d398304e811 /sys/riscv
parent13e5393598ff109c5ce1b2259ee5504b0f50ece6 (diff)
downloadFreeBSD-src-97821f014d479d772247a29ca66c704f0a6b4c44.zip
FreeBSD-src-97821f014d479d772247a29ca66c704f0a6b4c44.tar.gz
Use callee-saved registers to pass args through fork_trampoline().
Diffstat (limited to 'sys/riscv')
-rw-r--r--sys/riscv/riscv/swtch.S14
-rw-r--r--sys/riscv/riscv/vm_machdep.c12
2 files changed, 9 insertions, 17 deletions
diff --git a/sys/riscv/riscv/swtch.S b/sys/riscv/riscv/swtch.S
index c6336a9..413e666 100644
--- a/sys/riscv/riscv/swtch.S
+++ b/sys/riscv/riscv/swtch.S
@@ -109,14 +109,10 @@ ENTRY(cpu_switch)
/* Save the old context. */
ld x13, TD_PCB(a0)
- /* Store the callee-saved registers */
+ /* Store ra, sp and the callee-saved registers */
sd ra, (PCB_RA)(x13)
sd sp, (PCB_SP)(x13)
- /* We use these in fork_trampoline */
- sd t0, (PCB_T + 0 * 8)(x13)
- sd t1, (PCB_T + 1 * 8)(x13)
-
/* s[0-11] */
sd s0, (PCB_S + 0 * 8)(x13)
sd s1, (PCB_S + 1 * 8)(x13)
@@ -167,10 +163,6 @@ ENTRY(cpu_switch)
ld ra, (PCB_RA)(x13)
ld sp, (PCB_SP)(x13)
- /* We use these in fork_trampoline */
- ld t0, (PCB_T + 0 * 8)(x13)
- ld t1, (PCB_T + 1 * 8)(x13)
-
/* s[0-11] */
ld s0, (PCB_S + 0 * 8)(x13)
ld s1, (PCB_S + 1 * 8)(x13)
@@ -195,8 +187,8 @@ END(cpu_switch)
*/
ENTRY(fork_trampoline)
- mv a0, x5
- mv a1, x6
+ mv a0, s0
+ mv a1, s1
mv a2, sp
call _C_LABEL(fork_exit)
diff --git a/sys/riscv/riscv/vm_machdep.c b/sys/riscv/riscv/vm_machdep.c
index 5ea352b..49d31ba 100644
--- a/sys/riscv/riscv/vm_machdep.c
+++ b/sys/riscv/riscv/vm_machdep.c
@@ -97,8 +97,8 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags)
td2->td_frame = tf;
/* Set the return value registers for fork() */
- td2->td_pcb->pcb_t[0] = (uintptr_t)fork_return;
- td2->td_pcb->pcb_t[1] = (uintptr_t)td2;
+ td2->td_pcb->pcb_s[0] = (uintptr_t)fork_return;
+ td2->td_pcb->pcb_s[1] = (uintptr_t)td2;
td2->td_pcb->pcb_ra = (uintptr_t)fork_trampoline;
td2->td_pcb->pcb_sp = (uintptr_t)td2->td_frame;
@@ -165,8 +165,8 @@ cpu_set_upcall(struct thread *td, struct thread *td0)
bcopy(td0->td_frame, td->td_frame, sizeof(struct trapframe));
bcopy(td0->td_pcb, td->td_pcb, sizeof(struct pcb));
- td->td_pcb->pcb_t[0] = (uintptr_t)fork_return;
- td->td_pcb->pcb_t[1] = (uintptr_t)td;
+ td->td_pcb->pcb_s[0] = (uintptr_t)fork_return;
+ td->td_pcb->pcb_s[1] = (uintptr_t)td;
td->td_pcb->pcb_ra = (uintptr_t)fork_trampoline;
td->td_pcb->pcb_sp = (uintptr_t)td->td_frame;
@@ -240,8 +240,8 @@ void
cpu_set_fork_handler(struct thread *td, void (*func)(void *), void *arg)
{
- td->td_pcb->pcb_t[0] = (uintptr_t)func;
- td->td_pcb->pcb_t[1] = (uintptr_t)arg;
+ td->td_pcb->pcb_s[0] = (uintptr_t)func;
+ td->td_pcb->pcb_s[1] = (uintptr_t)arg;
td->td_pcb->pcb_ra = (uintptr_t)fork_trampoline;
td->td_pcb->pcb_sp = (uintptr_t)td->td_frame;
}
OpenPOWER on IntegriCloud