diff options
author | Bibo Mao <maobibo@loongson.cn> | 2025-03-08 13:52:01 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-03-13 13:07:40 +0100 |
commit | 095bcad7f5e2bb972d269e6f0187b0758b14354a (patch) | |
tree | bea8250d5d97a0a10691f7fde2d8f70e2cd02915 | |
parent | 445fca44d4921de415a7c0a2c52cc3ddbc3e29a0 (diff) |
LoongArch: KVM: Reload guest CSR registers after sleep
commit 78d7bc5a02e1468df53896df354fa80727f35b7d 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>
-rw-r--r-- | arch/loongarch/kvm/main.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/arch/loongarch/kvm/main.c b/arch/loongarch/kvm/main.c index 034402e0948c..d0b941459a6b 100644 --- a/arch/loongarch/kvm/main.c +++ b/arch/loongarch/kvm/main.c @@ -299,6 +299,13 @@ int kvm_arch_enable_virtualization_cpu(void) kvm_debug("GCFG:%lx GSTAT:%lx GINTC:%lx GTLBC:%lx", read_csr_gcfg(), read_csr_gstat(), read_csr_gintc(), read_csr_gtlbc()); + /* + * HW Guest CSR registers are lost after CPU suspend and resume. + * Clear last_vcpu so that Guest CSR registers forced to reload + * from vCPU SW state. + */ + this_cpu_ptr(vmcs)->last_vcpu = NULL; + return 0; } |