Patch "x86/microcode: Attempt late loading only when new microcode is present" has been added to the 4.14-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
x86/microcode: Attempt late loading only when new microcode is present
to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
x86-microcode-attempt-late-loading-only-when-new-microcode-is-present.patch
and it can be found in the queue-4.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
2613f36ed965d0e5a595a1d931fd3b480e82d6fdMon Sep 17 00:00:00 2001
From: Borislav Petkov <[email protected]>
Date: Wed, 14 Mar 2018 19:36:14 +0100
Subject: x86/microcode: Attempt late loading only when new microcode is present
From: Borislav Petkov <[email protected]>
commit 2613f36ed965d0e5a595a1d931fd3b480e82d6fd upstream.
Return UCODE_NEW from the scanning functions to denote that new microcode was found and only then attempt the expensive synchronization dance.
--- arch/x86/include/asm/microcode.h | 1 + arch/x86/kernel/cpu/microcode/amd.c | 34 +++++++++++++++++++++------------- arch/x86/kernel/cpu/microcode/core.c | 8 +++----- arch/x86/kernel/cpu/microcode/intel.c | 4 +++- 4 files changed, 28 insertions(+), 19 deletions(-)
arch/x86/include/asm/microcode.h +1 -0
@@ -39,6 +39,7 @@ struct device;enum ucode_state {UCODE_OK =0 , +UCODE_NEW ,UCODE_UPDATED ,UCODE_NFOUND ,UCODE_ERROR ,
arch/x86/kernel/cpu/microcode/amd.c +21 -13
@@ -339,7 +339,7 @@ int __init save_microcode_in_initrd_amd(return -EINVAL ; ret =load_microcode_amd (true,x86_family (cpuid_1_eax), desc.data, desc.size); -if (ret !=UCODE_OK ) +if (ret >UCODE_UPDATED )return -EINVAL ;return 0 ;
@@ -683,27 +683,35 @@ static enum ucode_state __load_microcodestatic enum ucode_state load_microcode_amd (bool save,u8 family,const u8 *data,size_t size) { +struct ucode_patch *p;enum ucode_state ret;/* free old equiv table */ free_equiv_cpu_table (); ret =__load_microcode_amd (family, data, size); - -if (ret !=UCODE_OK ) +if (ret !=UCODE_OK ) {cleanup (); +return ret; + } -#ifdef CONFIG_X86_32 -/* save BSP's matching patch for early load */ -if (save) { -struct ucode_patch *p =find_patch (0 ); -if (p) { -memset (amd_ucode_patch,0 ,PATCH_MAX_SIZE ); -memcpy (amd_ucode_patch, p->data,min_t (u32,ksize (p->data), -PATCH_MAX_SIZE )); - } + p =find_patch (0 ); +if (!p) { +return ret; + }else { +if (boot_cpu_data.microcode == p->patch_id) +return ret; + + ret =UCODE_NEW ; } -#endif + +/* save BSP's matching patch for early load */ +if (!save) +return ret; + +memset (amd_ucode_patch,0 ,PATCH_MAX_SIZE ); +memcpy (amd_ucode_patch, p->data,min_t (u32,ksize (p->data),PATCH_MAX_SIZE )); +return ret; }
arch/x86/kernel/cpu/microcode/core.c +3 -5
@@ -607,7 +607,7 @@ static ssize_t reload_store(struct devicreturn size; tmp_ret = microcode_ops->request_microcode_fw (bsp, µcode_pdev->dev, true); -if (tmp_ret !=UCODE_OK ) +if (tmp_ret !=UCODE_NEW )return size;get_online_cpus ();
@@ -691,10 +691,8 @@ static enum ucode_state microcode_init_cif (system_state !=SYSTEM_RUNNING )return UCODE_NFOUND ; - ustate = microcode_ops->request_microcode_fw (cpu, µcode_pdev->dev, - refresh_fw); - -if (ustate ==UCODE_OK ) { + ustate = microcode_ops->request_microcode_fw (cpu, µcode_pdev->dev, refresh_fw); +if (ustate ==UCODE_NEW ) {pr_debug ("CPU%d updated upon init\n" , cpu);apply_microcode_on_target (cpu); }
arch/x86/kernel/cpu/microcode/intel.c +3 -1
@@ -862,6 +862,7 @@ static enum ucode_state generic_load_micunsigned int leftover = size;unsigned int curr_mc_size =0 , new_mc_size =0 ;unsigned int csig, cpf; +enum ucode_state ret =UCODE_OK ;while (leftover) {struct microcode_header_intel mc_header;
@@ -903,6 +904,7 @@ static enum ucode_state generic_load_mic new_mc = mc; new_mc_size = mc_size; mc =NULL ;/* trigger new vmalloc */ + ret =UCODE_NEW ; } ucode_ptr += mc_size;
@@ -932,7 +934,7 @@ static enum ucode_state generic_load_micpr_debug ("CPU%d found a matching microcode update with version 0x%x (current=0x%x)\n" , cpu, new_rev, uci->cpu_sig.rev); -return UCODE_OK ; +return ret; }static int get_ucode_fw (void *to,const void *from,size_t n)
Patches currently in stable-queue which might be from [email protected] are
queue-4.14/x86-microcode-intel-check-microcode-revision-before-updating-sibling-threads.patch queue-4.14/x86-microcode-attempt-late-loading-only-when-new-microcode-is-present.patch queue-4.14/x86-microcode-propagate-return-value-from-updating-functions.patch queue-4.14/x86-cpu-check-cpu-feature-bits-after-microcode-upgrade.patch queue-4.14/x86-microcode-intel-writeback-and-invalidate-caches-before-updating-microcode.patch queue-4.14/x86-microcode-intel-look-into-the-patch-cache-first.patch queue-4.14/edac-mv64x60-fix-an-error-handling-path.patch queue-4.14/x86-microcode-request-microcode-on-the-bsp.patch queue-4.14/x86-microcode-get-rid-of-struct-apply_microcode_ctx.patch queue-4.14/x86-microcode-fix-cpu-synchronization-routine.patch queue-4.14/x86-microcode-synchronize-late-microcode-loading.patch queue-4.14/x86-microcode-do-not-upload-microcode-if-cpus-are-offline.patch queue-4.14/x86-cpu-add-a-microcode-loader-callback.patch