All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] arm64: spectre: increase parameters that can be used to turn off bhb mitigation individually
@ 2022-08-26 11:40 ` Liu Song
  0 siblings, 0 replies; 10+ messages in thread
From: Liu Song @ 2022-08-26 11:40 UTC (permalink / raw)
  To: catalin.marinas, will, james.morse; +Cc: linux-arm-kernel, linux-kernel

From: Liu Song <liusong@linux.alibaba.com>

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 <liusong@linux.alibaba.com>
---
 Documentation/admin-guide/kernel-parameters.txt |  5 +++++
 arch/arm64/kernel/proton-pack.c                 | 10 +++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index d7f3090..1edc9a6 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -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
 
diff --git a/arch/arm64/kernel/proton-pack.c b/arch/arm64/kernel/proton-pack.c
index 40be3a7..bd16903 100644
--- a/arch/arm64/kernel/proton-pack.c
+++ b/arch/arm64/kernel/proton-pack.c
@@ -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;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2] arm64: spectre: increase parameters that can be used to turn off bhb mitigation individually
@ 2022-08-26 11:40 ` Liu Song
  0 siblings, 0 replies; 10+ messages in thread
From: Liu Song @ 2022-08-26 11:40 UTC (permalink / raw)
  To: catalin.marinas, will, james.morse; +Cc: linux-arm-kernel, linux-kernel

From: Liu Song <liusong@linux.alibaba.com>

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 <liusong@linux.alibaba.com>
---
 Documentation/admin-guide/kernel-parameters.txt |  5 +++++
 arch/arm64/kernel/proton-pack.c                 | 10 +++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index d7f3090..1edc9a6 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -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
 
diff --git a/arch/arm64/kernel/proton-pack.c b/arch/arm64/kernel/proton-pack.c
index 40be3a7..bd16903 100644
--- a/arch/arm64/kernel/proton-pack.c
+++ b/arch/arm64/kernel/proton-pack.c
@@ -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;
-- 
1.8.3.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] arm64: spectre: increase parameters that can be used to turn off bhb mitigation individually
  2022-08-26 11:40 ` Liu Song
@ 2022-09-07 14:29   ` Catalin Marinas
  -1 siblings, 0 replies; 10+ messages in thread
From: Catalin Marinas @ 2022-09-07 14:29 UTC (permalink / raw)
  To: Liu Song; +Cc: will, james.morse, linux-arm-kernel, linux-kernel

On Fri, Aug 26, 2022 at 07:40:50PM +0800, Liu Song wrote:
> From: Liu Song <liusong@linux.alibaba.com>
> 
> 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 <liusong@linux.alibaba.com>

If people want to disable this mitigation and know what they are doing,
I have no objection:

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

(I guess that's more like 6.1 material)

-- 
Catalin

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] arm64: spectre: increase parameters that can be used to turn off bhb mitigation individually
@ 2022-09-07 14:29   ` Catalin Marinas
  0 siblings, 0 replies; 10+ messages in thread
From: Catalin Marinas @ 2022-09-07 14:29 UTC (permalink / raw)
  To: Liu Song; +Cc: will, james.morse, linux-arm-kernel, linux-kernel

On Fri, Aug 26, 2022 at 07:40:50PM +0800, Liu Song wrote:
> From: Liu Song <liusong@linux.alibaba.com>
> 
> 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 <liusong@linux.alibaba.com>

If people want to disable this mitigation and know what they are doing,
I have no objection:

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

(I guess that's more like 6.1 material)

-- 
Catalin

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] arm64: spectre: increase parameters that can be used to turn off bhb mitigation individually
  2022-09-07 14:29   ` Catalin Marinas
@ 2022-09-07 16:29     ` Will Deacon
  -1 siblings, 0 replies; 10+ messages in thread
From: Will Deacon @ 2022-09-07 16:29 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: Liu Song, james.morse, linux-arm-kernel, linux-kernel

On Wed, Sep 07, 2022 at 03:29:05PM +0100, Catalin Marinas wrote:
> On Fri, Aug 26, 2022 at 07:40:50PM +0800, Liu Song wrote:
> > From: Liu Song <liusong@linux.alibaba.com>
> > 
> > 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 <liusong@linux.alibaba.com>
> 
> If people want to disable this mitigation and know what they are doing,
> I have no objection:
> 
> Acked-by: Catalin Marinas <catalin.marinas@arm.com>

Thanks!

> (I guess that's more like 6.1 material)

Yup, agreed. I take it you'll pick it up, then?

Will

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] arm64: spectre: increase parameters that can be used to turn off bhb mitigation individually
@ 2022-09-07 16:29     ` Will Deacon
  0 siblings, 0 replies; 10+ messages in thread
From: Will Deacon @ 2022-09-07 16:29 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: Liu Song, james.morse, linux-arm-kernel, linux-kernel

