lkml.org 
[lkml]   [2014]   [Jun]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 11/13] kexec-bzImage: Support for loading bzImage using 64bit entry
On Sun, Jun 15, 2014 at 06:35:15PM +0200, Borislav Petkov wrote:

[..]
> > +int kexec_setup_initrd(struct boot_params *params,
> > + unsigned long initrd_load_addr, unsigned long initrd_len)
> > +{
> > + params->hdr.ramdisk_image = initrd_load_addr & 0xffffffffUL;
> > + params->hdr.ramdisk_size = initrd_len & 0xffffffffUL;
>
> We have more readable GENMASK* macros for contiguous masks. This one
> will then look like:
>
> params->hdr.ramdisk_image = initrd_load_addr & GENMASK(31, 0);
> params->hdr.ramdisk_size = initrd_len & GENMASK(31, 0);
>
> and this way we know exactly about which bits are we talking about. :)

[ CC gong.chen@linux.intel.com ]

GENMASK(31,0) outputs compilation warning.

arch/x86/kernel/machine_kexec.c: In function ‘kexec_setup_initrd’:
arch/x86/kernel/machine_kexec.c:30:2: warning: left shift count >= width
of type [enabled by default]
params->hdr.ramdisk_image = initrd_load_addr & GENMASK(31, 0);
^
arch/x86/kernel/machine_kexec.c:31:2: warning: left shift count >= width
of type [enabled by default]
params->hdr.ramdisk_size = initrd_len & GENMASK(31, 0);
^
arch/x86/kernel/machine_kexec.c: In function ‘kexec_setup_cmdline’:
arch/x86/kernel/machine_kexec.c:52:2: warning: left shift count >= width
of type [enabled by default]
cmdline_low_32 = cmdline_ptr_phys & GENMASK(31, 0);

I think problem is that we shift 1 by 32 bits in this case (31 - 0 + 1) and
that overflows the size of unsigned. So there is this corner case where
it does not seem to work (or atleast outputs warning).

Thanks
Vivek
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2014-06-24 22:21    [W:0.426 / U:0.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site