From: "Jan Beulich" Subject: Re: [v3][PATCH 06/16] hvmloader: get guest memory map into memory_map[] Date: Wed, 17 Jun 2015 11:22:04 +0100 Message-ID: <5581666C020000780008608C@mail.emea.novell.com> References: <1433985325-16676-1-git-send-email-tiejun.chen@intel.com> <1433985325-16676-7-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: <1433985325-16676-7-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: yang.z.zhang@intel.com, andrew.cooper3@citrix.com, kevin.tian@intel.com, tim@xen.org, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org >>> On 11.06.15 at 03:15, wrote: > --- a/tools/firmware/hvmloader/hvmloader.c > +++ b/tools/firmware/hvmloader/hvmloader.c > @@ -107,6 +107,8 @@ asm ( > " .text \n" > ); > > +struct e820map memory_map; Imo this should live in e820.c. > @@ -199,6 +201,39 @@ static void apic_setup(void) > ioapic_write(0x11, SET_APIC_ID(LAPIC_ID(0))); > } > > +void memory_map_setup(void) And perhaps this one too. Or if not, it should be static. > +{ > + unsigned int nr_entries = E820MAX, i; > + int rc; > + uint64_t alloc_addr = RESERVED_MEMORY_DYNAMIC_START - 1; > + uint64_t alloc_size = RESERVED_MEMORY_DYNAMIC_END - alloc_addr; > + > + rc = get_mem_mapping_layout(memory_map.map, &nr_entries); > + > + if ( rc ) > + { > + printf("Failed to get guest memory map.\n"); > + BUG(); > + } > + > + BUG_ON(!nr_entries); Please be consistent: printf()+BUG() or BUG_ON(). Also I think the two (sanity) checks above could combined into one (and the printf() should then print both rc and nr_entries). > @@ -368,6 +379,21 @@ uuid_to_string(char *dest, uint8_t *uuid) > *p = '\0'; > } > > +int get_mem_mapping_layout(struct e820entry entries[], uint32_t *max_entries) Again no need for a fixed width type here afaict. Jan