From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: Re: [v8][PATCH 05/16] hvmloader: get guest memory map into memory_map[] Date: Thu, 16 Jul 2015 10:18:32 +0100 Message-ID: <55A793080200007800091C20@mail.emea.novell.com> References: <1437029582-19564-1-git-send-email-tiejun.chen@intel.com> <1437029582-19564-6-git-send-email-tiejun.chen@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1437029582-19564-6-git-send-email-tiejun.chen@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: Wei Liu , Ian Campbell , Stefano Stabellini , Andrew Cooper , Ian Jackson , xen-devel@lists.xen.org, Keir Fraser List-Id: xen-devel@lists.xenproject.org >>> On 16.07.15 at 08:52, wrote: > Now we get this map layout by call XENMEM_memory_map then > save them into one global variable memory_map[]. It should > include lowmem range, rdm range and highmem range. Note > rdm range and highmem range may not exist in some cases. > > And here we need to check if any reserved memory conflicts with > [RESERVED_MEMORY_DYNAMIC_START, RESERVED_MEMORY_DYNAMIC_END]. [RESERVED_MEMORY_DYNAMIC_START, RESERVED_MEMORY_DYNAMIC_END) > --- a/tools/firmware/hvmloader/e820.c > +++ b/tools/firmware/hvmloader/e820.c > @@ -23,6 +23,41 @@ > #include "config.h" > #include "util.h" > > +struct e820map memory_map; > + > +void memory_map_setup(void) > +{ > + unsigned int nr_entries = E820MAX, i; > + int rc; > + uint64_t alloc_addr = RESERVED_MEMORY_DYNAMIC_START; > + uint64_t alloc_size = RESERVED_MEMORY_DYNAMIC_END - alloc_addr; > + > + rc = get_mem_mapping_layout(memory_map.map, &nr_entries); > + > + if ( rc || !nr_entries ) > + { > + printf("Get guest memory maps[%d] failed. (%d)\n", nr_entries, rc); > + BUG(); > + } > + > + memory_map.nr_map = nr_entries; > + > + for ( i = 0; i < nr_entries; i++ ) > + { > + if ( memory_map.map[i].type == E820_RESERVED ) > + { > + if ( check_overlap(alloc_addr, alloc_size, > + memory_map.map[i].addr, > + memory_map.map[i].size) ) > + { > + printf("Fail to setup memory map due to conflict"); > + printf(" on dynamic reserved memory range.\n"); > + BUG(); > + } > + } Another case of two if()-s which should be folded. Again, no need to re-submit just because of this; with it fixed Acked-by: Jan Beulich Jan