From: "Jan Beulich" Subject: Re: [PATCH for-xen-4.5 v4 12/18] x86: move modules data from mbi to boot_info and remove mbi Date: Mon, 20 Oct 2014 09:38:52 +0100 Message-ID: <5444E63C02000078000401DE@mail.emea.novell.com> References: <1413555132-22138-1-git-send-email-daniel.kiper@oracle.com> <1413555132-22138-13-git-send-email-daniel.kiper@oracle.com> <544199C0.60600@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xg8UT-0001iZ-Q8 for xen-devel@lists.xenproject.org; Mon, 20 Oct 2014 08:38:57 +0000 In-Reply-To: <544199C0.60600@citrix.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: Andrew Cooper Cc: Juergen Gross , keir@xen.org, ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, Daniel Kiper , roy.franz@linaro.org, ning.sun@intel.com, ross.philipson@citrix.com, xen-devel@lists.xenproject.org, qiaowei.ren@intel.com, richard.l.maliszewski@intel.com, gang.wei@intel.com, fu.wei@linaro.org List-Id: xen-devel@lists.xenproject.org >>> On 18.10.14 at 00:35, wrote: > On 17/10/2014 15:12, Daniel Kiper wrote: >> @@ -593,16 +582,17 @@ static void __init efi_arch_handle_module(struct file *file, const CHAR16 *name, >> >> /* >> * If options are provided, put them in >> - * mb_modules[mbi.mods_count].string after the filename, with a space >> - * separating them. place_string_u32() prepends strings and adds separating >> + * boot_info_efi.mods[boot_info_efi.mods_nr].cmdline >> + * after the filename, with a space separating them. >> + * place_string_u32() prepends strings and adds separating >> * spaces, so the call order is reversed. >> */ >> if ( options ) >> - place_string_u32(&mb_modules[mbi.mods_count].string, options); >> - place_string_u32(&mb_modules[mbi.mods_count].string, local_name.s); >> - mb_modules[mbi.mods_count].mod_start = file->addr >> PAGE_SHIFT; >> - mb_modules[mbi.mods_count].mod_end = file->size; >> - ++mbi.mods_count; >> + place_string_u32(&boot_info_efi.mods[boot_info_efi.mods_nr].cmdline, options); >> + place_string_u32(&boot_info_efi.mods[boot_info_efi.mods_nr].cmdline, local_name.s); >> + boot_info_efi.mods[boot_info_efi.mods_nr].start = file->addr >> PAGE_SHIFT; >> + boot_info_efi.mods[boot_info_efi.mods_nr].end = file->size; > > end is surely start + size (give or take a fencepost) ? How did the > pre-existing code work? You should look at pre-existing code first: setup.c, following the "Iterate backwards over all superpage-aligned RAM regions" comment, has for ( i = 0; !efi_enabled && i < mbi->mods_count; i++ ) { if ( mod[i].mod_start & (PAGE_SIZE - 1) ) panic("Bootloader didn't honor module alignment request."); mod[i].mod_end -= mod[i].mod_start; mod[i].mod_start >>= PAGE_SHIFT; mod[i].reserved = 0; } i.e. mod_start after this point no longer holds a byte address, and mod_end now holds only the size. The EFI code leverages this to make sure addresses beyond 4Gb can be expressed (which can't be in multiboot). >> @@ -723,16 +720,15 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr >> * we can relocate the dom0 kernel and other multiboot modules. Also, on >> * x86/64, we relocate Xen to higher memory. >> */ >> - for ( i = 0; !efi_enabled && i < mbi->mods_count; i++ ) >> + for ( i = 0; !efi_enabled && i < boot_info->mods_nr; i++ ) >> { >> - if ( mod[i].mod_start & (PAGE_SIZE - 1) ) >> + if ( boot_info->mods[i].start & (PAGE_SIZE - 1) ) >> panic("Bootloader didn't honor module alignment request."); >> - mod[i].mod_end -= mod[i].mod_start; >> - mod[i].mod_start >>= PAGE_SHIFT; >> - mod[i].reserved = 0; >> + boot_info->mods[i].end -= boot_info->mods[i].start; >> + boot_info->mods[i].start >>= PAGE_SHIFT; >> } >> >> - modules_headroom = bzimage_headroom(bootstrap_map(mod), mod->mod_end); >> + modules_headroom = bzimage_headroom(bootstrap_map(boot_info->mods), boot_info->mods->end); > > The old code was playing a little fast-and-loose with pointers vs arrays. > > Please convert to the more-appropriate mods[0] as you are transforming > the code anyway, which helps highlight the bzimage_headroom() check > applies to the dom0 kernel only. I disagree - arrays getting converted to pointers anyway when used in expressions makes it rather pointless to use [0], being more code to type, read, and parse, and hence making things (even if only slightly) less legible. Jan