part2 ver 0.4.0 avoid prefetch (maybe)

This commit is contained in:
ClF3 2024-11-04 20:56:00 +08:00
parent fb94e5f52e
commit 29b495c6b9
1 changed files with 8 additions and 1 deletions

View File

@ -17,6 +17,7 @@ int main() {
int flag = -1;
CYCLES time = -1;
int offset = 0;
int new_offset = 0;
// buf is shared between the attacker and the victim
char *buf = allocate_shared_buffer();
@ -26,7 +27,13 @@ int main() {
}
for(int i = 0; i < WAIT_TIME; i++);
for(int i = 0; i < 10000; i++) {
offset = (AVAR * offset + CVAR) % 1024;
new_offset = (AVAR * offset + CVAR) % 1024;
if(offset == new_offset||offset-new_offset==1||offset-new_offset==-1) {
offset = (offset + 712) % 1024;
}
else {
offset = new_offset;
}
time = measure_one_block_access_time((ADDR_PTR)buf + offset * 128);
if(time < CACHE_HIT_THRESHOLD) {
flag = offset;