Patchwork [2/3] Reset qemu timers when guest reset

login
register
mail settings
Submitter Bharat Bhushan
Date Dec. 17, 2012, 6:08 a.m.
Message ID <1355724498-15164-3-git-send-email-bharat.bhushan@freescale.com>
Download mbox | patch
Permalink /patch/206778/
State New
Headers show

Comments

Bharat Bhushan - Dec. 17, 2012, 6:08 a.m.
This patch install the timer reset handler. This will be called when
the guest is reset.

Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com>
---
 hw/ppc_booke.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
Alexander Graf - Dec. 17, 2012, 2:22 p.m.
On 17.12.2012, at 07:08, Bharat Bhushan wrote:

> This patch install the timer reset handler. This will be called when
> the guest is reset.
> 
> Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com>
> ---
> hw/ppc_booke.c |   12 ++++++++++++
> 1 files changed, 12 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/ppc_booke.c b/hw/ppc_booke.c
> index d51e7fa..837a5b6 100644
> --- a/hw/ppc_booke.c
> +++ b/hw/ppc_booke.c
> @@ -231,6 +231,16 @@ void store_booke_tcr(CPUPPCState *env, target_ulong val)
> 
> }
> 
> +static void ppc_booke_timer_reset_handle(void *opaque)
> +{
> +    CPUPPCState *env = opaque;
> +

Doesn't this need a cpu_synchronize_state() call?

Alex

> +    env->spr[SPR_BOOKE_TSR] = 0;
> +    env->spr[SPR_BOOKE_TCR] = 0;
> +
> +    booke_update_irq(env);
> +}
> +
> void ppc_booke_timers_init(CPUPPCState *env, uint32_t freq, uint32_t flags)
> {
>     ppc_tb_t *tb_env;
> @@ -251,4 +261,6 @@ void ppc_booke_timers_init(CPUPPCState *env, uint32_t freq, uint32_t flags)
>         qemu_new_timer_ns(vm_clock, &booke_fit_cb, env);
>     booke_timer->wdt_timer =
>         qemu_new_timer_ns(vm_clock, &booke_wdt_cb, env);
> +
> +    qemu_register_reset(ppc_booke_timer_reset_handle, env);
> }
> -- 
> 1.7.0.4
> 
>
Bharat Bhushan - Dec. 17, 2012, 3:09 p.m.
> -----Original Message-----
> From: Alexander Graf [mailto:agraf@suse.de]
> Sent: Monday, December 17, 2012 7:53 PM
> To: Bhushan Bharat-R65777
> Cc: qemu-devel@nongnu.org; qemu-ppc@nongnu.org; Bhushan Bharat-R65777
> Subject: Re: [PATCH 2/3] Reset qemu timers when guest reset
> 
> 
> On 17.12.2012, at 07:08, Bharat Bhushan wrote:
> 
> > This patch install the timer reset handler. This will be called when
> > the guest is reset.
> >
> > Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com>
> > ---
> > hw/ppc_booke.c |   12 ++++++++++++
> > 1 files changed, 12 insertions(+), 0 deletions(-)
> >
> > diff --git a/hw/ppc_booke.c b/hw/ppc_booke.c index d51e7fa..837a5b6
> > 100644
> > --- a/hw/ppc_booke.c
> > +++ b/hw/ppc_booke.c
> > @@ -231,6 +231,16 @@ void store_booke_tcr(CPUPPCState *env,
> > target_ulong val)
> >
> > }
> >
> > +static void ppc_booke_timer_reset_handle(void *opaque) {
> > +    CPUPPCState *env = opaque;
> > +
> 
> Doesn't this need a cpu_synchronize_state() call?

There are some more registered reset_handler which changes the spr's but does not call synchronize..

But is not the qemu_system_reset() ( which calls registered reset handler) synchronizes the cpu state ?

-Bharat

> 
> Alex
> 
> > +    env->spr[SPR_BOOKE_TSR] = 0;
> > +    env->spr[SPR_BOOKE_TCR] = 0;
> > +
> > +    booke_update_irq(env);
> > +}
> > +
> > void ppc_booke_timers_init(CPUPPCState *env, uint32_t freq, uint32_t
> > flags) {
> >     ppc_tb_t *tb_env;
> > @@ -251,4 +261,6 @@ void ppc_booke_timers_init(CPUPPCState *env, uint32_t
> freq, uint32_t flags)
> >         qemu_new_timer_ns(vm_clock, &booke_fit_cb, env);
> >     booke_timer->wdt_timer =
> >         qemu_new_timer_ns(vm_clock, &booke_wdt_cb, env);
> > +
> > +    qemu_register_reset(ppc_booke_timer_reset_handle, env);
> > }
> > --
> > 1.7.0.4
> >
> >
>
Alexander Graf - Dec. 17, 2012, 3:13 p.m.
On 17.12.2012, at 16:09, Bhushan Bharat-R65777 wrote:

