summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2011-03-12 18:50:08 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2011-03-12 18:50:08 +0000
commit9f584df1db4c7598c3be102bffb709cb2854fac6 (patch)
tree70a6c27209d78e5556d9e9a063b6ab902d5b673e
parent182d21b02135847279bb9f73915a223c6784bac8 (diff)
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.
-rw-r--r--lib/libc/arch/sparc/gen/divrem.m44
-rw-r--r--lib/libc/arch/sparc64/gen/divrem.m44
-rw-r--r--sys/lib/libkern/arch/sparc/divrem.m44
3 files changed, 6 insertions, 6 deletions
diff --git a/lib/libc/arch/sparc/gen/divrem.m4 b/lib/libc/arch/sparc/gen/divrem.m4
index bc0e2cc78db..9152f9f37e8 100644
--- a/lib/libc/arch/sparc/gen/divrem.m4
+++ b/lib/libc/arch/sparc/gen/divrem.m4
@@ -1,4 +1,4 @@
-/* $OpenBSD: divrem.m4,v 1.6 2009/10/28 06:49:55 deraadt Exp $ */
+/* $OpenBSD: divrem.m4,v 1.7 2011/03/12 18:50:05 deraadt Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -85,7 +85,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')')
/*
diff --git a/lib/libc/arch/sparc64/gen/divrem.m4 b/lib/libc/arch/sparc64/gen/divrem.m4
index 7fbab3c52f5..20e4f35ca0a 100644
--- a/lib/libc/arch/sparc64/gen/divrem.m4
+++ b/lib/libc/arch/sparc64/gen/divrem.m4
@@ -1,4 +1,4 @@
-/* $OpenBSD: divrem.m4,v 1.2 2003/06/02 20:18:32 millert Exp $ */
+/* $OpenBSD: divrem.m4,v 1.3 2011/03/12 18:50:07 deraadt Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -83,7 +83,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')')
/*
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')')
/*