]> www.infradead.org Git - users/hch/xfs.git/commitdiff
LoongArch: KVM: Invalidate guest steal time address on vCPU reset
authorBibo Mao <maobibo@loongson.cn>
Mon, 26 Aug 2024 15:11:32 +0000 (23:11 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Mon, 26 Aug 2024 15:11:32 +0000 (23:11 +0800)
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>
arch/loongarch/include/asm/kvm_vcpu.h
arch/loongarch/kvm/timer.c
arch/loongarch/kvm/vcpu.c

index c416cb7125c0e5eb2ef0f48c6cb1bb54d3cb3804..86570084e05aa86f105d697e28fb7f94eb99dc89 100644 (file)
@@ -76,7 +76,6 @@ static inline void kvm_restore_lasx(struct loongarch_fpu *fpu) { }
 #endif
 
 void kvm_init_timer(struct kvm_vcpu *vcpu, unsigned long hz);
-void kvm_reset_timer(struct kvm_vcpu *vcpu);
 void kvm_save_timer(struct kvm_vcpu *vcpu);
 void kvm_restore_timer(struct kvm_vcpu *vcpu);
 
index bcc6b6d063d914dbf820b43f2c1308803646b395..74a4b5c272d60e99523e12e89d5e663d53009c2b 100644 (file)
@@ -188,10 +188,3 @@ void kvm_save_timer(struct kvm_vcpu *vcpu)
        kvm_save_hw_gcsr(csr, LOONGARCH_CSR_ESTAT);
        preempt_enable();
 }
-
-void kvm_reset_timer(struct kvm_vcpu *vcpu)
-{
-       write_gcsr_timercfg(0);
-       kvm_write_sw_gcsr(vcpu->arch.csr, LOONGARCH_CSR_TCFG, 0);
-       hrtimer_cancel(&vcpu->arch.swtimer);
-}
index 16756ffb55e8603cefc2de3c8bef4b6764db5b17..6905283f535b969faae6db735cb99fb1422d6da6 100644 (file)
@@ -647,7 +647,7 @@ static int kvm_set_one_reg(struct kvm_vcpu *vcpu,
                                vcpu->kvm->arch.time_offset = (signed long)(v - drdtime());
                        break;
                case KVM_REG_LOONGARCH_VCPU_RESET:
-                       kvm_reset_timer(vcpu);
+                       vcpu->arch.st.guest_addr = 0;
                        memset(&vcpu->arch.irq_pending, 0, sizeof(vcpu->arch.irq_pending));
                        memset(&vcpu->arch.irq_clear, 0, sizeof(vcpu->arch.irq_clear));
                        break;