All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Hogan <james.hogan@imgtec.com>
To: <qemu-devel@nongnu.org>
Cc: James Hogan <james.hogan@imgtec.com>,
	Gleb Natapov <gleb@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>, <kvm@vger.kernel.org>
Subject: [PATCH] kvm: sync cpu state on internal error before dump
Date: Fri, 23 Aug 2013 13:26:00 +0100	[thread overview]
Message-ID: <1377260760-32056-1-git-send-email-james.hogan@imgtec.com> (raw)

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 <james.hogan@imgtec.com>
Cc: Gleb Natapov <gleb@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
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);
     }
-- 
1.8.1.2



WARNING: multiple messages have this Message-ID (diff)
From: James Hogan <james.hogan@imgtec.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	James Hogan <james.hogan@imgtec.com>,
	kvm@vger.kernel.org, Gleb Natapov <gleb@redhat.com>
Subject: [Qemu-devel] [PATCH] kvm: sync cpu state on internal error before dump
Date: Fri, 23 Aug 2013 13:26:00 +0100	[thread overview]
Message-ID: <1377260760-32056-1-git-send-email-james.hogan@imgtec.com> (raw)

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 <james.hogan@imgtec.com>
Cc: Gleb Natapov <gleb@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
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);
     }
-- 
1.8.1.2

             reply	other threads:[~2013-08-23 12:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-23 12:26 James Hogan [this message]
2013-08-23 12:26 ` [Qemu-devel] [PATCH] kvm: sync cpu state on internal error before dump James Hogan
2013-08-23 12:58 ` Gleb Natapov
2013-08-23 12:58   ` [Qemu-devel] " Gleb Natapov
2013-08-23 13:41   ` James Hogan
2013-08-23 13:41     ` [Qemu-devel] " James Hogan
2013-08-24 10:37     ` Gleb Natapov
2013-08-24 10:37       ` [Qemu-devel] " Gleb Natapov
2013-08-24 17:28       ` Andreas Färber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1377260760-32056-1-git-send-email-james.hogan@imgtec.com \
    --to=james.hogan@imgtec.com \
    --cc=gleb@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.