diff options
-rw-r--r-- | sys/kern/kern_mutex.c | 2 | ||||
-rw-r--r-- | sys/kern/kern_rwlock.c | 2 | ||||
-rw-r--r-- | sys/kern/kern_sx.c | 2 | ||||
-rw-r--r-- | sys/sys/systm.h | 4 |
4 files changed, 10 insertions, 0 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c index fc342c5..f625098 100644 --- a/sys/kern/kern_mutex.c +++ b/sys/kern/kern_mutex.c @@ -783,6 +783,8 @@ mtx_init(struct mtx *m, const char *name, const char *type, int opts) MPASS((opts & ~(MTX_SPIN | MTX_QUIET | MTX_RECURSE | MTX_NOWITNESS | MTX_DUPOK | MTX_NOPROFILE)) == 0); + ASSERT_ATOMIC_LOAD(m->mtx_lock, ("%s: mtx_lock not aligned for %s: %p", + __func__, name, &m->mtx_lock)); #ifdef MUTEX_DEBUG /* Diagnostic and error correction */ diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c index c07f595..e234250 100644 --- a/sys/kern/kern_rwlock.c +++ b/sys/kern/kern_rwlock.c @@ -174,6 +174,8 @@ rw_init_flags(struct rwlock *rw, const char *name, int opts) MPASS((opts & ~(RW_DUPOK | RW_NOPROFILE | RW_NOWITNESS | RW_QUIET | RW_RECURSE)) == 0); + ASSERT_ATOMIC_LOAD(rw->rw_lock, ("%s: rw_lock not aligned for %s: %p", + __func__, name, &rw->rw_lock)); flags = LO_UPGRADABLE; if (opts & RW_DUPOK) diff --git a/sys/kern/kern_sx.c b/sys/kern/kern_sx.c index 04c2c98..15c1c9b 100644 --- a/sys/kern/kern_sx.c +++ b/sys/kern/kern_sx.c @@ -205,6 +205,8 @@ sx_init_flags(struct sx *sx, const char *description, int opts) MPASS((opts & ~(SX_QUIET | SX_RECURSE | SX_NOWITNESS | SX_DUPOK | SX_NOPROFILE | SX_NOADAPTIVE)) == 0); + ASSERT_ATOMIC_LOAD(sx->sx_lock, ("%s: sx_lock not aligned for %s: %p", + __func__, description, &sx->sx_lock)); flags = LO_SLEEPABLE | LO_UPGRADABLE; if (opts & SX_DUPOK) diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 1956a8f..2e8b9ad 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -89,6 +89,10 @@ extern int maxusers; /* system tune hint */ #define __CTASSERT(x, y) typedef char __assert ## y[(x) ? 1 : -1] #endif +#define ASSERT_ATOMIC_LOAD(var,msg) \ + KASSERT(sizeof(var) <= sizeof(uintptr_t) && \ + ALIGN(&(var)) == (uintptr_t)&(var), msg) + /* * XXX the hints declarations are even more misplaced than most declarations * in this file, since they are needed in one file (per arch) and only used |