Re: [PATCH 04/13] x86/microcode/intel: Simplify load_ucode_intel_bsp()

From: Quentin Casasnovas
Date: Tue Feb 24 2015 - 11:20:11 EST


On Tue, Feb 24, 2015 at 11:37:03AM +0100, Borislav Petkov wrote:
> From: Borislav Petkov <bp@xxxxxxx>
>
> Don't compute start and end from start and size in order to compute size
> again down the path in scan_microcode(). So pass size directly instead
> and simplify a bunch. Shorten variable names and remove useless ones.
>
> No functionality change.
>

Unless I can't read, which is likely to be true, I think I might have
spotted one.

> @@ -555,12 +555,10 @@ EXPORT_SYMBOL_GPL(save_mc_for_early);
>
> static __initdata char ucode_name[] = "kernel/x86/microcode/GenuineIntel.bin";
> static __init enum ucode_state
> -scan_microcode(unsigned long start, unsigned long end,
> - struct mc_saved_data *mc_saved_data,
> - unsigned long *mc_saved_in_initrd,
> - struct ucode_cpu_info *uci)
> +scan_microcode(unsigned long start, unsigned long size,
> + struct mc_saved_data *mc_saved_data,
> + unsigned long *mc_saved_in_initrd, struct ucode_cpu_info *uci)
> {
> - unsigned int size = end - start + 1;

... here `size = end - start + 1`, so basically the original size in
`hdr.ramdisk_image` *plus one*, whereas the `size` you're passing around
does not include it. I'm not saying it's wrong, quite the opposite I think
you're fixing an off-by-one error present in the original code at the same
time :)

> + u64 start, size;
> #ifdef CONFIG_X86_32
> - struct boot_params *boot_params_p;
> + struct boot_params *p;
>
> - boot_params_p = (struct boot_params *)__pa_nodebug(&boot_params);
> - ramdisk_image = boot_params_p->hdr.ramdisk_image;
> - ramdisk_size = boot_params_p->hdr.ramdisk_size;
> - initrd_start_early = ramdisk_image;
> - initrd_end_early = initrd_start_early + ramdisk_size;
> + p = (struct boot_params *)__pa_nodebug(&boot_params);
> + start = p->hdr.ramdisk_image;
> + size = p->hdr.ramdisk_size;

Here is your size.

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