On Wed, Sep 07, 2022 at 03:29:05PM +0100, Catalin Marinas wrote:
> On Fri, Aug 26, 2022 at 07:40:50PM +0800, Liu Song wrote:
> > From: Liu Song <liusong@linux.alibaba.com>
> > 
> > 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 <liusong@linux.alibaba.com>
> 
> If people want to disable this mitigation and know what they are doing,
> I have no objection:
> 
> Acked-by: Catalin Marinas <catalin.marinas@arm.com>

Thanks!

> (I guess that's more like 6.1 material)

Yup, agreed. I take it you'll pick it up, then?

Will

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] arm64: spectre: increase parameters that can be used to turn off bhb mitigation individually
  2022-08-26 11:40 ` Liu Song
@ 2022-09-09 18:08   ` Catalin Marinas
  -1 siblings, 0 replies; 10+ messages in thread
From: Catalin Marinas @ 2022-09-09 18:08 UTC (permalink / raw)
  To: james.morse, will, Liu Song; +Cc: linux-kernel, linux-arm-kernel

On Fri, 26 Aug 2022 19:40:50 +0800, Liu Song wrote:
> From: Liu Song <liusong@linux.alibaba.com>
> 
> 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.
> 
> [...]

Applied to arm64 (for-next/misc), thanks!

[1/1] arm64: spectre: increase parameters that can be used to turn off bhb mitigation individually
      https://git.kernel.org/arm64/c/877ace9eab7d

-- 
Catalin


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] arm64: spectre: increase parameters that can be used to turn off bhb mitigation individually
@ 2022-09-09 18:08   ` Catalin Marinas
  0 siblings, 0 replies; 10+ messages in thread
From: Catalin Marinas @ 2022-09-09 18:08 UTC (permalink / raw)
  To: james.morse, will, Liu Song; +Cc: linux-kernel, linux-arm-kernel

On Fri, 26 Aug 2022 19:40:50 +0800, Liu Song wrote:
> From: Liu Song <liusong@linux.alibaba.com>
> 
> 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.
> 
> [...]

Applied to arm64 (for-next/misc), thanks!

[1/1] arm64: spectre: increase parameters that can be used to turn off bhb mitigation individually
      https://git.kernel.org/arm64/c/877ace9eab7d

-- 
Catalin


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2] arm64: spectre: increase parameters that can be used to turn off bhb mitigation individually
  2022-08-26 11:08 [PATCH] " Liu Song
@ 2022-08-26 12:44   ` Liu Song
  0 siblings, 0 replies; 10+ messages in thread
From: Liu Song @ 2022-08-26 12:44 UTC (permalink / raw)
  To: liusong
  Cc: catalin.marinas, james.morse, linux-arm-kernel, linux-kernel, will

From: Liu Song <liusong@linux.alibaba.com>

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 <liusong@linux.alibaba.com>
---
 Documentation/admin-guide/kernel-parameters.txt |  5 +++++
 arch/arm64/kernel/proton-pack.c                 | 10 +++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index d7f3090..1edc9a6 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -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
 
diff --git a/arch/arm64/kernel/proton-pack.c b/arch/arm64/kernel/proton-pack.c
index 40be3a7..bd16903 100644
--- a/arch/arm64/kernel/proton-pack.c
+++ b/arch/arm64/kernel/proton-pack.c
@@ -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;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2] arm64: spectre: increase parameters that can be used to turn off bhb mitigation individually
@ 2022-08-26 12:44   ` Liu Song
  0 siblings, 0 replies; 10+ messages in thread
From: Liu Song @ 2022-08-26 12:44 UTC (permalink / raw)
  To: liusong
  Cc: catalin.marinas, james.morse, linux-arm-kernel, linux-kernel, will

From: Liu Song <liusong@linux.alibaba.com>

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 <liusong@linux.alibaba.com>
---
 Documentation/admin-guide/kernel-parameters.txt |  5 +++++
 arch/arm64/kernel/proton-pack.c                 | 10 +++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index d7f3090..1edc9a6 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -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
 
diff --git a/arch/arm64/kernel/proton-pack.c b/arch/arm64/kernel/proton-pack.c
index 40be3a7..bd16903 100644
--- a/arch/arm64/kernel/proton-pack.c
+++ b/arch/arm64/kernel/proton-pack.c
@@ -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;
-- 
1.8.3.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-09-09 18:09 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-26 11:40 [PATCH v2] arm64: spectre: increase parameters that can be used to turn off bhb mitigation individually Liu Song
2022-08-26 11:40 ` Liu Song
2022-09-07 14:29 ` Catalin Marinas
2022-09-07 14:29   ` Catalin Marinas
2022-09-07 16:29   ` Will Deacon
2022-09-07 16:29     ` Will Deacon
2022-09-09 18:08 ` Catalin Marinas
2022-09-09 18:08   ` Catalin Marinas
  -- strict thread matches above, loose matches on Subject: below --
2022-08-26 11:08 [PATCH] " Liu Song
2022-08-26 12:44 ` [PATCH v2] " Liu Song
2022-08-26 12:44   ` Liu Song

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.