diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2020-06-14 17:56:55 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2020-06-14 17:56:55 +0000 |
commit | e2afe2ab8b232e5bce7dec4724d411830876e9bc (patch) | |
tree | b7928ebeb025232e1c3b458ee348f12079f352a0 | |
parent | 5e3815932ca0c3327d316043077dfdf43f49539d (diff) |
Get context switching between kernel threads going.
Since the stacks for kernel threads are not mapped 1:1 this involves
translating virtual addresses into physical addresses when making
OPAL calls.
-rw-r--r-- | sys/arch/powerpc64/dev/opal.c | 4 | ||||
-rw-r--r-- | sys/arch/powerpc64/dev/phb.c | 11 | ||||
-rw-r--r-- | sys/arch/powerpc64/dev/xive.c | 7 | ||||
-rw-r--r-- | sys/arch/powerpc64/include/cpu.h | 4 | ||||
-rw-r--r-- | sys/arch/powerpc64/include/frame.h | 35 | ||||
-rw-r--r-- | sys/arch/powerpc64/include/opal.h | 6 | ||||
-rw-r--r-- | sys/arch/powerpc64/include/pcb.h | 19 | ||||
-rw-r--r-- | sys/arch/powerpc64/include/proc.h | 3 | ||||
-rw-r--r-- | sys/arch/powerpc64/include/tcb.h | 8 | ||||
-rw-r--r-- | sys/arch/powerpc64/powerpc64/genassym.cf | 40 | ||||
-rw-r--r-- | sys/arch/powerpc64/powerpc64/locore.S | 74 | ||||
-rw-r--r-- | sys/arch/powerpc64/powerpc64/locore0.S | 5 | ||||
-rw-r--r-- | sys/arch/powerpc64/powerpc64/machdep.c | 10 | ||||
-rw-r--r-- | sys/arch/powerpc64/powerpc64/process_machdep.c | 4 | ||||
-rw-r--r-- | sys/arch/powerpc64/powerpc64/trap_subr.S | 4 | ||||
-rw-r--r-- | sys/arch/powerpc64/powerpc64/vm_machdep.c | 39 |
16 files changed, 225 insertions, 48 deletions
diff --git a/sys/arch/powerpc64/dev/opal.c b/sys/arch/powerpc64/dev/opal.c index f6f66874b07..152fc3a3391 100644 --- a/sys/arch/powerpc64/dev/opal.c +++ b/sys/arch/powerpc64/dev/opal.c @@ -1,4 +1,4 @@ -/* $OpenBSD: opal.c,v 1.1 2020/06/10 15:01:40 kettenis Exp $ */ +/* $OpenBSD: opal.c,v 1.2 2020/06/14 17:56:54 kettenis Exp $ */ /* * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> * @@ -88,7 +88,7 @@ opal_gettime(struct todr_chip_handle *ch, struct timeval *tv) int64_t error; do { - error = opal_rtc_read(&date, &time); + error = opal_rtc_read(opal_phys(&date), opal_phys(&time)); if (error == OPAL_BUSY_EVENT) opal_poll_events(NULL); } while (error == OPAL_BUSY_EVENT); diff --git a/sys/arch/powerpc64/dev/phb.c b/sys/arch/powerpc64/dev/phb.c index 86726f19f09..4cd808127bd 100644 --- a/sys/arch/powerpc64/dev/phb.c +++ b/sys/arch/powerpc64/dev/phb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: phb.c,v 1.6 2020/06/13 22:58:42 kettenis Exp $ */ +/* $OpenBSD: phb.c,v 1.7 2020/06/14 17:56:54 kettenis Exp $ */ /* * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> * @@ -383,7 +383,8 @@ phb_conf_read(void *v, pcitag_t tag, int reg) uint16_t pci_error_state; uint8_t freeze_state; - error = opal_pci_config_read_word(sc->sc_phb_id, tag, reg, &data); + error = opal_pci_config_read_word(sc->sc_phb_id, + tag, reg, opal_phys(&data)); if (error == OPAL_SUCCESS && data != 0xffffffff) return data; @@ -392,7 +393,7 @@ phb_conf_read(void *v, pcitag_t tag, int reg) * an error state. Clear the error. */ error = opal_pci_eeh_freeze_status(sc->sc_phb_id, sc->sc_pe_number, - &freeze_state, &pci_error_state, NULL); + opal_phys(&freeze_state), opal_phys(&pci_error_state), NULL); if (freeze_state) opal_pci_eeh_freeze_clear(sc->sc_phb_id, sc->sc_pe_number, OPAL_EEH_ACTION_CLEAR_FREEZE_ALL); @@ -469,11 +470,11 @@ phb_intr_establish(void *v, pci_intr_handle_t ih, int level, if (ih.ih_type == PCI_MSI32) { error = opal_get_msi_32(sc->sc_phb_id, 0, xive, - 1, &addr32, &data); + 1, opal_phys(&addr32), opal_phys(&data)); addr = addr32; } else { error = opal_get_msi_64(sc->sc_phb_id, 0, xive, - 1, &addr, &data); + 1, opal_phys(&addr), opal_phys(&data)); } if (error != OPAL_SUCCESS) return NULL; diff --git a/sys/arch/powerpc64/dev/xive.c b/sys/arch/powerpc64/dev/xive.c index 77e298fc597..3c96a2e4606 100644 --- a/sys/arch/powerpc64/dev/xive.c +++ b/sys/arch/powerpc64/dev/xive.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xive.c,v 1.1 2020/06/13 22:58:42 kettenis Exp $ */ +/* $OpenBSD: xive.c,v 1.2 2020/06/14 17:56:54 kettenis Exp $ */ /* * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> * @@ -234,8 +234,9 @@ xive_intr_establish(uint32_t girq, int type, int level, return NULL; lirq = sc->sc_lirq++; - error = opal_xive_get_irq_info(girq, &flags, &eoi_page, - &trig_page, &esb_shift, NULL); + error = opal_xive_get_irq_info(girq, opal_phys(&flags), + opal_phys(&eoi_page), opal_phys(&trig_page), + opal_phys(&esb_shift), NULL); if (error != OPAL_SUCCESS) return NULL; page_size = 1 << esb_shift; diff --git a/sys/arch/powerpc64/include/cpu.h b/sys/arch/powerpc64/include/cpu.h index ed1e2b49322..106b4269f3e 100644 --- a/sys/arch/powerpc64/include/cpu.h +++ b/sys/arch/powerpc64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.10 2020/06/13 22:58:42 kettenis Exp $ */ +/* $OpenBSD: cpu.h,v 1.11 2020/06/14 17:56:54 kettenis Exp $ */ /* * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> @@ -103,6 +103,8 @@ void delay(u_int); #define PROC_STACK(p) 0 #define PROC_PC(p) 0 +void proc_trampoline(void); + static inline void intr_enable(void) { diff --git a/sys/arch/powerpc64/include/frame.h b/sys/arch/powerpc64/include/frame.h index fff56e63634..7cadf7e48c9 100644 --- a/sys/arch/powerpc64/include/frame.h +++ b/sys/arch/powerpc64/include/frame.h @@ -1,4 +1,4 @@ -/* $OpenBSD: frame.h,v 1.2 2020/05/22 15:07:47 kettenis Exp $ */ +/* $OpenBSD: frame.h,v 1.3 2020/06/14 17:56:54 kettenis Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -38,6 +38,37 @@ * This is to ensure alignment of the stackpointer */ #define FRAMELEN roundup(sizeof(struct trapframe) + 32, 16) -#define trapframe(p) ((struct trapframe *)NULL) + +struct callframe { + register_t cf_sp; + register_t cf_cr; + register_t cf_lr; + register_t cf_toc; +}; + +struct switchframe { + register_t sf_sp; + register_t sf_cr; + register_t sf_lr; /* unused */ + register_t sf_toc; /* unused */ + register_t sf_r14; + register_t sf_r15; + register_t sf_r16; + register_t sf_r17; + register_t sf_r18; + register_t sf_r19; + register_t sf_r20; + register_t sf_r21; + register_t sf_r22; + register_t sf_r23; + register_t sf_r24; + register_t sf_r25; + register_t sf_r26; + register_t sf_r27; + register_t sf_r28; + register_t sf_r29; + register_t sf_r30; + register_t sf_r31; +}; #endif /* _MACHDEP_FRAME_H_ */ diff --git a/sys/arch/powerpc64/include/opal.h b/sys/arch/powerpc64/include/opal.h index 0a3f2094d88..741cde370a1 100644 --- a/sys/arch/powerpc64/include/opal.h +++ b/sys/arch/powerpc64/include/opal.h @@ -1,4 +1,4 @@ -/* $OpenBSD: opal.h,v 1.9 2020/06/13 22:58:42 kettenis Exp $ */ +/* $OpenBSD: opal.h,v 1.10 2020/06/14 17:56:54 kettenis Exp $ */ /* * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> @@ -131,6 +131,9 @@ #define XIVE_DUMP_EMU_STATE 0x00000005 #ifndef _LOCORE + +void *opal_phys(void *); + int64_t opal_test(uint64_t); int64_t opal_console_write(int64_t, int64_t *, const uint8_t *); int64_t opal_console_read(int64_t, int64_t *, uint8_t *); @@ -174,6 +177,7 @@ int64_t opal_xive_set_vp_info(uint64_t, uint64_t, uint64_t); int64_t opal_xive_dump(uint32_t, uint32_t); void opal_printf(const char *fmt, ...); + #endif #endif /* _MACHINE_OPAL_H_ */ diff --git a/sys/arch/powerpc64/include/pcb.h b/sys/arch/powerpc64/include/pcb.h index f6bf78bd428..a40e0ee8b50 100644 --- a/sys/arch/powerpc64/include/pcb.h +++ b/sys/arch/powerpc64/include/pcb.h @@ -1,7 +1,26 @@ +/* $OpenBSD: pcb.h,v 1.2 2020/06/14 17:56:54 kettenis Exp $ */ + +/* + * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + #ifndef _MACHINE_PCB_H_ #define _MACHINE_PCB_H_ struct pcb { + register_t pcb_sp; u_int pcb_flags; }; diff --git a/sys/arch/powerpc64/include/proc.h b/sys/arch/powerpc64/include/proc.h index 0fe31ea20c9..b5e2281f0b9 100644 --- a/sys/arch/powerpc64/include/proc.h +++ b/sys/arch/powerpc64/include/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.1 2020/05/16 17:11:14 kettenis Exp $ */ +/* $OpenBSD: proc.h,v 1.2 2020/06/14 17:56:54 kettenis Exp $ */ /* * Copyright (c) 1991 Regents of the University of California. @@ -38,6 +38,7 @@ * Machine-dependent part of the proc structure for arm64. */ struct mdproc { + struct trapframe *md_regs; volatile int md_astpending; }; diff --git a/sys/arch/powerpc64/include/tcb.h b/sys/arch/powerpc64/include/tcb.h index 26646141826..8b9d671f777 100644 --- a/sys/arch/powerpc64/include/tcb.h +++ b/sys/arch/powerpc64/include/tcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tcb.h,v 1.1 2020/05/16 17:11:14 kettenis Exp $ */ +/* $OpenBSD: tcb.h,v 1.2 2020/06/14 17:56:54 kettenis Exp $ */ /* * Copyright (c) 2011 Philip Guenther <guenther@openbsd.org> @@ -22,9 +22,9 @@ #ifdef _KERNEL #define TCB_GET(p) \ - ((void *)trapframe(p)->fixreg[2]) + ((void *)(p)->p_md.md_regs->fixreg[2]) #define TCB_SET(p, addr) \ - (trapframe(p)->fixreg[2] = (__register_t)(addr)) + ((p)->p_md.md_regs->fixreg[2] = (__register_t)(addr)) #else /* _KERNEL */ @@ -34,7 +34,7 @@ /* powerpc offsets the TCB pointer 0x7000 bytes after the data */ #define TCB_OFFSET 0x7000 -register void *__tcb __asm__ ("r2"); +register void *__tcb __asm__ ("r13"); #define TCB_GET() (__tcb) #define TCB_SET(tcb) ((__tcb) = (tcb)) diff --git a/sys/arch/powerpc64/powerpc64/genassym.cf b/sys/arch/powerpc64/powerpc64/genassym.cf index cc15a195a0e..92e42abdbd3 100644 --- a/sys/arch/powerpc64/powerpc64/genassym.cf +++ b/sys/arch/powerpc64/powerpc64/genassym.cf @@ -1,4 +1,4 @@ -# $OpenBSD: genassym.cf,v 1.3 2020/05/22 16:27:49 kettenis Exp $ +# $OpenBSD: genassym.cf,v 1.4 2020/06/14 17:56:54 kettenis Exp $ # # Copyright (c) 1982, 1990 The Regents of the University of California. # All rights reserved. @@ -31,8 +31,13 @@ # include <sys/param.h> +include <sys/proc.h> + +include <machine/intr.h> +include <machine/pcb.h> struct cpu_info +member ci_curproc member ci_tempsave define CPUSAVE_SRR0 0 define CPUSAVE_SRR1 8 @@ -87,3 +92,36 @@ member srr1 member dar member dsisr member exc + +struct pcb +member pcb_sp + +struct proc +member p_addr +member p_stat + +export SONPROC + +define SFRAMELEN sizeof(struct switchframe) +struct switchframe +member sf_r14 +member sf_r15 +member sf_r16 +member sf_r17 +member sf_r18 +member sf_r19 +member sf_r20 +member sf_r21 +member sf_r22 +member sf_r23 +member sf_r24 +member sf_r25 +member sf_r26 +member sf_r27 +member sf_r28 +member sf_r29 +member sf_r30 +member sf_r31 +member sf_cr + +export IPL_NONE diff --git a/sys/arch/powerpc64/powerpc64/locore.S b/sys/arch/powerpc64/powerpc64/locore.S index d3463a44069..66f1490d2f2 100644 --- a/sys/arch/powerpc64/powerpc64/locore.S +++ b/sys/arch/powerpc64/powerpc64/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.12 2020/06/13 22:58:42 kettenis Exp $ */ +/* $OpenBSD: locore.S,v 1.13 2020/06/14 17:56:54 kettenis Exp $ */ /* * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> @@ -16,6 +16,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "assym.h" + #include <machine/opal.h> #include <machine/psl.h> @@ -55,8 +57,78 @@ cpu_idle_leave: .globl cpu_switchto cpu_switchto: + mflr %r0 + std %r0, 16(%r1) + mfcr %r10 + stdu %r1, -SFRAMELEN(%r1) + std %r10, SF_CR(%r1) + std %r14, SF_R14(%r1) + std %r15, SF_R15(%r1) + std %r16, SF_R16(%r1) + std %r17, SF_R17(%r1) + std %r18, SF_R18(%r1) + std %r19, SF_R19(%r1) + std %r20, SF_R20(%r1) + std %r21, SF_R21(%r1) + std %r22, SF_R22(%r1) + std %r23, SF_R23(%r1) + std %r24, SF_R24(%r1) + std %r25, SF_R25(%r1) + std %r26, SF_R26(%r1) + std %r27, SF_R27(%r1) + std %r28, SF_R28(%r1) + std %r29, SF_R29(%r1) + std %r30, SF_R30(%r1) + std %r31, SF_R31(%r1) + + ld %r31, P_ADDR(%r3) + std %r1, PCB_SP(%r31) + + li %r31, SONPROC + stb %r31, P_STAT(%r4) + std %r4, CI_CURPROC(%r13) + + ld %r31, P_ADDR(%r4) + ld %r1, PCB_SP(%r31) + + ld %r31, SF_R31(%r1) + ld %r30, SF_R30(%r1) + ld %r29, SF_R29(%r1) + ld %r28, SF_R28(%r1) + ld %r27, SF_R27(%r1) + ld %r26, SF_R26(%r1) + ld %r25, SF_R25(%r1) + ld %r24, SF_R24(%r1) + ld %r23, SF_R23(%r1) + ld %r22, SF_R22(%r1) + ld %r21, SF_R21(%r1) + ld %r20, SF_R20(%r1) + ld %r19, SF_R19(%r1) + ld %r18, SF_R18(%r1) + ld %r17, SF_R17(%r1) + ld %r16, SF_R16(%r1) + ld %r15, SF_R15(%r1) + ld %r14, SF_R14(%r1) + ld %r10, SF_CR(%r1) + addi %r1, %r1, SFRAMELEN + mtcr %r10 + ld %r0, 16(%r1) + mtlr %r0 blr + .globl proc_trampoline +proc_trampoline: +#ifdef MULTIPROCESSOR + bl proc_trampoline_mp +#endif + li %r3, IPL_NONE + bl splx + mr %r12, %r31 + mr %r3, %r30 + mtctr %r12 + bctrl + b trapexit + /* * OPAL interfaces */ diff --git a/sys/arch/powerpc64/powerpc64/locore0.S b/sys/arch/powerpc64/powerpc64/locore0.S index baf7a893325..c1c8737c437 100644 --- a/sys/arch/powerpc64/powerpc64/locore0.S +++ b/sys/arch/powerpc64/powerpc64/locore0.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore0.S,v 1.3 2020/06/06 22:34:08 kettenis Exp $ */ +/* $OpenBSD: locore0.S,v 1.4 2020/06/14 17:56:54 kettenis Exp $ */ /* * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> @@ -33,7 +33,7 @@ _start: addis %r1, %r30, (initstack_end - 1b)@ha addi %r1, %r1, (initstack_end - 1b)@l - addi %r1, %r1, -32 + addi %r1, %r1, -(FRAMELEN + 32) /* * Not all kexec(8) flavours actually pass the OPAL entry point. @@ -68,6 +68,7 @@ _start: .data .align PAGE_SHIFT + .globl initstack initstack: .space USPACE initstack_end: diff --git a/sys/arch/powerpc64/powerpc64/machdep.c b/sys/arch/powerpc64/powerpc64/machdep.c index fad05d73487..050db4b0f47 100644 --- a/sys/arch/powerpc64/powerpc64/machdep.c +++ b/sys/arch/powerpc64/powerpc64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.22 2020/06/14 17:08:17 kettenis Exp $ */ +/* $OpenBSD: machdep.c,v 1.23 2020/06/14 17:56:54 kettenis Exp $ */ /* * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> @@ -22,6 +22,7 @@ #include <sys/exec.h> #include <sys/exec_elf.h> #include <sys/msgbuf.h> +#include <sys/proc.h> #include <sys/reboot.h> #include <machine/cpufunc.h> @@ -70,6 +71,8 @@ extern char hvtrapcode[], hvtrapcodeend[]; extern char generictrap[]; extern char generichvtrap[]; +extern char initstack[]; + struct fdt_reg memreg[VM_PHYSSEG_MAX]; int nmemreg; @@ -89,6 +92,7 @@ void init_powernv(void *fdt, void *tocbase) { struct fdt_reg reg; + register_t uspace; paddr_t trap; uint64_t msr; void *node; @@ -220,6 +224,10 @@ init_powernv(void *fdt, void *tocbase) isync(); initmsgbuf((caddr_t)uvm_pageboot_alloc(MSGBUFSIZE), MSGBUFSIZE); + + proc0paddr = (struct user *)initstack; + uspace = (register_t)proc0paddr + USPACE - FRAMELEN; + proc0.p_md.md_regs = (struct trapframe *)uspace; } void diff --git a/sys/arch/powerpc64/powerpc64/process_machdep.c b/sys/arch/powerpc64/powerpc64/process_machdep.c index 112d3b9ee55..8709ed2f3f7 100644 --- a/sys/arch/powerpc64/powerpc64/process_machdep.c +++ b/sys/arch/powerpc64/powerpc64/process_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: process_machdep.c,v 1.1 2020/05/16 17:11:14 kettenis Exp $ */ +/* $OpenBSD: process_machdep.c,v 1.2 2020/06/14 17:56:54 kettenis Exp $ */ /* $NetBSD: process_machdep.c,v 1.1 1996/09/30 16:34:53 ws Exp $ */ /* @@ -103,7 +103,7 @@ process_read_fpregs(struct proc *p, struct fpreg *regs) int process_set_pc(struct proc *p, caddr_t addr) { - struct trapframe *tf = trapframe(p); + struct trapframe *tf = p->p_md.md_regs; tf->srr0 = (u_int32_t)addr; return 0; diff --git a/sys/arch/powerpc64/powerpc64/trap_subr.S b/sys/arch/powerpc64/powerpc64/trap_subr.S index 0f1a633da1a..bcfcc82926b 100644 --- a/sys/arch/powerpc64/powerpc64/trap_subr.S +++ b/sys/arch/powerpc64/powerpc64/trap_subr.S @@ -1,4 +1,4 @@ -/* $OpenBSD: trap_subr.S,v 1.6 2020/06/13 22:58:42 kettenis Exp $ */ +/* $OpenBSD: trap_subr.S,v 1.7 2020/06/14 17:56:54 kettenis Exp $ */ /* $NetBSD: trap_subr.S,v 1.20 2002/04/22 23:20:08 kleink Exp $ */ /*- @@ -283,5 +283,7 @@ generictrap: addi %r3, %r1, 48 bl trap + .globl trapexit +trapexit: FRAME_LEAVE(CI_TEMPSAVE) rfid diff --git a/sys/arch/powerpc64/powerpc64/vm_machdep.c b/sys/arch/powerpc64/powerpc64/vm_machdep.c index 62ac3db8305..1112931c022 100644 --- a/sys/arch/powerpc64/powerpc64/vm_machdep.c +++ b/sys/arch/powerpc64/powerpc64/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.1 2020/05/16 17:11:14 kettenis Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.2 2020/06/14 17:56:54 kettenis Exp $ */ /*- * Copyright (c) 1995 Charles M. Hannum. All rights reserved. @@ -67,39 +67,36 @@ void cpu_fork(struct proc *p1, struct proc *p2, void *stack, void *tcb, void (*func)(void *), void *arg) { -#if 0 struct pcb *pcb = &p2->p_addr->u_pcb; struct trapframe *tf; + struct callframe *cf; struct switchframe *sf; - - // Does any flushing need to be done if process was running? + register_t kstack; /* Copy the pcb. */ *pcb = p1->p_addr->u_pcb; - pcb->pcb_fpcpu = NULL; pmap_activate(p2); - tf = (struct trapframe *)((u_long)p2->p_addr - + USPACE - - sizeof(struct trapframe) - - 0x10); - - tf = (struct trapframe *)STACKALIGN(tf); - pcb->pcb_tf = tf; - *tf = *p1->p_addr->u_pcb.pcb_tf; + kstack = (register_t)p2->p_addr + USPACE - FRAMELEN - + (arc4random() & PAGE_MASK & ~_STACKALIGNBYTES); + p2->p_md.md_regs = tf = (struct trapframe *)kstack; + *tf = *p1->p_md.md_regs; if (stack != NULL) - tf->tf_sp = STACKALIGN(stack); + tf->fixreg[1] = STACKALIGN(stack); if (tcb != NULL) - pcb->pcb_tcb = tcb; + tf->fixreg[13] = (register_t)tcb; - sf = (struct switchframe *)tf - 1; - sf->sf_x19 = (uint64_t)func; - sf->sf_x20 = (uint64_t)arg; - sf->sf_lr = (u_int64_t)&proc_trampoline; - pcb->pcb_sp = (uint64_t)sf; -#endif + cf = (struct callframe *)tf - 1; + memset(cf, 0, sizeof(*cf)); + cf->cf_lr = (register_t)&proc_trampoline; + + sf = (struct switchframe *)cf - 1; + memset(sf, 0, sizeof(*sf)); + sf->sf_r31 = (register_t)func; + sf->sf_r30 = (register_t)arg; + pcb->pcb_sp = (register_t)sf; } /* |