Skip to content

Commit 79dedf4

Browse files
committed
wolfcrypt/src/aes.c: add static volatile word32 x_volatile to PreFetchTe() and PreFetchSBox(), to move volatile accesses out of the loop iteration, reclaiming some (but not all) of the performance regression from 299e7bd.
1 parent 7efefc7 commit 79dedf4

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

wolfcrypt/src/aes.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,7 +1880,8 @@ static WARN_UNUSED_RESULT word32 inv_col_mul(
18801880
static WARN_UNUSED_RESULT WC_INLINE word32 PreFetchTe(void)
18811881
{
18821882
#ifndef WOLFSSL_AES_TOUCH_LINES
1883-
volatile word32 x = 0;
1883+
static volatile word32 x_volatile = 0;
1884+
word32 x = x_volatile;
18841885
int i;
18851886
int j;
18861887

@@ -1891,6 +1892,8 @@ static WARN_UNUSED_RESULT WC_INLINE word32 PreFetchTe(void)
18911892
}
18921893
}
18931894

1895+
x_volatile = x;
1896+
18941897
return x;
18951898
#else
18961899
return 0;
@@ -1901,13 +1904,16 @@ static WARN_UNUSED_RESULT WC_INLINE word32 PreFetchTe(void)
19011904
static WARN_UNUSED_RESULT WC_INLINE word32 PreFetchSBox(void)
19021905
{
19031906
#ifndef WOLFSSL_AES_TOUCH_LINES
1904-
volatile word32 x = 0;
1907+
static volatile word32 x_volatile = 0;
1908+
word32 x = x_volatile;
19051909
int i;
19061910

19071911
for (i = 0; i < 256; i += WC_CACHE_LINE_SZ/4) {
19081912
x &= Tsbox[i];
19091913
}
19101914

1915+
x_volatile = x;
1916+
19111917
return x;
19121918
#else
19131919
return 0;

0 commit comments

Comments
 (0)