From patchwork Fri Dec 19 11:53:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 422865 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9E2511400A0 for ; Fri, 19 Dec 2014 22:54:24 +1100 (AEDT) Received: from localhost ([::1]:57991 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1w8U-00055E-Tf for incoming@patchwork.ozlabs.org; Fri, 19 Dec 2014 06:54:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36155) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1w7g-0003a5-BS for qemu-devel@nongnu.org; Fri, 19 Dec 2014 06:53:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y1w7a-0007Y1-J9 for qemu-devel@nongnu.org; Fri, 19 Dec 2014 06:53:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60102) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1w7a-0007Xr-Ar; Fri, 19 Dec 2014 06:53:26 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sBJBrPDA013192 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 19 Dec 2014 06:53:25 -0500 Received: from playground.com (ovpn-112-26.ams2.redhat.com [10.36.112.26]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sBJBrGPW004994; Fri, 19 Dec 2014 06:53:23 -0500 From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 19 Dec 2014 12:53:14 +0100 Message-Id: <1418989994-17244-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1418989994-17244-1-git-send-email-pbonzini@redhat.com> References: <1418989994-17244-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: imammedo@redhat.com, qemu-stable@nongnu.org, ehabkost@redhat.com, dgilbert@redhat.com Subject: [Qemu-devel] [PATCH 2/2] exec: change default exception_index value for migration to -1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org In QEMU 2.2 the exception_index value was added to the migration stream through a subsection. The default was set to 0, which is wrong and should have been -1. However, 2.2 does not have commit e511b4d (cpu-exec: reset exception_index correctly, 2014-11-26), hence in 2.2 the exception_index is never used and is set to -1 on the next call to cpu_exec. So we can change the migration stream to make the default -1. The effects are: - 2.2.1 -> 2.2.0: cpu->exception_index set incorrectly to 0 if it were -1 on the source; then reset to -1 in cpu_exec. This is TCG only; KVM does not use exception_index. - 2.2.0 -> 2.2.1: cpu->exception_index set incorrectly to -1 if it were 0 on the source; but it would be reset to -1 in cpu_exec anyway. This is TCG only; KVM does not use exception_index. - 2.2.1 -> 2.1: two bugs fixed: 1) can migrate backwards if cpu->exception_index is set to -1; 2) should not migrate backwards (but 2.2.0 allows it) if cpu->exception_index is set to 0 - 2.2.0 -> 2.3.0: 2.2.0 will send the subsection unnecessarily if exception_index is -1, but that is not a problem. 2.3.0 will set cpu->exception_index to -1 if it is 0 on the source, but this would be anyway a problem for 2.2.0 -> 2.2.x migration (due to lack of commit e511b4d in 2.2.x) so we can ignore it - 2.2.1 -> 2.3.0: everything works. In addition, play it safe and never send the subsection unless TCG is in use. KVM does not use exception_index (PPC KVM stores values in it for use in the subsequent call to ppc_cpu_do_interrupt, but does not need it as soon as kvm_handle_debug returns). Xen and qtest do not run any code for the CPU at all. Reported-by: Igor Mammedov Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini --- exec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exec.c b/exec.c index 963481a..c2ed10a 100644 --- a/exec.c +++ b/exec.c @@ -434,7 +434,7 @@ static int cpu_common_pre_load(void *opaque) { CPUState *cpu = opaque; - cpu->exception_index = 0; + cpu->exception_index = -1; return 0; } @@ -443,7 +443,7 @@ static bool cpu_common_exception_index_needed(void *opaque) { CPUState *cpu = opaque; - return cpu->exception_index != 0; + return tcg_enabled() && cpu->exception_index != -1; } static const VMStateDescription vmstate_cpu_common_exception_index = {