summaryrefslogtreecommitdiff
path: root/chap/chap5.tex
blob: f7020a8179fe6138fd03791e19e75b0732395986 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
\chapter{评测}\label{sec:eval}

\section{评测环境}

本文对 gem5 模拟器修改,对以下 5 种配置进行评测:Baseline, Fence,
Fence+DIFT, IS, IS+DIFT. Baseline 表示受 Spectre 攻击影响的处理器模型,
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
\hline 
\hline 
指令系统 & x86\_64\tabularnewline
\hline 
\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 
LDQ & 32\tabularnewline
\hline 
STQ & 32\tabularnewline
\hline 
发射队列大小 & 64\tabularnewline
\hline 
转移预测 & TournamentBP, 4096 BTB, 16 RAS\tabularnewline
\hline 
L1 I-Cache & 32KB, 4路组相联, 1周期延迟\tabularnewline
\hline 
L1 D-Cache & 64KB, 8路组相联, 1周期延迟\tabularnewline
\hline 
L2 Cache & 2MB, 16路组相联, 8周期延迟\tabularnewline
\hline 
\end{tabular}
\end{table}

\section{评测指标}

本文评测每种微架构设计的安全性和性能。安全性表现为是否受 Spectre 攻击的
影响,本文构造测试程序测试微架构的安全性。性能指标使用每个微架构设计运
行基准程序,和 Baseline 的运行时间的比值,平均性能取这些比值的几何平均
数。

\section{评测结果与分析}

\subsection{微架构安全性测试}

本文构造一个测试程序对每种配置的处理器进行安全性的测试,用于验证实现的
方案可以防御 Spectre 攻击。

由于 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
攻击得到 X 的值 123. 而在其他配置中,array2 的所有位置都发生缓存缺失,
从而攻击者无法得出 X 的值,说明这些配置都能防御 Spectre 攻击。

\subsection{SPEC CPU2006的性能评测}

本文对 21 个 SPEC CPU2006 基准测试进行评测,基准测试的数据集使用 ref
集。所有的基准程序均用 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 指令后,推迟这
些指令的执行,有 15\% 的性能开销,平均性能开销比 InvisiSpec 小。在此基
础上,用 InvisiSpec 的方案执行这些 load 指令,可以进一步将性能开销减少
至 8.5\%.

\Todo: 评测结果的分析