From patchwork Fri Aug 23 12:26:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hogan X-Patchwork-Id: 2848774 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 397F79F271 for ; Fri, 23 Aug 2013 12:27:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1CF1920345 for ; Fri, 23 Aug 2013 12:27:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 04CFB2034E for ; Fri, 23 Aug 2013 12:27:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755198Ab3HWM1x (ORCPT ); Fri, 23 Aug 2013 08:27:53 -0400 Received: from multi.imgtec.com ([194.200.65.239]:17851 "EHLO multi.imgtec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753452Ab3HWM1w (ORCPT ); Fri, 23 Aug 2013 08:27:52 -0400 From: James Hogan To: CC: James Hogan , Gleb Natapov , Paolo Bonzini , Subject: [PATCH] kvm: sync cpu state on internal error before dump Date: Fri, 23 Aug 2013 13:26:00 +0100 Message-ID: <1377260760-32056-1-git-send-email-james.hogan@imgtec.com> X-Mailer: git-send-email 1.8.1.2 MIME-Version: 1.0 X-Originating-IP: [192.168.154.65] X-SEF-Processed: 7_3_0_01192__2013_08_23_13_27_49 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When a KVM internal error occurs QEMU dumps the CPU state, however it doesn't synchronise the state from KVM first so the dumped state is out of date. Add the synchronisation calls before the dump in both locations (which is used depends on whether the arch says to stop or not). Note that x86 does a sync in its kvm_arch_stop_on_emulation_error() function so at least for emulation errors is unaffected. Signed-off-by: James Hogan Cc: Gleb Natapov Cc: Paolo Bonzini Cc: kvm@vger.kernel.org --- kvm-all.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kvm-all.c b/kvm-all.c index b788fcd..803141a 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1546,6 +1546,7 @@ static int kvm_handle_internal_error(CPUState *cpu, struct kvm_run *run) if (run->internal.suberror == KVM_INTERNAL_ERROR_EMULATION) { fprintf(stderr, "emulation failure\n"); if (!kvm_arch_stop_on_emulation_error(cpu)) { + kvm_cpu_synchronize_state(cpu); cpu_dump_state(cpu, stderr, fprintf, CPU_DUMP_CODE); return EXCP_INTERRUPT; } @@ -1701,6 +1702,7 @@ int kvm_cpu_exec(CPUState *cpu) } while (ret == 0); if (ret < 0) { + kvm_cpu_synchronize_state(cpu); cpu_dump_state(cpu, stderr, fprintf, CPU_DUMP_CODE); vm_stop(RUN_STATE_INTERNAL_ERROR); }