Skip to content

Commit 12ccf71

Browse files
bp3tk0vgregkh
authored andcommitted
x86/microcode/AMD: Merge early_apply_microcode() into its single callsite
commit dc15675 upstream. No functional changes. Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/r/20250211163648.30531-4-bp@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 42d04c3 commit 12ccf71

File tree

1 file changed

+26
-34
lines changed
  • arch/x86/kernel/cpu/microcode

1 file changed

+26
-34
lines changed

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

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -512,39 +512,6 @@ static bool __apply_microcode_amd(struct microcode_amd *mc, unsigned int psize)
512512
return true;
513513
}
514514

515-
/*
516-
* Early load occurs before we can vmalloc(). So we look for the microcode
517-
* patch container file in initrd, traverse equivalent cpu table, look for a
518-
* matching microcode patch, and update, all in initrd memory in place.
519-
* When vmalloc() is available for use later -- on 64-bit during first AP load,
520-
* and on 32-bit during save_microcode_in_initrd() -- we can call
521-
* load_microcode_amd() to save equivalent cpu table and microcode patches in
522-
* kernel heap memory.
523-
*
524-
* Returns true if container found (sets @desc), false otherwise.
525-
*/
526-
static bool early_apply_microcode(u32 old_rev, void *ucode, size_t size)
527-
{
528-
struct cont_desc desc = { 0 };
529-
struct microcode_amd *mc;
530-
bool ret = false;
531-
532-
scan_containers(ucode, size, &desc);
533-
534-
mc = desc.mc;
535-
if (!mc)
536-
return ret;
537-
538-
/*
539-
* Allow application of the same revision to pick up SMT-specific
540-
* changes even if the revision of the other SMT thread is already
541-
* up-to-date.
542-
*/
543-
if (old_rev > mc->hdr.patch_id)
544-
return ret;
545-
546-
return __apply_microcode_amd(mc, desc.psize);
547-
}
548515

549516
static bool get_builtin_microcode(struct cpio_data *cp)
550517
{
@@ -583,8 +550,19 @@ static bool __init find_blobs_in_containers(struct cpio_data *ret)
583550
return found;
584551
}
585552

553+
/*
554+
* Early load occurs before we can vmalloc(). So we look for the microcode
555+
* patch container file in initrd, traverse equivalent cpu table, look for a
556+
* matching microcode patch, and update, all in initrd memory in place.
557+
* When vmalloc() is available for use later -- on 64-bit during first AP load,
558+
* and on 32-bit during save_microcode_in_initrd() -- we can call
559+
* load_microcode_amd() to save equivalent cpu table and microcode patches in
560+
* kernel heap memory.
561+
*/
586562
void __init load_ucode_amd_bsp(struct early_load_data *ed, unsigned int cpuid_1_eax)
587563
{
564+
struct cont_desc desc = { };
565+
struct microcode_amd *mc;
588566
struct cpio_data cp = { };
589567
u32 dummy;
590568

@@ -598,7 +576,21 @@ void __init load_ucode_amd_bsp(struct early_load_data *ed, unsigned int cpuid_1_
598576
if (!find_blobs_in_containers(&cp))
599577
return;
600578

601-
if (early_apply_microcode(ed->old_rev, cp.data, cp.size))
579+
scan_containers(cp.data, cp.size, &desc);
580+
581+
mc = desc.mc;
582+
if (!mc)
583+
return;
584+
585+
/*
586+
* Allow application of the same revision to pick up SMT-specific
587+
* changes even if the revision of the other SMT thread is already
588+
* up-to-date.
589+
*/
590+
if (ed->old_rev > mc->hdr.patch_id)
591+
return;
592+
593+
if (__apply_microcode_amd(mc, desc.psize))
602594
native_rdmsr(MSR_AMD64_PATCH_LEVEL, ed->new_rev, dummy);
603595
}
604596

0 commit comments

Comments
 (0)