From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH v3 07/19] libxl: x86: factor out e820_host_sanitize Date: Wed, 14 Jan 2015 11:40:42 +0000 Message-ID: <1421235642.19103.227.camel@citrix.com> References: <1421151107-20842-1-git-send-email-wei.liu2@citrix.com> <1421151107-20842-8-git-send-email-wei.liu2@citrix.com> <54B58781.5030904@citrix.com> <20150114103015.GW4226@zion.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20150114103015.GW4226@zion.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Wei Liu Cc: jbeulich@suse.com, Andrew Cooper , dario.faggioli@citrix.com, Ian Jackson , xen-devel@lists.xen.org, Elena Ufimtseva List-Id: xen-devel@lists.xenproject.org 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 > > > Cc: Ian Campbell > > > Cc: Ian Jackson > > > Cc: Dario Faggioli > > > Cc: Elena Ufimtseva > > > --- > > > 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.)