summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2019-05-14 10:03:43 +0800
committerIru Cai <mytbk920423@gmail.com>2019-05-14 10:04:56 +0800
commit5d37ef2d9257901b28726d2cbef33a400d52091c (patch)
tree7af213c22017e6d26f3582f0daabb403ec085a72
parent1a202d61457eac05e6548c7dc27397ace55efb96 (diff)
downloaddissertation-5d37ef2d9257901b28726d2cbef33a400d52091c.tar.xz
upd
-rw-r--r--chap/chap5.tex185
-rw-r--r--chap/encl1.tex62
-rw-r--r--thesis.tex5
3 files changed, 176 insertions, 76 deletions
diff --git a/chap/chap5.tex b/chap/chap5.tex
index 05a30ff..f7020a8 100644
--- a/chap/chap5.tex
+++ b/chap/chap5.tex
@@ -8,8 +8,11 @@ Fence 和 IS 分别表示对所有推测式执行中的 load 指令,推迟执
InvisiSpec的方案执行,Fence+DIFT 和 IS+DIFT 则是使用动态信息流追踪识别
可能泄露秘密数据的 load,只对这些 load 使用相应的安全的执行方案。
-对所有的处理器配置,基本配置如下:
+表\ref{tab:gem5_conf}中列出了所有处理器配置的基本配置。
+\begin{table}
+\caption{模拟的处理器的基本配置}
+\label{tab:gem5_conf}
\begin{tabular}{|c|c|}
\hline
参数 & 配置 \tabularnewline
@@ -17,7 +20,25 @@ InvisiSpec的方案执行,Fence+DIFT 和 IS+DIFT 则是使用动态信息流
\hline
指令系统 & x86\_64\tabularnewline
\hline
-处理器类型 & 8发射乱序处理器\tabularnewline
+\multirow{9}{*}{功能单元} & IntAlu\tabularnewline
+\cline{2-2}
+ & IntMult + IntAlu\tabularnewline
+\cline{2-2}
+ & FloatAdd + FloatCmp + FloatCvt\tabularnewline
+\cline{2-2}
+ & FloatMult + FloatMultAcc + FloatMisc + FloatDiv + FloatSqrt\tabularnewline
+\cline{2-2}
+ & MemRead + FloatMemRead\tabularnewline
+\cline{2-2}
+ & SIMD\tabularnewline
+\cline{2-2}
+ & MemWrite + FloatMemWrite\tabularnewline
+\cline{2-2}
+ & MemRead + MemWrite + FloatMemRead + FloatMemWrite\tabularnewline
+\cline{2-2}
+ & IprAccess\tabularnewline
+\hline
+提交宽度 & 8\tabularnewline
\hline
ROB & 192\tabularnewline
\hline
@@ -25,7 +46,9 @@ LDQ & 32\tabularnewline
\hline
STQ & 32\tabularnewline
\hline
-发射队列 & 64\tabularnewline
+发射队列大小 & 64\tabularnewline
+\hline
+转移预测 & TournamentBP, 4096 BTB, 16 RAS\tabularnewline
\hline
L1 I-Cache & 32KB, 4路组相联, 1周期延迟\tabularnewline
\hline
@@ -34,85 +57,31 @@ L1 D-Cache & 64KB, 8路组相联, 1周期延迟\tabularnewline
L2 Cache & 2MB, 16路组相联, 8周期延迟\tabularnewline
\hline
\end{tabular}
+\end{table}
\section{评测指标}
-\section{评测结果}
+本文评测每种微架构设计的安全性和性能。安全性表现为是否受 Spectre 攻击的
+影响,本文构造测试程序测试微架构的安全性。性能指标使用每个微架构设计运
+行基准程序,和 Baseline 的运行时间的比值,平均性能取这些比值的几何平均
+数。
+
+\section{评测结果与分析}
\subsection{微架构安全性测试}
本文构造一个测试程序对每种配置的处理器进行安全性的测试,用于验证实现的
方案可以防御 Spectre 攻击。
-由于 gem5 的 Ruby 存储模型不支持 clflush 指令,因此测试程序使用
-Evict+Reload 的方式进行攻击。由于配置的系统末级缓存为 2MB,可以对一个
-2MB 的存储区域进行访问,以清除缓存内原有内容。
-
-具体代码如下:
-
-\begin{minted}{C}
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-#include <x86intrin.h>
-
-/* default: 64B line size, L1-D 64KB assoc 2, L1-I 32KB assoc 2, L2 2MB assoc 8 */
-#define LLC_SIZE (2 << 20)
-
-uint8_t dummy[LLC_SIZE];
-size_t array_size = 4;
-uint8_t array1[200] = {1, 2, 3, 4};
-uint8_t array2[256 * 64 * 2];
-uint8_t X;
-uint8_t array3[4096];
-uint8_t tmp;
-
-uint8_t victim(size_t idx)
-{
- if (idx < array_size) {
- return array2[array1[idx] * 64];
- }
- return 0;
-}
-
-int main()
-{
- unsigned long t[256];
- volatile uint8_t x;
-
- victim(0);
- victim(0);
- victim(0);
- victim(0);
- victim(0);
-
- memset(dummy, 1, sizeof(dummy)); // flush L2
- X = 123; // set the secret value, and also bring it to cache
-
- _mm_mfence();
-
- size_t attack_idx = &X - array1;
- victim(attack_idx);
-
- for (int i = 0; i < 256; i++) {
- unsigned int junk;
- unsigned long time1 = __rdtscp(&junk);
- x ^= array2[i * 64];
- unsigned long time2 = __rdtscp(&junk);
- t[i] = time2 - time1;
- }
-
- printf("attack_idx = %ld\n", attack_idx);
- for (int i = 0; i < 256; i++) {
- printf("%d: %d, %s\n", i, t[i], (t[i] < 40)? "hit": "miss");
- }
-}
-\end{minted}
-
-在以上代码中,攻击者要通过受害者执行的函数 victim 的推测式执行泄露
-victim 在正常执行中无法访问的 X 的值。攻击者先训练 victim 的分支预测器,
-清除缓存中原有的内容,之后我们设置 X 为 123,然后攻击者再让 victim 执
-行访问 X,最后扫描 array2 检查其中是否有元素在缓存中命中。
+由于 gem5 的 Ruby 存储模型不支持 clflush 指令,因此测试程序使
+用Evict+Reload 的方式进行攻击。由于配置的系统末级缓存为 2MB,可以对一
+个2MB 的存储区域进行访问,以清除缓存内原有内容,具体代码可
+见附件\ref{lst:poc_for_gem5}。
+
+在此验证程序中,攻击者要通过受害者执行的函数 victim 的推测式执行泄
+露 victim 在正常执行中无法访问的 X 的值。攻击者先训练 victim 的分支预测
+器,清除缓存中原有的内容,之后我们设置 X 为 123,然后攻击者再让 victim
+执行访问 X,最后扫描 array2 检查其中是否有元素在缓存中命中。
在 Baseline 配置中,执行上述程序,可以看到 \verb|array2[123 * 64]| 在
缓存中命中,在 array2 的其他位置缓存缺失,从而攻击者可以通过 Spectre
@@ -122,12 +91,78 @@ victim 在正常执行中无法访问的 X 的值。攻击者先训练 victim
\subsection{SPEC CPU2006的性能评测}
本文对 21 个 SPEC CPU2006 基准测试进行评测,基准测试的数据集使用 ref
-集。先用 gem5 的 AtomicSimpleCPU 运行 10000000000 条指令,再用待评测的
-处理器配置运行 1000000000 条指令,得出评测结果。
+集。所有的基准程序均用 GCC 8.3.0 编译,编译优化选项为 -O2,并且和
+Glibc 2.24 静态链接。
+
+由于 gem5 模拟器运行 SPEC CPU2006 所需时间过长,因此评测时选取部分指令,
+方法是先用 gem5 的 AtomicSimpleCPU 运行 10000000000 条指令进行程序的预
+热,再用待评测的处理器配置运行 1000000000 条指令,得出评测结果。
+
+表\ref{tab:spec2006}中列出每个 SPEC CPU2006 在 Baseline 模式下运行的指
+令数和操作数,在其他处理器配置下,实际运行的指令数可能有增加或减少,相
+应的操作数也有增加或减少。
+
+\begin{table}
+\begin{tabular}{|c|c|c|c|}
+\hline
+基准测试程序 & 类型 & 指令数 & 操作数\tabularnewline
+\hline
+\hline
+401.bzip2 & int & 1000000015 & 1607899217\tabularnewline
+\hline
+429.mcf & int & 1000000012 & 1308544223\tabularnewline
+\hline
+445.gobmk & int & 1000000014 & 1932674840\tabularnewline
+\hline
+456.hmmer & int & 1000000013 & 1980694497\tabularnewline
+\hline
+458.sjeng & int & 1000000010 & 1827828221\tabularnewline
+\hline
+462.libquantum & int & 1000000011 & 1714852019\tabularnewline
+\hline
+464.h264ref & int & 1000000017 & 1545541668\tabularnewline
+\hline
+471.omnetpp & int & 1000000011 & 1971636254\tabularnewline
+\hline
+473.astar & int & 1000000010 & 1702905457\tabularnewline
+\hline
+410.bwaves & fp & 1000000011 & 1839010239\tabularnewline
+\hline
+433.milc & fp & 1000000018 & 1285963875\tabularnewline
+\hline
+434.zeusmp & fp & 1000000014 & 1524235186\tabularnewline
+\hline
+435.gromacs & fp & 1000000013 & 1630938771\tabularnewline
+\hline
+436.cactusADM & fp & 1000000014 & 1320986203\tabularnewline
+\hline
+437.leslie3d & fp & 1000000010 & 1415843900\tabularnewline
+\hline
+444.namd & fp & 1000000009 & 1333316425\tabularnewline
+\hline
+450.soplex & fp & 1000000013 & 1664925057\tabularnewline
+\hline
+454.calculix & fp & 1000000010 & 1691328153\tabularnewline
+\hline
+459.GemsFDTD & fp & 1000000014 & 1320385828\tabularnewline
+\hline
+470.lbm & fp & 1000000011 & 1191402714\tabularnewline
+\hline
+482.sphinx3 & fp & 1000000016 & 1618883137\tabularnewline
+\hline
+\end{tabular}
+\caption{SPEC CPU2006 各基准程序的指令数和操作数}
+\label{tab:spec2006}
+\end{table}
+
+图\ref{fig:is_spec06_result}是每种配置的处理器运行 SPEC CPU2006 相对于
+Baseline 的运行时间。
\begin{figure}[htbp]
\centering
\includegraphics[width=0.8\textwidth]{result.eps}
+ \caption{每种配置的处理器运行 SPEC CPU2006 的相对运行时间}
+ \label{fig:is_spec06_result}
\end{figure}
从评测结果可以看出,在使用 DIFT 识别可能泄露数据的 load 指令后,推迟这
diff --git a/chap/encl1.tex b/chap/encl1.tex
index 1858c65..a2eafac 100644
--- a/chap/encl1.tex
+++ b/chap/encl1.tex
@@ -3,4 +3,64 @@
\chapter{附件}
-% vim:ts=4:sw=4
+\section{在 gem5 中验证处理器模型安全性的代码}\label{lst:poc_for_gem5}
+
+\begin{minted}{C}
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <x86intrin.h>
+
+/* default: 64B line size, L1-D 64KB assoc 2, L1-I 32KB assoc 2, L2 2MB assoc 8 */
+#define LLC_SIZE (2 << 20)
+
+uint8_t dummy[LLC_SIZE];
+size_t array_size = 4;
+uint8_t array1[200] = {1, 2, 3, 4};
+uint8_t array2[256 * 64 * 2];
+uint8_t X;
+uint8_t array3[4096];
+uint8_t tmp;
+
+uint8_t victim(size_t idx)
+{
+ if (idx < array_size) {
+ return array2[array1[idx] * 64];
+ }
+ return 0;
+}
+
+int main()
+{
+ unsigned long t[256];
+ volatile uint8_t x;
+
+ victim(0);
+ victim(0);
+ victim(0);
+ victim(0);
+ victim(0);
+
+ memset(dummy, 1, sizeof(dummy)); // flush L2
+ X = 123; // set the secret value, and also bring it to cache
+
+ _mm_mfence();
+
+ size_t attack_idx = &X - array1;
+ victim(attack_idx);
+
+ for (int i = 0; i < 256; i++) {
+ unsigned int junk;
+ unsigned long time1 = __rdtscp(&junk);
+ x ^= array2[i * 64];
+ unsigned long time2 = __rdtscp(&junk);
+ t[i] = time2 - time1;
+ }
+
+ printf("attack_idx = %ld\n", attack_idx);
+ for (int i = 0; i < 256; i++) {
+ printf("%d: %d, %s\n", i, t[i], (t[i] < 40)? "hit": "miss");
+ }
+}
+\end{minted}
+
diff --git a/thesis.tex b/thesis.tex
index 7ea7406..407fb93 100644
--- a/thesis.tex
+++ b/thesis.tex
@@ -78,6 +78,11 @@
% 自动生成目录。
\tableofcontents
+ \renewcommand*\listfigurename{图目录}
+ \listoffigures
+ \renewcommand*\listtablename{表目录}
+ \listoftables
+
% 以下为正文部分,默认要进行章节编号。
\mainmatter
% 各章节。