[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v3 07/19] libxl: x86: factor out e820_host_sanitize



On Wed, 2015-01-14 at 10:30 +0000, Wei Liu wrote:
> On Tue, Jan 13, 2015 at 09:00:49PM +0000, Andrew Cooper wrote:
> > On 13/01/15 12:11, Wei Liu wrote:
> > > This function gets the machine E820 map and sanitize it according to PV
> > > guest configuration.
> > >
> > > This will be used in later patch. No functional change introduced in
> > > this patch.
> > >
> > > Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
> > > Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
> > > Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
> > > Cc: Dario Faggioli <dario.faggioli@xxxxxxxxxx>
> > > Cc: Elena Ufimtseva <ufimtseva@xxxxxxxxx>
> > > ---
> > >  tools/libxl/libxl_x86.c |   31 ++++++++++++++++++++++---------
> > >  1 file changed, 22 insertions(+), 9 deletions(-)
> > >
> > > diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c
> > > index 9ceb373..e959e37 100644
> > > --- a/tools/libxl/libxl_x86.c
> > > +++ b/tools/libxl/libxl_x86.c
> > > @@ -207,6 +207,27 @@ static int e820_sanitize(libxl_ctx *ctx, struct 
> > > e820entry src[],
> > >      return 0;
> > >  }
> > >  
> > > +static int e820_host_sanitize(libxl__gc *gc,
> > > +                              libxl_domain_build_info *b_info,
> > > +                              struct e820entry map[],
> > > +                              uint32_t *nr)
> > > +{
> > > +    int rc;
> > > +
> > > +    rc = xc_get_machine_memory_map(CTX->xch, map, E820MAX);
> > 
> > This function should not assume that map[] is E820MAX entries long.  The
> > code you copied was passing a local variable whereas here you are
> > passing someone else's pointer.  You should pass the length in *nr like
> > e820_sanitize() does.
> > 
> 
> Good catch. I will fix.

Does it also work to make the prototpe "map[E820MAX]" thereby causing
the compiler to force the caller to use a suitably sized array? (not
sure what the constraints on the caller are here, i.e. whether it needs
to be dynamically allocated.)


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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.