From 29b495c6b90c872d0725c63420904385d2cb511c Mon Sep 17 00:00:00 2001 From: ClF3 Date: Mon, 4 Nov 2024 20:56:00 +0800 Subject: [PATCH] part2 ver 0.4.0 avoid prefetch (maybe) --- Part2-FlushReload/attacker.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Part2-FlushReload/attacker.c b/Part2-FlushReload/attacker.c index 80c4f35..86ddc14 100644 --- a/Part2-FlushReload/attacker.c +++ b/Part2-FlushReload/attacker.c @@ -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;