Skip to content

Commit 968966c

Browse files
committed
Merge tag 'x86-urgent-2026-05-31' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Ingo Molnar: - Make the clearcpuid= boot parameter less prominent and warn about its dangers & caveats (Borislav Petkov) - Do not access the (new) PLATFORM_ID MSR when running as a guest (Borislav Petkov) - x86 ftrace: Relocate %rip-relative percpu refs in dynamic trampolines, to fix crash when using such trampolines (Alexis Lothoré) - Fix x86-64 CFI build error (Peter Zijlstra) - Revert FPU signal return magic number check optimization, because it broke CRIU and gVisor in certain FPU configurations (Andrei Vagin) * tag 'x86-urgent-2026-05-31' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: Revert "x86/fpu: Refine and simplify the magic number check during signal return" x86/kvm/vmx: Fix x86_64 CFI build x86/ftrace: Relocate %rip-relative percpu refs in dynamic trampolines x86/microcode: Do not access MSR_IA32_PLATFORM_ID when running as a guest Documentation/arch/x86: Hide clearcpuid=
2 parents 13bd441 + 44eeff9 commit 968966c

12 files changed

Lines changed: 40 additions & 47 deletions

File tree

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -789,24 +789,6 @@ Kernel parameters
789789
cio_ignore= [S390]
790790
See Documentation/arch/s390/common_io.rst for details.
791791

792-
clearcpuid=X[,X...] [X86]
793-
Disable CPUID feature X for the kernel. See
794-
arch/x86/include/asm/cpufeatures.h for the valid bit
795-
numbers X. Note the Linux-specific bits are not necessarily
796-
stable over kernel options, but the vendor-specific
797-
ones should be.
798-
X can also be a string as appearing in the flags: line
799-
in /proc/cpuinfo which does not have the above
800-
instability issue. However, not all features have names
801-
in /proc/cpuinfo.
802-
Note that using this option will taint your kernel.
803-
Also note that user programs calling CPUID directly
804-
or using the feature without checking anything
805-
will still see it. This just prevents it from
806-
being used by the kernel or shown in /proc/cpuinfo.
807-
Also note the kernel might malfunction if you disable
808-
some critical bits.
809-
810792
clk_ignore_unused
811793
[CLK]
812794
Prevents the clock framework from automatically gating

Documentation/arch/x86/cpuinfo.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ to disable features using the feature number as defined in
187187
Protection can be disabled using clearcpuid=514. The number 514 is calculated
188188
from #define X86_FEATURE_UMIP (16*32 + 2).
189189

190+
DO NOT USE this cmdline option in production - it is meant to be used only as
191+
a quick'n'dirty debugging aid to rule out a feature-enabling code is the
192+
culprit. If you use it, it'll taint the kernel.
193+
190194
In addition, there exists a variety of custom command-line parameters that
191195
disable specific features. The list of parameters includes, but is not limited
192196
to, nofsgsbase, nosgx, noxsave, etc. 5-level paging can also be disabled using

arch/x86/entry/common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ noinstr void x86_entry_from_kvm(unsigned int event_type, unsigned int vector)
5555
* The FRED NMI context is significantly different and will not work
5656
* right (specifically FRED fixed the NMI recursion issue).
5757
*/
58-
idt_entry_from_kvm(vector);
58+
idt_do_nmi_irqoff();
5959
}
6060
EXPORT_SYMBOL_FOR_KVM(x86_entry_from_kvm);
6161
#endif

arch/x86/entry/entry.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,13 @@ EXPORT_SYMBOL(__ref_stack_chk_guard);
109109
RET
110110
.endm
111111

112+
#ifndef CONFIG_X86_64
112113
.pushsection .text, "ax"
113114
SYM_FUNC_START(idt_do_interrupt_irqoff)
114115
IDT_DO_EVENT_IRQOFF CALL_NOSPEC _ASM_ARG1
115116
SYM_FUNC_END(idt_do_interrupt_irqoff)
116117
.popsection
118+
#endif
117119

118120
.pushsection .noinstr.text, "ax"
119121
SYM_FUNC_START(idt_do_nmi_irqoff)

arch/x86/include/asm/processor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,7 @@ bool xen_set_default_idle(void);
733733
#endif
734734

