From 9f584df1db4c7598c3be102bffb709cb2854fac6 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Sat, 12 Mar 2011 18:50:08 +0000 Subject: In the original sparc V7 book (and in the v8 book), the divrem leaf code used local registers for a few temporaries. This was changed to use two global registers. Maybe to permit use in-kernel without conflicting with the register V7 register window handlers. (Was this done by Chris Torek? Is this related to Gordon Irlam's work? Or was it in NetBSD? Hard to tell because NetBSD removed their original cvs tree.) In V8 the ABI was tightened; more global registers became offlimits in different ways. We started supporting sun4m, and did not consider this. As a result, the global registers chosen are the wrong choice. In particular, %g7 is a poor choice for upcoming TLS work. It looks like it is safer to use %g5 and %g6 since these functions are "system software". All re-entrant parts of the system save it. On sparc64 these functions are in libc per ABI requirement, but are unused. On sparc, they occur in bootblocks (no reentrancy), kernel (reentrancy saves globals; kernel is not ABI compliant), userland libc (signal handlers save globals), and ld.so (symbol binding is not re-entrant on its own). Discussed rather extensively with guenther, kettenis, miod and drahn. --- sys/lib/libkern/arch/sparc/divrem.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sys/lib') diff --git a/sys/lib/libkern/arch/sparc/divrem.m4 b/sys/lib/libkern/arch/sparc/divrem.m4 index 1651801009a..b7b5b609477 100644 --- a/sys/lib/libkern/arch/sparc/divrem.m4 +++ b/sys/lib/libkern/arch/sparc/divrem.m4 @@ -1,4 +1,4 @@ -/* $OpenBSD: divrem.m4,v 1.7 2007/11/24 19:47:05 deraadt Exp $ */ +/* $OpenBSD: divrem.m4,v 1.8 2011/03/12 18:50:07 deraadt Exp $ */ /* $NetBSD: divrem.m4,v 1.3 1995/04/22 09:37:39 pk Exp $ */ /* @@ -88,7 +88,7 @@ define(V, `%o5') /* m4 reminder: ifelse(a,b,c,d) => if a is b, then c, else d */ define(T, `%g1') -define(SC, `%g7') +define(SC, `%g5') ifelse(S, `true', `define(SIGN, `%g6')') /* -- cgit v1.2.3