diff --git a/BCB/Cheang et al/A_Formal_Approach_to_Secure_Speculation.pdf b/BCB/Cheang et al/A_Formal_Approach_to_Secure_Speculation.pdf new file mode 100644 index 0000000000000000000000000000000000000000..6fd4a765448d0f7cd730264b0b4ba2523d06bd68 Binary files /dev/null and b/BCB/Cheang et al/A_Formal_Approach_to_Secure_Speculation.pdf differ diff --git a/BCB/Cheang et al/Example NI/exNI.c b/BCB/Cheang et al/Example NI/exNI.c new file mode 100644 index 0000000000000000000000000000000000000000..c26173741d7edebfffe42b1f5d86b67c9e942121 --- /dev/null +++ b/BCB/Cheang et al/Example NI/exNI.c @@ -0,0 +1,9 @@ +void victim_function_nested_ifs(unsigned x) { + unsigned val1, val2; + if (x < array1_size) { + val1 = array1[x]; + if (val1 & 1) { + val2 = array2[0]; + } + } +} \ No newline at end of file diff --git a/BCB/Cheang et al/Example NI/exNI_cheang.c b/BCB/Cheang et al/Example NI/exNI_cheang.c new file mode 100644 index 0000000000000000000000000000000000000000..f468d8dcfa3e9f04957b620da0941867294e57f7 --- /dev/null +++ b/BCB/Cheang et al/Example NI/exNI_cheang.c @@ -0,0 +1,10 @@ +void cheang_sol_nested_ifs(unsigned x) { + unsigned val1, val2; + if (x < array1_size) { + val1 = array1[x]; + if (val1 & 1) { + _mm_lfence(); + val2 = array2[0]; + } + } +} \ No newline at end of file diff --git a/BCB/1807.03757.pdf b/BCB/Kiriansky et al/1807.03757.pdf similarity index 100% rename from BCB/1807.03757.pdf rename to BCB/Kiriansky et al/1807.03757.pdf diff --git a/BCB/sec21-kirzner.pdf b/BCB/Kirzner et al/sec21-kirzner.pdf similarity index 100% rename from BCB/sec21-kirzner.pdf rename to BCB/Kirzner et al/sec21-kirzner.pdf diff --git a/BCB/Oleksenko et al/ConditionalBranchMisprediction/cbm.c b/BCB/Oleksenko et al/ConditionalBranchMisprediction/cbm.c new file mode 100644 index 0000000000000000000000000000000000000000..fd3402c04a1ad81d71699de4af11a16a6536c1f9 --- /dev/null +++ b/BCB/Oleksenko et al/ConditionalBranchMisprediction/cbm.c @@ -0,0 +1,9 @@ +checkpoint() +if x >= array_size: +goto skip_branch +if x < array_size +skip_branch: +result = array[x] +... +if terminate_simulation(): +rollback() // to line 4 \ No newline at end of file diff --git a/BCB/sec20-oleksenko.pdf b/BCB/Oleksenko et al/sec20-oleksenko.pdf similarity index 100% rename from BCB/sec20-oleksenko.pdf rename to BCB/Oleksenko et al/sec20-oleksenko.pdf diff --git a/BCB/Paul Kocher/Example 1/ex01.c b/BCB/Paul Kocher/Example 1/ex01.c index 0ac54ea5f75bbad9287b69c1b37b673923e88571..df409d4f75d30b8015b08d872a77eb40113bd8b2 100644 --- a/BCB/Paul Kocher/Example 1/ex01.c +++ b/BCB/Paul Kocher/Example 1/ex01.c @@ -1,5 +1,7 @@ +#include "../ex_main.h" + void victim_function_v01(size_t x) { - if (x < array1_size) { - temp &= array2[array1[x] * 512]; - } -} \ No newline at end of file + if (x < array1_size) { + temp &= array2[array1[x] * 512]; + } +} diff --git a/BCB/Paul Kocher/Example 1/ex01_ms.c b/BCB/Paul Kocher/Example 1/ex01_ms.c new file mode 100644 index 0000000000000000000000000000000000000000..7f4f9ddda1668de950a8c703daa850fc4445c5ff --- /dev/null +++ b/BCB/Paul Kocher/Example 1/ex01_ms.c @@ -0,0 +1,8 @@ +#include "../ex_main.h" + +void ms_solution_v01(size_t x) { + if (x < array1_size) { + __mm_lfence(); + temp &= array2[array1[x] * 512]; + } +} diff --git a/BCB/Paul Kocher/Example 1/ex01_optimal.c b/BCB/Paul Kocher/Example 1/ex01_optimal.c new file mode 100644 index 0000000000000000000000000000000000000000..6d4bf76229226ec4854308f7abed424eea3e9286 --- /dev/null +++ b/BCB/Paul Kocher/Example 1/ex01_optimal.c @@ -0,0 +1,9 @@ +#include "../ex_main.h" + +void optimal_solution_v01(size_t x) { + if (x < array1_size) { + uint8_t v = array1[x] * 512; + __mm_lfence(); + temp &= array2[v]; + } +} diff --git a/BCB/Paul Kocher/Example 10/ex10.c b/BCB/Paul Kocher/Example 10/ex10.c index 403e97d201c788f3f7e151ba8d82e2c4317d95eb..b8265606cad7076694b7bab9c0c6e41354ecb0a8 100644 --- a/BCB/Paul Kocher/Example 10/ex10.c +++ b/BCB/Paul Kocher/Example 10/ex10.c @@ -1,6 +1,8 @@ +#include "../ex_main.h" + void victim_function_v10(size_t x, uint8_t k) { - if (x < array1_size) { - if (array1[x] == k) - temp &= array2[0]; - } + if (x < array1_size) { + if (array1[x] == k) + temp &= array2[0]; + } } \ No newline at end of file diff --git a/BCB/Paul Kocher/Example 10/ex10_cheang.c b/BCB/Paul Kocher/Example 10/ex10_cheang.c new file mode 100644 index 0000000000000000000000000000000000000000..d2b7d54f0e4a326ffe1f9f4fbcc63b032fb6d4fd --- /dev/null +++ b/BCB/Paul Kocher/Example 10/ex10_cheang.c @@ -0,0 +1,9 @@ +#include "../ex_main.h" + +void cheang_sol_v10(size_t x, uint8_t k) { + if (x < array1_size) { + _mm_lfence(); + if (array1[x] == k) + temp &= array2[0]; + } +} \ No newline at end of file diff --git a/BCB/Paul Kocher/Example 11/ex11.c b/BCB/Paul Kocher/Example 11/ex11.c index 5087987caf4f639c0a344583168813834c1e30c6..ee498eb2f94f5683ab01adce7e8df90307f6f250 100644 --- a/BCB/Paul Kocher/Example 11/ex11.c +++ b/BCB/Paul Kocher/Example 11/ex11.c @@ -1,3 +1,5 @@ +#include "../ex_main.h" + void victim_function_v11(size_t x) { if (x < array1_size) temp = memcmp(&temp, array2 + (array1[x] * 512), 1); diff --git a/BCB/Paul Kocher/Example 11/ex11_cheang.c b/BCB/Paul Kocher/Example 11/ex11_cheang.c new file mode 100644 index 0000000000000000000000000000000000000000..6a7a8d02acf21826f3f43366be26429fe81fa2c4 --- /dev/null +++ b/BCB/Paul Kocher/Example 11/ex11_cheang.c @@ -0,0 +1,8 @@ +#include "../ex_main.h" + +void cheang_sol_v11(size_t x) { + if (x < array1_size) { + _mm_lfence(); + temp = memcmp(&temp, array2 + (array1[x] * 512), 1); + } +} diff --git a/BCB/Paul Kocher/Example 11/ex11_sol.c b/BCB/Paul Kocher/Example 11/ex11_sol.c new file mode 100644 index 0000000000000000000000000000000000000000..c97a22964f563db83f5216965540298e36be9e32 --- /dev/null +++ b/BCB/Paul Kocher/Example 11/ex11_sol.c @@ -0,0 +1,9 @@ +#include "../ex_main.h" + +void optimal_sol_v11(size_t x) { + if (x < array1_size) { + uint8_t v = (array1[x] * 512); + _mm_lfence(); + temp = memcmp(&temp, array2 + v, 1); + } +} diff --git a/BCB/Paul Kocher/Example 12/ex12.c b/BCB/Paul Kocher/Example 12/ex12.c index 6d4e4d60a36f258d67f7bfd2779bb58ade99f134..bd69110608daa2a3afb643658c4475f58375ca3c 100644 --- a/BCB/Paul Kocher/Example 12/ex12.c +++ b/BCB/Paul Kocher/Example 12/ex12.c @@ -1,4 +1,6 @@ +#include "../ex_main.h" + void victim_function_v12(size_t x, size_t y) { if ((x + y) < array1_size) temp &= array2[array1[x + y] * 512]; -} \ No newline at end of file +} diff --git a/BCB/Paul Kocher/Example 12/ex12_sol.c b/BCB/Paul Kocher/Example 12/ex12_sol.c new file mode 100644 index 0000000000000000000000000000000000000000..f7649248f8b85296bd63d117384d923d754462da --- /dev/null +++ b/BCB/Paul Kocher/Example 12/ex12_sol.c @@ -0,0 +1,8 @@ +#include "../ex_main.h" + +void optimal_sol_v12(size_t x, size_t y) { + if ((x + y) < array1_size) + uint8_t v = array1[x + y] * 512; + _mm_lfence(); + temp &= array2[v]; +} diff --git a/BCB/Paul Kocher/Example 13/ex13.c b/BCB/Paul Kocher/Example 13/ex13.c index be25b5168b8bc7ac113eef8550dd3951a68ebf5e..2bc42eca409bcb544b3686be46ddf961a98de874 100644 --- a/BCB/Paul Kocher/Example 13/ex13.c +++ b/BCB/Paul Kocher/Example 13/ex13.c @@ -1,5 +1,7 @@ +#include "../ex_main.h" + __inline int is_x_safe(size_t x) { if (x < array1_size) return 1; return 0; } void victim_function_v13(size_t x) { if (is_x_safe(x)) temp &= array2[array1[x] * 512]; -} \ No newline at end of file +} diff --git a/BCB/Paul Kocher/Example 13/ex13_sol.c b/BCB/Paul Kocher/Example 13/ex13_sol.c new file mode 100644 index 0000000000000000000000000000000000000000..1c2dd9008e03e5a18588162b1a88be996a35ad4a --- /dev/null +++ b/BCB/Paul Kocher/Example 13/ex13_sol.c @@ -0,0 +1,9 @@ +#include "../ex_main.h" + +__inline int is_x_safe(size_t x) { if (x < array1_size) return 1; return 0; } +void victim_function_v13(size_t x) { + if (is_x_safe(x)) + uint8_t v = array1[x] * 512; + _mm_lfence(); + temp &= array2[v]; +} diff --git a/BCB/Paul Kocher/Example 14/ex14.c b/BCB/Paul Kocher/Example 14/ex14.c index 15d73de8ec9845f553858227f26b009073dc2cea..834efd00a70a5015cfcfd532cb3f374c3ad42d87 100644 --- a/BCB/Paul Kocher/Example 14/ex14.c +++ b/BCB/Paul Kocher/Example 14/ex14.c @@ -1,4 +1,6 @@ +#include "../ex_main.h" + void victim_function_v14(size_t x) { if (x < array1_size) temp &= array2[array1[x ^ 255] * 512]; -} \ No newline at end of file +} diff --git a/BCB/Paul Kocher/Example 14/ex14_sol.c b/BCB/Paul Kocher/Example 14/ex14_sol.c new file mode 100644 index 0000000000000000000000000000000000000000..df5312c987c337ae7e814817e9b8f939e54aa679 --- /dev/null +++ b/BCB/Paul Kocher/Example 14/ex14_sol.c @@ -0,0 +1,9 @@ +#include "../ex_main.h" + +void victim_function_v14(size_t x) { + if (x < array1_size) { + uint8_t v = array1[x ^ 255] * 512; + _mm_lfence(); + temp &= array2[v]; + } +} diff --git a/BCB/Paul Kocher/Example 15/ex15.c b/BCB/Paul Kocher/Example 15/ex15.c index 5f26288cb1ada07499a0c53a0d17dcc4b4c32eee..e48f8c7c0923edfacade84ddbd760e180e3f82a9 100644 --- a/BCB/Paul Kocher/Example 15/ex15.c +++ b/BCB/Paul Kocher/Example 15/ex15.c @@ -1,3 +1,5 @@ +#include "../ex_main.h" + void victim_function_v15(size_t *x) { if (*x < array1_size) temp &= array2[array1[*x] * 512]; diff --git a/BCB/Paul Kocher/Example 15/ex15_sol.c b/BCB/Paul Kocher/Example 15/ex15_sol.c new file mode 100644 index 0000000000000000000000000000000000000000..85eb54a21ac8b2cc3d9c84be48a78f2448d3929c --- /dev/null +++ b/BCB/Paul Kocher/Example 15/ex15_sol.c @@ -0,0 +1,9 @@ +#include "../ex_main.h" + +void victim_function_v15(size_t *x) { + if (*x < array1_size) { + uint8_t v = array1[*x] * 512; + _mm_lfence(); + temp &= array2[v]; + } +} \ No newline at end of file diff --git a/BCB/Paul Kocher/Example 2/ex02.c b/BCB/Paul Kocher/Example 2/ex02.c index 4342ebcef63f16639b858682d4ac962086b1f22d..1ff7116b86326575be8bc70bb8f3783e03b5b1b3 100644 --- a/BCB/Paul Kocher/Example 2/ex02.c +++ b/BCB/Paul Kocher/Example 2/ex02.c @@ -1,3 +1,5 @@ +#include "../ex_main.h" + void leakByteLocalFunction_v02(uint8_t k) { temp &= array2[(k)* 512]; } diff --git a/BCB/Paul Kocher/Example 2/ex02_ms.c b/BCB/Paul Kocher/Example 2/ex02_ms.c new file mode 100644 index 0000000000000000000000000000000000000000..796f8b9ba010ad384d6c577fb5f72ba393711408 --- /dev/null +++ b/BCB/Paul Kocher/Example 2/ex02_ms.c @@ -0,0 +1,12 @@ +#include "../ex_main.h" + +void leakByteLocalFunction_v02(uint8_t k) { + __mm_lfence(); + temp &= array2[(k)* 512]; +} + +void ms_solution_v02(size_t x) { + if (x < array1_size) { + leakByteLocalFunction(array1[x]); + } +} diff --git a/BCB/Paul Kocher/Example 2/ex02_optimal.c b/BCB/Paul Kocher/Example 2/ex02_optimal.c new file mode 100644 index 0000000000000000000000000000000000000000..8e7e6908c5c4ac24aa1fe90c7b0492b5372b8415 --- /dev/null +++ b/BCB/Paul Kocher/Example 2/ex02_optimal.c @@ -0,0 +1,13 @@ +#include "../ex_main.h" + +void leakByteLocalFunction_v02(uint8_t k) { + uint8_t v = k * 512; + __mm_lfence(); + temp &= array2[v]; +} + +void optimal_solution_v02(size_t x) { + if (x < array1_size) { + leakByteLocalFunction(array1[x]); + } +} diff --git a/BCB/Paul Kocher/Example 3/ex03.c b/BCB/Paul Kocher/Example 3/ex03.c index 730adc7d3073acb5aedfda682a7594d4ebb8e86c..784df502f94fc209c40e88092a751937f4ed9252 100644 --- a/BCB/Paul Kocher/Example 3/ex03.c +++ b/BCB/Paul Kocher/Example 3/ex03.c @@ -1,5 +1,10 @@ -__declspec(noinline) void leakByteNoinlineFunction(uint8_t k) { temp &= array2[(k)* 512]; } +#include "../ex_main.h" + +__declspec(noinline) void leakByteNoinlineFunction(uint8_t k) { + temp &= array2[(k)* 512]; +} + void victim_function_v03(size_t x) { - if (x < array1_size) - leakByteNoinlineFunction(array1[x]); + if (x < array1_size) + leakByteNoinlineFunction(array1[x]); } diff --git a/BCB/Paul Kocher/Example 3/ex03_sol.c b/BCB/Paul Kocher/Example 3/ex03_sol.c new file mode 100644 index 0000000000000000000000000000000000000000..da2b9ba92442d3b8e451a05ab4cde8e2be3e0dec --- /dev/null +++ b/BCB/Paul Kocher/Example 3/ex03_sol.c @@ -0,0 +1,12 @@ +#include "../ex_main.h" + +__declspec(noinline) void leakByteNoinlineFunction(uint8_t k) { + uint8_t v = (k)* 512; + _mm_lfence(); + temp &= array2[v]; +} + +void solution_v03(size_t x) { + if (x < array1_size) + leakByteNoinlineFunction(array1[x]); +} diff --git a/BCB/Paul Kocher/Example 4/ex04.c b/BCB/Paul Kocher/Example 4/ex04.c index 374caa19634df282a62bea1fcdcadbaa551b68b5..94391e0c8f5b79732df5ee2f8f657415460242eb 100644 --- a/BCB/Paul Kocher/Example 4/ex04.c +++ b/BCB/Paul Kocher/Example 4/ex04.c @@ -1,4 +1,6 @@ +#include "../ex_main.h" + void victim_function_v04(size_t x) { - if (x < array1_size) - temp &= array2[array1[x << 1] * 512]; -} \ No newline at end of file + if (x < array1_size) + temp &= array2[array1[x << 1] * 512]; +} diff --git a/BCB/Paul Kocher/Example 4/ex04_sol.c b/BCB/Paul Kocher/Example 4/ex04_sol.c new file mode 100644 index 0000000000000000000000000000000000000000..3e4c2b0d7e3a79ecf3e8775c9a01980d445f342f --- /dev/null +++ b/BCB/Paul Kocher/Example 4/ex04_sol.c @@ -0,0 +1,7 @@ +#include "../ex_main.h" + +void solution_v04(size_t x) { + if (x < array1_size) + uint8_t v = array1[x << 1] * 512; + temp &= array2[v]; +} diff --git a/BCB/Paul Kocher/Example 5/ex05.c b/BCB/Paul Kocher/Example 5/ex05.c index 8a83c34139a8748d0fc4da3be92c5f7b228180b5..8199356a3fdf3caae02b11f3180a147925a46890 100644 --- a/BCB/Paul Kocher/Example 5/ex05.c +++ b/BCB/Paul Kocher/Example 5/ex05.c @@ -1,7 +1,9 @@ +#include "../ex_main.h" + void victim_function_v05(size_t x) { - size_t i; - if (x < array1_size) { - for (i = x - 1; i >= 0; i--) - temp &= array2[array1[i] * 512]; - } -} \ No newline at end of file + size_t i; + if (x < array1_size) { + for (i = x - 1; i >= 0; i--) + temp &= array2[array1[i] * 512]; + } +} diff --git a/BCB/Paul Kocher/Example 5/ex05_cheang_sol.c b/BCB/Paul Kocher/Example 5/ex05_cheang_sol.c new file mode 100644 index 0000000000000000000000000000000000000000..2fe6c39c4824f7ca2b543b731b1f2cce8fd233b7 --- /dev/null +++ b/BCB/Paul Kocher/Example 5/ex05_cheang_sol.c @@ -0,0 +1,11 @@ +#include "../ex_main.h" + +void cheang_solution_v05(size_t x) { + size_t i; + if (x < array1_size) { + for (i = x - 1; i >= 0; i--) { + _mm_lfence(); + temp &= array2[array1[i] * 512]; + } + } +} diff --git a/BCB/Paul Kocher/Example 5/ex05_sol.c b/BCB/Paul Kocher/Example 5/ex05_sol.c new file mode 100644 index 0000000000000000000000000000000000000000..5bc985abe7dfbe68769b5d66f58ca6abe4b60840 --- /dev/null +++ b/BCB/Paul Kocher/Example 5/ex05_sol.c @@ -0,0 +1,12 @@ +#include "../ex_main.h" + +void optimal_solution_v05(size_t x) { + size_t i; + if (x < array1_size) { + for (i = x - 1; i >= 0; i--) { + uint8_t v = array1[i] * 512; + _mm_lfence(); + temp &= array2[v]; + } + } +} diff --git a/BCB/Paul Kocher/Example 6/ex06.c b/BCB/Paul Kocher/Example 6/ex06.c index 79c9d113614e418640043714d92f3c8c2ae2032d..20add3223bc5f5af07d4b4c5cefda1a902a9fce1 100644 --- a/BCB/Paul Kocher/Example 6/ex06.c +++ b/BCB/Paul Kocher/Example 6/ex06.c @@ -1,4 +1,6 @@ +#include "../ex_main.h" + void victim_function_v06(size_t x) { - if ((x & array_size_mask) == x) - temp &= array2[array1[x] * 512]; -} \ No newline at end of file + if ((x & array_size_mask) == x) + temp &= array2[array1[x] * 512]; +} diff --git a/BCB/Paul Kocher/Example 6/ex06_sol.c b/BCB/Paul Kocher/Example 6/ex06_sol.c new file mode 100644 index 0000000000000000000000000000000000000000..491d0e67763f2a0cfcc6c1d8ea5d510f8f241577 --- /dev/null +++ b/BCB/Paul Kocher/Example 6/ex06_sol.c @@ -0,0 +1,8 @@ +#include "../ex_main.h" + +void solution_v06(size_t x) { + if ((x & array_size_mask) == x) + uint8_t v = array1[x] * 512; + _mm_lfence(); + temp &= array2[v]; +} diff --git a/BCB/Paul Kocher/Example 7/ex07.c b/BCB/Paul Kocher/Example 7/ex07.c index 331c96c9eb4aaf3a0de5ca3ecc58ae0ab5445d19..00a00b1baab013771043034547ebc523f379e7f3 100644 --- a/BCB/Paul Kocher/Example 7/ex07.c +++ b/BCB/Paul Kocher/Example 7/ex07.c @@ -1,7 +1,9 @@ -void victim_function_v07(size_t x) { - static size_t last_x = 0; - if (x == last_x) - temp &= array2[array1[x] * 512]; - if (x < array1_size) - last_x = x; -} \ No newline at end of file +#include "../ex_main.h" + +void optimal_sol_v07(size_t x) { + static size_t last_x = 0; + if (x == last_x) + temp &= array2[array1[x] * 512]; + if (x < array1_size) + last_x = x; +} diff --git a/BCB/Paul Kocher/Example 7/ex07_cheang.c b/BCB/Paul Kocher/Example 7/ex07_cheang.c new file mode 100644 index 0000000000000000000000000000000000000000..b73c0dd59119fb59c6327b12827c67a544dc4a5f --- /dev/null +++ b/BCB/Paul Kocher/Example 7/ex07_cheang.c @@ -0,0 +1,11 @@ +#include "../ex_main.h" + +void optimal_sol_v07(size_t x) { + static size_t last_x = 0; + if (x == last_x) { + _mm_lfence(); + temp &= array2[array1[x] * 512]; + } + if (x < array1_size) + last_x = x; +} diff --git a/BCB/Paul Kocher/Example 7/ex07_sol.c b/BCB/Paul Kocher/Example 7/ex07_sol.c new file mode 100644 index 0000000000000000000000000000000000000000..9f5ef77db675b3a33290c452edad52cce04e914a --- /dev/null +++ b/BCB/Paul Kocher/Example 7/ex07_sol.c @@ -0,0 +1,12 @@ +#include "../ex_main.h" + +void optimal_sol_v07(size_t x) { + static size_t last_x = 0; + if (x == last_x) { + uint8_t v = array1[x] * 512; + _mm_lfence(); + temp &= array2[v]; + } + if (x < array1_size) + last_x = x; +} diff --git a/BCB/Paul Kocher/Example 8/ex08.c b/BCB/Paul Kocher/Example 8/ex08.c index ff57f8e1973b0b84fb13a046949f85a4b5fbcbf0..9ed6f858926e29ea73b54a6e410a4a70ef0e58fd 100644 --- a/BCB/Paul Kocher/Example 8/ex08.c +++ b/BCB/Paul Kocher/Example 8/ex08.c @@ -1,3 +1,5 @@ +#include "../ex_main.h" + void victim_function_v08(size_t x) { - temp &= array2[array1[x < array1_size ? (x + 1) : 0] * 512]; + temp &= array2[array1[x < array1_size ? (x + 1) : 0] * 512]; } \ No newline at end of file diff --git a/BCB/Paul Kocher/Example 8/ex08_cheang.c b/BCB/Paul Kocher/Example 8/ex08_cheang.c new file mode 100644 index 0000000000000000000000000000000000000000..d9f16f9ace2a48fa98132c3bc1bbaeb52085b001 --- /dev/null +++ b/BCB/Paul Kocher/Example 8/ex08_cheang.c @@ -0,0 +1,7 @@ +#include "../ex_main.h" + +void cheang_sol_v08(size_t x) { + bool cond = x < array1_size; + _mm_lfence(); + temp &= array2[array1[cond ? (x + 1) : 0] * 512]; +} diff --git a/BCB/Paul Kocher/Example 8/ex08_sol.c b/BCB/Paul Kocher/Example 8/ex08_sol.c new file mode 100644 index 0000000000000000000000000000000000000000..3eccf4c951c76c667f16d89eb9846fff4d38922d --- /dev/null +++ b/BCB/Paul Kocher/Example 8/ex08_sol.c @@ -0,0 +1,7 @@ +#include "../ex_main.h" + +void optimal_sol_v08(size_t x) { + uint8_t v = array1[x < array1_size ? (x + 1) : 0] * 512; + _mm_lfence(); + temp &= array2[v]; +} diff --git a/BCB/Paul Kocher/Example 9/ex09.c b/BCB/Paul Kocher/Example 9/ex09.c index c112b54eff42828f6bee7031564ba23bdcbbeeb7..50f5842bc60628ac0e0c54eac34a826dd7e70cd8 100644 --- a/BCB/Paul Kocher/Example 9/ex09.c +++ b/BCB/Paul Kocher/Example 9/ex09.c @@ -1,3 +1,5 @@ +#include "../ex_main.h" + void victim_function_v09(size_t x, int *x_is_safe) { if (*x_is_safe) temp &= array2[array1[x] * 512]; diff --git a/BCB/Paul Kocher/Example 9/ex09_sol.c b/BCB/Paul Kocher/Example 9/ex09_sol.c new file mode 100644 index 0000000000000000000000000000000000000000..7ab44f30c69b473a6dc2652b4d164ab032a580fd --- /dev/null +++ b/BCB/Paul Kocher/Example 9/ex09_sol.c @@ -0,0 +1,8 @@ +#include "../ex_main.h" + +void solution_v09(size_t x, int *x_is_safe) { + if (*x_is_safe) + uint8_t v = array1[x] * 512; + _mm_lfence(); + temp &= array2[v]; +} diff --git a/BCB/Spectre_Attacks_Exploiting_Speculative_Execution.pdf b/BCB/Paul Kocher/Spectre_Attacks_Exploiting_Speculative_Execution.pdf similarity index 100% rename from BCB/Spectre_Attacks_Exploiting_Speculative_Execution.pdf rename to BCB/Paul Kocher/Spectre_Attacks_Exploiting_Speculative_Execution.pdf diff --git a/BCB/Paul Kocher/ex_main.h b/BCB/Paul Kocher/ex_main.h new file mode 100644 index 0000000000000000000000000000000000000000..e43b13d667cc4ece8b220f4751c5c5bc110efa7b --- /dev/null +++ b/BCB/Paul Kocher/ex_main.h @@ -0,0 +1,5 @@ +#include <stdlib.h> +#include <stdint.h> + +extern size_t array1_size, array2_size, array_size_mask; +extern uint8_t array1[], array2[], temp; \ No newline at end of file diff --git a/BCB/oo7_Low-Overhead_Defense_Against_Spectre_Attacks_via_Program_Analysis.pdf b/BCB/oo7/oo7_Low-Overhead_Defense_Against_Spectre_Attacks_via_Program_Analysis.pdf similarity index 100% rename from BCB/oo7_Low-Overhead_Defense_Against_Spectre_Attacks_via_Program_Analysis.pdf rename to BCB/oo7/oo7_Low-Overhead_Defense_Against_Spectre_Attacks_via_Program_Analysis.pdf