arm64: spectre: increase parameters that can be used to turn off bhb mitigation individually
Subsystems (2)
PATCH 1/1 arm64: spectre: increase parameters that can be used to turn off bhb mitigation individually
From: Liu Song <[email protected]>
In our environment, it was found that the mitigation BHB has a great impact on the benchmark performance. For example, in the lmbench test, the "process fork && exit" test performance drops by 20%. So it is necessary to have the ability to turn off the mitigation individually through cmdline, thus avoiding having to compile the kernel by adjusting the config.
--- arch/arm64/kernel/proton-pack.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
arch/arm64/kernel/proton-pack.c +9 -1
@@ -988,6 +988,14 @@ static void this_cpu_set_vectors(enum arm64_bp_harden_el1_vectors slot)isb (); } +static bool __read_mostly __nospectre_bhb; +static int __init parse_spectre_bhb_param (char *str) +{ + __nospectre_bhb = true; +return 0 ; +} +early_param ("nospectre_bhb" , parse_spectre_bhb_param); +void spectre_bhb_enable_mitigation (const struct arm64_cpu_capabilities *entry) {bp_hardening_cb_t cpu_cb;
@@ -1001,7 +1009,7 @@ void spectre_bhb_enable_mitigation(const struct arm64_cpu_capabilities *entry)/* No point mitigating Spectre-BHB alone. */ }else if (!IS_ENABLED (CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY )) {pr_info_once ("spectre-bhb mitigation disabled by compile time option\n" ); - }else if (cpu_mitigations_off ()) { + }else if (cpu_mitigations_off () || __nospectre_bhb) {pr_info_once ("spectre-bhb mitigation disabled by command line option\n" ); }else if (supports_ecbhb (SCOPE_LOCAL_CPU )) { state =SPECTRE_MITIGATED ;
Signature · 1 line
1.8.3.1
Hi,
Is there any potential problem with this modification? Looking forward to your reply.
Thanks
Quoted 42 lines
From: Liu Song <[email protected]>
In our environment, it was found that the mitigation BHB has a great impact on the benchmark performance. For example, in the lmbench test, the "process fork && exit" test performance drops by 20%. So it is necessary to have the ability to turn off the mitigation individually through cmdline, thus avoiding having to compile the kernel by adjusting the config.
Signed-off-by Liu Song <[email protected]>--- arch/arm64/kernel/proton-pack.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)arch/arm64/kernel/proton-pack.c +9
-1@@ -988,6 +988,14 @@ static void this_cpu_set_vectors(enum arm64_bp_harden_el1_vectors slot)isb (); } +static bool __read_mostly __nospectre_bhb; +static int __init parse_spectre_bhb_param (char *str) +{ + __nospectre_bhb = true; +return 0 ; +} +early_param ("nospectre_bhb" , parse_spectre_bhb_param); +void spectre_bhb_enable_mitigation (const struct arm64_cpu_capabilities *entry) {bp_hardening_cb_t cpu_cb;@@ -1001,7 +1009,7 @@ void spectre_bhb_enable_mitigation(const struct arm64_cpu_capabilities *entry)/* No point mitigating Spectre-BHB alone. */ }else if (!IS_ENABLED (CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY )) {pr_info_once ("spectre-bhb mitigation disabled by compile time option\n" ); - }else if (cpu_mitigations_off ()) { + }else if (cpu_mitigations_off () || __nospectre_bhb) {pr_info_once ("spectre-bhb mitigation disabled by command line option\n" ); }else if (supports_ecbhb (SCOPE_LOCAL_CPU )) { state =SPECTRE_MITIGATED ;
Will Deacon
maintainerQuoted 34 lines · Liu Song
From: Liu Song <[email protected]>
In our environment, it was found that the mitigation BHB has a great impact on the benchmark performance. For example, in the lmbench test, the "process fork && exit" test performance drops by 20%. So it is necessary to have the ability to turn off the mitigation individually through cmdline, thus avoiding having to compile the kernel by adjusting the config.
Signed-off-by Liu Song <[email protected]>--- arch/arm64/kernel/proton-pack.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)arch/arm64/kernel/proton-pack.c +8
-0@@ -988,6 +988,14 @@ static void this_cpu_set_vectors(enum arm64_bp_harden_el1_vectors slot)isb (); } +static bool __read_mostly __nospectre_bhb; +static int __init parse_spectre_bhb_param (char *str) +{ + __nospectre_bhb = true; +return 0 ; +} +early_param ("nospectre_bhb" , parse_spectre_bhb_param); +void spectre_bhb_enable_mitigation (const struct arm64_cpu_capabilities *entry) {bp_hardening_cb_t cpu_cb;
arch/arm64/kernel/proton-pack.c void spectre_bhb_enable_mitigation(const struct arm64_cpu_capabilities *entry) · line 1015
Quoted 8 lines
arch/arm64/kernel/proton-pack.c +1
-1@@ -1001,7 +1009,7 @@ void spectre_bhb_enable_mitigation(const struct arm64_cpu_capabilities *entry)/* No point mitigating Spectre-BHB alone. */ }else if (!IS_ENABLED (CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY )) {pr_info_once ("spectre-bhb mitigation disabled by compile time option\n" ); - }else if (cpu_mitigations_off ()) { + }else if (cpu_mitigations_off () || __nospectre_bhb) {pr_info_once ("spectre-bhb mitigation disabled by command line option\n" ); }else if (supports_ecbhb (SCOPE_LOCAL_CPU )) { state =SPECTRE_MITIGATED ;
It would be good to have an Ack (or a shrug) from somebody @arm.com on this one.
Other than that, the documentation needs updating for the new option.
Will
Quoted 46 lines · Liu Song
Quoted 34 lines
From: Liu Song <[email protected]>
In our environment, it was found that the mitigation BHB has a great impact on the benchmark performance. For example, in the lmbench test, the "process fork && exit" test performance drops by 20%. So it is necessary to have the ability to turn off the mitigation individually through cmdline, thus avoiding having to compile the kernel by adjusting the config.
Signed-off-by Liu Song <[email protected]>--- arch/arm64/kernel/proton-pack.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)arch/arm64/kernel/proton-pack.c +8
-0@@ -988,6 +988,14 @@ static void this_cpu_set_vectors(enum arm64_bp_harden_el1_vectors slot)isb (); } +static bool __read_mostly __nospectre_bhb; +static int __init parse_spectre_bhb_param (char *str) +{ + __nospectre_bhb = true; +return 0 ; +} +early_param ("nospectre_bhb" , parse_spectre_bhb_param); +void spectre_bhb_enable_mitigation (const struct arm64_cpu_capabilities *entry) {bp_hardening_cb_t cpu_cb;arch/arm64/kernel/proton-pack.c void spectre_bhb_enable_mitigation(const struct arm64_cpu_capabilities *entry) · line 1015
Quoted 8 lines
arch/arm64/kernel/proton-pack.c +1
-1@@ -1001,7 +1009,7 @@ void spectre_bhb_enable_mitigation(const struct arm64_cpu_capabilities *entry)/* No point mitigating Spectre-BHB alone. */ }else if (!IS_ENABLED (CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY )) {pr_info_once ("spectre-bhb mitigation disabled by compile time option\n" ); - }else if (cpu_mitigations_off ()) { + }else if (cpu_mitigations_off () || __nospectre_bhb) {pr_info_once ("spectre-bhb mitigation disabled by command line option\n" ); }else if (supports_ecbhb (SCOPE_LOCAL_CPU )) { state =SPECTRE_MITIGATED ;It would be good to have an Ack (or a shrug) from somebody @arm.com on this one.
Quoted 1 line
Other than that, the documentation needs updating for the new option.
Thanks for the reminder, I will post another V2 version.
Thanks
Quoted 2 lines
Will
PATCH v2 1/1 arm64: spectre: increase parameters that can be used to turn off bhb mitigation individually
From: Liu Song <[email protected]>
In our environment, it was found that the mitigation BHB has a great impact on the benchmark performance. For example, in the lmbench test, the "process fork && exit" test performance drops by 20%. So it is necessary to have the ability to turn off the mitigation individually through cmdline, thus avoiding having to compile the kernel by adjusting the config.
--- Documentation/admin-guide/kernel-parameters.txt | 5 +++++ arch/arm64/kernel/proton-pack.c | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +5 -0
@@ -3207,6 +3207,7 @@ spectre_v2_user=off [X86] spec_store_bypass_disable=off [X86,PPC] ssbd=force-off [ARM64] + nospectre_bhb [ARM64] l1tf=off [X86] mds=off [X86] tsx_async_abort=off [X86]
@@ -3631,6 +3632,10 @@ vulnerability. System may allow data leaks with this option. + nospectre_bhb [ARM64] Disable all mitigations for Spectre-BHB (branch + history injection) vulnerability. System may allow data leaks + with this option. + nospec_store_bypass_disable [HW] Disable all mitigations for the Speculative Store Bypass vulnerability
arch/arm64/kernel/proton-pack.c +9 -1
@@ -988,6 +988,14 @@ static void this_cpu_set_vectors(enum arm64_bp_harden_el1_vectors slot)isb (); } +static bool __read_mostly __nospectre_bhb; +static int __init parse_spectre_bhb_param (char *str) +{ + __nospectre_bhb = true; +return 0 ; +} +early_param ("nospectre_bhb" , parse_spectre_bhb_param); +void spectre_bhb_enable_mitigation (const struct arm64_cpu_capabilities *entry) {bp_hardening_cb_t cpu_cb;
@@ -1001,7 +1009,7 @@ void spectre_bhb_enable_mitigation(const struct arm64_cpu_capabilities *entry)/* No point mitigating Spectre-BHB alone. */ }else if (!IS_ENABLED (CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY )) {pr_info_once ("spectre-bhb mitigation disabled by compile time option\n" ); - }else if (cpu_mitigations_off ()) { + }else if (cpu_mitigations_off () || __nospectre_bhb) {pr_info_once ("spectre-bhb mitigation disabled by command line option\n" ); }else if (supports_ecbhb (SCOPE_LOCAL_CPU )) { state =SPECTRE_MITIGATED ;
Signature · 1 line
1.8.3.1