LoongArch QEMU virt is a generic platform that does not require any actual hardware. The minimum required QEMU version is 8.1, the minimum required GCC version is GCC13, the minimum required Binutils version is 2.40.
Install LoongArch64 cross compiler, LoongArch system QEMU.
yum install gcc-loongarch64-linux-gnu yum install qemu-system-loongarch64
Download:
wget https://github.com/loongson/build-tools/releases/download/2023.08.08/x86_64-cross-tools-loongarch64-binutils_2.41-gcc_13.2.0.tar.xz
Configure the cross-tools environment:
mkdir /opt/loongarch64_cross-toolchain/ tar -vxf x86_64-cross-tools-loongarch64-binutils_2.41-gcc_13.2.0.tar.xz -C /opt/loongarch64_cross-toolchain/ export PATH=/opt/loongarch64_cross-toolchain/cross-tools/bin:$PATH
Note: Please obtain the latest cross-compilation toolchains.
git clone https://gitlab.com/qemu-project/qemu.git
Note: Please refer to QEMU compilation rules, located in qemu/doc/system/loongarch/virt.rst.
git clone --recurse-submodule https://github.com/tianocore/edk2.git
export WORKSPACE=`pwd` export GCC_LOONGARCH64_PREFIX=loongarch64-unknown-linux-gnu- export PACKAGES_PATH=$WORKSPACE/edk2 export EDK_TOOLS_PATH=$WORKSPACE/edk2/BaseTools source edk2/edksetup.sh --reconfig make -C edk2/BaseTools source edk2/edksetup.sh BaseTools build -b RELEASE -t GCC -a LOONGARCH64 -p OvmfPkg/LoongArchVirt/LoongArchVirtQemu.dsc
LoongArchVirt Secure Boot builds that are intended to keep Secure Boot state locked from the guest should use the QEMU UEFI variable store:
build -b RELEASE -t GCC -a LOONGARCH64 \ -p OvmfPkg/LoongArchVirt/LoongArchVirtQemu.dsc \ -D SECURE_BOOT_ENABLE=TRUE \ -D QEMU_PV_VARS=TRUE
When using QEMU_PV_VARS=TRUE, configure the QEMU uefi-vars-sysbus device with policy options that keep Secure Boot enabled and prevent guest-side Custom Mode changes:
-device uefi-vars-sysbus,jsonfile=/path/to/varstore.json,\
disable-custom-mode=on,force-secure-boot=on
Without these QEMU-side policy options, the VM manager does not lock the guest out of Custom Mode or Secure Boot state changes through UEFI variable services. LoongArchVirt does not provide a hardware-backed physical-presence mechanism, so locked Secure Boot deployments must express this policy in the QEMU configuration.
Refer to OvmfPkg/QEMU_PV_VARS.md for more information about the QEMU UEFI variable store.
qemu-system-loongarch64 \ -m 4G \ -M virt \ -smp 2 \ -cpu la464 \ -bios Build/LoongArchVirtQemu/RELEASE_GCC/FV/QEMU_EFI.fd \ -serial stdio