From: "Jan Beulich" Subject: Re: [RFC][PATCH 4/5] tools:firmware:hvmloader: reserve RMRR mappings in e820 Date: Fri, 08 Aug 2014 08:43:43 +0100 Message-ID: <53E49BCF020000780002A644@mail.emea.novell.com> References: <1407409371-31728-1-git-send-email-tiejun.chen@intel.com> <1407409371-31728-5-git-send-email-tiejun.chen@intel.com> <53E36B10.1050805@citrix.com> <53E431E1.3070200@intel.com> <53E48D8D020000780002A4F7@mail.emea.novell.com> <53E47C86.7060400@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <53E47C86.7060400@intel.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Tiejun Chen Cc: kevin.tian@intel.com, ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, Andrew Cooper , ian.jackson@eu.citrix.com, xen-devel@lists.xen.org, yang.z.zhang@intel.com List-Id: xen-devel@lists.xenproject.org >>> On 08.08.14 at 09:30, wrote: > On 2014/8/8 14:42, Jan Beulich wrote: >> You never allocate memory for the map, i.e. you invoke the >> hypercall with a NULL second argument. This just happens to work, >> but is very unlikely what you intended to do. >> > > Looks scratch_alloc() should be used to allocate in hvmloader, so what > about this? > > --- a/tools/firmware/hvmloader/util.c > +++ b/tools/firmware/hvmloader/util.c > @@ -766,6 +766,16 @@ struct shared_info *get_shared_info(void) > return shared_info; > } > > +struct e820map *get_rmrr_map_info(void) > +{ > + struct e820map *e820_map = scratch_alloc(sizeof(struct e820map), 0); > + > + if ( hypercall_memory_op(XENMEM_RMRR_memory_map, e820_map) != 0 ) > + BUG(); > + > + return e820_map; > +} More reasonable, albeit now you lost the fetch-just-once behavior. Furthermore - do you really need this to be a dynamic allocation? The structure you use right now is fixed size. Which gets me to another point though: Is it said in any part of the VT-d spec that there is an upper limit to the number of RMRRs? The re-use of the E820 interface structure looks pretty odd here (I simply didn't get to looking at your patches in full yet). Jan