x86/microcode/AMD: Simplify saving from initrd

No need to use the previously stashed info in the container - simply go
ahead and parse the initrd once more. It simplifies and streamlines the
code a whole lot.

Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20170120202955.4091-15-bp@alien8.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
This commit is contained in:
Borislav Petkov 2017-01-20 21:29:53 +01:00 committed by Thomas Gleixner
parent e71bb4ec07
commit 72edfe950b
1 changed files with 13 additions and 30 deletions

View File

@ -372,43 +372,26 @@ load_microcode_amd(int cpu, u8 family, const u8 *data, size_t size);
int __init save_microcode_in_initrd_amd(unsigned int cpuid_1_eax) int __init save_microcode_in_initrd_amd(unsigned int cpuid_1_eax)
{ {
struct cont_desc desc = { 0 };
enum ucode_state ret; enum ucode_state ret;
int retval = 0; struct cpio_data cp;
if (!cont.data) { cp = find_microcode_in_initrd(ucode_path, false);
if (IS_ENABLED(CONFIG_X86_32) && (cont.size != -1)) { if (!(cp.data && cp.size))
struct cpio_data cp; return -EINVAL;
cp = find_microcode_in_initrd(ucode_path, false); desc.cpuid_1_eax = cpuid_1_eax;
if (!(cp.data && cp.size)) {
cont.size = -1;
return -EINVAL;
}
cont.cpuid_1_eax = cpuid_1_eax; scan_containers(cp.data, cp.size, &desc);
if (!desc.eq_id)
return -EINVAL;
scan_containers(cp.data, cp.size, &cont); ret = load_microcode_amd(smp_processor_id(), x86_family(cpuid_1_eax),
if (!cont.eq_id) { desc.data, desc.size);
cont.size = -1;
return -EINVAL;
}
} else
return -EINVAL;
}
ret = load_microcode_amd(smp_processor_id(), x86_family(cpuid_1_eax), cont.data, cont.size);
if (ret != UCODE_OK) if (ret != UCODE_OK)
retval = -EINVAL; return -EINVAL;
/* return 0;
* This will be freed any msec now, stash patches for the current
* family and switch to patch cache for cpu hotplug, etc later.
*/
cont.data = NULL;
cont.size = 0;
return retval;
} }
void reload_ucode_amd(void) void reload_ucode_amd(void)