From b760658a92b9a237c65416aeafb07eadd361dca6 Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Fri, 17 May 2019 06:41:48 +0800 Subject: upd --- chap/chap1.tex | 103 +++- chap/chap2.tex | 6 +- skylake.pdf | Bin 0 -> 243085 bytes skylake.svg | 1561 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ thesis.bib | 90 +++- 5 files changed, 1731 insertions(+), 29 deletions(-) create mode 100644 skylake.pdf create mode 100644 skylake.svg diff --git a/chap/chap1.tex b/chap/chap1.tex index 30e335b..4a0e94e 100644 --- a/chap/chap1.tex +++ b/chap/chap1.tex @@ -8,33 +8,86 @@ \section{选题背景与研究意义} 现代微处理器使用了超标量流水线、乱序执行等设计,通过利用程序内的指令级 -并行性,掩盖指令的延迟的方法,提高处理器的指令执行效率。乱序执行是处理 -器对指令进行动态调度的技术,它允许一条指令在满足数据依赖后即可进入执行 -单元执行,而无需等待程序序列之前的指令。超标量处理器设计多条执行流水线, -使得处理器每一周期可以执行多条指令。由于程序中大量出现转移指令,计算转 -移方向和目标之前可能有较长延迟,影响流水线的利用率,因此处理器使用了转 -移预测和推测式执行技术。处理器可以根据转移预测得出的分支方向和转移目标, -从预测的目标地址处或取指令并执行。 - -由于处理器在执行程序的过程中,处理器可能接收外部中断,指令执行可能产生 -异常,因此乱序执行的处理器使用一个称为重排序缓冲的队列,按程序序列保存 -流水线中的指令,在产生中断或异常后,将产生异常的指令及其之后执行的指令 -产生的效果撤销。在使用推测式执行的处理器中,处理器在预测错误时,由该预 -测产生的推测式执行的指令,也需要类似的错误恢复机制撤销。处理器中的错误 -恢复机制使得处理器在体系结构层次上的状态保持正确,从而程序正确运行。 - -2018年公布的 Meltdown\supercite{meltdown} 和 +并行性,掩盖指令的延迟的方法,提高处理器的指令执行效率。 + +乱序执行是处理器对指令进行动态调度的技术,它允许一条指令在满足数据依赖 +后即可进入执行单元执行,而无需等待程序序列之前的指令。在乱序执行处理器 +中,处理器存在多个不同的执行单元,用于同时处理多个指令。处理器使用 +Tomasulo 算法\supercite{tomasulo},可以识别指令之间的依赖关系,允许无 +依赖关系的指令并行执行。 + +在乱序执行中,指令可以不按程序序列改变体系结构状态,在指令执行发生异常 +时,发生异常之后的指令可能已经执行,使得处理器无法在处理异常后,恢复异 +常发生时的体系结构状态。为了解决这个问题,处理器需要支持精确中断。现代 +处理器通常使用重排序缓冲区(ROB)\supercite{preciseint}实现精确中断, +它使得指令按序提交至体系结构状态中,如果异常发生,则丢弃未提交的指令的 +结果。 + +超标量处理器设计允许处理器平均没周期执行多于一条指令,它可以在一周期内 +同时分发多个指令至不同的执行单元,从而利用程序的指令级并行性。 + +程序中除了数据相关,还有控制相关。程序中存在大量的分支指令,等待分支指 +令执行,则后续指令在分支指令执行期间均无法执行,降低了执行单元的利用率, +导致总体性能下降。因此现代微处理器使用了推测式执行技术,在分支指令执行 +结束前,根据分支预测的结果,执行预测将要执行的指令。分支预测需要预测分 +支的方向和目标地址。处理器使用分支目标缓冲器(BTB)预测分支指令的方向 +和目标地址\supercite{btb}。为了预测函数调用的返回地址,处理器还使用栈 +结构的返回栈缓冲器(RSB)\supercite{rsb}。 + +为了开发出多任务系统的线程级并行性,部分处理器使用了多线程技术。同时多 +线程(SMT)\supercite{smt}是一种多线程技术,它对超标量处理器做了少量修 +改,使得多个线程可以共用一组执行单元,提高执行单元的利用率。 + +\begin{figure}[htbp] + \centering + \includegraphics[width=0.8\textwidth]{skylake.pdf} + \caption{Skylake 微体系结构示意图} + \label{fig:skylake} +\end{figure} + +图\ref{fig:skylake}是 Intel Skylake 微体系结构的示意图\footnote{图片来 + 自 https://mdsattacks.com/images/skylake.svg},它是一个乱序执行超标 +量处理器体系结构,每周期最多可以将 6 个微操作发射至 8 组执行单元中执行, +它的 ROB 使得流水线中可以同时存在 224 个微操作,它的分支预测器可以预测 +分支的方向和目标地址,使处理器在预测的目标处取出指令至指令缓存。 + +2018 年公布的 Meltdown\supercite{meltdown} 和 Spectre\supercite{spectre} 攻击使人们发现,虽然处理器在执行指令产生异 常,或推测式执行错误后,通过恢复可以使体系结构层次上的状态保持正确,但 -是这些错误执行的指令在微体系结构中产生了副作用,并且可能泄露系统中的秘密数 -据,破坏了系统的安全。从 Meltdown 和 Spectre 被发现之后,Intel、AMD、 -ARM等处理器设计厂商,和Google、Microsoft等软件厂商,均提出了软件补丁或 -处理器微码更新,用于减轻 Meltdown 和 Spectre 的威胁。Intel 在后续的处 -理器中,也在硬件上对一些攻击做出了防御。\supercite{intel-9900k} - -已有的基于软件的解决方法,存在性能开销大,防御的攻击种类单一等缺点。因 -此也有研究,尝试通过微体系结构的设计,低开销地防御 Meltdown 和 Spectre 攻 -击。本文的目标是设计并实现一种微体系结构,防御 Spectre 攻击。 +是这些错误执行的指令在微体系结构中产生了副作用,并且可能泄露系统中的秘 +密数据,破坏了系统的安全。在 Meltdown 和 Spectre 之后,研究者发现了更 +多相似的攻击种类,包括 Foreshadow\supercite{foreshadow}、 +Fallout\supercite{fallout}、RIDL\supercite{ridl}、 +ZombieLoad\supercite{zombie}。 + +面对这些新型攻击,Intel、AMD、ARM 等处理器设计厂商,和 Google、 +Microsoft 等软件厂商,均发布了软件补丁或处理器微码更新,用于减轻这些攻 +击的威胁。Intel 在后续的处理器中,也在硬件上对一些攻击做出了防御 +\supercite{intel-9900k}。当前的基于软件的防御方法,均对性能造成一定的 +损失,并且通常无法防御更新的攻击手段。表\ref{tab:perf_mitigation}列出 +了部分已有的软件和微码防御方法,它们所防御的攻击,和造成的性能损失。 +\supercite{systematic} + +\begin{table}[htbp] + \begin{tabular}{ccc} + \hline + 防御方法 & 防御的攻击种类 & 性能损失\tabularnewline + \hline + KAISER & Meltdown & 0-2.6\%\tabularnewline + Retpoline & Spectre v2 & 5\%-10\%\tabularnewline + IBRS/IBPB/STIPB & Spectre v2 & 20\%-50\%\tabularnewline + SSBD/SSBB & Spectre v4 & 2\%-8\%\tabularnewline + 串行化指令 & Spectre v1 & 62\%\tabularnewline + 推测式装载加固 & Spectre v1 & 29\%\tabularnewline + \hline + \end{tabular} + \centering + \caption{软件防御对性能的影响} + \label{tab:perf_mitigation} +\end{table} + +因此,通过改进微体系结构的设计,低开销地防御 Meltdown 和 Spectre 攻击, +具有重要的研究意义。本文的目标是设计一种微体系结构,防御 Spectre 攻击。 \section{研究平台与环境} diff --git a/chap/chap2.tex b/chap/chap2.tex index 17f99c1..86ab846 100644 --- a/chap/chap2.tex +++ b/chap/chap2.tex @@ -615,13 +615,13 @@ ARM 处理器上进行验证,确认它们受 Spectre v1 的影响。 如图\ref{lst:spec-buf-overflow}中的程序: \begin{figure} - \centering - \caption{推测式缓冲区溢出} - \label{lst:spec-buf-overflow} \begin{minted}{C} if (x < len) a[x] = z; \end{minted} + \centering + \caption{推测式缓冲区溢出} + \label{lst:spec-buf-overflow} \end{figure} 攻击者给出一个超过数组 \verb|a| 大小的 \verb|x| 时,在推测式执行时,会 diff --git a/skylake.pdf b/skylake.pdf new file mode 100644 index 0000000..0c792c0 Binary files /dev/null and b/skylake.pdf differ diff --git a/skylake.svg b/skylake.svg new file mode 100644 index 0000000..480bd19 --- /dev/null +++ b/skylake.svg @@ -0,0 +1,1561 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/thesis.bib b/thesis.bib index 4dbdb5e..35a3875 100644 --- a/thesis.bib +++ b/thesis.bib @@ -21,6 +21,69 @@ bibsource = {dblp computer science bibliography, https://dblp.org} } +@ARTICLE{tomasulo, +author={R. M. {Tomasulo}}, +journal={IBM Journal of Research and Development}, +title={An Efficient Algorithm for Exploiting Multiple Arithmetic Units}, +year={1967}, +volume={11}, +number={1}, +pages={25-33}, +keywords={}, +doi={10.1147/rd.111.0025}, +ISSN={0018-8646}, +month={Jan}, +type={J}, +} + +@article{btb, + title={Branch prediction strategies and branch target buffer design}, + author={Lee, Johnny KF and Smith, Alan Jay}, + journal={Computer}, + number={1}, + pages={6--22}, + year={1984}, + publisher={IEEE}, + type={J}, +} + +@inproceedings{rsb, + title={Branch history table prediction of moving target branches due to subroutine returns}, + author={Kaeli, David R and Emma, Philip G}, + booktitle={ACM SIGARCH Computer Architecture News}, + volume={19}, + number={3}, + pages={34--42}, + year={1991}, + organization={Citeseer}, + type={C}, +} + +@inproceedings{smt, + title={Simultaneous multithreading: Maximizing on-chip parallelism}, + author={Tullsen, Dean M and Eggers, Susan J and Levy, Henry M}, + booktitle={ACM SIGARCH computer architecture news}, + volume={23}, + number={2}, + pages={392--403}, + year={1995}, + organization={ACM}, + type={C}, +} + + +@article{preciseint, + title={Implementing precise interrupts in pipelined processors}, + author={Smith, James E. and Pleszkun, Andrew R.}, + journal={IEEE Transactions on computers}, + volume={37}, + number={5}, + pages={562--573}, + year={1988}, + publisher={IEEE}, + type={J}, +} + @inproceedings{meltdown, author = {Moritz Lipp and Michael Schwarz and Daniel Gruss and Thomas Prescher and Werner Haas and Anders Fogh and Jann Horn and Stefan Mangard and Paul Kocher and Daniel Genkin and Yuval Yarom and Mike Hamburg}, title = {Meltdown: Reading Kernel Memory from User Space}, @@ -347,7 +410,7 @@ timestamp = {Mon, 13 Aug 2018 16:48:54 +0200}, biburl = {https://dblp.org/rec/bib/journals/corr/abs-1806-05179}, bibsource = {dblp computer science bibliography, https://dblp.org}, - type={J}, + type={R}, } @INPROCEEDINGS{invisispec, @@ -751,4 +814,29 @@ This thesis highlights two aspects of the BOOM design: its industry-competitive type={J} } +@article{zombie, + title = {{ZombieLoad}: Cross-Privilege-Boundary Data Sampling}, + author = {Schwarz, Michael and Lipp, Moritz and Moghimi, Daniel and Van Bulck, Jo and Stecklina, Julian and Prescher, Thomas and Gruss, Daniel}, + journal = {arXiv:1905.05726}, + year = {2019}, + type={R}, +} + +@inproceedings{ridl, + title = {{RIDL}: Rogue In-flight Data Load}, + booktitle = {S\&{P}}, + author = {van Schaik, Stephan and Milburn, Alyssa and Österlund, Sebastian and Frigo, Pietro and Maisuradze, Giorgi and Razavi, Kaveh and Bos, Herbert and Giuffrida, Cristiano}, + month = may, + year = {2019}, + type={C}, +} + +@article{fallout, + title={{Fallout}: Reading Kernel Writes From User Space}, + author={Minkin, Marina and Moghimi, Daniel and Lipp, Moritz and Schwarz, Michael and Van Bulck, Jo, and Genkin, Daniel and Gruss, Daniel and Sunar, Berk and Piessens, Frank and Yarom, Yuval}, + year={2019}, + type={R}, +} + + % vim:ts=4:sw=4 -- cgit v1.2.3