Move registers r10-r13 over to the Caller-saved set, at least as far

as intrframe and trapframe are concerned.

According to the ABI, only the low 32-bits of these registers are
guaranteed to be preserved by the callee. Therefore, we need to
preserve all 64-bits of them in the interrupt trampoline.
This commit is contained in:
scw 2002-09-01 11:40:54 +00:00
parent 2b9b8f5bd3
commit f387921c31
8 changed files with 82 additions and 73 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: frame.h,v 1.3 2002/08/29 16:04:10 scw Exp $ */
/* $NetBSD: frame.h,v 1.4 2002/09/01 11:40:54 scw Exp $ */
/*
* Copyright 2002 Wasabi Systems, Inc.
@ -63,10 +63,11 @@ struct stateframe {
/*
* SH5 ABI Callee-saved registers.
*
* Note: See comments in <sh5/sh5/exception.S> as to why r10-r14 are NOT
* part of the Caller-Saved set.
*/
struct exc_calleesave {
register_t r10; register_t r11; register_t r12; register_t r13;
register_t r28; register_t r29; register_t r30; register_t r31;
register_t r32; register_t r33; register_t r34; register_t r35;
@ -81,7 +82,7 @@ struct exc_calleesave {
/*
* SH5 ABI Caller-saved registers
*
* Note: See comments in <sh5/sh5/exception.S> as to why r14 is
* Note: See comments in <sh5/sh5/exception.S> as to why r10-r14 are
* part of the Caller-Saved set.
*/
struct exc_callersave {
@ -89,9 +90,12 @@ struct exc_callersave {
register_t r4; register_t r5; register_t r6; register_t r7;
register_t r8; register_t r9;
register_t r14; register_t r15; register_t r16; register_t r17;
register_t r18; register_t r19; register_t r20; register_t r21;
register_t r22; register_t r23;
register_t r10; register_t r11; register_t r12; register_t r13;
register_t r14;
register_t r15; register_t r16; register_t r17; register_t r18;
register_t r19; register_t r20; register_t r21; register_t r22;
register_t r23;
register_t r25; register_t r26; register_t r27;
@ -157,12 +161,19 @@ struct fpregs {
* kernel context.
* This consists of the callee-saved register set, the current kernel
* stack pointer, the program counter, and the status register.
*
* Note that due to ABI issues, r10-r13 are not part of exc_calleesave.
* However, we still have to save/restore them on a context switch.
*/
struct switchframe {
register_t sf_pc; /* Saved program counter */
register_t sf_sr; /* Status register */
register_t sf_sp; /* Kernel stack pointer */
register_t sf_fp; /* Kernel frame pointer */
register_t sf_r10;
register_t sf_r11;
register_t sf_r12;
register_t sf_r13;
struct exc_calleesave sf_regs; /* Saved registers */
struct fpregs sf_fpregs;
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu_switch.S,v 1.6 2002/08/29 16:04:10 scw Exp $ */
/* $NetBSD: cpu_switch.S,v 1.7 2002/09/01 11:40:54 scw Exp $ */
/*
* Copyright 2002 Wasabi Systems, Inc.
@ -216,7 +216,7 @@
* When no processes are ready to run, cpu_switch branches to idle to
* wait for someone to come ready.
*
* On entry, r11 points to "sched_whichqs".
* On entry, r29 points to "sched_whichqs".
* On exit, r0 must hold the contents of "sched_whichqs"
*
* We don't need to preserve caller-save registers.
@ -258,7 +258,7 @@ ASENTRY_NOPROFILE(idle)
pta/u 1b, tr0
#endif
ld.l r11, 0, r0 /* Fetch sched_whichqs */
ld.l r29, 0, r0 /* Fetch sched_whichqs */
beq/u r0, r63, tr0 /* Back around if nobody's awake */
pta/l Lsw2, tr0
blink tr0, r63 /* Otherwise, back to cpu_switch */
@ -299,8 +299,8 @@ ENTRY_NOPROFILE(cpu_switch)
Lsw1:
pta/u _ASM_LABEL(idle), tr0
LEA(_C_LABEL(sched_whichqs), r11)
ld.l r11, 0, r0 /* Fetch sched_whichqs */
LEA(_C_LABEL(sched_whichqs), r29)
ld.l r29, 0, r0 /* Fetch sched_whichqs */
beq/u r0, r63, tr0 /* Go to sleep if nobody's around */
Lsw2:
@ -340,26 +340,26 @@ Lsw2:
sub r3, r4, r4 /* r4 == 0 if queue is now empty */
cmveq r4, r5, r0 /* Update sched_whichqs bitmap */
st.l r11, 0, r0
st.l r29, 0, r0
/*
* At this point: r2 == process we're about to switch to
*/
getcon kcr0, r10
LDPTR r10, CI_CURPROC, r10 /* Fetch curproc (NULL if we idled) */
getcon kcr0, r28
LDPTR r28, CI_CURPROC, r28 /* Fetch curproc (NULL if we idled) */
pta/u 1f, tr0
beq/u r10, r63, tr0 /* Jump if no previous curproc */
beq/u r28, r63, tr0 /* Jump if no previous curproc */
pta/u 2f, tr0
beq/u r2, r10, tr0 /* Jump if switching to same process */
beq/u r2, r28, tr0 /* Jump if switching to same process */
/* Deactivate the old process' pmap */
LEAF(_C_LABEL(pmap_deactivate), r0)
ptabs/l r0, tr0
or r2, r63, r11 /* Save new proc in r11 */
or r10, r63, r2 /* Get old proc to r2 */
or r2, r63, r29 /* Save new proc in r29 */
or r28, r63, r2 /* Get old proc to r2 */
blink tr0, r18
or r11, r63, r2 /* Restore r2 */
or r29, r63, r2 /* Restore r2 */
1: getcon kcr0, r0
LDPTR r2, P_ADDR, r1 /* Point to process' pcb */
@ -369,10 +369,10 @@ Lsw2:
/* Activate the new process' pmap */
LEAF(_C_LABEL(pmap_activate), r0)
ptabs/l r0, tr0
or r2, r63, r10 /* Save new proc in r10 */
or r2, r63, r28 /* Save new proc in r28 */
blink tr0, r18
LDPTR r10, P_ADDR, r3 /* Fetch new process' pcb */
or r10, r63, r2 /* new proc to r2 */
LDPTR r28, P_ADDR, r3 /* Fetch new process' pcb */
or r28, r63, r2 /* new proc to r2 */
2:
LDPTR r2, P_MD_REGS, r1 /* Fetch pointer to trapframe */

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_interface.c,v 1.2 2002/09/01 09:01:33 scw Exp $ */
/* $NetBSD: db_interface.c,v 1.3 2002/09/01 11:40:54 scw Exp $ */
/*
* Copyright 2002 Wasabi Systems, Inc.
@ -73,12 +73,10 @@ const struct db_variable db_regs[] = {
{ "r7", (long *)&ddb_regs.tf_caller.r7, db_var_reg },
{ "r8", (long *)&ddb_regs.tf_caller.r8, db_var_reg },
{ "r9", (long *)&ddb_regs.tf_caller.r9, db_var_reg },
{ "r10", (long *)&ddb_regs.tf_callee.r10, db_var_reg },
{ "r11", (long *)&ddb_regs.tf_callee.r11, db_var_reg },
{ "r12", (long *)&ddb_regs.tf_callee.r12, db_var_reg },
{ "r13", (long *)&ddb_regs.tf_callee.r13, db_var_reg },
{ "r10", (long *)&ddb_regs.tf_caller.r10, db_var_reg },
{ "r11", (long *)&ddb_regs.tf_caller.r11, db_var_reg },
{ "r12", (long *)&ddb_regs.tf_caller.r12, db_var_reg },
{ "r13", (long *)&ddb_regs.tf_caller.r13, db_var_reg },
{ "r14", (long *)&ddb_regs.tf_caller.r14, db_var_reg },
{ "r15", (long *)&ddb_regs.tf_caller.r15, db_var_reg },
{ "r16", (long *)&ddb_regs.tf_caller.r16, db_var_reg },

View File

@ -1,4 +1,4 @@
/* $NetBSD: exception.S,v 1.8 2002/08/31 09:25:24 scw Exp $ */
/* $NetBSD: exception.S,v 1.9 2002/09/01 11:40:54 scw Exp $ */
/*
* Copyright 2002 Wasabi Systems, Inc.
@ -249,24 +249,28 @@
*
* Note: Assumes r0, r1, r2 and tr0 were saved by _EXCEPTION_ENTRY macro.
*
* Note: We have to save r14 here even though it's not a true Caller-Saved
* register. Basically, C code *will* save the register as part of a
* Note: We have to save r10-r14 here even though they're not true Caller-Saved
* registers. Basically, C code *will* save the registers as part of a
* function's prologue. However if the kernel is IPL32, only the low 32-bits
* of r14 will be saved. This will kind of screw things up should we be called
* from LP64 user code as assignments in ILP32 will sign-extend to the upper
* 32-bits regardless.
* will be saved (yes, this is how the ABI specifies it should happen). This
* will kind of screw things up should we be called from LP64 user code as
* assignments in ILP32 will sign-extend to the upper 32-bits regardless.
*
* And anyway, we want to fix up r14 so kernel stack traces work.
*/
#define _INTR_FRAME_SAVE(sz) \
st.q r15, SFO(SF_FLAGS,sz), r63 ;\
st.q r15, IFO(IF_R3,sz), r3 /* Save r3 - r9 */ ;\
st.q r15, IFO(IF_R3,sz), r3 /* Save r3 - r13 */ ;\
st.q r15, IFO(IF_R4,sz), r4 ;\
st.q r15, IFO(IF_R5,sz), r5 ;\
st.q r15, IFO(IF_R6,sz), r6 ;\
st.q r15, IFO(IF_R7,sz), r7 ;\
st.q r15, IFO(IF_R8,sz), r8 ;\
st.q r15, IFO(IF_R9,sz), r9 ;\
st.q r15, IFO(IF_R10,sz), r10 ;\
st.q r15, IFO(IF_R11,sz), r11 ;\
st.q r15, IFO(IF_R12,sz), r12 ;\
st.q r15, IFO(IF_R13,sz), r13 ;\
st.q r15, IFO(IF_R14,sz), r14/* Save r14 (frame pointer) */ ;\
st.q r15, IFO(IF_R16,sz), r16/* Save r16 - r23 */ ;\
st.q r15, IFO(IF_R17,sz), r17 ;\
@ -309,13 +313,17 @@
* Note: Assumes r0, r1, r2 and tr0 will be restored by _EXCEPTION_EXIT macro.
*/
#define _INTR_FRAME_RESTORE(sz) \
ld.q r15, IFO(IF_R3,sz), r3 /* Restore r3 - r9 */ ;\
ld.q r15, IFO(IF_R3,sz), r3 /* Restore r3 - r13 */ ;\
ld.q r15, IFO(IF_R4,sz), r4 ;\
ld.q r15, IFO(IF_R5,sz), r5 ;\
ld.q r15, IFO(IF_R6,sz), r6 ;\
ld.q r15, IFO(IF_R7,sz), r7 ;\
ld.q r15, IFO(IF_R8,sz), r8 ;\
ld.q r15, IFO(IF_R9,sz), r9 ;\
ld.q r15, IFO(IF_R10,sz), r10 ;\
ld.q r15, IFO(IF_R11,sz), r11 ;\
ld.q r15, IFO(IF_R12,sz), r12 ;\
ld.q r15, IFO(IF_R13,sz), r13 ;\
ld.q r15, IFO(IF_R14,sz), r14/* Restore r14 */ ;\
ld.q r15, IFO(IF_R16,sz), r16/* Restore r16 - r23 */ ;\
ld.q r15, IFO(IF_R17,sz), r17 ;\
@ -360,10 +368,6 @@
#define _TRAP_FRAME_SAVE(sz) \
movi SF_FLAGS_CALLEE_SAVED, r0 ;\
st.q r15, SFO(SF_FLAGS,sz), r0 ;\
st.q r15, TFO(TF_R10,sz), r10 /* Save r10 - r13 */ ;\
st.q r15, TFO(TF_R11,sz), r11 ;\
st.q r15, TFO(TF_R12,sz), r12 ;\
st.q r15, TFO(TF_R13,sz), r13 ;\
st.q r15, TFO(TF_R28,sz), r28 /* Save r28 - r35 */ ;\
st.q r15, TFO(TF_R29,sz), r29 ;\
st.q r15, TFO(TF_R30,sz), r30 ;\
@ -405,10 +409,6 @@
pta/u 99f, tr0 ;\
ld.q r15, SFO(SF_FLAGS,sz), r0 ;\
beq/u r0, r63, tr0 ;\
ld.q r15, TFO(TF_R10,sz), r10 /* Restore r10 - r13 */ ;\
ld.q r15, TFO(TF_R11,sz), r11 ;\
ld.q r15, TFO(TF_R12,sz), r12 ;\
ld.q r15, TFO(TF_R13,sz), r13 ;\
ld.q r15, TFO(TF_R28,sz), r28 /* Restore r28 - r35 */ ;\
ld.q r15, TFO(TF_R29,sz), r29 ;\
ld.q r15, TFO(TF_R30,sz), r30 ;\
@ -759,7 +759,7 @@ Lsh5_event_panic:
*
* - Save only a very small subset of registers initially.
* (Over and above those saved by _INTR_FRAME_SAVE()).
* First thoughts on this would be r1, r2-r9, r14, r15, r18, r26, r27
* First thoughts on this would be r1, r2-r14, r15, r18, r26, r27
*
* - Invoke trapa().
*

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.5 2002/08/31 09:12:59 scw Exp $
# $NetBSD: genassym.cf,v 1.6 2002/09/01 11:40:54 scw Exp $
# Copyright 2002 Wasabi Systems, Inc.
# All rights reserved.
@ -80,10 +80,10 @@ define PCB_CTX_PC offsetof(struct pcb, pcb_ctx.sf_pc)
define PCB_CTX_SR offsetof(struct pcb, pcb_ctx.sf_sr)
define PCB_CTX_SP offsetof(struct pcb, pcb_ctx.sf_sp)
define PCB_CTX_FP offsetof(struct pcb, pcb_ctx.sf_fp)
define PCB_CTX_REGS_R10 offsetof(struct pcb, pcb_ctx.sf_regs.r10)
define PCB_CTX_REGS_R11 offsetof(struct pcb, pcb_ctx.sf_regs.r11)
define PCB_CTX_REGS_R12 offsetof(struct pcb, pcb_ctx.sf_regs.r12)
define PCB_CTX_REGS_R13 offsetof(struct pcb, pcb_ctx.sf_regs.r13)
define PCB_CTX_REGS_R10 offsetof(struct pcb, pcb_ctx.sf_r10)
define PCB_CTX_REGS_R11 offsetof(struct pcb, pcb_ctx.sf_r11)
define PCB_CTX_REGS_R12 offsetof(struct pcb, pcb_ctx.sf_r12)
define PCB_CTX_REGS_R13 offsetof(struct pcb, pcb_ctx.sf_r13)
define PCB_CTX_REGS_R28 offsetof(struct pcb, pcb_ctx.sf_regs.r28)
define PCB_CTX_REGS_R29 offsetof(struct pcb, pcb_ctx.sf_regs.r29)
define PCB_CTX_REGS_R30 offsetof(struct pcb, pcb_ctx.sf_regs.r30)
@ -143,6 +143,10 @@ define IF_R6 offsetof(struct intrframe, if_caller.r6)
define IF_R7 offsetof(struct intrframe, if_caller.r7)
define IF_R8 offsetof(struct intrframe, if_caller.r8)
define IF_R9 offsetof(struct intrframe, if_caller.r9)
define IF_R10 offsetof(struct intrframe, if_caller.r10)
define IF_R11 offsetof(struct intrframe, if_caller.r11)
define IF_R12 offsetof(struct intrframe, if_caller.r12)
define IF_R13 offsetof(struct intrframe, if_caller.r13)
define IF_R14 offsetof(struct intrframe, if_caller.r14)
define IF_R15 offsetof(struct intrframe, if_caller.r15)
define IF_R16 offsetof(struct intrframe, if_caller.r16)
@ -175,10 +179,6 @@ define IF_TR4 offsetof(struct intrframe, if_caller.tr4)
define IF_SSR offsetof(struct intrframe, if_state.sf_ssr)
define SZ_TRAPFRAME sizeof(struct trapframe)
define TF_R10 offsetof(struct trapframe, tf_callee.r10)
define TF_R11 offsetof(struct trapframe, tf_callee.r11)
define TF_R12 offsetof(struct trapframe, tf_callee.r12)
define TF_R13 offsetof(struct trapframe, tf_callee.r13)
define TF_R28 offsetof(struct trapframe, tf_callee.r28)
define TF_R29 offsetof(struct trapframe, tf_callee.r29)
define TF_R30 offsetof(struct trapframe, tf_callee.r30)

View File

@ -1,4 +1,4 @@
/* $NetBSD: process_machdep.c,v 1.1 2002/07/05 13:32:06 scw Exp $ */
/* $NetBSD: process_machdep.c,v 1.2 2002/09/01 11:40:54 scw Exp $ */
/*
* Copyright 2002 Wasabi Systems, Inc.
@ -144,10 +144,10 @@ process_read_regs(struct proc *p, struct reg *regs)
regs->r_intregs[8] = tf->tf_caller.r8;
regs->r_intregs[9] = tf->tf_caller.r9;
regs->r_intregs[10] = tf->tf_callee.r10;
regs->r_intregs[11] = tf->tf_callee.r11;
regs->r_intregs[12] = tf->tf_callee.r12;
regs->r_intregs[13] = tf->tf_callee.r13;
regs->r_intregs[10] = tf->tf_caller.r10;
regs->r_intregs[11] = tf->tf_caller.r11;
regs->r_intregs[12] = tf->tf_caller.r12;
regs->r_intregs[13] = tf->tf_caller.r13;
regs->r_intregs[14] = tf->tf_caller.r14;
regs->r_intregs[15] = tf->tf_caller.r15;
@ -246,10 +246,10 @@ process_write_regs(struct proc *p, struct reg *regs)
tf->tf_caller.r8 = regs->r_intregs[8];
tf->tf_caller.r9 = regs->r_intregs[9];
tf->tf_callee.r10 = regs->r_intregs[10];
tf->tf_callee.r11 = regs->r_intregs[11];
tf->tf_callee.r12 = regs->r_intregs[12];
tf->tf_callee.r13 = regs->r_intregs[13];
tf->tf_caller.r10 = regs->r_intregs[10];
tf->tf_caller.r11 = regs->r_intregs[11];
tf->tf_caller.r12 = regs->r_intregs[12];
tf->tf_caller.r13 = regs->r_intregs[13];
tf->tf_caller.r14 = regs->r_intregs[14];
tf->tf_caller.r15 = regs->r_intregs[15];

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.6 2002/08/31 09:41:05 scw Exp $ */
/* $NetBSD: trap.c,v 1.7 2002/09/01 11:40:54 scw Exp $ */
/*
* Copyright 2002 Wasabi Systems, Inc.
@ -499,11 +499,11 @@ dump_trapframe(struct trapframe *tf)
print_a_reg(" r8", tf->tf_caller.r8, 1);
print_a_reg(" r9", tf->tf_caller.r9, 0);
print_a_reg("r10", tf->tf_callee.r10, 0);
print_a_reg("r11", tf->tf_callee.r11, 1);
print_a_reg("r10", tf->tf_caller.r10, 0);
print_a_reg("r11", tf->tf_caller.r11, 1);
print_a_reg("r12", tf->tf_callee.r12, 0);
print_a_reg("r13", tf->tf_callee.r13, 0);
print_a_reg("r12", tf->tf_caller.r12, 0);
print_a_reg("r13", tf->tf_caller.r13, 0);
print_a_reg("r14", tf->tf_caller.r14, 1);
print_a_reg("r15", tf->tf_caller.r15, 0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: vm_machdep.c,v 1.2 2002/08/26 10:32:55 scw Exp $ */
/* $NetBSD: vm_machdep.c,v 1.3 2002/09/01 11:40:54 scw Exp $ */
/*
* Copyright 2002 Wasabi Systems, Inc.
@ -218,8 +218,8 @@ cpu_fork(struct proc *p1, struct proc *p2, void *stack, size_t stacksize,
*/
pcb->pcb_ctx.sf_pc = (register_t)(intptr_t)proc_trampoline;
pcb->pcb_ctx.sf_sp = (register_t)(intptr_t)tf;
pcb->pcb_ctx.sf_regs.r10 = (register_t)(intptr_t)func;
pcb->pcb_ctx.sf_regs.r11 = (register_t)(intptr_t)arg;
pcb->pcb_ctx.sf_r10 = (register_t)(intptr_t)func;
pcb->pcb_ctx.sf_r11 = (register_t)(intptr_t)arg;
}
/*