Older kernels which require the double check of the __kuser_cmpxchg
result are no longer supported as of Go 1.18 which requires at least
Linux 2.6.32.
For #45964
Change-Id: Ic3d6691bf006353ac51b9d43e742d970e3d4e961
Reviewed-on: https://go-review.googlesource.com/c/go/+/424556
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
// LR = return address
// The function returns with CS true if the swap happened.
// http://lxr.linux.no/linux+v2.6.37.2/arch/arm/kernel/entry-armv.S#L850
-// On older kernels (before 2.6.24) the function can incorrectly
-// report a conflict, so we have to double-check the compare ourselves
-// and retry if necessary.
//
// https://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=b49c0f24cf6744a3f4fd09289fe7cade349dead5
//
// because we don't know how to traceback through __kuser_cmpxchg
MOVW (R2), R0
MOVW old+4(FP), R0
-loop:
MOVW new+8(FP), R1
BL cas<>(SB)
- BCC check
+ BCC ret0
MOVW $1, R0
MOVB R0, ret+12(FP)
RET
-check:
- // Kernel lies; double-check.
- MOVW ptr+0(FP), R2
- MOVW old+4(FP), R0
- MOVW 0(R2), R3
- CMP R0, R3
- BEQ loop
+ret0:
MOVW $0, R0
MOVB R0, ret+12(FP)
RET