Module Name: src Committed By: chs Date: Fri Nov 2 00:01:20 UTC 2012
Modified Files: src/sys/arch/sparc/include: types.h src/sys/arch/sparc/sparc: genassym.cf locore.s machdep.c Log Message: Add RAS support for sparc. To generate a diff of this commit: cvs rdiff -u -r1.61 -r1.62 src/sys/arch/sparc/include/types.h cvs rdiff -u -r1.67 -r1.68 src/sys/arch/sparc/sparc/genassym.cf cvs rdiff -u -r1.266 -r1.267 src/sys/arch/sparc/sparc/locore.s cvs rdiff -u -r1.324 -r1.325 src/sys/arch/sparc/sparc/machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/sparc/include/types.h diff -u src/sys/arch/sparc/include/types.h:1.61 src/sys/arch/sparc/include/types.h:1.62 --- src/sys/arch/sparc/include/types.h:1.61 Sat Jul 30 19:29:12 2011 +++ src/sys/arch/sparc/include/types.h Fri Nov 2 00:01:19 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: types.h,v 1.61 2011/07/30 19:29:12 martin Exp $ */ +/* $NetBSD: types.h,v 1.62 2012/11/02 00:01:19 chs Exp $ */ /* * Copyright (c) 1992, 1993 @@ -122,15 +122,13 @@ typedef volatile unsigned char __cpu_si #define __GENERIC_SOFT_INTERRUPTS_ALL_LEVELS #define __HAVE_CPU_DATA_FIRST #define __HAVE_CPU_VMSPACE_EXEC +#define __HAVE_RAS #ifdef SUN4U #define __HAVE_DEVICE_REGISTER_POSTCONFIG #define __HAVE_ATOMIC64_OPS #define __HAVE_CPU_COUNTER /* sparc v9 CPUs have %tick */ #define __HAVE_FAST_SOFTINTS -#if defined(_KERNEL) -#define __HAVE_RAS -#endif #else #define __HAVE_MM_MD_READWRITE #endif Index: src/sys/arch/sparc/sparc/genassym.cf diff -u src/sys/arch/sparc/sparc/genassym.cf:1.67 src/sys/arch/sparc/sparc/genassym.cf:1.68 --- src/sys/arch/sparc/sparc/genassym.cf:1.67 Mon Aug 15 02:19:44 2011 +++ src/sys/arch/sparc/sparc/genassym.cf Fri Nov 2 00:01:19 2012 @@ -1,4 +1,4 @@ -# $NetBSD: genassym.cf,v 1.67 2011/08/15 02:19:44 mrg Exp $ +# $NetBSD: genassym.cf,v 1.68 2012/11/02 00:01:19 chs Exp $ # # Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -106,18 +106,23 @@ include <sparc/dev/fdvar.h> define BSD BSD define USRSTACK USRSTACK -# proc fields and values +# LWP fields and values define L_PCB offsetof(struct lwp, l_addr) define L_PROC offsetof(struct lwp, l_proc) define L_STAT offsetof(struct lwp, l_stat) define L_WCHAN offsetof(struct lwp, l_wchan) define L_CPU offsetof(struct lwp, l_cpu) define L_PRIORITY offsetof(struct lwp, l_priority) -define P_VMSPACE offsetof(struct proc, p_vmspace) -define P_MD_SYSCALL offsetof(struct proc, p_md.md_syscall) +define L_TF offsetof(struct lwp, l_md.md_tf) + define LSRUN LSRUN define LSONPROC LSONPROC +# proc fields +define P_VMSPACE offsetof(struct proc, p_vmspace) +define P_RASLIST offsetof(struct proc, p_raslist) +define P_MD_SYSCALL offsetof(struct proc, p_md.md_syscall) + # VM structure fields define VM_PMAP offsetof(struct vmspace, vm_map.pmap) define PMAP_CTX offsetof(struct pmap, pm_ctx) @@ -219,6 +224,10 @@ define PCB_PC offsetof(struct pcb, pcb_ define PCB_UW offsetof(struct pcb, pcb_uw) define PCB_WIM offsetof(struct pcb, pcb_wim) +# trapframe fields +define TF_PC offsetof(struct trapframe, tf_pc) +define TF_NPC offsetof(struct trapframe, tf_npc) + # interrupt enable register PTE define IE_REG_PTE_PG (PG_V | PG_W | PG_S | PG_NC | PG_OBIO) Index: src/sys/arch/sparc/sparc/locore.s diff -u src/sys/arch/sparc/sparc/locore.s:1.266 src/sys/arch/sparc/sparc/locore.s:1.267 --- src/sys/arch/sparc/sparc/locore.s:1.266 Sun Feb 19 21:06:28 2012 +++ src/sys/arch/sparc/sparc/locore.s Fri Nov 2 00:01:19 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.266 2012/02/19 21:06:28 rmind Exp $ */ +/* $NetBSD: locore.s,v 1.267 2012/11/02 00:01:19 chs Exp $ */ /* * Copyright (c) 1996 Paul Kranenburg @@ -4949,8 +4949,27 @@ Lnosaveoldlwp: st %o0, [%o4 + PMAP_CPUSET] #endif + /* + * Check for restartable atomic sequences (RAS) + */ + ld [%g3 + L_PROC], %o0 ! now %o0 points to p + ld [%o0 + P_RASLIST], %o1 ! any RAS in p? + cmp %o1, 0 + be Lsw_noras ! no, skip RAS check + mov %g1, %i0 ! restore oldlwp (for return value) + ld [%g3 + L_TF], %l3 ! pointer to trap frame + call _C_LABEL(ras_lookup) + ld [%l3 + TF_PC], %o1 + cmp %o0, -1 + be Lsw_noras + add %o0, 4, %o1 + st %o0, [%l3 + TF_PC] ! store rewound %pc + st %o1, [%l3 + TF_NPC] ! and %npc + +Lsw_noras: + ret - restore %g0, %g1, %o0 ! return (lastproc) + restore ! return (oldlwp) /* * Call the idlespin() function if it exists, otherwise just return. Index: src/sys/arch/sparc/sparc/machdep.c diff -u src/sys/arch/sparc/sparc/machdep.c:1.324 src/sys/arch/sparc/sparc/machdep.c:1.325 --- src/sys/arch/sparc/sparc/machdep.c:1.324 Thu Sep 13 11:49:16 2012 +++ src/sys/arch/sparc/sparc/machdep.c Fri Nov 2 00:01:20 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.324 2012/09/13 11:49:16 martin Exp $ */ +/* $NetBSD: machdep.c,v 1.325 2012/11/02 00:01:20 chs Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.324 2012/09/13 11:49:16 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.325 2012/11/02 00:01:20 chs Exp $"); #include "opt_compat_netbsd.h" #include "opt_compat_sunos.h" @@ -103,6 +103,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v #include <sys/simplelock.h> #include <sys/module.h> #include <sys/mutex.h> +#include <sys/ras.h> #include <dev/mm.h> @@ -594,6 +595,7 @@ cpu_getmcontext(struct lwp *l, mcontext_ { struct trapframe *tf = (struct trapframe *)l->l_md.md_tf; __greg_t *r = mcp->__gregs; + __greg_t ras_pc; #ifdef FPU_CONTEXT __fpregset_t *f = &mcp->__fpregs; struct fpstate *fps = l->l_md.md_fpstate; @@ -633,6 +635,12 @@ cpu_getmcontext(struct lwp *l, mcontext_ r[_REG_O6] = tf->tf_out[6]; r[_REG_O7] = tf->tf_out[7]; + if ((ras_pc = (__greg_t)ras_lookup(l->l_proc, + (void *) r[_REG_PC])) != -1) { + r[_REG_PC] = ras_pc; + r[_REG_nPC] = ras_pc + 4; + } + *flags |= (_UC_CPU|_UC_TLSBASE); #ifdef FPU_CONTEXT