How to launch ARM aarch64 VM with QEMU from scratch

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 and the qemu-efi-aarch64 package, which includes the efi firmware. apt-get install qemu-system-arm apt-get install qemu-efi-aarch64 apt-get install qemu-utils Create the flash images with the correct sizes. dd if=/dev/zero of=flash1.img bs=1M count=64 dd if=/dev/zero of=flash0.img bs=1M count=64 dd if=/usr/share/qemu-efi-aarch64/QEMU_EFI.fd of=flash0.img conv=notrunc Create a dedicated directory (folder) on your host system to contain this virtual machine. Download the latest  “Virtual” ISO file for…

Understanding the LLVM Compiler

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 across different languages and architectures. 1. Frontend The frontend is responsible for: Parsing the high-level source code (written in languages like C, C++, Rust, etc.). Checking for syntax and semantic correctness. Generating the LLVM Intermediate Representation (IR), which is an abstract, platform-independent code representation. Key Processes in the Frontend: Lexical Analysis (Tokenization): The source code is broken into meaningful chunks called tokens (e.g.,…

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

1、数据冒险 数据相关有四种,分别是RAR、WAR、WAW、RAW。其中“RAR”不会影响指令的执行,所以提数据相关的时候一般忽略,而WAR、WAW、RAW的重要差别就出在“数据依赖”上。“WAR”和“WAW”这两种数据相关其实没有数据依赖,即发生冒险的指令之间其实没有数据流动,通过寄存器重命名就可以消除冒险。“RAW”冒险则无法解决,因为后序指令读取的数据由前序指令算得,这个过程有明确的数据依赖。 2、Tomasulo算法 Tomasulo是计算机硬件架构的一种指令动态调度算法,其通过寄存器重命名消除了假数据冒险,提高了机器的乱序性能。Tomasulo算法的调度分为三个步骤:发射、执行、写回。 Tomasulo算法的实现结构 发射:Tomasulo算法是顺序发射的,即指令按照程序中的顺序一条接一条被发射到保留站。判断能否发射的唯一标准是指令对应通路的保留站是否有空余位置,只要保留站有空余,就可以把指令发射到保留站中。周期结束时会更新保留站和寄存器结果状态表,如果指令有可以读取的数据,就会立刻拷贝到保留站中;寄存器结果状态表中总是存有最新的值,即如果后...

RISC-V simulation with Qemu

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 few important extra steps are needed. In order to use the user mode simulation, your host system must be Linux. I recommend installing from source as described on this  using configure with --target-list= riscv32-linux-user,riscv64-linux-user, riscv32-softmmu,riscv64-softmmu as a configuration. I assume you have a RV toolchain running, if not,  is how. User-Mode The simplest way of getting an environment for RV programming is…

Installing & Building RISC-V 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 gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev libslirp-dev Create a directory and clone $ mkdir ~/riscv && cd ~/riscv $ git clone https://github.com/riscv/riscv-gnu-toolchain Configure and make $ mkdir /opt/riscv $ ./configure --prefix=/opt/riscv $ make linux Your tool will be available on /opt/riscv/bin Add /opt/riscv/bin to PATH Edit the ~/.bashrc file $ sudo vim ~/.bashrc Add below at the end of the file and…