From patchwork Sun Jul 30 20:01:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Hao X-Patchwork-Id: 9870451 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 448BD6037D for ; Sun, 30 Jul 2017 11:49:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CE072832B for ; Sun, 30 Jul 2017 11:49:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1FA60285B8; Sun, 30 Jul 2017 11:49:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00, DATE_IN_FUTURE_06_12, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8D29C2832B for ; Sun, 30 Jul 2017 11:49:28 +0000 (UTC) Received: from localhost ([::1]:54932 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dbmiu-0004HT-2w for patchwork-qemu-devel@patchwork.kernel.org; Sun, 30 Jul 2017 07:49:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dbmiD-0004F1-Vw for qemu-devel@nongnu.org; Sun, 30 Jul 2017 07:48:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dbmiA-00068O-Sh for qemu-devel@nongnu.org; Sun, 30 Jul 2017 07:48:46 -0400 Received: from out1.zte.com.cn ([202.103.147.172]:51882) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dbmiA-00065h-9B for qemu-devel@nongnu.org; Sun, 30 Jul 2017 07:48:42 -0400 X-scanvirus: By SEG_CYREN AntiVirus Engine X-scanresult: CLEAN X-MAILFROM: X-RCPTTO: X-FROMIP: 10.30.3.20 X-SEG-Scaned: 1 X-Received: unknown,10.30.3.20,20170730194641 Received: from unknown (HELO mse01.zte.com.cn) (10.30.3.20) by localhost with (AES256-SHA encrypted) SMTP; 30 Jul 2017 11:46:41 -0000 Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id v6UBmMkB095090; Sun, 30 Jul 2017 19:48:22 +0800 (GMT-8) (envelope-from peng.hao2@zte.com.cn) Received: from localhost.localdomain ([10.74.120.59]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2017073019483123-305636 ; Sun, 30 Jul 2017 19:48:31 +0800 From: Peng Hao To: pbonzini@redhat.com, mtosatti@redhat.com, rth@twiddle.net, ehabkost@redhat.com Date: Mon, 31 Jul 2017 04:01:38 +0800 Message-Id: <1501444898-27668-1-git-send-email-peng.hao2@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-07-30 19:48:31, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2017-07-30 19:48:20, Serialize complete at 2017-07-30 19:48:20 X-MAIL: mse01.zte.com.cn v6UBmMkB095090 X-HQIP: 127.0.0.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 202.103.147.172 Subject: [Qemu-devel] [PATCH] target-i386 : fix a race condition result to lost INIT X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peng Hao , qemu-devel@nongnu.org, kvm@vger.kernel.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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; } }