All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kvm: sync cpu state on internal error before dump
@ 2013-08-23 12:26 ` James Hogan
  0 siblings, 0 replies; 9+ messages in thread
From: James Hogan @ 2013-08-23 12:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: James Hogan, Gleb Natapov, Paolo Bonzini, kvm

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



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH] kvm: sync cpu state on internal error before dump
@ 2013-08-23 12:26 ` James Hogan
  0 siblings, 0 replies; 9+ messages in thread
From: James Hogan @ 2013-08-23 12:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, James Hogan, kvm, Gleb Natapov

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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] kvm: sync cpu state on internal error before dump
  2013-08-23 12:26 ` [Qemu-devel] " James Hogan
@ 2013-08-23 12:58   ` Gleb Natapov
  -1 siblings, 0 replies; 9+ messages in thread
From: Gleb Natapov @ 2013-08-23 12:58 UTC (permalink / raw)
  To: James Hogan; +Cc: qemu-devel, Paolo Bonzini, kvm

On Fri, Aug 23, 2013 at 01:26:00PM +0100, James Hogan wrote:
> 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).
> 
x86_cpu_dump_state() calls cpu_synchronize_state() already.

> 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
> 

--
			Gleb.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] kvm: sync cpu state on internal error before dump
@ 2013-08-23 12:58   ` Gleb Natapov
  0 siblings, 0 replies; 9+ messages in thread
From: Gleb Natapov @ 2013-08-23 12:58 UTC (permalink / raw)
  To: James Hogan; +Cc: Paolo Bonzini, qemu-devel, kvm

On Fri, Aug 23, 2013 at 01:26:00PM +0100, James Hogan wrote:
> 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).
> 
x86_cpu_dump_state() calls cpu_synchronize_state() already.

> 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
> 

--
			Gleb.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] kvm: sync cpu state on internal error before dump
  2013-08-23 12:58   ` [Qemu-devel] " Gleb Natapov
@ 2013-08-23 13:41     ` James Hogan
  -1 siblings, 0 replies; 9+ messages in thread
From: James Hogan @ 2013-08-23 13:41 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: qemu-devel, Paolo Bonzini, kvm

On 23/08/13 13:58, Gleb Natapov wrote:
> On Fri, Aug 23, 2013 at 01:26:00PM +0100, James Hogan wrote:
>> 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).
>>
> x86_cpu_dump_state() calls cpu_synchronize_state() already.

Ah yes, thanks. I hadn't noticed that.

Out of the arches that support KVM only x86 and ppc call it. arm, mips
(qemu support not upstream yet), and s390 don't. s390 never seems to
emit that exit code, and arm only does so for unsupported exceptions
(which should never happen).

I'll fix in mips_cpu_dump_state() instead.

Cheers
James


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] kvm: sync cpu state on internal error before dump
@ 2013-08-23 13:41     ` James Hogan
  0 siblings, 0 replies; 9+ messages in thread
From: James Hogan @ 2013-08-23 13:41 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: Paolo Bonzini, qemu-devel, kvm

On 23/08/13 13:58, Gleb Natapov wrote:
> On Fri, Aug 23, 2013 at 01:26:00PM +0100, James Hogan wrote:
>> 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).
>>
> x86_cpu_dump_state() calls cpu_synchronize_state() already.

Ah yes, thanks. I hadn't noticed that.

Out of the arches that support KVM only x86 and ppc call it. arm, mips
(qemu support not upstream yet), and s390 don't. s390 never seems to
emit that exit code, and arm only does so for unsupported exceptions
(which should never happen).

I'll fix in mips_cpu_dump_state() instead.

Cheers
James

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] kvm: sync cpu state on internal error before dump
  2013-08-23 13:41     ` [Qemu-devel] " James Hogan
@ 2013-08-24 10:37       ` Gleb Natapov
  -1 siblings, 0 replies; 9+ messages in thread
From: Gleb Natapov @ 2013-08-24 10:37 UTC (permalink / raw)
  To: James Hogan; +Cc: qemu-devel, Paolo Bonzini, kvm

On Fri, Aug 23, 2013 at 02:41:13PM +0100, James Hogan wrote:
> On 23/08/13 13:58, Gleb Natapov wrote:
> > On Fri, Aug 23, 2013 at 01:26:00PM +0100, James Hogan wrote:
> >> 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).
> >>
> > x86_cpu_dump_state() calls cpu_synchronize_state() already.
> 
> Ah yes, thanks. I hadn't noticed that.
> 
> Out of the arches that support KVM only x86 and ppc call it. arm, mips
> (qemu support not upstream yet), and s390 don't. s390 never seems to
> emit that exit code, and arm only does so for unsupported exceptions
> (which should never happen).
> 
> I'll fix in mips_cpu_dump_state() instead.
> 
Moving cpu_synchronize_state() up to cpu_dump_state() would be better.

--
			Gleb.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] kvm: sync cpu state on internal error before dump
@ 2013-08-24 10:37       ` Gleb Natapov
  0 siblings, 0 replies; 9+ messages in thread
From: Gleb Natapov @ 2013-08-24 10:37 UTC (permalink / raw)
  To: James Hogan; +Cc: Paolo Bonzini, qemu-devel, kvm

On Fri, Aug 23, 2013 at 02:41:13PM +0100, James Hogan wrote:
> On 23/08/13 13:58, Gleb Natapov wrote:
> > On Fri, Aug 23, 2013 at 01:26:00PM +0100, James Hogan wrote:
> >> 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).
> >>
> > x86_cpu_dump_state() calls cpu_synchronize_state() already.
> 
> Ah yes, thanks. I hadn't noticed that.
> 
> Out of the arches that support KVM only x86 and ppc call it. arm, mips
> (qemu support not upstream yet), and s390 don't. s390 never seems to
> emit that exit code, and arm only does so for unsupported exceptions
> (which should never happen).
> 
> I'll fix in mips_cpu_dump_state() instead.
> 
Moving cpu_synchronize_state() up to cpu_dump_state() would be better.

--
			Gleb.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] kvm: sync cpu state on internal error before dump
  2013-08-24 10:37       ` [Qemu-devel] " Gleb Natapov
  (?)
@ 2013-08-24 17:28       ` Andreas Färber
  -1 siblings, 0 replies; 9+ messages in thread
From: Andreas Färber @ 2013-08-24 17:28 UTC (permalink / raw)
  To: Gleb Natapov, James Hogan; +Cc: Paolo Bonzini, qemu-devel, kvm

Am 24.08.2013 12:37, schrieb Gleb Natapov:
> On Fri, Aug 23, 2013 at 02:41:13PM +0100, James Hogan wrote:
>> On 23/08/13 13:58, Gleb Natapov wrote:
>>> On Fri, Aug 23, 2013 at 01:26:00PM +0100, James Hogan wrote:
>>>> 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).
>>>>
>>> x86_cpu_dump_state() calls cpu_synchronize_state() already.
>>
>> Ah yes, thanks. I hadn't noticed that.
>>
>> Out of the arches that support KVM only x86 and ppc call it. arm, mips
>> (qemu support not upstream yet), and s390 don't. s390 never seems to
>> emit that exit code, and arm only does so for unsupported exceptions
>> (which should never happen).
>>
>> I'll fix in mips_cpu_dump_state() instead.
>>
> Moving cpu_synchronize_state() up to cpu_dump_state() would be better.

Yes, please. I did not review the hooks themselves much, just avoided
global functions.

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-08-24 17:28 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-23 12:26 [PATCH] kvm: sync cpu state on internal error before dump James Hogan
2013-08-23 12:26 ` [Qemu-devel] " 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

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.