diff mbox

target-i386 : fix a race condition result to lost INIT

Message ID 1501444898-27668-1-git-send-email-peng.hao2@zte.com.cn (mailing list archive)
State New, archived
Headers show

Commit Message

Peng Hao July 30, 2017, 8:01 p.m. UTC
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=0
 send INIT to vcpu1
   set vcpu1's pending_events
                               kvm_vcpu_ioctl_x86_set_vcpu_events
                                    events->smi.latched_init == 0
                                      clear INIT in pending_events
considering migration, just at level >= KVM_PUT_RESET_STATE,
add KVM_VCPUEVENT_VALID_SMM in events.flags.I think it is better to
modify in qemu.

Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
---
 target/i386/kvm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Wanpeng Li July 30, 2017, 12:40 p.m. UTC | #1
2017-07-31 4:01 GMT+08:00 Peng Hao <peng.hao2@zte.com.cn>:
> 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=0
>  send INIT to vcpu1
>    set vcpu1's pending_events
>                                kvm_vcpu_ioctl_x86_set_vcpu_events
>                                     events->smi.latched_init == 0
>                                       clear INIT in pending_events
> considering migration, just at level >= KVM_PUT_RESET_STATE,
> add KVM_VCPUEVENT_VALID_SMM in events.flags.I think it is better to
> modify in qemu.

Do it in qemu just avoids to trigger the bug instead of fixing it. Why
we touch INIT pending if INIT is not latched in SMM?

Regards,
Wanpeng Li

>
> Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
> ---
>  target/i386/kvm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target/i386/kvm.c b/target/i386/kvm.c
> index a6613e1..be146cb 100644
> --- a/target/i386/kvm.c
> +++ b/target/i386/kvm.c
> @@ -2438,7 +2438,7 @@ static int kvm_put_vcpu_events(X86CPU *cpu, int level)
>          /* Stop SMI delivery on old machine types to avoid a reboot
>           * on an inward migration of an old VM.
>           */
> -        if (!cpu->kvm_no_smi_migration) {
> +        if (!cpu->kvm_no_smi_migration && (level >= KVM_PUT_RESET_STATE)) {
>              events.flags |= KVM_VCPUEVENT_VALID_SMM;
>          }
>      }
> --
> 1.8.3.1
>
>
diff mbox

Patch

diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index a6613e1..be146cb 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -2438,7 +2438,7 @@  static int kvm_put_vcpu_events(X86CPU *cpu, int level)
         /* Stop SMI delivery on old machine types to avoid a reboot
          * on an inward migration of an old VM.
          */
-        if (!cpu->kvm_no_smi_migration) {
+        if (!cpu->kvm_no_smi_migration && (level >= KVM_PUT_RESET_STATE)) {
             events.flags |= KVM_VCPUEVENT_VALID_SMM;
         }
     }