linux-stable/arch/x86/kernel/cpu
Chen Yu 1a371e67dc x86/microcode/intel: Check patch signature before saving microcode for early loading
Currently, scan_microcode() leverages microcode_matches() to check
if the microcode matches the CPU by comparing the family and model.
However, the processor stepping and flags of the microcode signature
should also be considered when saving a microcode patch for early
update.

Use find_matching_signature() in scan_microcode() and get rid of the
now-unused microcode_matches() which is a good cleanup in itself.

Complete the verification of the patch being saved for early loading in
save_microcode_patch() directly. This needs to be done there too because
save_mc_for_early() will call save_microcode_patch() too.

The second reason why this needs to be done is because the loader still
tries to support, at least hypothetically, mixed-steppings systems and
thus adds all patches to the cache that belong to the same CPU model
albeit with different steppings.

For example:

  microcode: CPU: sig=0x906ec, pf=0x2, rev=0xd6
  microcode: mc_saved[0]: sig=0x906e9, pf=0x2a, rev=0xd6, total size=0x19400, date = 2020-04-23
  microcode: mc_saved[1]: sig=0x906ea, pf=0x22, rev=0xd6, total size=0x19000, date = 2020-04-27
  microcode: mc_saved[2]: sig=0x906eb, pf=0x2, rev=0xd6, total size=0x19400, date = 2020-04-23
  microcode: mc_saved[3]: sig=0x906ec, pf=0x22, rev=0xd6, total size=0x19000, date = 2020-04-27
  microcode: mc_saved[4]: sig=0x906ed, pf=0x22, rev=0xd6, total size=0x19400, date = 2020-04-23

The patch which is being saved for early loading, however, can only be
the one which fits the CPU this runs on so do the signature verification
before saving.

 [ bp: Do signature verification in save_microcode_patch()
       and rewrite commit message. ]

Fixes: ec400ddeff ("x86/microcode_intel_early.c: Early update ucode on Intel's CPU")
Signed-off-by: Chen Yu <yu.c.chen@intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: stable@vger.kernel.org
Link: https://bugzilla.kernel.org/show_bug.cgi?id=208535
Link: https://lkml.kernel.org/r/20201113015923.13960-1-yu.c.chen@intel.com
2020-11-17 10:33:18 +01:00
..
mce task_work: cleanup notification modes 2020-10-17 15:05:30 -06:00
microcode x86/microcode/intel: Check patch signature before saving microcode for early loading 2020-11-17 10:33:18 +01:00
mtrr treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
resctrl task_work: cleanup notification modes 2020-10-17 15:05:30 -06:00
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
acrn.c x86/acrn: Remove redundant chars from ACRN signature 2020-08-07 01:32:00 +02:00
amd.c x86/cpufeatures: Add SEV-ES CPU feature 2020-09-07 19:45:24 +02:00
aperfmperf.c
bugs.c x86/speculation: Allow IBPB to be conditionally enabled on CPUs with always-on STIBP 2020-11-05 21:43:34 +01:00
cacheinfo.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
centaur.c x86/cpu/centaur: Add Centaur family >=7 CPUs initialization support 2020-09-11 10:53:19 +02:00
common.c This feature enhances the current guest memory encryption support 2020-10-14 10:21:34 -07:00
cpu.h treewide: Convert macro and uses of __section(foo) to __section("foo") 2020-10-25 14:51:49 -07:00
cpuid-deps.c * Misc cleanups to the resctrl code in preparation for the ARM side, by 2020-10-12 10:53:32 -07:00
cyrix.c
feat_ctl.c x86/cpu: Fix a -Wmissing-prototypes warning for init_ia32_feat_ctl() 2020-03-23 12:01:59 +01:00
hygon.c locking/seqlock, headers: Untangle the spaghetti monster 2020-08-06 16:13:13 +02:00
hypervisor.c
intel.c A set of locking fixes and updates: 2020-08-10 19:07:44 -07:00
intel_epb.c
intel_pconfig.c
Makefile kbuild: remove cc-option test of -fno-stack-protector 2020-07-07 11:13:10 +09:00
match.c x86/cpu: Add a steppings field to struct x86_cpu_id 2020-04-20 12:19:21 +02:00
mkcapflags.sh x86/cpu: Print VMX flags in /proc/cpuinfo using VMX_FEATURES_* 2020-01-13 18:36:02 +01:00
mshyperv.c Drivers: hv: vmbus: Add parsing of VMbus interrupt in ACPI DSDT 2020-10-14 19:14:51 +00:00
perfctr-watchdog.c x86/perf: Add hardware performance events support for Zhaoxin CPU. 2020-04-30 20:14:35 +02:00
powerflags.c
proc.c x86/cpu: Print VMX flags in /proc/cpuinfo using VMX_FEATURES_* 2020-01-13 18:36:02 +01:00
rdrand.c x86/rdrand: Sanity-check RDRAND output 2019-10-01 19:55:32 +02:00
scattered.c This feature enhances the current guest memory encryption support 2020-10-14 10:21:34 -07:00
topology.c x86/mm/pat: Rename <asm/pat.h> => <asm/memtype.h> 2019-12-10 10:12:55 +01:00
transmeta.c
tsx.c Merge branch 'x86-cpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2020-01-28 12:46:42 -08:00
umc.c
umwait.c KVM: VMX: Stop context switching MSR_IA32_UMWAIT_CONTROL 2020-06-22 20:54:57 -04:00
vmware.c x86/vmware: Add VMware-specific handling for VMMCALL under SEV-ES 2020-09-09 11:33:20 +02:00
zhaoxin.c x86/cpu: Reinitialize IA32_FEAT_CTL MSR on BSP during wakeup 2020-06-15 14:18:37 +02:00