LoongArch: KVM: Add PV IPI support on host side
authorBibo Mao <maobibo@loongson.cn>
Mon, 6 May 2024 14:00:47 +0000 (22:00 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Mon, 6 May 2024 14:00:47 +0000 (22:00 +0800)
commite33bda7ee50c3c20d80f5ca6dc5ca2cd37863518
tree20725db700c1e1bacaba03bfa564650ac5baca85
parent73516e9da512adc63ba3859fbd82a21f6257348f
LoongArch: KVM: Add PV IPI support on host side

On LoongArch system, IPI hw uses iocsr registers. There are one iocsr
register access on IPI sending, and two iocsr access on IPI receiving
for the IPI interrupt handler. In VM mode all iocsr accessing will cause
VM to trap into hypervisor. So with one IPI hw notification there will
be three times of trap.

In this patch PV IPI is added for VM, hypercall instruction is used for
IPI sender, and hypervisor will inject an SWI to the destination vcpu.
During the SWI interrupt handler, only CSR.ESTAT register is written to
clear irq. CSR.ESTAT register access will not trap into hypervisor, so
with PV IPI supported, there is one trap with IPI sender, and no trap
with IPI receiver, there is only one trap with IPI notification.

Also this patch adds IPI multicast support, the method is similar with
x86. With IPI multicast support, IPI notification can be sent to at
most 128 vcpus at one time. It greatly reduces the times of trapping
into hypervisor.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/include/asm/kvm_host.h
arch/loongarch/include/asm/kvm_para.h
arch/loongarch/include/asm/kvm_vcpu.h
arch/loongarch/include/asm/loongarch.h
arch/loongarch/kvm/exit.c
arch/loongarch/kvm/vcpu.c