41
41
#ifdef HAVE_SYSCTL_ARND
42
42
#include < sys/sysctl.h>
43
43
#endif
44
- #if defined(HAVE_STRONG_GETAUXVAL) && defined(__aarch64__)
45
- #include < sys/auxv.h>
46
- #endif
47
44
48
45
namespace {
49
46
@@ -189,62 +186,6 @@ uint64_t GetRdSeed() noexcept
189
186
#endif
190
187
}
191
188
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
-
248
189
#else
249
190
/* Access to other hardware random number generators could be added here later,
250
191
* assuming it is sufficiently fast (in the order of a few hundred CPU cycles).
@@ -263,12 +204,6 @@ void SeedHardwareFast(CSHA512& hasher) noexcept {
263
204
hasher.Write ((const unsigned char *)&out, sizeof (out));
264
205
return ;
265
206
}
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
- }
272
207
#endif
273
208
}
274
209
@@ -294,14 +229,6 @@ void SeedHardwareSlow(CSHA512& hasher) noexcept {
294
229
}
295
230
return ;
296
231
}
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
- }
305
232
#endif
306
233
}
307
234
0 commit comments