This is an odd architecture and is mostly interesting here just because its the only BE system available in the CI system.
It compiles the following simple code into variable time code:
0 yes |= (a->d[0] >= SECP256K1_N_0) & ~no;
The same thing happens in the analogous part of the 32-bit version of the function.
I tried all manner of compiler switches and could only make the situation worse– with other similar comparisons becoming variable time.
The issue is that the architecture has an instruction which works functionally like memcmp, and the compiler will sometimes emit it for seemingly arbitrary comparisons.
0 0x00000000040483e8 <+296>: b9 04 00 49 lgr %r4,%r9
1 0x00000000040483ec <+300>: b9 98 00 55 alcr %r5,%r5
2=> 0x00000000040483f0 <+304>: d5 07 f0 a8 d0 18 clc 168(8,%r15),24(%r13)
3 0x00000000040483f6 <+310>: b9 94 00 22 llcr %r2,%r2
4 0x00000000040483fa <+314>: e5 48 f0 c0 00 00 mvghi 192(%r15),0
I tried several different forms for the code but couldn’t get it to stop. I don’t expect anyone working on this repository to do anything about it now, but I’m planning on opening a GCC bug report and want something to point to.