2
0

OPENSSL_instrument_bus.pod 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. =pod
  2. =head1 NAME
  3. OPENSSL_instrument_bus, OPENSSL_instrument_bus2 - instrument references to memory bus
  4. =head1 SYNOPSIS
  5. #ifdef OPENSSL_CPUID_OBJ
  6. size_t OPENSSL_instrument_bus(int *vector, size_t num);
  7. size_t OPENSSL_instrument_bus2(int *vector, size_t num, size_t max);
  8. #endif
  9. =head1 DESCRIPTION
  10. It was empirically found that timings of references to primary memory
  11. are subject to irregular, apparently non-deterministic variations. The
  12. subroutines in question instrument these references for purposes of
  13. gathering randomness for random number generator. In order to make it
  14. bus-bound a 'flush cache line' instruction is used between probes. In
  15. addition probes are added to B<vector> elements in atomic or
  16. interlocked manner, which should contribute additional noise on
  17. multi-processor systems. This also means that B<vector[num]> should be
  18. zeroed upon invocation (if you want to retrieve actual probe values).
  19. OPENSSL_instrument_bus() performs B<num> probes and records the number of
  20. oscillator cycles every probe took.
  21. OPENSSL_instrument_bus2() on the other hand B<accumulates> consecutive
  22. probes with the same value, i.e. in a way it records duration of
  23. periods when probe values appeared deterministic. The subroutine
  24. performs at most B<max> probes in attempt to fill the B<vector[num]>,
  25. with B<max> value of 0 meaning "as many as it takes."
  26. =head1 RETURN VALUES
  27. Return value of 0 indicates that CPU is not capable of performing the
  28. benchmark, either because oscillator counter or 'flush cache line' is
  29. not available on current platform. For reference, on x86 'flush cache
  30. line' was introduced with the SSE2 extensions.
  31. Otherwise number of recorded values is returned.
  32. =head1 COPYRIGHT
  33. Copyright 2011-2018 The OpenSSL Project Authors. All Rights Reserved.
  34. Licensed under the Apache License 2.0 (the "License"). You may not use
  35. this file except in compliance with the License. You can obtain a copy
  36. in the file LICENSE in the source distribution or at
  37. L<https://www.openssl.org/source/license.html>.
  38. =cut