From d46b6d79700d183fc6ecab67c23ea524130be913 Mon Sep 17 00:00:00 2001 From: LEAN-ESX Date: Tue, 15 Oct 2019 22:50:02 -0700 Subject: [PATCH] x86: Enable fast strings on Intel CPUs if BIOS hasn't config for kernel 4.9 --- .../luci-app-ssr-plus/po/zh-cn/ssr-plus.po | 6 ++ ...ings-on-Intel-if-BIOS-hasn-t-already.patch | 57 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 target/linux/x86/patches-4.9/900-x86-Enable-fast-strings-on-Intel-if-BIOS-hasn-t-already.patch diff --git a/package/lean/luci-app-ssr-plus/po/zh-cn/ssr-plus.po b/package/lean/luci-app-ssr-plus/po/zh-cn/ssr-plus.po index b261d79c0..28fd353d0 100644 --- a/package/lean/luci-app-ssr-plus/po/zh-cn/ssr-plus.po +++ b/package/lean/luci-app-ssr-plus/po/zh-cn/ssr-plus.po @@ -511,3 +511,9 @@ msgstr "仅常用端口(不走P2P流量到代理)" msgid "Ping Latency" msgstr "Ping延迟" + +msgid "Bypass Domain List" +msgstr "域名白名单" + +msgid "Black Domain List" +msgstr "域名黑名单" diff --git a/target/linux/x86/patches-4.9/900-x86-Enable-fast-strings-on-Intel-if-BIOS-hasn-t-already.patch b/target/linux/x86/patches-4.9/900-x86-Enable-fast-strings-on-Intel-if-BIOS-hasn-t-already.patch new file mode 100644 index 000000000..b23ab971a --- /dev/null +++ b/target/linux/x86/patches-4.9/900-x86-Enable-fast-strings-on-Intel-if-BIOS-hasn-t-already.patch @@ -0,0 +1,57 @@ +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 +@@ -124,6 +124,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)) { +@@ -233,20 +234,39 @@ + * Ingo Molnar reported a Pentium D (model 6) and a Xeon + * (model 2) with the same problem. + */ +- if (c->x86 == 15) ++ if (c->x86 == 15) { ++ allow_fast_string = false; + if (msr_clear_bit(MSR_IA32_MISC_ENABLE, + MSR_IA32_MISC_ENABLE_FAST_STRING_BIT) > 0) + pr_info("kmemcheck: Disabling fast string operations\n"); ++ } + #endif + + /* +- * 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); + } +