summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorRoger A. Faulkner <Roger.Faulkner@Sun.COM>2009-09-23 17:01:56 -0700
committerRoger A. Faulkner <Roger.Faulkner@Sun.COM>2009-09-23 17:01:56 -0700
commit35e6f27ad0d19ae8ac48ddcbccbe1af717832f29 (patch)
tree7b4358ff35039f841475879305ea18a2b827fc88 /usr/src
parent1caae4fbfd50fd4b25e58671b37fd9a0ee43d46a (diff)
downloadillumos-gate-35e6f27ad0d19ae8ac48ddcbccbe1af717832f29.tar.gz
6883880 non-8-byte-aligned mutexes: update needed for solaris_nevada
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/lib/libc/port/threads/assfail.c22
-rw-r--r--usr/src/lib/libc/port/threads/thr.c20
-rw-r--r--usr/src/lib/libc/sparc/threads/asm_subr.s7
3 files changed, 41 insertions, 8 deletions
diff --git a/usr/src/lib/libc/port/threads/assfail.c b/usr/src/lib/libc/port/threads/assfail.c
index 54fbe959a0..e37ce4f276 100644
--- a/usr/src/lib/libc/port/threads/assfail.c
+++ b/usr/src/lib/libc/port/threads/assfail.c
@@ -20,12 +20,10 @@
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "lint.h"
#include "thr_uberdata.h"
@@ -161,14 +159,19 @@ ultos(uint64_t n, int base, char *s)
void
lock_error(const mutex_t *mp, const char *who, void *cv, const char *msg)
{
- /* take a snapshot of the mutex before it changes (we hope!) */
- mutex_t mcopy = *mp;
+ mutex_t mcopy;
char buf[800];
uberdata_t *udp;
ulwp_t *self;
lwpid_t lwpid;
pid_t pid;
+ /*
+ * Take a snapshot of the mutex before it changes (we hope!).
+ * Use memcpy() rather than 'mcopy = *mp' in case mp is unaligned.
+ */
+ (void) memcpy(&mcopy, mp, sizeof (mcopy));
+
/* avoid recursion deadlock */
if ((self = __curthread()) != NULL) {
if (assert_thread == self)
@@ -246,8 +249,7 @@ lock_error(const mutex_t *mp, const char *who, void *cv, const char *msg)
void
rwlock_error(const rwlock_t *rp, const char *who, const char *msg)
{
- /* take a snapshot of the rwlock before it changes (we hope) */
- rwlock_t rcopy = *rp;
+ rwlock_t rcopy;
uint32_t rwstate;
char buf[800];
uberdata_t *udp;
@@ -256,6 +258,12 @@ rwlock_error(const rwlock_t *rp, const char *who, const char *msg)
pid_t pid;
int process;
+ /*
+ * Take a snapshot of the rwlock before it changes (we hope!).
+ * Use memcpy() rather than 'rcopy = *rp' in case rp is unaligned.
+ */
+ (void) memcpy(&rcopy, rp, sizeof (rcopy));
+
/* avoid recursion deadlock */
if ((self = __curthread()) != NULL) {
if (assert_thread == self)
diff --git a/usr/src/lib/libc/port/threads/thr.c b/usr/src/lib/libc/port/threads/thr.c
index bfad10c06a..5cfcb2daef 100644
--- a/usr/src/lib/libc/port/threads/thr.c
+++ b/usr/src/lib/libc/port/threads/thr.c
@@ -1434,6 +1434,26 @@ libc_init(void)
self->ul_adaptive_spin = thread_adaptive_spin;
self->ul_queue_spin = thread_queue_spin;
+#if defined(__sparc) && !defined(_LP64)
+ if (self->ul_misaligned) {
+ /*
+ * Tell the kernel to fix up ldx/stx instructions that
+ * refer to non-8-byte aligned data instead of giving
+ * the process an alignment trap and generating SIGBUS.
+ *
+ * Programs compiled for 32-bit sparc with the Studio SS12
+ * compiler get this done for them automatically (in _init()).
+ * We do it here for the benefit of programs compiled with
+ * other compilers, like gcc.
+ *
+ * This is necessary for the _THREAD_LOCKS_MISALIGNED=1
+ * environment variable horrible hack to work.
+ */
+ extern void _do_fix_align(void);
+ _do_fix_align();
+ }
+#endif
+
/*
* When we have initialized the primary link map, inform
* the dynamic linker about our interface functions.
diff --git a/usr/src/lib/libc/sparc/threads/asm_subr.s b/usr/src/lib/libc/sparc/threads/asm_subr.s
index b7fa8fef1e..95dcfb1740 100644
--- a/usr/src/lib/libc/sparc/threads/asm_subr.s
+++ b/usr/src/lib/libc/sparc/threads/asm_subr.s
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -82,6 +82,11 @@
retl
ta ST_GETPSR
SET_SIZE(_getpsr)
+
+ ENTRY(_do_fix_align)
+ retl
+ ta ST_FIX_ALIGN
+ SET_SIZE(_do_fix_align)
#endif
ENTRY(_getfsr)