qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] kvmvapic: patch_instruction fix
@ 2014-10-30  9:31 Pavel Dovgalyuk
  2014-10-30 11:15 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Dovgalyuk @ 2014-10-30  9:31 UTC (permalink / raw)
  To: qemu-devel
  Cc: mark.burton, batuzovk, maria.klimushenkova, pavel.dovgaluk,
	pbonzini, zealot351, fred.konrad

When QEMU works in icount mode cpu_restore_state function performs two actions:
restoring the program counter and updating icount to the correct value.
kvmvapic's patch_instruction function is called by cpu_report_tpr_access
function which also invokes cpu_restore_state. It results to calling
cpu_restore_state twice - in cpu_report_tpr_access and in patch_instruction.
When icount is disabled second call is safe. But when icount is enabled,
cpu_restore_state modifies instructions counter twice, which leads to incorrect
behavior. This patch removes useless cpu_restore_state call from kvmvapic.

Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
---
 hw/i386/kvmvapic.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c
index f9da050..28547a7 100644
--- a/hw/i386/kvmvapic.c
+++ b/hw/i386/kvmvapic.c
@@ -405,7 +405,6 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
     }
 
     if (!kvm_enabled()) {
-        cpu_restore_state(cs, cs->mem_io_pc);
         cpu_get_tb_cpu_state(env, &current_pc, &current_cs_base,
                              &current_flags);
     }

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

* Re: [Qemu-devel] [PATCH] kvmvapic: patch_instruction fix
  2014-10-30  9:31 [Qemu-devel] [PATCH] kvmvapic: patch_instruction fix Pavel Dovgalyuk
@ 2014-10-30 11:15 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2014-10-30 11:15 UTC (permalink / raw)
  To: Pavel Dovgalyuk, qemu-devel
  Cc: fred.konrad, zealot351, maria.klimushenkova, mark.burton,
	batuzovk



On 10/30/2014 10:31 AM, Pavel Dovgalyuk wrote:
> When QEMU works in icount mode cpu_restore_state function performs two actions:
> restoring the program counter and updating icount to the correct value.
> kvmvapic's patch_instruction function is called by cpu_report_tpr_access
> function which also invokes cpu_restore_state. It results to calling
> cpu_restore_state twice - in cpu_report_tpr_access and in patch_instruction.
> When icount is disabled second call is safe. But when icount is enabled,
> cpu_restore_state modifies instructions counter twice, which leads to incorrect
> behavior. This patch removes useless cpu_restore_state call from kvmvapic.
> 
> Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
> ---
>  hw/i386/kvmvapic.c |    1 -
>  1 files changed, 0 insertions(+), 1 deletions(-)
> 
> diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c
> index f9da050..28547a7 100644
> --- a/hw/i386/kvmvapic.c
> +++ b/hw/i386/kvmvapic.c
> @@ -405,7 +405,6 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
>      }
>  
>      if (!kvm_enabled()) {
> -        cpu_restore_state(cs, cs->mem_io_pc);
>          cpu_get_tb_cpu_state(env, &current_pc, &current_cs_base,
>                               &current_flags);
>      }
> 

Thanks, applying.

Paolo

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

end of thread, other threads:[~2014-10-30 11:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-30  9:31 [Qemu-devel] [PATCH] kvmvapic: patch_instruction fix Pavel Dovgalyuk
2014-10-30 11:15 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).