From: Chen Jiahao chenjiahao16@huawei.com
hulk inclusion category: feature bugzilla: 186682, https://gitee.com/openeuler/kernel/issues/I5ZUU3
--------------------------------
openEuler 5.10 enables spectre-bhb mitigation by default for ARM64, which may cause performance regression. implement a cmdline parameter 'nospectre_bhb' to provide an option to disable spectre-bhb mitigation.
Signed-off-by: Chen Jiahao chenjiahao16@huawei.com Reviewed-by: Zhang Jianhua chris.zjh@huawei.com Reviewed-by: Liao Chang liaochang1@huawei.com Signed-off-by: Zheng Zengkai zhengzengkai@huawei.com --- arch/arm64/kernel/proton-pack.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/kernel/proton-pack.c b/arch/arm64/kernel/proton-pack.c index e807f77737e0..a010a28d9b68 100644 --- a/arch/arm64/kernel/proton-pack.c +++ b/arch/arm64/kernel/proton-pack.c @@ -81,6 +81,8 @@ ssize_t cpu_show_spectre_v1(struct device *dev, struct device_attribute *attr, static enum mitigation_state spectre_v2_state;
static bool __read_mostly __nospectre_v2; +static bool __read_mostly __nospectre_bhb; + static int __init parse_spectre_v2_param(char *str) { __nospectre_v2 = true; @@ -88,6 +90,13 @@ static int __init parse_spectre_v2_param(char *str) } early_param("nospectre_v2", parse_spectre_v2_param);
+static int __init parse_spectre_bhb_param(char *str) +{ + __nospectre_bhb = true; + return 0; +} +early_param("nospectre_bhb", parse_spectre_bhb_param); + static bool spectre_v2_mitigations_off(void) { bool ret = __nospectre_v2 || cpu_mitigations_off(); @@ -1060,7 +1069,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 (__nospectre_bhb || cpu_mitigations_off()) { pr_info_once("spectre-bhb mitigation disabled by command line option\n"); } else if (supports_ecbhb(SCOPE_LOCAL_CPU)) { state = SPECTRE_MITIGATED;