LoongArch Linux Patches Enable KVM Virtualization

Written by Michael Larabel in Virtualization on 15 February 2023 at 05:46 AM EST. Add A Comment
VIRTUALIZATION
While LoongArch merged for Linux 5.19 last year, that initial kernel port to the Chinese CPU architecture wasn't entirely complete and some Loongson 3A5000 features are still being enabled for the mainline kernel. The latest feature work being carried out by Loongson engineers is for supporting hardware virtualization on the 3A5000 processors with KVM.

Sent out on Tuesday were the initial 24 patches for getting KVM LoongArch support started. Loongson engineer Tianrui Zhao explained in the patch series:
"This series adds KVM LoongArch support. Loongson 3A5000 supports hardware assisted virtualization. With cpu virtualization, there are separate hw-supported user mode and kernel mode in guest mode. With memory virtualization, there are two-level hw mmu table for guest mode and host mode. Also there is separate hw cpu timer with consant frequency in guest mode, so that vm can migrate between hosts with different freq. Currently, we are able to boot LoongArch Linux Guests.

Few key aspects of KVM LoongArch added by this series are:
1. Enable kvm hardware function when kvm module is loaded.
2. Implement VM and vcpu related ioctl interface such as vcpu create, vcpu run etc. GET_ONE_REG/SET_ONE_REG ioctl commands are use to get general registers one by one; KVM_GET_CSRS can be used to get system registers with batch mode similar with KVM_GET_MSRS in x86.
3. Hardware access about MMU, timer and csr are emulated in kernel.
4. Hardwares such as mmio and iocsr device are emulated in user space such as APIC, IPI, pci devices etc."

Along with these LoongArch KVM patches now under review, Loongson is also maintaining a fork of QEMU for the moment with their LoongArch support there as well as a modified TianoCore UEFI BIOS for booting.

Loongson 3A5000


More details on the LoongArch KVM support via the v1 patch series.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week