Arm架构下的分支目标缓冲器逆向工程研究
Branch Target Buffer Reverse Engineering on Arm
AI总结:
本研究针对ARM处理器BTB实现细节未公开的空白,将Intel x86平台的BTB逆向技术适配到ARM平台,通过特定PMU事件测出树莓派4B的Cortex-A72的BTB参数并开源代码。
摘要:
分支目标缓冲器(Branch Target Buffer, BTB)在CPU高效分支预测中发挥着关键作用。掌握BTB的设计与实现细节,既能为编译器设计提供有价值的参考,也能助力Spectre等硬件攻击的防护研究。然而,Intel、AMD、苹果、高通等主流厂商的CPU均为专有设计,其BTB的具体实现细节并未公开。为突破这一限制,已有多项研究成功逆向解析了BTB的容量、相联度等信息,但这些研究主要针对Intel的x86处理器。据我们所知,目前尚无研究尝试逆向解析并公开ARM处理器的BTB实现细节。\n本项目旨在填补这一研究空白,对ARM处理器的BTB展开探究。我们具体研究了为Intel BTB开发的现有逆向工程技术是否可适配ARM平台。我们复现了x86平台的研究方法,并确定了ARM平台下可辅助逆向工程过程的特定性能监控单元(PMU)事件。实验中,我们以树莓派4B搭载的四核Cortex-A72这款ARM CPU为研究对象展开测试。结果显示,该CPU的BTB容量为4K,组索引从程序计数器(PC)的第5位开始,到第15位结束(共11位),每组包含2路。项目源代码可在https://github.com/stefan1wan/BTB_ARM_RE 获取。
英文摘要:
The Branch Target Buffer (BTB) plays a critical role in efficient CPU branch prediction. Understanding the design and implementation of the BTB provides valuable insights for both compiler design and the mitigation of hardware attacks such as Spectre. However, the proprietary nature of dominant CPUs, such as those from Intel, AMD, Apple, and Qualcomm, means that specific BTB implementation details are not publicly available. To address this limitation, several previous works have successfully reverse-engineered BTB information, including capacity and associativity, primarily targeting Intel's x86 processors. However, to our best knowledge, no research has attempted to reverse-engineer and expose the BTB implementation of ARM processors. This project aims to fill the gap by exploring the BTB of ARM processors. Specifically, we investigate whether existing reverse-engineering techniques developed for Intel BTB can be adapted for ARM. We reproduce the x86 methodology and identify specific PMU events for ARM to facilitate the reverse engineering process. In our experiment, we investigated our ARM CPU, i.e., the quad-core Cortex-A72 of the Raspberry Pi 4B. Our results show that the BTB capacity is 4K, the set index starts from the 5th bit and ends with the 15th bit of the PC (11 bits in total), and there are 2 ways in each set. The source code can be find at https://github.com/stefan1wan/BTB_ARM_RE.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。