Skip to content

Commit c22ccc4

Browse files
committed
Merge tag 'x86_urgent_for_v5.15_rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Borislav Petkov: - A FPU fix to properly handle invalid MXCSR values: 32-bit masks them out due to historical reasons and 64-bit kernels reject them - A fix to clear X86_FEATURE_SMAP when support for is not config-enabled - Three fixes correcting misspelled Kconfig symbols used in code - Two resctrl object cleanup fixes - Yet another attempt at fixing the neverending saga of botched x86 timers, this time because some incredibly smart hardware decides to turn off the HPET timer in a low power state - who cares if the OS is relying on it... - Check the full return value range of an SEV VMGEXIT call to determine whether it returned an error * tag 'x86_urgent_for_v5.15_rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/fpu: Restore the masking out of reserved MXCSR bits x86/Kconfig: Correct reference to MWINCHIP3D x86/platform/olpc: Correct ifdef symbol to intended CONFIG_OLPC_XO15_SCI x86/entry: Clear X86_FEATURE_SMAP when CONFIG_X86_SMAP=n x86/entry: Correct reference to intended CONFIG_64_BIT x86/resctrl: Fix kfree() of the wrong type in domain_add_cpu() x86/resctrl: Free the ctrlval arrays when domain_setup_mon_state() fails x86/hpet: Use another crystalball to evaluate HPET usability x86/sev: Return an error on a returned non-zero SW_EXITINFO1[31:0]
2 parents 7fd2bf8 + d298b03 commit c22ccc4

File tree

9 files changed

+99
-14
lines changed

9 files changed

+99
-14
lines changed

arch/x86/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1405,7 +1405,7 @@ config HIGHMEM4G
14051405

14061406
config HIGHMEM64G
14071407
bool "64GB"
1408-
depends on !M486SX && !M486 && !M586 && !M586TSC && !M586MMX && !MGEODE_LX && !MGEODEGX1 && !MCYRIXIII && !MELAN && !MWINCHIPC6 && !WINCHIP3D && !MK6
1408+
depends on !M486SX && !M486 && !M586 && !M586TSC && !M586MMX && !MGEODE_LX && !MGEODEGX1 && !MCYRIXIII && !MELAN && !MWINCHIPC6 && !MWINCHIP3D && !MK6
14091409
select X86_PAE
14101410
help
14111411
Select this if you have a 32-bit processor and more than 4

arch/x86/include/asm/entry-common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static __always_inline void arch_check_user_regs(struct pt_regs *regs)
2525
* For !SMAP hardware we patch out CLAC on entry.
2626
*/
2727
if (boot_cpu_has(X86_FEATURE_SMAP) ||
28-
(IS_ENABLED(CONFIG_64_BIT) && boot_cpu_has(X86_FEATURE_XENPV)))
28+
(IS_ENABLED(CONFIG_64BIT) && boot_cpu_has(X86_FEATURE_XENPV)))
2929
mask |= X86_EFLAGS_AC;
3030

3131
WARN_ON_ONCE(flags & mask);

arch/x86/kernel/cpu/common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
326326
#ifdef CONFIG_X86_SMAP
327327
cr4_set_bits(X86_CR4_SMAP);
328328
#else
329+
clear_cpu_cap(c, X86_FEATURE_SMAP);
329330
cr4_clear_bits(X86_CR4_SMAP);
330331
#endif
331332
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,12 +527,14 @@ static void domain_add_cpu(int cpu, struct rdt_resource *r)
527527
rdt_domain_reconfigure_cdp(r);
528528

529529
if (r->alloc_capable && domain_setup_ctrlval(r, d)) {
530-
kfree(d);
530+
kfree(hw_dom);
531531
return;
532532
}
533533

534534
if (r->mon_capable && domain_setup_mon_state(r, d)) {
535-
kfree(d);
535+
kfree(hw_dom->ctrl_val);
536+
kfree(hw_dom->mbps_val);
537+
kfree(hw_dom);
536538
return;
537539
}
538540

arch/x86/kernel/early-quirks.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -714,12 +714,6 @@ static struct chipset early_qrk[] __initdata = {
714714
*/
715715
{ PCI_VENDOR_ID_INTEL, 0x0f00,
716716
PCI_CLASS_BRIDGE_HOST, PCI_ANY_ID, 0, force_disable_hpet},
717-
{ PCI_VENDOR_ID_INTEL, 0x3e20,
718-
PCI_CLASS_BRIDGE_HOST, PCI_ANY_ID, 0, force_disable_hpet},
719-
{ PCI_VENDOR_ID_INTEL, 0x3ec4,
720-
PCI_CLASS_BRIDGE_HOST, PCI_ANY_ID, 0, force_disable_hpet},
721-
{ PCI_VENDOR_ID_INTEL, 0x8a12,
722-
PCI_CLASS_BRIDGE_HOST, PCI_ANY_ID, 0, force_disable_hpet},
723717
{ PCI_VENDOR_ID_BROADCOM, 0x4331,
724718
PCI_CLASS_NETWORK_OTHER, PCI_ANY_ID, 0, apple_airport_reset},
725719
{}

arch/x86/kernel/fpu/signal.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,14 @@ static int __fpu_restore_sig(void __user *buf, void __user *buf_fx,
379379
sizeof(fpu->state.fxsave)))
380380
return -EFAULT;
381381

