[PATCH OLK-6.6 0/3] Revert syscall performance degradation patches

This patch group has about 30% impact on syscall performance. liwei (3): Revert "x86/bugs: Replace CONFIG_SPECTRE_BHI_{ON,OFF} with CONFIG_MITIGATION_SPECTRE_BHI" Revert "x86/bugs: Remove CONFIG_BHI_MITIGATION_AUTO and spectre_bhi=auto" Revert "x86: set SPECTRE_BHI_ON as default" Documentation/admin-guide/hw-vuln/spectre.rst | 4 ++++ .../admin-guide/kernel-parameters.txt | 3 +++ arch/x86/Kconfig | 21 ++++++++++++++++--- arch/x86/kernel/cpu/bugs.c | 10 ++++++++- 4 files changed, 34 insertions(+), 4 deletions(-) -- 2.25.1

hulk inclusion category: performance bugzilla: https://gitee.com/openeuler/kernel/issues/I9O7V8 --------------------------- This reverts commit a35298b9398e7f5d2dac99928bfbd8397d38af04. Revert syscall performance degradation pre-patch. Signed-off-by: liwei <liwei728@huawei.com> --- arch/x86/Kconfig | 17 ++++++++++++++--- arch/x86/kernel/cpu/bugs.c | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index a993a3716738..d7562807f538 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2633,16 +2633,27 @@ config MITIGATION_RFDS stored in floating point, vector and integer registers. See also <file:Documentation/admin-guide/hw-vuln/reg-file-data-sampling.rst> -config MITIGATION_SPECTRE_BHI - bool "Mitigate Spectre-BHB (Branch History Injection)" +choice + prompt "Clear branch history" depends on CPU_SUP_INTEL - default y + default SPECTRE_BHI_ON help Enable BHI mitigations. BHI attacks are a form of Spectre V2 attacks where the branch history buffer is poisoned to speculatively steer indirect branches. See <file:Documentation/admin-guide/hw-vuln/spectre.rst> +config SPECTRE_BHI_ON + bool "on" + help + Equivalent to setting spectre_bhi=on command line parameter. +config SPECTRE_BHI_OFF + bool "off" + help + Equivalent to setting spectre_bhi=off command line parameter. + +endchoice + endif config ARCH_HAS_ADD_PAGES diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index c2dc9b7426ac..4c5e33b0130b 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -1627,7 +1627,7 @@ enum bhi_mitigations { }; static enum bhi_mitigations bhi_mitigation __ro_after_init = - IS_ENABLED(CONFIG_MITIGATION_SPECTRE_BHI) ? BHI_MITIGATION_ON : BHI_MITIGATION_OFF; + IS_ENABLED(CONFIG_SPECTRE_BHI_ON) ? BHI_MITIGATION_ON : BHI_MITIGATION_OFF; static int __init spectre_bhi_parse_cmdline(char *str) { -- 2.25.1

hulk inclusion category: performance bugzilla: https://gitee.com/openeuler/kernel/issues/I9O7V8 --------------------------- This reverts commit 1ef2a4268dee6b0cc9156de58b0978228f03f3d8. Revert syscall performance degradation pre-patch. Signed-off-by: liwei <liwei728@huawei.com> --- Documentation/admin-guide/hw-vuln/spectre.rst | 4 ++++ Documentation/admin-guide/kernel-parameters.txt | 3 +++ arch/x86/Kconfig | 4 ++++ arch/x86/kernel/cpu/bugs.c | 10 +++++++++- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/hw-vuln/spectre.rst b/Documentation/admin-guide/hw-vuln/spectre.rst index e0a1be97fa75..081f28900898 100644 --- a/Documentation/admin-guide/hw-vuln/spectre.rst +++ b/Documentation/admin-guide/hw-vuln/spectre.rst @@ -669,6 +669,10 @@ kernel command line. needed. off Disable the mitigation. + auto + Enable the HW mitigation if needed, but + *don't* enable the SW mitigation except for KVM. + The system may be vulnerable. For spectre_v2_user see Documentation/admin-guide/kernel-parameters.txt diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 1fd094bec52a..f0ac624c73bb 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -6054,6 +6054,9 @@ on - (default) Enable the HW or SW mitigation as needed. off - Disable the mitigation. + auto - Enable the HW mitigation if needed, but + *don't* enable the SW mitigation except + for KVM. The system may be vulnerable. spectre_v2= [X86] Control mitigation of Spectre variant 2 (indirect branch speculation) vulnerability. diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index d7562807f538..3f0c286ac662 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2651,6 +2651,10 @@ config SPECTRE_BHI_OFF bool "off" help Equivalent to setting spectre_bhi=off command line parameter. +config SPECTRE_BHI_AUTO + bool "auto" + help + Equivalent to setting spectre_bhi=auto command line parameter. endchoice diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 4c5e33b0130b..c3cb6e88ee4e 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -1624,10 +1624,13 @@ static bool __init spec_ctrl_bhi_dis(void) enum bhi_mitigations { BHI_MITIGATION_OFF, BHI_MITIGATION_ON, + BHI_MITIGATION_AUTO, }; static enum bhi_mitigations bhi_mitigation __ro_after_init = - IS_ENABLED(CONFIG_SPECTRE_BHI_ON) ? BHI_MITIGATION_ON : BHI_MITIGATION_OFF; + IS_ENABLED(CONFIG_SPECTRE_BHI_ON) ? BHI_MITIGATION_ON : + IS_ENABLED(CONFIG_SPECTRE_BHI_OFF) ? BHI_MITIGATION_OFF : + BHI_MITIGATION_AUTO; static int __init spectre_bhi_parse_cmdline(char *str) { @@ -1638,6 +1641,8 @@ static int __init spectre_bhi_parse_cmdline(char *str) bhi_mitigation = BHI_MITIGATION_OFF; else if (!strcmp(str, "on")) bhi_mitigation = BHI_MITIGATION_ON; + else if (!strcmp(str, "auto")) + bhi_mitigation = BHI_MITIGATION_AUTO; else pr_err("Ignoring unknown spectre_bhi option (%s)", str); @@ -1668,6 +1673,9 @@ static void __init bhi_select_mitigation(void) setup_force_cpu_cap(X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT); pr_info("Spectre BHI mitigation: SW BHB clearing on vm exit\n"); + if (bhi_mitigation == BHI_MITIGATION_AUTO) + return; + /* Mitigate syscalls when the mitigation is forced =on */ setup_force_cpu_cap(X86_FEATURE_CLEAR_BHB_LOOP); pr_info("Spectre BHI mitigation: SW BHB clearing on syscall\n"); -- 2.25.1

hulk inclusion category: performance bugzilla: https://gitee.com/openeuler/kernel/issues/I9O7V8 --------------------------- This reverts commit ed1788cccc679592de2cc89a4992d2990e24d44c. This patch has about 30% impact on syscall performance. Signed-off-by: liwei <liwei728@huawei.com> --- arch/x86/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 3f0c286ac662..308b869d1551 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2636,7 +2636,7 @@ config MITIGATION_RFDS choice prompt "Clear branch history" depends on CPU_SUP_INTEL - default SPECTRE_BHI_ON + default SPECTRE_BHI_AUTO help Enable BHI mitigations. BHI attacks are a form of Spectre V2 attacks where the branch history buffer is poisoned to speculatively steer -- 2.25.1

反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/7144 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/7... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/7144 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/7...
participants (2)
-
liwei
-
patchwork bot