[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] RE: [PATCH v4 4/5] common/domain: add a domain context record for shared_info...
> -----Original Message----- [snip] > > diff --git a/xen/common/domain.c b/xen/common/domain.c > > index 7cc9526139..14e96c3bc2 100644 > > --- a/xen/common/domain.c > > +++ b/xen/common/domain.c > > @@ -33,6 +33,7 @@ > > #include <xen/xenoprof.h> > > #include <xen/irq.h> > > #include <xen/argo.h> > > +#include <xen/save.h> > > #include <asm/debugger.h> > > #include <asm/p2m.h> > > #include <asm/processor.h> > > @@ -1649,6 +1650,64 @@ int continue_hypercall_on_cpu( > > return 0; > > } > > > > +static int save_shared_info(const struct domain *d, struct domain_context > > *c, > > + bool dry_run) > > +{ > > + struct domain_shared_info_context ctxt = { > > +#ifdef CONFIG_COMPAT > > + .flags = has_32bit_shinfo(d) ? DOMAIN_SAVE_32BIT_SHINFO : 0, > > +#endif > > + .buffer_size = sizeof(shared_info_t), > > + }; > > + size_t hdr_size = offsetof(typeof(ctxt), buffer); > > + int rc; > > + > > + rc = DOMAIN_SAVE_BEGIN(SHARED_INFO, c, 0); > > + if ( rc ) > > + return rc; > > + > > + rc = domain_save_data(c, &ctxt, hdr_size); > > + if ( rc ) > > + return rc; > > + > > + rc = domain_save_data(c, d->shared_info, ctxt.buffer_size); > > + if ( rc ) > > + return rc; > > + > > + return domain_save_end(c); > > +} > > + > > +static int load_shared_info(struct domain *d, struct domain_context *c) > > +{ > > + struct domain_shared_info_context ctxt; > > + size_t hdr_size = offsetof(typeof(ctxt), buffer); > > + unsigned int i; > > + int rc; > > + > > + rc = DOMAIN_LOAD_BEGIN(SHARED_INFO, c, &i); > > + if ( rc || i ) /* expect only a single instance */ > > + return rc; > > This will return 0 if there is multiple instance. Is it intended? > No, it ought to be an error... probably ENOENT. > > + > > + rc = domain_load_data(c, &ctxt, hdr_size); > > + if ( rc ) > > + return rc; > > + > > + if ( ctxt.buffer_size != sizeof(shared_info_t) ) > > + return -EINVAL; > > + > > +#ifdef CONFIG_COMPAT > > + has_32bit_shinfo(d) = ctxt.flags & DOMAIN_SAVE_32BIT_SHINFO; > > +#endif > Should we check the flag is not set when compat is not supported? > > This would prevent someone to try restoring a compat shared info on a > platform not support it. > That would be prudent, yes. Probably a straight EINVAL for this one. Paul
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |