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