part2 ver 0.2.1

This commit is contained in:
ClF3 2024-11-04 19:45:17 +08:00
parent 84ea3267db
commit a5c6a2bd5f
1 changed files with 3 additions and 2 deletions

View File

@ -12,7 +12,7 @@
#define WAIT_TIME 100 #define WAIT_TIME 100
int main() { int main() {
int flag = -1; int flag = -1;
CYCLES time = -1;
// buf is shared between the attacker and the victim // buf is shared between the attacker and the victim
char *buf = allocate_shared_buffer(); char *buf = allocate_shared_buffer();
@ -22,13 +22,14 @@ int main() {
} }
for(int i = 0; i < WAIT_TIME; i++); for(int i = 0; i < WAIT_TIME; i++);
for(int i = 0; i < 1024; i++) { for(int i = 0; i < 1024; i++) {
CYCLES time = measure_one_block_access_time((ADDR_PTR)buf + (i * 10020107) % 1024 * 128); time = measure_one_block_access_time((ADDR_PTR)buf + (i * 10020107) % 1024 * 128);
if(time < CACHE_HIT_THRESHOLD) { if(time < CACHE_HIT_THRESHOLD) {
flag = (i * 10020107) % 1024; flag = (i * 10020107) % 1024;
break; break;
} }
} }
printf("Flag: %d\n", flag); printf("Flag: %d\n", flag);
printf("Time: %d\n", time);
deallocate_shared_buffer(buf); deallocate_shared_buffer(buf);
return 0; return 0;