Skip to content

Commit 72edfe9

Browse files
suryasaimadhuKAGA-KOKO
authored andcommitted
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 <[email protected]> Reviewed-by: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Thomas Gleixner <[email protected]>
1 parent e71bb4e commit 72edfe9

File tree

1 file changed

+13
-30
lines changed
  • arch/x86/kernel/cpu/microcode

1 file changed

+13
-30
lines changed

arch/x86/kernel/cpu/microcode/amd.c

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -372,43 +372,26 @@ load_microcode_amd(int cpu, u8 family, const u8 *data, size_t size);
372372

373373
int __init save_microcode_in_initrd_amd(unsigned int cpuid_1_eax)
374374
{
375+
struct cont_desc desc = { 0 };
375376
enum ucode_state ret;
376-
int retval = 0;
377-
378-
if (!cont.data) {
379-
if (IS_ENABLED(CONFIG_X86_32) && (cont.size != -1)) {
380-
struct cpio_data cp;
381-
382-
cp = find_microcode_in_initrd(ucode_path, false);
383-
if (!(cp.data && cp.size)) {
384-
cont.size = -1;
385-
return -EINVAL;
386-
}
377+
struct cpio_data cp;
387378

388-
cont.cpuid_1_eax = cpuid_1_eax;
379+
cp = find_microcode_in_initrd(ucode_path, false);
380+
if (!(cp.data && cp.size))
381+
return -EINVAL;
389382

390-
scan_containers(cp.data, cp.size, &cont);
391-
if (!cont.eq_id) {
392-
cont.size = -1;
393-
return -EINVAL;
394-
}
383+
desc.cpuid_1_eax = cpuid_1_eax;
395384

396-
} else
397-
return -EINVAL;
398-
}
385+
scan_containers(cp.data, cp.size, &desc);
386+
if (!desc.eq_id)
387+
return -EINVAL;
399388

400-
ret = load_microcode_amd(smp_processor_id(), x86_family(cpuid_1_eax), cont.data, cont.size);
389+
ret = load_microcode_amd(smp_processor_id(), x86_family(cpuid_1_eax),
390+
desc.data, desc.size);
401391
if (ret != UCODE_OK)
402-
retval = -EINVAL;
403-
404-
/*
405-
* This will be freed any msec now, stash patches for the current
406-
* family and switch to patch cache for cpu hotplug, etc later.
407-
*/
408-
cont.data = NULL;
409-
cont.size = 0;
392+
return -EINVAL;
410393

411-
return retval;
394+
return 0;
412395
}
413396

414397
void reload_ucode_amd(void)

0 commit comments

Comments
 (0)