> 
> 
>> -----Original Message-----
>> From: Alexander Graf [mailto:agraf@suse.de]
>> Sent: Monday, December 17, 2012 7:53 PM
>> To: Bhushan Bharat-R65777
>> Cc: qemu-devel@nongnu.org; qemu-ppc@nongnu.org; Bhushan Bharat-R65777
>> Subject: Re: [PATCH 2/3] Reset qemu timers when guest reset
>> 
>> 
>> On 17.12.2012, at 07:08, Bharat Bhushan wrote:
>> 
>>> This patch install the timer reset handler. This will be called when
>>> the guest is reset.
>>> 
>>> Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com>
>>> ---
>>> hw/ppc_booke.c |   12 ++++++++++++
>>> 1 files changed, 12 insertions(+), 0 deletions(-)
>>> 
>>> diff --git a/hw/ppc_booke.c b/hw/ppc_booke.c index d51e7fa..837a5b6
>>> 100644
>>> --- a/hw/ppc_booke.c
>>> +++ b/hw/ppc_booke.c
>>> @@ -231,6 +231,16 @@ void store_booke_tcr(CPUPPCState *env,
>>> target_ulong val)
>>> 
>>> }
>>> 
>>> +static void ppc_booke_timer_reset_handle(void *opaque) {
>>> +    CPUPPCState *env = opaque;
>>> +
>> 
>> Doesn't this need a cpu_synchronize_state() call?
> 
> There are some more registered reset_handler which changes the spr's but does not call synchronize..
> 
> But is not the qemu_system_reset() ( which calls registered reset handler) synchronizes the cpu state ?

Probably :). Just wanted to make sure it's left out on purpose.


Alex

Patch

diff --git a/hw/ppc_booke.c b/hw/ppc_booke.c
index d51e7fa..837a5b6 100644
--- a/hw/ppc_booke.c
+++ b/hw/ppc_booke.c
@@ -231,6 +231,16 @@  void store_booke_tcr(CPUPPCState *env, target_ulong val)
 
 }
 
+static void ppc_booke_timer_reset_handle(void *opaque)
+{
+    CPUPPCState *env = opaque;
+
+    env->spr[SPR_BOOKE_TSR] = 0;
+    env->spr[SPR_BOOKE_TCR] = 0;
+
+    booke_update_irq(env);
+}
+
 void ppc_booke_timers_init(CPUPPCState *env, uint32_t freq, uint32_t flags)
 {
     ppc_tb_t *tb_env;
@@ -251,4 +261,6 @@  void ppc_booke_timers_init(CPUPPCState *env, uint32_t freq, uint32_t flags)
         qemu_new_timer_ns(vm_clock, &booke_fit_cb, env);
     booke_timer->wdt_timer =
         qemu_new_timer_ns(vm_clock, &booke_wdt_cb, env);
+
+    qemu_register_reset(ppc_booke_timer_reset_handle, env);
 }