735735
void __noreturn stop_this_cpu(void *dummy);
736+
extern bool x86_hypervisor_present;
736737
void microcode_check(struct cpuinfo_x86 *prev_info);
737738
void store_cpu_caps(struct cpuinfo_x86 *info);
738739

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ static u32 get_patch_level(void)
322322
{
323323
u32 rev, dummy __always_unused;
324324

325-
if (IS_ENABLED(CONFIG_MICROCODE_DBG) && hypervisor_present) {
325+
if (IS_ENABLED(CONFIG_MICROCODE_DBG) && x86_hypervisor_present) {
326326
int cpu = smp_processor_id();
327327

328328
if (!microcode_rev[cpu]) {
@@ -714,7 +714,7 @@ static bool __apply_microcode_amd(struct microcode_amd *mc, u32 *cur_rev,
714714
invlpg(p_addr_end);
715715
}
716716

717-
if (IS_ENABLED(CONFIG_MICROCODE_DBG) && hypervisor_present)
717+
if (IS_ENABLED(CONFIG_MICROCODE_DBG) && x86_hypervisor_present)
718718
microcode_rev[smp_processor_id()] = mc->hdr.patch_id;
719719

720720
/* verify patch application was successful */

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ bool force_minrev = IS_ENABLED(CONFIG_MICROCODE_LATE_FORCE_MINREV);
5757
u32 base_rev;
5858
u32 microcode_rev[NR_CPUS] = {};
5959

60-
bool hypervisor_present;
60+
bool __ro_after_init x86_hypervisor_present;
6161

6262
/*
6363
* Synchronization.
@@ -118,14 +118,9 @@ bool __init microcode_loader_disabled(void)
118118
/*
119119
* Disable when:
120120
*
121-
* 1) The CPU does not support CPUID.
122-
*/
123-
if (!cpuid_feature()) {
124-
dis_ucode_ldr = true;
125-
return dis_ucode_ldr;
126-
}
127-
128-
/*
121+
* 1) The CPU does not support CPUID, detected below in
122+
* load_ucode_bsp().
123+
*
129124
* 2) Bit 31 in CPUID[1]:ECX is clear
130125
* The bit is reserved for hypervisor use. This is still not
131126
* completely accurate as XEN PV guests don't see that CPUID bit
@@ -135,9 +130,7 @@ bool __init microcode_loader_disabled(void)
135130
* 3) Certain AMD patch levels are not allowed to be
136131
* overwritten.
137132
*/
138-
hypervisor_present = native_cpuid_ecx(1) & BIT(31);
139-
140-
if ((hypervisor_present && !IS_ENABLED(CONFIG_MICROCODE_DBG)) ||
133+
if ((x86_hypervisor_present && !IS_ENABLED(CONFIG_MICROCODE_DBG)) ||
141134
amd_check_current_patch_level())
142135
dis_ucode_ldr = true;
143136

@@ -179,6 +172,11 @@ void __init load_ucode_bsp(void)
179172

180173
early_parse_cmdline();
181174

175+
if (!cpuid_feature())
176+
dis_ucode_ldr = true;
177+
else
178+
x86_hypervisor_present = native_cpuid_ecx(1) & BIT(31);
179+
182180
if (microcode_loader_disabled())
183181
return;
184182

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ u32 intel_get_platform_id(void)
138138
{
139139
unsigned int val[2];
140140

141+
if (x86_hypervisor_present)
142+
return 0;
143+
141144
/*
142145
* This can be called early. Use CPUID directly instead of
143146
* relying on cpuinfo_x86 which may not be fully initialized.

arch/x86/kernel/cpu/microcode/internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ extern struct early_load_data early_data;
4848
extern struct ucode_cpu_info ucode_cpu_info[];
4949
extern u32 microcode_rev[NR_CPUS];
5050
extern u32 base_rev;
51-
extern bool hypervisor_present;
5251

5352
struct cpio_data find_microcode_in_initrd(const char *path);
5453

arch/x86/kernel/fpu/signal.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,19 @@
2727
static inline bool check_xstate_in_sigframe(struct fxregs_state __user *fxbuf,
2828
struct _fpx_sw_bytes *fx_sw)
2929
{
30+
int min_xstate_size = sizeof(struct fxregs_state) +
31+
sizeof(struct xstate_header);
3032
void __user *fpstate = fxbuf;
3133
unsigned int magic2;
3234

3335
if (__copy_from_user(fx_sw, &fxbuf->sw_reserved[0], sizeof(*fx_sw)))
3436
return false;
3537

36-
/* Check for the first magic field */
37-
if (fx_sw->magic1 != FP_XSTATE_MAGIC1)
38+
/* Check for the first magic field and other error scenarios. */
39+
if (fx_sw->magic1 != FP_XSTATE_MAGIC1 ||
40+
fx_sw->xstate_size < min_xstate_size ||
41+
fx_sw->xstate_size > x86_task_fpu(current)->fpstate->user_size ||
42+
fx_sw->xstate_size > fx_sw->extended_size)
3843
goto setfx;
3944

4045
/*
@@ -43,7 +48,7 @@ static inline bool check_xstate_in_sigframe(struct fxregs_state __user *fxbuf,
4348
* fpstate layout with out copying the extended state information
4449
* in the memory layout.
4550
*/
46-
if (__get_user(magic2, (__u32 __user *)(fpstate + x86_task_fpu(current)->fpstate->user_size)))
51+
if (__get_user(magic2, (__u32 __user *)(fpstate + fx_sw->xstate_size)))
4752
return false;
4853

4954
if (likely(magic2 == FP_XSTATE_MAGIC2))

0 commit comments

Comments
 (0)