This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Atomic write (LDAXR/STLXR) causes infinite loop on Cortex-A72

I have code which runs on Cortex-A72 (AArch64) and it disassembles to the following:
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
0: d53800a9 mrs x9, mpidr_el1
4: 92400529 and x9, x9, #0x3
8: b4000069 cbz x9, 0x14
c: d503205f wfe
10: 17ffffff b 0xc
14: 10ffff69 adr x9, 0x0
18: 9100013f mov sp, x9
// write to uninitialized memory beyond executable image (BSS section)
1c: 90000008 adrp x8, 0x0
20: 91016108 add x8, x8, #0x58
24: c85ffd09 ldaxr x9, [x8]
28: b2720129 orr x9, x9, #0x4000
2c: c80afd09 stlxr w10, x9, [x8]
30: 35ffffaa cbnz w10, 0x24
// turn on ACT LED -- this code never executes
34: d2bfc404 mov x4, #0xfe200000
38: b9401080 ldr w0, [x4, #16]
3c: 12177000 and w0, w0, #0xfffffe3f
40: 321a0000 orr w0, w0, #0x40
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX



The problem is it enters infinite loop with stlxr/ldaxr and I have no idea how to debug or where to look at to resolve the issue.

I've read about exclusive access monitor in the ARNv8-A Reference Manual:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
aarch64/functions/exclusive/AArch64.ExclusiveMonitorsPass
// AArch64.ExclusiveMonitorsPass()
// ===============================
// Return TRUE if the Exclusives monitors for the current PE include all of the addresses
// associated with the virtual address region of size bytes starting at address.
// The immediately following memory write must be to the same addresses.
boolean AArch64.ExclusiveMonitorsPass(bits(64) address, integer size)
// It is IMPLEMENTATION DEFINED whether the detection of memory aborts happens
// before or after the check on the local Exclusives monitor. As a result a failure
// of the local monitor can occur on some implementations even if the memory
// access would give an memory abort.
acctype = AccType_ATOMIC;
iswrite = TRUE;
aligned = (address == Align(address, size));
if !aligned then
secondstage = FALSE;
AArch64.Abort(address, AArch64.AlignmentFault(acctype, iswrite, secondstage));
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


Could it be something related? I don't enable address translation and I don't initialize exclusive access monitor. Do I need to?
Any advice or help is highly appreciated. Thanks in advance!
0