Skip to content

Commit 3700cd7

Browse files
bibo-maogregkh
authored andcommitted
LoongArch: KVM: Reload guest CSR registers after sleep
commit 78d7bc5 upstream. On host, the HW guest CSR registers are lost after suspend and resume operation. Since last_vcpu of boot CPU still records latest vCPU pointer so that the guest CSR register skips to reload when boot CPU resumes and vCPU is scheduled. Here last_vcpu is cleared so that guest CSR registers will reload from scheduled vCPU context after suspend and resume. 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>
1 parent 5f3f7d2 commit 3700cd7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

arch/loongarch/kvm/main.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,13 @@ int kvm_arch_enable_virtualization_cpu(void)
297297
kvm_debug("GCFG:%lx GSTAT:%lx GINTC:%lx GTLBC:%lx",
298298
read_csr_gcfg(), read_csr_gstat(), read_csr_gintc(), read_csr_gtlbc());
299299

300+
/*
301+
* HW Guest CSR registers are lost after CPU suspend and resume.
302+
* Clear last_vcpu so that Guest CSR registers forced to reload
303+
* from vCPU SW state.
304+
*/
305+
this_cpu_ptr(vmcs)->last_vcpu = NULL;
306+
300307
return 0;
301308
}
302309

0 commit comments

Comments
 (0)