kvm: x86: fix a race condition result to lost INIT
2017-07-30 19:33 GMT+08:00 <[email protected]>:
Quoted 44 lines
Quoted 44 lines
2017-07-30 18:42 GMT+08:00 <[email protected]>:
Quoted 38 lines
Quoted 37 lines
2017-07-31 0:24 GMT+08:00 Peng Hao <[email protected]>:
Quoted 24 lines
when SMP VM start, AP may lost INIT because of receiving INIT between kvm_vcpu_ioctl_x86_get/set_vcpu_events.
vcpu 0 vcpu 1
kvm_vcpu_ioctl_x86_get_vcpu_events events->smi.latched_init=0send INIT to vcpu1
set vcpu1'spending_events
kvm_vcpu_ioctl_x86_set_vcpu_events
events->smi.latched_init== 0
clear INIT inpending_events
I don't think it need set/clear kernel state according to userspace's info.Signed-off-by Peng Hao <[email protected]>--- arch/x86/kvm/x86.c | 6 ------ 1 file changed, 6 deletions(-)arch/x86/kvm/x86.c +0
-0arch/x86/kvm/x86.c static int · line 3161
Quoted 8 lines
arch/x86/kvm/x86.c +0
-3@@ -3157,12 +3157,6 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu, vcpu->arch.hflags |= HF_SMM_INSIDE_NMI_MASK; else vcpu->arch.hflags &= ~HF_SMM_INSIDE_NMI_MASK; -if (lapic_in_kernel (vcpu)) { -if (events->smi.latched_init) -set_bit (KVM_APIC_INIT , &vcpu->arch.apic->pending_events);This is not correct, you will lose the INIT after live migration. I just send out another patch to fix it. Thanks for the report.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
yes, you're right. I should modify on qemu not kernel.
There is a patch here to fix it in kvm, https://lkml.org/lkml/2017/7/30/72
Quoted 1 line
I was affected by sipi, kernel never report valid sipi to user space,
How you afftected by SIPI? In addition, you reported the lost of INIT. Is it observed by your workload or by code review?
Regards,
Wanpeng Li
Quoted 11 lines
we don't care whether sipi is lost after migration. Why?
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
arch/x86/kvm/x86.c +0
-3-else -clear_bit (KVM_APIC_INIT , &vcpu->arch.apic->pending_events); - }}
2017-07-30 19:33 GMT+08:00 <[email protected]>:
Quoted 46 lines
Quoted 45 lines
2017-07-30 18:42 GMT+08:00 <[email protected]>:
Quoted 39 lines
Quoted 21 lines
2017-07-31 0:24 GMT+08:00 Peng Hao <[email protected]>:
Quoted 19 lines
when SMP VM start, AP may lost INIT because of receiving INIT between kvm_vcpu_ioctl_x86_get/set_vcpu_events.
vcpu 0 vcpu 1
kvm_vcpu_ioctl_x86_get_vcpu_events events->smi.latched_init=0send INIT to vcpu1
set vcpu1'spending_events
kvm_vcpu_ioctl_x86_set_vcpu_events
events->smi.latched_init== 0
clear INIT inpending_events
I don't think it need set/clear kernel state according to userspace's info.Signed-off-by Peng Hao <[email protected]>--- arch/x86/kvm/x86.c | 6 ------ 1 file changed, 6 deletions(-)Quoted 16 lines
arch/x86/kvm/x86.c static int · line 3161
Quoted 13 lines
arch/x86/kvm/x86.c +0
-3@@ -3157,12 +3157,6 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu, vcpu->arch.hflags |= HF_SMM_INSIDE_NMI_MASK; else vcpu->arch.hflags &= ~HF_SMM_INSIDE_NMI_MASK; -if (lapic_in_kernel (vcpu)) { -if (events->smi.latched_init) -set_bit (KVM_APIC_INIT , &vcpu->arch.apic->pending_events);This is not correct, you will lose the INIT after live migration. I just send out another patch to fix it. Thanks for the report.
yes, you're right. I should modify on qemu not kernel.
Quoted 7 lines
Quoted 3 lines
There is a patch here to fix it in kvm, https://lkml.org/lkml/2017/7/30/72
Quoted 1 line
I was affected by sipi, kernel never report valid sipi to user space,
we don't care whether sipi is lost after migration. Why?
Please refer to Paolo's suggestion,
https://www.mail-archive.com/[email protected]/msg464882.html
Regards,
Wanpeng Li
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
arch/x86/kvm/x86.c +0
-3-else -clear_bit (KVM_APIC_INIT , &vcpu->arch.apic->pending_events); - }}