This series add loongarch kvm support, mainly implement some interfaces used by kvm such as kvm_arch_get/set_regs, kvm_arch_handle_exit, kvm_loongarch_set_interrupt, etc.
Currently, we are able to boot LoongArch KVM Linux Guests. In loongarch VM, mmio devices and iocsr devices are emulated in user space such as APIC, IPI, pci devices, etc, other hardwares such as MMU, timer and csr are emulated in kernel. It is based on temporarily unaccepted linux kvm: https://github.com/loongson/linux-loongarch-kvm And We will remove the RFC flag until the linux kvm patches are merged. The running environment of LoongArch virt machine: 1. Get the linux source by the above mentioned link. git checkout kvm-loongarch make ARCH=loongarch CROSS_COMPILE=loongarch64-unknown-linux-gnu- loongson3_defconfig make ARCH=loongarch CROSS_COMPILE=loongarch64-unknown-linux-gnu- 2. Get the qemu source: https://github.com/loongson/qemu git checkout kvm-loongarch ./configure --target-list="loongarch64-softmmu" --enable-kvm make 3. Get uefi bios of LoongArch virt machine: Link: https://github.com/tianocore/edk2-platforms/tree/master/Platform/Loongson/LoongArchQemuPkg#readme 4. Also you can access the binary files we have already build: https://github.com/yangxiaojuan-loongson/qemu-binary The command to boot loongarch virt machine: $ qemu-system-loongarch64 -machine virt -m 4G -cpu la464 \ -smp 1 -bios QEMU_EFI.fd -kernel vmlinuz.efi -initrd ramdisk \ -serial stdio -monitor telnet:localhost:4495,server,nowait \ -append "root=/dev/ram rdinit=/sbin/init console=ttyS0,115200" \ --nographic Tianrui Zhao (10): linux-headers: Add KVM headers for loongarch target/loongarch: Define some kvm_arch interfaces target/loongarch: Supplement vcpu env initial when vcpu reset target/loongarch: Implement kvm get/set registers target/loongarch: Implement kvm_arch_init function target/loongarch: Implement kvm_arch_init_vcpu target/loongarch: Implement kvm_arch_handle_exit target/loongarch: Implement set vcpu intr for kvm target/loongarch: Add kvm-stub.c target/loongarch: Add kvm file into meson build linux-headers/asm-loongarch/kvm.h | 99 ++++++ linux-headers/linux/kvm.h | 9 + meson.build | 2 + target/loongarch/cpu.c | 21 +- target/loongarch/cpu.h | 3 + target/loongarch/kvm-stub.c | 17 + target/loongarch/kvm.c | 545 ++++++++++++++++++++++++++++++ target/loongarch/kvm_loongarch.h | 14 + target/loongarch/meson.build | 1 + 9 files changed, 706 insertions(+), 5 deletions(-) create mode 100644 linux-headers/asm-loongarch/kvm.h create mode 100644 target/loongarch/kvm-stub.c create mode 100644 target/loongarch/kvm.c create mode 100644 target/loongarch/kvm_loongarch.h -- 2.31.1