diff --git a/BCB/Cheang et al/Figure 3b/Figure_3b.c b/BCB/Cheang et al/Figure 3b/Figure_3b.c new file mode 100644 index 0000000000000000000000000000000000000000..212d77804cee3ceab2c08686ce69cd80664c7202 --- /dev/null +++ b/BCB/Cheang et al/Figure 3b/Figure_3b.c @@ -0,0 +1,10 @@ +#include "../ex_main.h" + +__declspec(dllexport) +uint8_t foo(unsigned i) { + if (i < N) { + _mm_lfence(); + return array2[array1[i]*S]; + } + return 0; +} \ No newline at end of file diff --git a/BCB/Cheang et al/Figure 3b/Figure_3b.cod b/BCB/Cheang et al/Figure 3b/Figure_3b.cod index 56e3d6fc9d9a72fb5e72a41afa40c3f170cba8ea..12bf769f101934830c38cf965cc77a670c6f0b31 100644 --- a/BCB/Cheang et al/Figure 3b/Figure_3b.cod +++ b/BCB/Cheang et al/Figure 3b/Figure_3b.cod @@ -6,9 +6,11 @@ INCLUDELIB MSVCRT INCLUDELIB OLDNAMES PUBLIC foo -EXTRN array1_size:QWORD EXTRN array1:BYTE EXTRN array2:BYTE +EXTRN N:BYTE +EXTRN S:BYTE +EXTRN __ImageBase:BYTE ; Function compile flags: /Ogtpy ; File C:\Users\piano\Documents\PhD\hyperproperties\IsabelleScripts\Relative_Security_Spectre\Kevin Cheang\3b\Figure_3b.c ; COMDAT foo @@ -16,37 +18,43 @@ _TEXT SEGMENT i$ = 8 foo PROC ; COMDAT -; 5 : if (i < array1_size) { +; 5 : if (i < N) { - 00000 8b c1 mov eax, ecx - 00002 48 3b 05 00 00 - 00 00 cmp rax, QWORD PTR array1_size - 00009 73 18 jae SHORT $LN2@foo + 00000 0f b6 05 00 00 + 00 00 movzx eax, BYTE PTR N + 00007 3b c8 cmp ecx, eax + 00009 73 27 jae SHORT $LN2@foo -; 6 : uint8_t v = array1[0]; -; 7 : return array2[v*512]+i; +; 6 : _mm_lfence(); - 0000b 0f b6 15 00 00 - 00 00 movzx edx, BYTE PTR array1 - 00012 48 8d 05 00 00 - 00 00 lea rax, OFFSET FLAT:array2 - 00019 c1 e2 09 shl edx, 9 - 0001c 02 0c 02 add cl, BYTE PTR [rdx+rax] - 0001f 0f b6 c1 movzx eax, cl + 0000b 0f ae e8 lfence + +; 7 : return array2[array1[i]*S]; + + 0000e 8b c1 mov eax, ecx + 00010 48 8d 15 00 00 + 00 00 lea rdx, OFFSET FLAT:__ImageBase + 00017 0f b6 8c 10 00 + 00 00 00 movzx ecx, BYTE PTR array1[rax+rdx] + 0001f 0f b6 05 00 00 + 00 00 movzx eax, BYTE PTR S + 00026 0f af c8 imul ecx, eax + 00029 0f b6 84 11 00 + 00 00 00 movzx eax, BYTE PTR array2[rcx+rdx] ; 10 : } - 00022 c3 ret 0 + 00031 c3 ret 0 $LN2@foo: -; 8 : } +; 8 : } ; 9 : return 0; - 00023 32 c0 xor al, al + 00032 32 c0 xor al, al ; 10 : } - 00025 c3 ret 0 + 00034 c3 ret 0 foo ENDP _TEXT ENDS END diff --git a/BCB/Cheang et al/Figure 3b/Figure_3b.dll b/BCB/Cheang et al/Figure 3b/Figure_3b.dll index 104015525759aa2eb1f482b20b5eb565c8c913e3..bda191a3e975afd508e2843b47d94bd933b8b3f5 100644 Binary files a/BCB/Cheang et al/Figure 3b/Figure_3b.dll and b/BCB/Cheang et al/Figure 3b/Figure_3b.dll differ