From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Chen, Tiejun" Subject: Re: [v3][PATCH 06/16] hvmloader: get guest memory map into memory_map[] Date: Thu, 18 Jun 2015 17:13:29 +0800 Message-ID: <55828BB9.1030704@intel.com> References: <1433985325-16676-1-git-send-email-tiejun.chen@intel.com> <1433985325-16676-7-git-send-email-tiejun.chen@intel.com> <5581666C020000780008608C@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <5581666C020000780008608C@mail.emea.novell.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: Jan Beulich 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 2015/6/17 18:22, Jan Beulich wrote: >>>> 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. Okay. > >> @@ -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. I'd like to move this into e820.c as well. > >> +{ >> + 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). What about this? if ( rc || !nr_entries ) { printf("Get guest memory maps[%d] failed. (%d)\n", nr_entries, rc); BUG(); } > > >> @@ -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) s/uint32_t/unsigned int/ > > Again no need for a fixed width type here afaict. > Thanks Tiejun