diff mbox

[RFC,v4,06/25] cpu-exec: reset exception_index correctly

Message ID 20141107103201.6136.89187.stgit@PASHA-ISP
State New
Headers show

Commit Message

Pavel Dovgalyuk Nov. 7, 2014, 10:32 a.m. UTC
Exception index is reset at every entry at every entry into cpu_exec()
function. This may cause missing the exceptions while replaying them.
This patch moves exception_index reset to the locations where they are
processed.

Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
---
 cpu-exec.c |    2 +-
 cpus.c     |    1 +
 2 files changed, 2 insertions(+), 1 deletions(-)

Comments

Paolo Bonzini Nov. 7, 2014, 11:27 a.m. UTC | #1
On 07/11/2014 11:32, Pavel Dovgalyuk wrote:
> Exception index is reset at every entry at every entry into cpu_exec()
> function. This may cause missing the exceptions while replaying them.
> This patch moves exception_index reset to the locations where they are
> processed.
> 
> Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
> ---
>  cpu-exec.c |    2 +-
>  cpus.c     |    1 +
>  2 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/cpu-exec.c b/cpu-exec.c
> index 8830255..011f51f 100644
> --- a/cpu-exec.c
> +++ b/cpu-exec.c
> @@ -358,7 +358,6 @@ int cpu_exec(CPUArchState *env)
>      }
>  
>      cc->cpu_exec_enter(cpu);
> -    cpu->exception_index = -1;
>  
>      /* Calculate difference between guest clock and host clock.
>       * This delay includes the delay of the last cycle, so
> @@ -378,6 +377,7 @@ int cpu_exec(CPUArchState *env)
>                      if (ret == EXCP_DEBUG) {
>                          cpu_handle_debug_exception(env);
>                      }
> +                    cpu->exception_index = -1;
>                      break;
>                  } else {
>  #if defined(CONFIG_USER_ONLY)
> diff --git a/cpus.c b/cpus.c
> index e53d605..7e8c507 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -1016,6 +1016,7 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
>      CPU_FOREACH(cpu) {
>          cpu->thread_id = qemu_get_thread_id();
>          cpu->created = true;
> +        cpu->exception_index = -1;
>      }
>      qemu_cond_signal(&qemu_cpu_cond);
>  
> 

Thanks, I queued this for 2.3 already.

Paolo
Paolo Bonzini Nov. 12, 2014, 12:02 p.m. UTC | #2
On 07/11/2014 11:32, Pavel Dovgalyuk wrote:
> Exception index is reset at every entry at every entry into cpu_exec()
> function. This may cause missing the exceptions while replaying them.
> This patch moves exception_index reset to the locations where they are
> processed.
> 
> Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
> ---
>  cpu-exec.c |    2 +-
>  cpus.c     |    1 +
>  2 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/cpu-exec.c b/cpu-exec.c
> index 8830255..011f51f 100644
> --- a/cpu-exec.c
> +++ b/cpu-exec.c
> @@ -358,7 +358,6 @@ int cpu_exec(CPUArchState *env)
>      }
>  
>      cc->cpu_exec_enter(cpu);
> -    cpu->exception_index = -1;
>  
>      /* Calculate difference between guest clock and host clock.
>       * This delay includes the delay of the last cycle, so
> @@ -378,6 +377,7 @@ int cpu_exec(CPUArchState *env)
>                      if (ret == EXCP_DEBUG) {
>                          cpu_handle_debug_exception(env);
>                      }
> +                    cpu->exception_index = -1;
>                      break;
>                  } else {
>  #if defined(CONFIG_USER_ONLY)
> diff --git a/cpus.c b/cpus.c
> index e53d605..7e8c507 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -1016,6 +1016,7 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
>      CPU_FOREACH(cpu) {
>          cpu->thread_id = qemu_get_thread_id();
>          cpu->created = true;
> +        cpu->exception_index = -1;
>      }
>      qemu_cond_signal(&qemu_cpu_cond);
>  
> 
> 
> 

What about user-mode emulation?  Do you need to reset
cpu->exception_index for it too?

Paolo
Pavel Dovgalyuk Nov. 13, 2014, 11:41 a.m. UTC | #3
> From: Paolo Bonzini [mailto:paolo.bonzini@gmail.com] On Behalf Of Paolo Bonzini
> On 07/11/2014 11:32, Pavel Dovgalyuk wrote:
> > Exception index is reset at every entry at every entry into cpu_exec()
> > function. This may cause missing the exceptions while replaying them.
> > This patch moves exception_index reset to the locations where they are
> > processed.
> >
> > Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
> > ---
> >  cpu-exec.c |    2 +-
> >  cpus.c     |    1 +
> >  2 files changed, 2 insertions(+), 1 deletions(-)
> >
> > diff --git a/cpu-exec.c b/cpu-exec.c
> > index 8830255..011f51f 100644
> > --- a/cpu-exec.c
> > +++ b/cpu-exec.c
> > @@ -358,7 +358,6 @@ int cpu_exec(CPUArchState *env)
> >      }
> >
> >      cc->cpu_exec_enter(cpu);
> > -    cpu->exception_index = -1;
> >
> >      /* Calculate difference between guest clock and host clock.
> >       * This delay includes the delay of the last cycle, so
> > @@ -378,6 +377,7 @@ int cpu_exec(CPUArchState *env)
> >                      if (ret == EXCP_DEBUG) {
> >                          cpu_handle_debug_exception(env);
> >                      }
> > +                    cpu->exception_index = -1;
> >                      break;
> >                  } else {
> >  #if defined(CONFIG_USER_ONLY)
> > diff --git a/cpus.c b/cpus.c
> > index e53d605..7e8c507 100644
> > --- a/cpus.c
> > +++ b/cpus.c
> > @@ -1016,6 +1016,7 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
> >      CPU_FOREACH(cpu) {
> >          cpu->thread_id = qemu_get_thread_id();
> >          cpu->created = true;
> > +        cpu->exception_index = -1;
> >      }
> >      qemu_cond_signal(&qemu_cpu_cond);
> >
> >
> >
> >
> 
> What about user-mode emulation?  Do you need to reset
> cpu->exception_index for it too?

Thank you, I missed that.

Pavel Dovgalyuk
diff mbox

Patch

diff --git a/cpu-exec.c b/cpu-exec.c
index 8830255..011f51f 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -358,7 +358,6 @@  int cpu_exec(CPUArchState *env)
     }
 
     cc->cpu_exec_enter(cpu);
-    cpu->exception_index = -1;
 
     /* Calculate difference between guest clock and host clock.
      * This delay includes the delay of the last cycle, so
@@ -378,6 +377,7 @@  int cpu_exec(CPUArchState *env)
                     if (ret == EXCP_DEBUG) {
                         cpu_handle_debug_exception(env);
                     }
+                    cpu->exception_index = -1;
                     break;
                 } else {
 #if defined(CONFIG_USER_ONLY)
diff --git a/cpus.c b/cpus.c
index e53d605..7e8c507 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1016,6 +1016,7 @@  static void *qemu_tcg_cpu_thread_fn(void *arg)
     CPU_FOREACH(cpu) {
         cpu->thread_id = qemu_get_thread_id();
         cpu->created = true;
+        cpu->exception_index = -1;
     }
     qemu_cond_signal(&qemu_cpu_cond);