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 [email protected] ]

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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to