382-
/* Reject invalid MXCSR values. */
383-
if (fpu->state.fxsave.mxcsr & ~mxcsr_feature_mask)
384-
return -EINVAL;
382+
if (IS_ENABLED(CONFIG_X86_64)) {
383+
/* Reject invalid MXCSR values. */
384+
if (fpu->state.fxsave.mxcsr & ~mxcsr_feature_mask)
385+
return -EINVAL;
386+
} else {
387+
/* Mask invalid bits out for historical reasons (broken hardware). */
388+
fpu->state.fxsave.mxcsr &= ~mxcsr_feature_mask;
389+
}
385390

386391
/* Enforce XFEATURE_MASK_FPSSE when XSAVE is enabled */
387392
if (use_xsave())

arch/x86/kernel/hpet.c

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <asm/irq_remapping.h>
1111
#include <asm/hpet.h>
1212
#include <asm/time.h>
13+
#include <asm/mwait.h>
1314

1415
#undef pr_fmt
1516
#define pr_fmt(fmt) "hpet: " fmt
@@ -916,6 +917,83 @@ static bool __init hpet_counting(void)
916917
return false;
917918
}
918919

920+
static bool __init mwait_pc10_supported(void)
921+
{
922+
unsigned int eax, ebx, ecx, mwait_substates;
923+
924+
if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)
925+
return false;
926+
927+
if (!cpu_feature_enabled(X86_FEATURE_MWAIT))
928+
return false;
929+
930+
if (boot_cpu_data.cpuid_level < CPUID_MWAIT_LEAF)
931+
return false;
932+
933+
cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &mwait_substates);
934+
935+
return (ecx & CPUID5_ECX_EXTENSIONS_SUPPORTED) &&
936+
(ecx & CPUID5_ECX_INTERRUPT_BREAK) &&
937+
(mwait_substates & (0xF << 28));
938+
}
939+
940+
/*
941+
* Check whether the system supports PC10. If so force disable HPET as that
942+
* stops counting in PC10. This check is overbroad as it does not take any
943+
* of the following into account:
944+
*
945+
* - ACPI tables
946+
* - Enablement of intel_idle
947+
* - Command line arguments which limit intel_idle C-state support
948+
*
949+
* That's perfectly fine. HPET is a piece of hardware designed by committee
950+
* and the only reasons why it is still in use on modern systems is the
951+
* fact that it is impossible to reliably query TSC and CPU frequency via
952+
* CPUID or firmware.
953+
*
954+
* If HPET is functional it is useful for calibrating TSC, but this can be
955+
* done via PMTIMER as well which seems to be the last remaining timer on
956+
* X86/INTEL platforms that has not been completely wreckaged by feature
957+
* creep.
958+
*
959+
* In theory HPET support should be removed altogether, but there are older
960+
* systems out there which depend on it because TSC and APIC timer are
961+
* dysfunctional in deeper C-states.
962+
*
963+
* It's only 20 years now that hardware people have been asked to provide
964+
* reliable and discoverable facilities which can be used for timekeeping
965+
* and per CPU timer interrupts.
966+
*
967+
* The probability that this problem is going to be solved in the
968+
* forseeable future is close to zero, so the kernel has to be cluttered
969+
* with heuristics to keep up with the ever growing amount of hardware and
970+
* firmware trainwrecks. Hopefully some day hardware people will understand
971+
* that the approach of "This can be fixed in software" is not sustainable.
972+
* Hope dies last...
973+
*/
974+
static bool __init hpet_is_pc10_damaged(void)
975+
{
976+
unsigned long long pcfg;
977+
978+
/* Check whether PC10 substates are supported */
979+
if (!mwait_pc10_supported())
980+
return false;
981+
982+
/* Check whether PC10 is enabled in PKG C-state limit */
983+
rdmsrl(MSR_PKG_CST_CONFIG_CONTROL, pcfg);
984+
if ((pcfg & 0xF) < 8)
985+
return false;
986+
987+
if (hpet_force_user) {
988+
pr_warn("HPET force enabled via command line, but dysfunctional in PC10.\n");
989+
return false;
990+
}
991+
992+
pr_info("HPET dysfunctional in PC10. Force disabled.\n");
993+
boot_hpet_disable = true;
994+
return true;
995+
}
996+
919997
/**
920998
* hpet_enable - Try to setup the HPET timer. Returns 1 on success.
921999
*/
@@ -929,6 +1007,9 @@ int __init hpet_enable(void)
9291007
if (!is_hpet_capable())
9301008
return 0;
9311009

1010+
if (hpet_is_pc10_damaged())
1011+
return 0;
1012+
9321013
hpet_set_mapping();
9331014
if (!hpet_virt_address)
9341015
return 0;

arch/x86/kernel/sev-shared.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ static enum es_result sev_es_ghcb_hv_call(struct ghcb *ghcb,
130130
} else {
131131
ret = ES_VMM_ERROR;
132132
}
133+
} else if (ghcb->save.sw_exit_info_1 & 0xffffffff) {
134+
ret = ES_VMM_ERROR;
133135
} else {
134136
ret = ES_OK;
135137
}

arch/x86/platform/olpc/olpc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ static struct olpc_ec_driver ec_xo1_driver = {
274274

275275
static struct olpc_ec_driver ec_xo1_5_driver = {
276276
.ec_cmd = olpc_xo1_ec_cmd,
277-
#ifdef CONFIG_OLPC_XO1_5_SCI
277+
#ifdef CONFIG_OLPC_XO15_SCI
278278
/*
279279
* XO-1.5 EC wakeups are available when olpc-xo15-sci driver is
280280
* compiled in

0 commit comments

Comments
 (0)