Commit 02f35177 authored by Borislav Petkov's avatar Borislav Petkov

x86/microcode/intel: Simplify load_ucode_intel_bsp()

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.
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
parent 2d48bb9b
...@@ -552,12 +552,10 @@ EXPORT_SYMBOL_GPL(save_mc_for_early); ...@@ -552,12 +552,10 @@ EXPORT_SYMBOL_GPL(save_mc_for_early);
static __initdata char ucode_name[] = "kernel/x86/microcode/GenuineIntel.bin"; static __initdata char ucode_name[] = "kernel/x86/microcode/GenuineIntel.bin";
static __init enum ucode_state static __init enum ucode_state
scan_microcode(unsigned long start, unsigned long end, scan_microcode(unsigned long start, unsigned long size,
struct mc_saved_data *mc_saved_data, struct mc_saved_data *mc_saved_data,
unsigned long *mc_saved_in_initrd, unsigned long *mc_saved_in_initrd, struct ucode_cpu_info *uci)
struct ucode_cpu_info *uci)
{ {
unsigned int size = end - start + 1;
struct cpio_data cd; struct cpio_data cd;
long offset = 0; long offset = 0;
#ifdef CONFIG_X86_32 #ifdef CONFIG_X86_32
...@@ -573,7 +571,6 @@ scan_microcode(unsigned long start, unsigned long end, ...@@ -573,7 +571,6 @@ scan_microcode(unsigned long start, unsigned long end,
if (!cd.data) if (!cd.data)
return UCODE_ERROR; return UCODE_ERROR;
return get_matching_model_microcode(0, start, cd.data, cd.size, return get_matching_model_microcode(0, start, cd.data, cd.size,
mc_saved_data, mc_saved_in_initrd, mc_saved_data, mc_saved_in_initrd,
uci); uci);
...@@ -721,50 +718,40 @@ int __init save_microcode_in_initrd_intel(void) ...@@ -721,50 +718,40 @@ int __init save_microcode_in_initrd_intel(void)
static void __init static void __init
_load_ucode_intel_bsp(struct mc_saved_data *mc_saved_data, _load_ucode_intel_bsp(struct mc_saved_data *mc_saved_data,
unsigned long *mc_saved_in_initrd, unsigned long *mc_saved_in_initrd,
unsigned long initrd_start_early, unsigned long start, unsigned long size)
unsigned long initrd_end_early)
{ {
struct ucode_cpu_info uci; struct ucode_cpu_info uci;
enum ucode_state ret; enum ucode_state ret;
collect_cpu_info_early(&uci); collect_cpu_info_early(&uci);
scan_microcode(initrd_start_early, initrd_end_early, mc_saved_data, scan_microcode(start, size, mc_saved_data, mc_saved_in_initrd, &uci);
mc_saved_in_initrd, &uci);
ret = load_microcode(mc_saved_data, mc_saved_in_initrd, ret = load_microcode(mc_saved_data, mc_saved_in_initrd, start, &uci);
initrd_start_early, &uci);
if (ret != UCODE_OK) if (ret != UCODE_OK)
return; return;
apply_microcode_early(&uci, true); apply_microcode_early(&uci, true);
} }
void __init void __init load_ucode_intel_bsp(void)
load_ucode_intel_bsp(void)
{ {
u64 ramdisk_image, ramdisk_size; u64 start, size;
unsigned long initrd_start_early, initrd_end_early;
#ifdef CONFIG_X86_32 #ifdef CONFIG_X86_32
struct boot_params *boot_params_p; struct boot_params *p;
boot_params_p = (struct boot_params *)__pa_nodebug(&boot_params); p = (struct boot_params *)__pa_nodebug(&boot_params);
ramdisk_image = boot_params_p->hdr.ramdisk_image; start = p->hdr.ramdisk_image;
ramdisk_size = boot_params_p->hdr.ramdisk_size; size = p->hdr.ramdisk_size;
initrd_start_early = ramdisk_image;
initrd_end_early = initrd_start_early + ramdisk_size;
_load_ucode_intel_bsp( _load_ucode_intel_bsp(
(struct mc_saved_data *)__pa_nodebug(&mc_saved_data), (struct mc_saved_data *)__pa_nodebug(&mc_saved_data),
(unsigned long *)__pa_nodebug(&mc_saved_in_initrd), (unsigned long *)__pa_nodebug(&mc_saved_in_initrd),
initrd_start_early, initrd_end_early); start, size);
#else #else
ramdisk_image = boot_params.hdr.ramdisk_image; start = boot_params.hdr.ramdisk_image + PAGE_OFFSET;
ramdisk_size = boot_params.hdr.ramdisk_size; size = boot_params.hdr.ramdisk_size;
initrd_start_early = ramdisk_image + PAGE_OFFSET;
initrd_end_early = initrd_start_early + ramdisk_size;
_load_ucode_intel_bsp(&mc_saved_data, mc_saved_in_initrd, _load_ucode_intel_bsp(&mc_saved_data, mc_saved_in_initrd, start, size);
initrd_start_early, initrd_end_early);
#endif #endif
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment