On Wed, 2015-12-16 at 15:53 +0000, Stefano Stabellini wrote:
> On Wed, 9 Dec 2015, Ian Campbell wrote:
> > Signed-off-by: Ian Campbell <ian.campb...@citrix.com>
> > ---
> >  xen/arch/arm/vtimer.c                  | 72
> > ++++++++++++++++++++++++++++++++++
> >  xen/include/public/arch-arm/hvm/save.h | 15 ++++++-
> >  2 files changed, 86 insertions(+), 1 deletion(-)
> > 
> > diff --git a/xen/arch/arm/vtimer.c b/xen/arch/arm/vtimer.c
> > index 629feb4..9dfc699 100644
> > --- a/xen/arch/arm/vtimer.c
> > +++ b/xen/arch/arm/vtimer.c
> > @@ -22,6 +22,7 @@
> >  #include <xen/timer.h>
> >  #include <xen/sched.h>
> >  #include <xen/perfc.h>
> > +#include <xen/hvm/save.h>
> >  #include <asm/div64.h>
> >  #include <asm/irq.h>
> >  #include <asm/time.h>
> > @@ -355,6 +356,77 @@ int vtimer_emulate(struct cpu_user_regs *regs,
> > union hsr hsr)
> >      }
> >  }
> >  
> > +static int timer_save_one(hvm_domain_context_t *h,
> > +                          struct vcpu *v, struct vtimer *t,
> > +                          int type, uint64_t offset)
> > +{
> > +   struct hvm_hw_timer ctxt;
> > +
> > +   ctxt.cval = t->cval;
> > +   ctxt.ctl = t->ctl;
> > +   ctxt.vtb_offset = offset;
> > +   ctxt.type = type;
> > +   if ( hvm_save_entry(A15_TIMER, v->vcpu_id, h, &ctxt) != 0 )
> > +       return 1;
> > +   return 0;
> > +}
> > +
> > +static int timer_save(struct domain *d, hvm_domain_context_t *h)
> > +{
> > +    struct vcpu *v;
> > +
> > +    /* Save the state of vtimer and ptimer */
> > +    for_each_vcpu( d, v )
> > +    {
> > +        timer_save_one(h, v, &v->arch.phys_timer,
> > +                       HVM_SAVE_TIMER_TYPE_PHYS, d-
> > >arch.phys_timer_base.offset);
> > +        timer_save_one(h, v, &v->arch.virt_timer,
> > +                       HVM_SAVE_TIMER_TYPE_VIRT, d-
> > >arch.virt_timer_base.offset);
> > +    }
> 
> I don't think we should save phys_timer_base.offset and
> virt_timer_base.offset: they represent host specific offsets. I think we
> need to save:
> 
> phys_timer:
>     ctxt.offset = NOW() - d->arch.phys_timer_base.offset;
> virt_timer:
>     ctxt.offset = READ_SYSREG64(CNTPCT_EL0) - d-
> >arch.virt_timer_base.offset

Yes, I meant to come back to this (and the restore side) with a bigger
thinking cap on and forgot.
 
> > +#define HVM_SAVE_TIMER_TYPE_VIRT 0
> > +#define HVM_SAVE_TIMER_TYPE_PHYS 1
> > +
> > +struct hvm_hw_timer
> > +{
> > +    uint64_t vtb_offset; /* XXX Should be abs time since guest booted
> > */
> 
> I would call this simply "offset" with a comment

OK. The comment here was supposed to remind me about the bigger thinking
cap. Oops.

> > +    uint32_t ctl;
> > +    uint64_t cval;
> > +    uint32_t type;
> 
> Isn't a uint32_t a bit too much for one bit?
> Don't we need to save and restore the PPIs too?

This is an ABI, so I wanted to avoid bit fields etc, I could make it a
uint8_t but then array alignment gets interesting. Really I guess this is
actually a uint8_t and 3 bytes of padding.

I don't think the save record format has density of the information as a
particularly high priority though.

The PPI state is saved by the GIC. Perhaps we should save the actual number
used by the guest here though.

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

Reply via email to