git: 716baab384de - stable/12 - [PowerPC] Fix atomic_cmpset_masked().

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Thu, 07 Oct 2021 03:28:14 UTC
The branch stable/12 has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=716baab384ded0d02bad67a4be52e9d2408ae636

commit 716baab384ded0d02bad67a4be52e9d2408ae636
Author:     Brandon Bergren <bdragon@FreeBSD.org>
AuthorDate: 2020-05-26 19:03:45 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2021-10-07 03:27:27 +0000

    [PowerPC] Fix atomic_cmpset_masked().
    
    A recent kernel change caused the previously unused atomic_cmpset_masked() to
    be used.
    
    It had a typo in it.
    
    Instead of reading the old value from an uninitialized variable, read it
    from the passed-in pointer as intended.
    
    This fixes crashes on 64 bit Book-E.
    
    Obtained from:  jhibbits
    
    (cherry picked from commit 9941cb0657d63b4b1570dcf384196bb599bf9024)
---
 sys/powerpc/include/atomic.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/powerpc/include/atomic.h b/sys/powerpc/include/atomic.h
index 2510160a402a..8da4607d71ff 100644
--- a/sys/powerpc/include/atomic.h
+++ b/sys/powerpc/include/atomic.h
@@ -621,7 +621,7 @@ atomic_cmpset_masked(uint32_t *p, uint32_t cmpval, uint32_t newval,
 	uint32_t	tmp;
 
 	__asm __volatile (
-		"1:\tlwarx %2, 0, %2\n\t"	/* load old value */
+		"1:\tlwarx %2, 0, %3\n\t"	/* load old value */
 		"and %0, %2, %7\n\t"
 		"cmplw %4, %0\n\t"		/* compare */
 		"bne- 2f\n\t"			/* exit if not equal */