LoongArch: KVM: Fully clear some CSRs when VM reboot
authorBibo Mao <maobibo@loongson.cn>
Thu, 24 Apr 2025 12:15:52 +0000 (20:15 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 May 2025 05:59:07 +0000 (07:59 +0200)
commitbe83fd71ac6e423d9c2d36ca67e0f5279314d2ea
tree2ed80f54d3e7243dd6b761dea666d09cf38a60df
parent3b7f341eee945864f607bc1f30e342579819fde8
LoongArch: KVM: Fully clear some CSRs when VM reboot

commit 9ea86232a5520d9d21832d06031ea80f055a6ff8 upstream.

Some registers such as LOONGARCH_CSR_ESTAT and LOONGARCH_CSR_GINTC are
partly cleared with function _kvm_setcsr(). This comes from the hardware
specification, some bits are read only in VM mode, and however they can
be written in host mode. So they are partly cleared in VM mode, and can
be fully cleared in host mode.

These read only bits show pending interrupt or exception status. When VM
reset, the read-only bits should be cleared, otherwise vCPU will receive
unknown interrupts in boot stage.

Here registers LOONGARCH_CSR_ESTAT/LOONGARCH_CSR_GINTC are fully cleared
in ioctl KVM_REG_LOONGARCH_VCPU_RESET vCPU reset path.

Cc: stable@vger.kernel.org
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/loongarch/kvm/vcpu.c