Skip to content

Commit bffeb2f

Browse files
ChangSeokBaebp3tk0v
authored andcommitted
x86/microcode/intel: Enable staging when available
With staging support implemented, enable it when the CPU reports the feature. [ bp: Sort in the MSR properly. ] Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Chao Gao <chao.gao@intel.com> Reviewed-by: Tony Luck <tony.luck@intel.com> Tested-by: Anselm Busse <abusse@amazon.de> Link: https://lore.kernel.org/20250320234104.8288-1-chang.seok.bae@intel.com
1 parent 4ab4102 commit bffeb2f

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

arch/x86/include/asm/msr-index.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@
166166
* Processor MMIO stale data
167167
* vulnerabilities.
168168
*/
169+
#define ARCH_CAP_MCU_ENUM BIT(16) /*
170+
* Indicates the presence of microcode update
171+
* feature enumeration and status information.
172+
*/
169173
#define ARCH_CAP_FB_CLEAR BIT(17) /*
170174
* VERW clears CPU fill buffer
171175
* even on MDS_NO CPUs.
@@ -929,6 +933,10 @@
929933
#define MSR_IA32_APICBASE_BASE (0xfffff<<12)
930934

931935
#define MSR_IA32_UCODE_WRITE 0x00000079
936+
937+
#define MSR_IA32_MCU_ENUMERATION 0x0000007b
938+
#define MCU_STAGING BIT(4)
939+
932940
#define MSR_IA32_UCODE_REV 0x0000008b
933941

934942
/* Intel SGX Launch Enclave Public Key Hash MSRs */

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,18 @@ static __init void calc_llc_size_per_core(struct cpuinfo_x86 *c)
983983
llc_size_per_core = (unsigned int)llc_size;
984984
}
985985

986+
static __init bool staging_available(void)
987+
{
988+
u64 val;
989+
990+
val = x86_read_arch_cap_msr();
991+
if (!(val & ARCH_CAP_MCU_ENUM))
992+
return false;
993+
994+
rdmsrq(MSR_IA32_MCU_ENUMERATION, val);
995+
return !!(val & MCU_STAGING);
996+
}
997+
986998
struct microcode_ops * __init init_intel_microcode(void)
987999
{
9881000
struct cpuinfo_x86 *c = &boot_cpu_data;
@@ -993,6 +1005,11 @@ struct microcode_ops * __init init_intel_microcode(void)
9931005
return NULL;
9941006
}
9951007

1008+
if (staging_available()) {
1009+
microcode_intel_ops.use_staging = true;
1010+
pr_info("Enabled staging feature.\n");
1011+
}
1012+
9961013
calc_llc_size_per_core(c);
9971014

9981015
return &microcode_intel_ops;

0 commit comments

Comments
 (0)