[PATCH 11/13] kexec-bzImage: Support for loading bzImage using 64bit entry
Vivek Goyal
vgoyal at redhat.com
Tue Jun 24 10:31:25 PDT 2014
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 at 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
More information about the kexec
mailing list