Enabling PAC and BTI on AArch64 for Linux

https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/enabling-pac-and-bti-on-aarch64 https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/p2-enabling-pac-and-bti-on-aarch64 https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/p3-enabling-pac-and-bti-on-aarch64 Source code for the examples can be found at https://gitlab.arm.com/pac-and-bti-blog/blog-example and the tag will be referenced with the "Tag" keyword before source examples. Certain versions of Arm…

Running arm64 docker container on x86

Make sure to install the packages mentioned in Multi-platform builds, which then will allows docker to leverage qemu, which then emulates the target cpu architecture. binfmt Use the tonistiigi/binfmt image to install QEMU…

A Quick and Easy Guide to tmux

https://hamvocke.com/blog/a-quick-and-easy-guide-to-tmux I love working with the command line. I think there’s hardly any more productive and versatile tool for a software developer than the terminal. The additional hacker/wizard/neckbeard kind of…

Everything I know about GNU toolchain

https://maskray.me/blog/2021-01-24-gnu-toolchain#:~:text=Main%20tools:%20as%20(%20gas/,make%20%2DC%20out/debug%20all As mainly an LLVM person, I occasionally contribute to GNU toolchain projects. This is sometimes for fun, sometimes for investigating why an (usually ancient) feature works in a particular…

How to compile coreutils / binutils for aarch64 in x64

Dockcross git clone https://github.com/dockcross/dockcross.git cd dockcross docker run --rm dockcross/linux-arm64> ./dockcross-linux-arm64 chmod +x ./dockcross-linux-arm64 mv ./dockcross-linux-arm64 ~/bin/ Coreutils / Binutils //Go to the repository diretory dockcross-linux-arm64 bash //In the docker…

How to launch ARM aarch64 VM with QEMU from scratch

https://futurewei-cloud.github.io/ARM-Datacenter/qemu/how-to-launch-aarch64-vm https://ww2.coastal.edu/mmurphy2/oer/qemu/aarch64 The below instructions will allow for bringing up an ARM VM from scratch. To launch an aarch64 VM we first need to install a few dependencies, including QEMU…

Understanding the LLVM Compiler

https://medium.com/@abhilashkrish/understanding-the-llvm-compiler-a-comprehensive-guide-to-code-translation-and-optimization-decea91fe29d#:~:text=Middle%2Dend%3A%20Optimizes%20the%20LLVM,%2C%20registers%2C%20and%20instruction%20set. https://www.npopov.com/2023/04/07/LLVM-middle-end-pipeline.html Components of LLVM: LLVM is designed with a three-phase architecture: Frontend, Middle-end, and Backend. Each component plays a crucial role in translating high-level source code into machine-executable code, while allowing modularity and optimizations…

【计算机体系结构】Tomasulo算法

https://zhuanlan.zhihu.com/p/499978902 1、数据冒险 数据相关有四种,分别是RAR、WAR、WAW、RAW。其中“RAR”不会影响指令的执行,所以提数据相关的时候一般忽略,而WAR、WAW、RAW的重要差别就出在“数据依赖”上。“WAR”和“WAW”这两种数据相关其实没有数据依赖,即发生冒险的指令之间其实没有数据流动,通过寄存器重命名就可以消除冒险。“RAW”冒险则无法解决,因为后序指令读取的数据由前序指令算得,这个过程有明确的数据依赖。 2、Tomasulo算法 Tomasulo是计算机硬件架构的一种指令动态调度算法,其通过寄存器重命名消除了假数据冒险,提高了机器的乱序性能。Tomasulo算法的调度分为三个步骤:发射、执行、写回。 Tomasulo算法的实现结构 发射:Tomasulo算法是顺序发射的,即指令按照程序中的顺序一条接一条被发射到保留站。判断能否发射的唯一标准是指令对应通路的保留站是否有空余位置,只要保留站有空余,就可以把指令发射到保留站中。周期结束时会更新保留站和寄存器结果状态表,如果指令有可以读取的数据,就会立刻拷贝到保留站中;寄存器结果状态表中总是存有最新的值,即如果后序指令的目的寄存器和前序指令的目的寄存器重合,那就只保留后序指令的写信息。 执行:指令通过拷贝数据和监听CDB获得源数据,然后开始执行,执行可能是多周期的,在执行过程中不改变处理器状态。 写回:指令在写回阶段通过CDB总线将数据直通到寄存器堆和各个保留站;周期结束时,根据寄存器结果状态表来更新寄存器堆,并且清除保留站和寄存器结果状态表的信息。 保留站 寄存器结果状态 Tomuasulo调度流程中的要点: 一条指令能否发射,要看对应配置通路的保留站是否有空余,只要有空余,就可以发射到保留站中等待执行;发射的同时会把能读取的数据直接拷贝到保留站,这样做就不用考虑WAR冒险。 指令在发射的时候会更新寄存器状态表,如果后序指令和前序指令的目的寄存器重合了,就用后序指令的写信息标志寄存器,即只会把后序指令的计算结果写进寄存器,这样可以解决WAW冒险。 如果执行单元中有指令正在执行,其他指令就在保留站中等待;如果指令缺少源数据,就留在保留站中,时刻监听CDB总线,如果CDB总线广播了需要的数据,就立马拷贝下来,然后准备执行。 一条指令在源数据全部准备好之后就可以执行,执行可能是多周期的。 一条指令只要完成计算,就可以写回,写回的数据通过CDB总线直通寄存器堆和各个保留站。但是指令的结果未必会写进寄存器堆,因为寄存器结果状态表中总是存有最新的状态,即如果发生WAW冒险,Tomasulo算法会记录下最新的写指令,而抛弃前序的写指令结果,前序写指令的结果不会写回到寄存器堆。 Tomasulo算法不支持精确中断,即在指令和指令之间如果出现了中断/异常,那么处理器要确保中断/异常之前的所有指令都执行完毕,而中断/异常之后的所有指令都没有执行。这使得程序的正确执行无法保证,为分支指令的处理和程序员调试程序带来了巨大的麻烦。要支持精确中断,就要确保指令按序提交,因此,设计人员提出了重排序缓冲的概念,对Tomasulo算法进行改进,从而实现处理器的按序发射-乱序执行-按序提交。

RISC-V simulation with Qemu

https://medium.com/@e1d1/risc-v-simulation-with-qemu-61ea8f2d8f4b Installation of Qemu On the Qemu website, you can find a lot of information on how to get it running. But for the specific purpose of this tutorial, a…

Installing & Building RISC-V Toolchain

https://bernardnongpoh.github.io/posts/riscv https://github.com/riscv-collab/riscv-gnu-toolchain Prerequisites Several standard packages are needed to build the toolchain $ sudo apt-get install autoconf automake autotools-dev curl python3 python3-pip libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo…