svn commit: r350023 - head/sys/powerpc/powerpc
Justin Hibbits
jhibbits at FreeBSD.org
Tue Jul 16 03:55:28 UTC 2019
Author: jhibbits
Date: Tue Jul 16 03:55:27 2019
New Revision: 350023
URL: https://svnweb.freebsd.org/changeset/base/350023
Log:
powerpc: Fix casueword(9) post-r349951
'=' asm constraint marks a variable as write-only. Because of this, gcc
throws away the initialization of 'res', causing garbage to be returned if
the CAS was successful. Use '+' to mark res as read/write, so that the
initialization stays in the generated asm. Also, fix the reservation
clearing stwcx store index register in casueword32, and only do the dummy
store when needed, skip it if the real store has already succeeded.
Modified:
head/sys/powerpc/powerpc/copyinout.c
Modified: head/sys/powerpc/powerpc/copyinout.c
==============================================================================
--- head/sys/powerpc/powerpc/copyinout.c Tue Jul 16 03:32:21 2019 (r350022)
+++ head/sys/powerpc/powerpc/copyinout.c Tue Jul 16 03:55:27 2019 (r350023)
@@ -456,13 +456,13 @@ casueword32(volatile uint32_t *addr, uint32_t old, uin
"cmplw %4, %0\n\t" /* compare */
"bne 1f\n\t" /* exit if not equal */
"stwcx. %5, 0, %3\n\t" /* attempt to store */
- "bne- 1f\n\t" /* if failed */
- "b 2f\n\t" /* we've succeeded */
+ "bne- 2f\n\t" /* if failed */
+ "b 3f\n\t" /* we've succeeded */
"1:\n\t"
- "stwcx. %0, 0, %4\n\t" /* clear reservation (74xx) */
- "li %2, 1\n\t"
- "2:\n\t"
- : "=&r" (val), "=m" (*p), "=&r" (res)
+ "stwcx. %0, 0, %3\n\t" /* clear reservation (74xx) */
+ "2:li %2, 1\n\t"
+ "3:\n\t"
+ : "=&r" (val), "=m" (*p), "+&r" (res)
: "r" (p), "r" (old), "r" (new), "m" (*p)
: "cr0", "memory");
@@ -511,13 +511,13 @@ casueword(volatile u_long *addr, u_long old, u_long *o
"cmpld %4, %0\n\t" /* compare */
"bne 1f\n\t" /* exit if not equal */
"stdcx. %5, 0, %3\n\t" /* attempt to store */
- "bne- 1f\n\t" /* if failed */
- "b 2f\n\t" /* we've succeeded */
+ "bne- 2f\n\t" /* if failed */
+ "b 3f\n\t" /* we've succeeded */
"1:\n\t"
"stdcx. %0, 0, %3\n\t" /* clear reservation (74xx) */
- "li %2, 1\n\t"
- "2:\n\t"
- : "=&r" (val), "=m" (*p), "=&r" (res)
+ "2:li %2, 1\n\t"
+ "3:\n\t"
+ : "=&r" (val), "=m" (*p), "+&r" (res)
: "r" (p), "r" (old), "r" (new), "m" (*p)
: "cr0", "memory");
More information about the svn-src-all
mailing list