diff options
author | 2013-12-26 21:02:37 +0000 | |
---|---|---|
committer | 2013-12-26 21:02:37 +0000 | |
commit | 25b8a2fa4c529245454d4dc801b24c234aa8730b (patch) | |
tree | 32dd47436c9eb5f47892e1bbac257074b7457ec4 | |
parent | Back at t2k13, I wrote code to park APs in real mode before resuming a (diff) | |
download | wireguard-openbsd-25b8a2fa4c529245454d4dc801b24c234aa8730b.tar.xz wireguard-openbsd-25b8a2fa4c529245454d4dc801b24c234aa8730b.zip |
When running the ll/sc version of the mutex code (for MULTIPROCESSOR kernels),
correctly handle sc failures. All other ll/sc constructs were doing this
correctly but apparently noone had noticed mutex did not.
-rw-r--r-- | sys/arch/octeon/octeon/mutex.c | 15 | ||||
-rw-r--r-- | sys/arch/sgi/sgi/mutex.c | 15 |
2 files changed, 18 insertions, 12 deletions
diff --git a/sys/arch/octeon/octeon/mutex.c b/sys/arch/octeon/octeon/mutex.c index 2026a6088e3..8876a5edd66 100644 --- a/sys/arch/octeon/octeon/mutex.c +++ b/sys/arch/octeon/octeon/mutex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mutex.c,v 1.5 2011/04/21 04:34:12 miod Exp $ */ +/* $OpenBSD: mutex.c,v 1.6 2013/12/26 21:02:37 miod Exp $ */ /* * Copyright (c) 2004 Artur Grabowski <art@openbsd.org> @@ -39,12 +39,15 @@ try_lock(struct mutex *mtx) asm volatile ( ".set noreorder\n" - "ll %0, %2\n" - "bnez %0, 1f\n" - "nop\n" - "li %1, 1\n" - "sc %1, %2\n" "1:\n" + "ll %0, %2\n" /* tmp = mtx->mtx_lock */ + "bnez %0, 2f\n" + " li %1, 0\n" /* ret = 0 */ + "li %1, 1\n" /* ret = 1 */ + "sc %1, %2\n" /* mtx->mtx_lock = 1 */ + "beqz %1, 1b\n" /* update failed */ + " nop\n" + "2:\n" ".set reorder\n" : "+r"(tmp), "+r"(ret) : "m"(mtx->mtx_lock)); diff --git a/sys/arch/sgi/sgi/mutex.c b/sys/arch/sgi/sgi/mutex.c index 2c85fa89e19..3fa43dac71c 100644 --- a/sys/arch/sgi/sgi/mutex.c +++ b/sys/arch/sgi/sgi/mutex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mutex.c,v 1.12 2011/04/21 04:34:12 miod Exp $ */ +/* $OpenBSD: mutex.c,v 1.13 2013/12/26 21:02:37 miod Exp $ */ /* * Copyright (c) 2004 Artur Grabowski <art@openbsd.org> @@ -39,12 +39,15 @@ try_lock(struct mutex *mtx) asm volatile ( ".set noreorder\n" - "ll %0, %2\n" - "bnez %0, 1f\n" - "nop\n" - "li %1, 1\n" - "sc %1, %2\n" "1:\n" + "ll %0, %2\n" /* tmp = mtx->mtx_lock */ + "bnez %0, 2f\n" + " li %1, 0\n" /* ret = 0 */ + "li %1, 1\n" /* ret = 1 */ + "sc %1, %2\n" /* mtx->mtx_lock = 1 */ + "beqz %1, 1b\n" /* update failed */ + " nop\n" + "2:\n" ".set reorder\n" : "+r"(tmp), "+r"(ret) : "m"(mtx->mtx_lock)); |