From c39ae7f5d7ba8d3d2767a68d39209720a2a504ac Mon Sep 17 00:00:00 2001 From: uwe Date: Sun, 1 Jun 2008 23:07:20 +0000 Subject: [PATCH] Recycle unused _REG_EXPEVT slot in mcontext for _REG_GBR. As the size of mcontext is not changed, we avoid the hassle of versioning all the calls that use it. _REG_EXPEVT was never used by any code in the tree. Reporting EXPEVT makes sense only for signals and in that case we pass it to userland in ksi_trap already which is official MI way to get this (MD) information. Old binaries running on new kernels will now have their GBR set from new mcontext, but that's ok too, as GBR was not properly supported by old kernels (not saved in trapframe), so old binaries couldn't have possibly used it anyway. --- lib/libpthread/arch/sh3/_context_u.S | 8 +++++++- lib/libpthread/arch/sh3/genassym.cf | 4 ++-- sys/arch/sh3/include/mcontext.h | 4 ++-- sys/arch/sh3/sh3/sh3_machdep.c | 8 ++++---- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/libpthread/arch/sh3/_context_u.S b/lib/libpthread/arch/sh3/_context_u.S index ba2295931049..b765035d8f63 100644 --- a/lib/libpthread/arch/sh3/_context_u.S +++ b/lib/libpthread/arch/sh3/_context_u.S @@ -1,4 +1,4 @@ -/* $NetBSD: _context_u.S,v 1.5 2006/01/04 17:44:53 uwe Exp $ */ +/* $NetBSD: _context_u.S,v 1.6 2008/06/01 23:07:20 uwe Exp $ */ /* * Copyright (c) 2003 Christian P. Groessler @@ -58,6 +58,9 @@ mov.l r14, @((_REG_R14 * 4), r1) ; \ /* _REG_R15 is too far to use @(disp, Rn) */ \ \ + stc gbr, r0 ; \ + mov.l r0, @((_REG_GBR * 4), r1) ; \ + \ /* in Hitachi calling convention mac regs are callee saved */ \ sts mach, r0 ; \ mov.l r0, @((_REG_MACH * 4), r1) ; \ @@ -93,6 +96,9 @@ mov.l @((_REG_R14 * 4), r1), r14 ; \ /* _REG_R15 is too far to use @(disp, Rn) */ \ \ + mov.l @((_REG_GBR * 4), r1), r0 ; \ + ldc r0, gbr ; \ + \ /* in Hitachi calling convention mac regs are callee saved */ \ mov.l @((_REG_MACH * 4), r1), r0 ; \ mov.l @((_REG_MACL * 4), r1), r2 ; \ diff --git a/lib/libpthread/arch/sh3/genassym.cf b/lib/libpthread/arch/sh3/genassym.cf index c6c11e680153..4970b0693202 100644 --- a/lib/libpthread/arch/sh3/genassym.cf +++ b/lib/libpthread/arch/sh3/genassym.cf @@ -1,4 +1,4 @@ -# $NetBSD: genassym.cf,v 1.7 2008/04/28 20:23:02 martin Exp $ +# $NetBSD: genassym.cf,v 1.8 2008/06/01 23:07:20 uwe Exp $ # Copyright (c) 2001 The NetBSD Foundation, Inc. # All rights reserved. @@ -49,7 +49,7 @@ define _UC_FPU _UC_FPU define _UC_USER _UC_USER define _UC_USER_BIT _UC_USER_BIT -define _REG_EXPEVT _REG_EXPEVT +define _REG_GBR _REG_GBR define _REG_PC _REG_PC define _REG_SR _REG_SR define _REG_MACL _REG_MACL diff --git a/sys/arch/sh3/include/mcontext.h b/sys/arch/sh3/include/mcontext.h index 9e15fd1f44fe..539efb53efc5 100644 --- a/sys/arch/sh3/include/mcontext.h +++ b/sys/arch/sh3/include/mcontext.h @@ -1,4 +1,4 @@ -/* $NetBSD: mcontext.h,v 1.6 2008/04/28 20:23:35 martin Exp $ */ +/* $NetBSD: mcontext.h,v 1.7 2008/06/01 23:07:20 uwe Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -40,7 +40,7 @@ typedef int __greg_t; typedef __greg_t __gregset_t[_NGREG]; -#define _REG_EXPEVT 0 +#define _REG_GBR 0 #define _REG_PC 1 #define _REG_SR 2 #define _REG_MACL 3 diff --git a/sys/arch/sh3/sh3/sh3_machdep.c b/sys/arch/sh3/sh3/sh3_machdep.c index f791b2992d24..eab71f96bd7c 100644 --- a/sys/arch/sh3/sh3/sh3_machdep.c +++ b/sys/arch/sh3/sh3/sh3_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: sh3_machdep.c,v 1.73 2008/06/01 00:46:01 uwe Exp $ */ +/* $NetBSD: sh3_machdep.c,v 1.74 2008/06/01 23:07:20 uwe Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2002 The NetBSD Foundation, Inc. @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sh3_machdep.c,v 1.73 2008/06/01 00:46:01 uwe Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sh3_machdep.c,v 1.74 2008/06/01 23:07:20 uwe Exp $"); #include "opt_kgdb.h" #include "opt_memsize.h" @@ -583,7 +583,7 @@ cpu_getmcontext(l, mcp, flags) __greg_t ras_pc; /* Save register context. */ - gr[_REG_EXPEVT] = tf->tf_expevt; + gr[_REG_GBR] = tf->tf_gbr; gr[_REG_PC] = tf->tf_spc; gr[_REG_SR] = tf->tf_ssr; gr[_REG_MACL] = tf->tf_macl; @@ -632,7 +632,7 @@ cpu_setmcontext(l, mcp, flags) if (((tf->tf_ssr ^ gr[_REG_SR]) & PSL_USERSTATIC) != 0) return (EINVAL); - /* _REG_EXPEVT not restored */ + tf->tf_gbr = gr[_REG_GBR]; tf->tf_spc = gr[_REG_PC]; tf->tf_ssr = gr[_REG_SR]; tf->tf_macl = gr[_REG_MACL];