Commit 4ff8cda8 authored by Chen Jiahao's avatar Chen Jiahao Committed by Zheng Zengkai
Browse files

arm64: Provide a command line to disable spectre_bhb mitigation

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: default avatarChen Jiahao <chenjiahao16@huawei.com>
Reviewed-by: default avatarZhang Jianhua <chris.zjh@huawei.com>
Reviewed-by: default avatarLiao Chang <liaochang1@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 81ad62c3
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -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;