Skip to content

Commit 4956e07

Browse files
bibo-maochenhuacai
authored andcommitted
LoongArch: KVM: Invalidate guest steal time address on vCPU reset
If ParaVirt steal time feature is enabled, there is a percpu gpa address passed from guest vCPU and host modifies guest memory space with this gpa address. When vCPU is reset normally, it will notify host and invalidate gpa address. However if VM is crashed and VMM reboots VM forcely, the vCPU reboot notification callback will not be called in VM. Host needs invalidate the gpa address, else host will modify guest memory during VM reboots. Here it is invalidated from the vCPU KVM_REG_LOONGARCH_VCPU_RESET ioctl interface. Also funciton kvm_reset_timer() is removed at vCPU reset stage, since SW emulated timer is only used in vCPU block state. When a vCPU is removed from the block waiting queue, kvm_restore_timer() is called and SW timer is cancelled. And the timer register is also cleared at VMM when a vCPU is reset. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent 8037632 commit 4956e07

3 files changed

Lines changed: 1 addition & 9 deletions

File tree

arch/loongarch/include/asm/kvm_vcpu.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ static inline void kvm_restore_lasx(struct loongarch_fpu *fpu) { }
7676
#endif
7777

7878
void kvm_init_timer(struct kvm_vcpu *vcpu, unsigned long hz);
79-
void kvm_reset_timer(struct kvm_vcpu *vcpu);
8079
void kvm_save_timer(struct kvm_vcpu *vcpu);
8180
void kvm_restore_timer(struct kvm_vcpu *vcpu);
8281

arch/loongarch/kvm/timer.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,3 @@ void kvm_save_timer(struct kvm_vcpu *vcpu)
188188
kvm_save_hw_gcsr(csr, LOONGARCH_CSR_ESTAT);
189189
preempt_enable();
190190
}
191-
192-
void kvm_reset_timer(struct kvm_vcpu *vcpu)
193-
{
194-
write_gcsr_timercfg(0);
195-
kvm_write_sw_gcsr(vcpu->arch.csr, LOONGARCH_CSR_TCFG, 0);
196-
hrtimer_cancel(&vcpu->arch.swtimer);
197-
}

arch/loongarch/kvm/vcpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ static int kvm_set_one_reg(struct kvm_vcpu *vcpu,
647647
vcpu->kvm->arch.time_offset = (signed long)(v - drdtime());
648648
break;
649649
case KVM_REG_LOONGARCH_VCPU_RESET:
650-
kvm_reset_timer(vcpu);
650+
vcpu->arch.st.guest_addr = 0;
651651
memset(&vcpu->arch.irq_pending, 0, sizeof(vcpu->arch.irq_pending));
652652
memset(&vcpu->arch.irq_clear, 0, sizeof(vcpu->arch.irq_clear));
653653
break;

0 commit comments

Comments
 (0)