target/loongarch/kvm: Add vCPU reset function

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>
This commit is contained in:
Bibo Mao 2024-08-22 10:28:27 +08:00 committed by Song Gao
parent d69490c499
commit a724f5a84e
3 changed files with 6 additions and 3 deletions

View File

@ -577,7 +577,7 @@ static void loongarch_cpu_reset_hold(Object *obj, ResetType type)
memset(env->tlb, 0, sizeof(env->tlb)); memset(env->tlb, 0, sizeof(env->tlb));
#endif #endif
if (kvm_enabled()) { if (kvm_enabled()) {
kvm_arch_reset_vcpu(env); kvm_arch_reset_vcpu(cs);
} }
#endif #endif

View File

@ -476,9 +476,12 @@ static int kvm_loongarch_put_regs_fp(CPUState *cs)
return ret; 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; 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) static int kvm_loongarch_get_mpstate(CPUState *cs)

View File

@ -11,6 +11,6 @@
#define QEMU_KVM_LOONGARCH_H #define QEMU_KVM_LOONGARCH_H
int kvm_loongarch_set_interrupt(LoongArchCPU *cpu, int irq, int level); 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 #endif