mirror of
https://gitlab.com/Nils_Kasulke/spectre_project.git
synced 2026-04-03 23:37:25 +00:00
- added non flush windows binaries
- added a test with flush - added e480 outputs
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
#include<time.h>
|
||||
|
||||
//////////
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/bio.h>
|
||||
//#include <openssl/sha.h>
|
||||
//#include <openssl/bio.h>
|
||||
/////////
|
||||
|
||||
/*
|
||||
@@ -19,11 +19,30 @@
|
||||
#define CHAR_START '1'
|
||||
#define CHAR_END '9'
|
||||
|
||||
//#define MEASURE_FUNC string_bit_count
|
||||
#define MEASURE_FUNC string_bit_count
|
||||
//#define MEASURE_FUNC string_bit_count2
|
||||
//#define MEASURE_FUNC string_bit_count3
|
||||
#define MEASURE_FUNC sha1_int_from_string
|
||||
//#define MEASURE_FUNC sha1_int_from_string
|
||||
void mem_flush(const void *p, unsigned int allocation_size) {
|
||||
const size_t cache_line = 64;
|
||||
const char *cp = (const char *)p;
|
||||
size_t i = 0;
|
||||
|
||||
if (p == NULL || allocation_size <= 0)
|
||||
return;
|
||||
|
||||
for (i = 0; i < allocation_size; i += cache_line) {
|
||||
asm volatile("clflush (%0)\n\t"
|
||||
:
|
||||
: "r"(&cp[i])
|
||||
: "memory");
|
||||
}
|
||||
|
||||
asm volatile("sfence\n\t"
|
||||
:
|
||||
:
|
||||
: "memory");
|
||||
}
|
||||
/*
|
||||
* returns dynamically allocated random string
|
||||
* with a strlen between minLen and maxLen
|
||||
@@ -112,6 +131,8 @@ int main(int argc, char* argv[])
|
||||
unsigned long long counter = 0;
|
||||
clock_t t1, t0 = clock();
|
||||
for(; *p; ++p) {
|
||||
size_t len = strlen(*p);
|
||||
mem_flush(*p, len+1);
|
||||
counter += MEASURE_FUNC(*p);
|
||||
}
|
||||
t1 = clock();
|
||||
@@ -261,7 +282,7 @@ char** read_strings(const char* fileName, size_t* nRead) {
|
||||
return out_array;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
int sha1_int_from_string(const char* s) {
|
||||
SHA_CTX c;
|
||||
SHA1_Init(&c);
|
||||
@@ -274,3 +295,4 @@ int sha1_int_from_string(const char* s) {
|
||||
}
|
||||
return count;
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user