]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
target/loongarch/kvm: Add vCPU reset function
authorBibo Mao <maobibo@loongson.cn>
Thu, 22 Aug 2024 02:28:27 +0000 (10:28 +0800)
committerSong Gao <gaosong@loongson.cn>
Thu, 12 Sep 2024 12:51:18 +0000 (20:51 +0800)
KVM provides interface KVM_REG_LOONGARCH_VCPU_RESET to reset vCPU,
it can be used to clear internal state about kvm kernel. vCPU reset
function is added here for kvm mode.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
Message-Id: <20240822022827.2273534-1-maobibo@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
target/loongarch/cpu.c
target/loongarch/kvm/kvm.c
target/loongarch/kvm/kvm_loongarch.h

index 115922113ab57d0a2c71d5f0c43431b51e19130c..6a569285b889dbda55d688c1fbc91178c612227f 100644 (file)
@@ -577,7 +577,7 @@ static void loongarch_cpu_reset_hold(Object *obj, ResetType type)
     memset(env->tlb, 0, sizeof(env->tlb));
 #endif
     if (kvm_enabled()) {
-        kvm_arch_reset_vcpu(env);
+        kvm_arch_reset_vcpu(cs);
     }
 #endif
 
index e1be6a695947f8c21fc4d0d79ed4df7734ea0f78..4786cd5efa4089ddd9878aa39315c96234b273eb 100644 (file)
@@ -476,9 +476,12 @@ static int kvm_loongarch_put_regs_fp(CPUState *cs)
     return ret;
 }
 
-void kvm_arch_reset_vcpu(CPULoongArchState *env)
+void kvm_arch_reset_vcpu(CPUState *cs)
 {
+    CPULoongArchState *env = cpu_env(cs);
+
     env->mp_state = KVM_MP_STATE_RUNNABLE;
+    kvm_set_one_reg(cs, KVM_REG_LOONGARCH_VCPU_RESET, 0);
 }
 
 static int kvm_loongarch_get_mpstate(CPUState *cs)
index d945b6bb822a776eba000f6c5d8a9a7cbb676f96..1051a341ec2633647e55f3c37ad5998c4f02ba06 100644 (file)
@@ -11,6 +11,6 @@
 #define QEMU_KVM_LOONGARCH_H
 
 int  kvm_loongarch_set_interrupt(LoongArchCPU *cpu, int irq, int level);
-void kvm_arch_reset_vcpu(CPULoongArchState *env);
+void kvm_arch_reset_vcpu(CPUState *cs);
 
 #endif