x64: enable fast string operation for kernel 4.19

This commit is contained in:
LEAN-ESX 2019-10-17 05:34:31 -07:00
parent 634ed26b5c
commit cc8058a24a
5 changed files with 77 additions and 5 deletions

View File

@ -22,7 +22,7 @@ include $(INCLUDE_DIR)/target.mk
DEFAULT_PACKAGES += partx-utils mkf2fs fdisk e2fsprogs wpad kmod-usb-hid \
kmod-ath5k kmod-ath9k kmod-ath9k-htc kmod-ath10k kmod-rt2800-usb kmod-e1000e kmod-igb kmod-igbvf kmod-ixgbe kmod-pcnet32 kmod-tulip kmod-vmxnet3 kmod-i40e kmod-i40evf kmod-fs-f2fs \
htop lm-sensors autocore automount autosamba luci-app-zerotier luci-app-ipsec-vpnd luci-app-pptp-server luci-proto-bonding luci-app-zerotier luci-app-unblockmusic luci-app-transmission luci-app-docker \
ath10k-firmware-qca988x ath10k-firmware-qca9888 ath10k-firmware-qca9984 brcmfmac-firmware-43602a1-pcie intel-microcode amd64-microcode kmod-crypto-misc \
ath10k-firmware-qca988x ath10k-firmware-qca9888 ath10k-firmware-qca9984 brcmfmac-firmware-43602a1-pcie kmod-crypto-misc \
alsa-utils kmod-ac97 kmod-sound-hda-core kmod-sound-hda-codec-realtek kmod-sound-hda-codec-via kmod-sound-via82xx kmod-usb-audio \
kmod-usb-net kmod-usb-net-asix kmod-usb-net-asix-ax88179 kmod-usb-net-rtl8150 kmod-usb-net-rtl8152 \
shadowsocks-libev-ss-redir v2ray shadowsocksr-libev-server shadowsocksr-libev-ssr-local dsmboot cfdisk

View File

@ -325,6 +325,7 @@ CONFIG_IRQ_FORCED_THREADING=y
CONFIG_IRQ_WORK=y
# CONFIG_ISA is not set
CONFIG_ISA_DMA_API=y
# CONFIG_ISCSI_IBFT is not set
# CONFIG_ISCSI_IBFT_FIND is not set
# CONFIG_IT8712F_WDT is not set
# CONFIG_IT87_WDT is not set
@ -601,4 +602,3 @@ CONFIG_XPS=y
CONFIG_XZ_DEC_BCJ=y
CONFIG_XZ_DEC_X86=y
CONFIG_ZLIB_INFLATE=y
# CONFIG_ISCSI_IBFT is not set

View File

@ -307,6 +307,7 @@ CONFIG_IRQ_FORCED_THREADING=y
CONFIG_IRQ_WORK=y
# CONFIG_ISA is not set
CONFIG_ISA_DMA_API=y
# CONFIG_ISCSI_IBFT is not set
# CONFIG_ISCSI_IBFT_FIND is not set
# CONFIG_IT8712F_WDT is not set
# CONFIG_IT87_WDT is not set
@ -384,7 +385,6 @@ CONFIG_NVRAM=y
CONFIG_OLD_SIGACTION=y
CONFIG_OLD_SIGSUSPEND3=y
CONFIG_OPROFILE_NMI_TIMER=y
# CONFIG_OPTIMIZE_INLINING is not set
CONFIG_OUTPUT_FORMAT="elf32-i386"
CONFIG_PADATA=y
CONFIG_PAGE_OFFSET=0xC0000000
@ -446,6 +446,7 @@ CONFIG_SATA_AHCI_PLATFORM=y
CONFIG_SATA_MV=y
CONFIG_SATA_NV=y
CONFIG_SATA_VIA=y
# CONFIG_SATA_ZPODD is not set
# CONFIG_SBC7240_WDT is not set
# CONFIG_SBC8360_WDT is not set
# CONFIG_SBC_EPX_C3_WATCHDOG is not set
@ -593,5 +594,3 @@ CONFIG_XPS=y
CONFIG_XZ_DEC_BCJ=y
CONFIG_XZ_DEC_X86=y
CONFIG_ZLIB_INFLATE=y
# CONFIG_SATA_ZPODD is not set
# CONFIG_ISCSI_IBFT is not set

View File

@ -0,0 +1,53 @@
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 1905ce9..a4a3ef2 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -164,6 +164,7 @@
static void early_init_intel(struct cpuinfo_x86 *c)
{
u64 misc_enable;
+ bool allow_fast_string = true;
/* Unmask CPUID levels if masked: */
if (c->x86 > 6 || (c->x86 == 6 && c->x86_model >= 0xd)) {
@@ -259,17 +260,35 @@
*
* Enable PAT WC only on P4, Core 2 or later CPUs.
*/
- if (c->x86 == 6 && c->x86_model < 15)
+ if (c->x86 == 6 && c->x86_model < 15) {
+ allow_fast_string = false;
clear_cpu_cap(c, X86_FEATURE_PAT);
-
+ }
/*
- * If fast string is not enabled in IA32_MISC_ENABLE for any reason,
- * clear the fast string and enhanced fast string CPU capabilities.
+ * If BIOS didn't enable fast string operation, try to enable
+ * it ourselves. If that fails, then clear the fast string
+ * and enhanced fast string CPU capabilities.
*/
if (c->x86 > 6 || (c->x86 == 6 && c->x86_model >= 0xd)) {
rdmsrl(MSR_IA32_MISC_ENABLE, misc_enable);
+
+ if (allow_fast_string &&
+ !(misc_enable & MSR_IA32_MISC_ENABLE_FAST_STRING)) {
+ misc_enable |= MSR_IA32_MISC_ENABLE_FAST_STRING;
+ wrmsrl_safe(MSR_IA32_MISC_ENABLE, misc_enable);
+
+ /* Re-read to make sure it stuck. */
+ rdmsrl(MSR_IA32_MISC_ENABLE, misc_enable);
+
+ if (misc_enable & MSR_IA32_MISC_ENABLE_FAST_STRING)
+ printk_once(KERN_INFO "BIOS disabled fast string operation, re-enabled sucessfully.\n");
+ }
+
if (!(misc_enable & MSR_IA32_MISC_ENABLE_FAST_STRING)) {
- pr_info("Disabled fast string operations\n");
+ if (allow_fast_string)
+ printk_once(KERN_INFO FW_WARN "BIOS disabled fast string operation, re-enable failed.\n");
+ else
+ printk_once(KERN_INFO "Disabled fast string operations\n");
setup_clear_cpu_cap(X86_FEATURE_REP_GOOD);
setup_clear_cpu_cap(X86_FEATURE_ERMS);
}

View File

@ -0,0 +1,20 @@
diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 1d7770447b3e..1691311e5b23 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -705,8 +705,14 @@ void __init fpu__init_system_xstate(void)
WARN_ON_FPU(!on_boot_cpu);
on_boot_cpu = 0;
+ if (!boot_cpu_has(X86_FEATURE_FPU)) {
+ pr_info("x86/fpu: No FPU detected.\n");
+ return;
+ }
+
if (!boot_cpu_has(X86_FEATURE_XSAVE)) {
- pr_info("x86/fpu: Legacy x87 FPU detected.\n");
+ pr_info("x86/fpu: x87 FPU will use %s.\n",
+ boot_cpu_has(X86_FEATURE_FXSR) ? "FXSAVE" : "FSAVE");
return;
}