From: "Jan Beulich" Subject: Re: [PATCH for-xen-4.5 v3 04/16] x86: Introduce MultiBoot Data (MBD) type Date: Tue, 14 Oct 2014 17:26:05 +0100 Message-ID: <543D6ABD020000780003ED31@mail.emea.novell.com> References: <1412790736-28915-1-git-send-email-daniel.kiper@oracle.com> <1412790736-28915-5-git-send-email-daniel.kiper@oracle.com> <543D5CF1020000780003ECB3@mail.emea.novell.com> <20141014160309.GH3460@olila.local.net-space.pl> 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 1Xe4vK-0003pi-WD for xen-devel@lists.xenproject.org; Tue, 14 Oct 2014 16:26:11 +0000 In-Reply-To: <20141014160309.GH3460@olila.local.net-space.pl> 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: Daniel Kiper Cc: Juergen Gross , keir@xen.org, ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, andrew.cooper3@citrix.com, 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 14.10.14 at 18:03, wrote: > On Tue, Oct 14, 2014 at 04:27:13PM +0100, Jan Beulich wrote: >> >>> On 08.10.14 at 19:52, wrote: >> > +static mbd_t __used *__reloc(void *mbi) >> > +{ >> > + mbd_t *mbd; >> > >> > - /* Mask features we don't understand or don't relocate. */ >> > - mbi->flags &= (MBI_MEMLIMITS | >> > - MBI_BOOTDEV | >> > - MBI_CMDLINE | >> > - MBI_MODULES | >> > - MBI_MEMMAP | >> > - MBI_LOADERNAME); >> > + mbd = (mbd_t *)alloc_struct(sizeof(mbd_t)); >> > + zero_struct((u32)mbd, sizeof(mbd_t)); >> >> Here and elsewhere - please prefer sizeof() over >> sizeof() where possible. Also I continue to be questioning > > You mean alloc_struct(sizeof(*mbd)) in this case? Yes. >> the myriad of casts you're adding - why can't you use void *, >> following what the old code did? > > Most of mbi, mbi2 and mbd members are u32. So, that is why > all basic functions use u32 arguments and returns u32. There > are only two needed casts related to this functions and you can > see them above. Patch 3 had quite a few more of them. >> > +unsigned long __init __init_mbi(u32 mbd_pa) >> > +{ >> > + mbd_t *mbd = __va(mbd_pa); >> > + >> > + enable_exception_support(); >> > + >> > + if ( mbd->boot_loader_name ) { >> > + mbi.flags = MBI_LOADERNAME; >> > + mbi.boot_loader_name = mbd->boot_loader_name; >> > + } >> > + >> > + if ( mbd->cmdline ) { >> > + mbi.flags |= MBI_CMDLINE; >> > + mbi.cmdline = mbd->cmdline; >> > + } >> > + >> > + mbi.flags |= MBI_MEMLIMITS; >> > + mbi.mem_lower = mbd->mem_lower; >> > + mbi.mem_upper = mbd->mem_upper; >> > + >> > + mbi.flags |= MBI_MEMMAP; >> > + mbi.mmap_length = mbd->mmap_size; >> > + mbi.mmap_addr = mbd->mmap; >> > + >> > + mbi.flags |= MBI_MODULES; >> > + mbi.mods_count = mbd->mods_nr; >> > + mbi.mods_addr = mbd->mods; >> > + >> > + return __pa(&mbi); >> > +} >> >> You shouldn't be blindly setting these flags - the incoming structure >> has them, but you discard them in reloc.c instead of propagating >> them here. > > Good point. I think that this should work: > > if ( mbd->mem_lower || mbd->mem_upper ) > { > mbi.flags |= MBI_MEMLIMITS; > mbi.mem_lower = mbd->mem_lower; > mbi.mem_upper = mbd->mem_upper; > } If it is guaranteed that whatever non-zero field(s) if and only if original flag set - fine by me. But I guess it would be better if you forwarded the flags values. Jan