Skip to content

Commit dfa2813

Browse files
committed
Merge bitcoin/bitcoin#32248: Remove support for RNDR/RNDRRS for aarch64
7749d92 Remove support for RNDR/RNDRRS for aarch64 on Linux (laanwj) Pull request description: This hardware feature is - Rarely supported on SoCs (and broken on like half of the chips that support it in the first place) (#31817). It is not clear if, or how, the brokenness will be worked around in the kernel, but working around it in user space seems the wrong thing to do, this is not the place to maintain special workarounds for specific hardware (which despite that, was attempted in #31826, but had to be reverted in #31908 due to other problems). - Apparently not compiled into the release binary anymore (bitcoin/bitcoin#31817 (comment)). Did check this at the time, but a build system change must have caused this, and went undetected. - Hard to test in CI (as well as manually), due to unavailability of hardware. Better to remove it. This reverts commit aee5404 from #26839. Closes #31817. ACKs for top commit: sipa: utACK 7749d92 davidgumberg: utACK bitcoin/bitcoin@7749d92 achow101: ACK 7749d92 w0xlt: utACK bitcoin/bitcoin@7749d92 Tree-SHA512: d243ad7f745fb46f711f24b6983d9ea1d94e5d8ee60959229bafdba5caa210a60801a1c2cb5b558a0e72f365371b32285aee9a8d0cd24a60589adc7b03dd6a44
2 parents cdc3299 + 7749d92 commit dfa2813

File tree

1 file changed

+0
-73
lines changed

1 file changed

+0
-73
lines changed

src/random.cpp

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@
4141
#ifdef HAVE_SYSCTL_ARND
4242
#include <sys/sysctl.h>
4343
#endif
44-
#if defined(HAVE_STRONG_GETAUXVAL) && defined(__aarch64__)
45-
#include <sys/auxv.h>
46-
#endif
4744

4845
namespace {
4946

@@ -189,62 +186,6 @@ uint64_t GetRdSeed() noexcept
189186
#endif
190187
}
191188

192-
#elif defined(__aarch64__) && defined(HWCAP2_RNG)
193-
194-
bool g_rndr_supported = false;
195-
196-
void InitHardwareRand()
197-
{
198-
if (getauxval(AT_HWCAP2) & HWCAP2_RNG) {
199-
g_rndr_supported = true;
200-
}
201-
}
202-
203-
void ReportHardwareRand()
204-
{
205-
// This must be done in a separate function, as InitHardwareRand() may be indirectly called
206-
// from global constructors, before logging is initialized.
207-
if (g_rndr_supported) {
208-
LogPrintf("Using RNDR and RNDRRS as additional entropy sources\n");
209-
}
210-
}
211-
212-
/** Read 64 bits of entropy using rndr.
213-
*
214-
* Must only be called when RNDR is supported.
215-
*/
216-
uint64_t GetRNDR() noexcept
217-
{
218-
uint8_t ok = 0;
219-
uint64_t r1;
220-
do {
221-
// https://developer.arm.com/documentation/ddi0601/2022-12/AArch64-Registers/RNDR--Random-Number
222-
__asm__ volatile("mrs %0, s3_3_c2_c4_0; cset %w1, ne;"
223-
: "=r"(r1), "=r"(ok)::"cc");
224-
if (ok) break;
225-
__asm__ volatile("yield");
226-
} while (true);
227-
return r1;
228-
}
229-
230-
/** Read 64 bits of entropy using rndrrs.
231-
*
232-
* Must only be called when RNDRRS is supported.
233-
*/
234-
uint64_t GetRNDRRS() noexcept
235-
{
236-
uint8_t ok = 0;
237-
uint64_t r1;
238-
do {
239-
// https://developer.arm.com/documentation/ddi0601/2022-12/AArch64-Registers/RNDRRS--Reseeded-Random-Number
240-
__asm__ volatile("mrs %0, s3_3_c2_c4_1; cset %w1, ne;"
241-
: "=r"(r1), "=r"(ok)::"cc");
242-
if (ok) break;
243-
__asm__ volatile("yield");
244-
} while (true);
245-
return r1;
246-
}
247-
248189
#else
249190
/* Access to other hardware random number generators could be added here later,
250191
* assuming it is sufficiently fast (in the order of a few hundred CPU cycles).
@@ -263,12 +204,6 @@ void SeedHardwareFast(CSHA512& hasher) noexcept {
263204
hasher.Write((const unsigned char*)&out, sizeof(out));
264205
return;
265206
}
266-
#elif defined(__aarch64__) && defined(HWCAP2_RNG)
267-
if (g_rndr_supported) {
268-
uint64_t out = GetRNDR();
269-
hasher.Write((const unsigned char*)&out, sizeof(out));
270-
return;
271-
}
272207
#endif
273208
}
274209

@@ -294,14 +229,6 @@ void SeedHardwareSlow(CSHA512& hasher) noexcept {
294229
}
295230
return;
296231
}
297-
#elif defined(__aarch64__) && defined(HWCAP2_RNG)
298-
if (g_rndr_supported) {
299-
for (int i = 0; i < 4; ++i) {
300-
uint64_t out = GetRNDRRS();
301-
hasher.Write((const unsigned char*)&out, sizeof(out));
302-
}
303-
return;
304-
}
305232
#endif
306233
}
307234

0 commit comments

Comments
 (0)