diff mbox series

[v5] powerpc/64s: support nospectre_v2 cmdline option

Message ID 20190524024647.381-1-cmr@informatik.wtf (mailing list archive)
State Accepted
Commit d8f0e0b073e1ec52a05f0c2a56318b47387d2f10
Headers show
Series [v5] powerpc/64s: support nospectre_v2 cmdline option | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch next (8150a153c013aa2dd1ffae43370b89ac1347a7fb)
snowpatch_ozlabs/build-ppc64le fail build failed!
snowpatch_ozlabs/build-ppc64be fail build failed!
snowpatch_ozlabs/build-ppc64e success Build succeeded
snowpatch_ozlabs/build-pmac32 success Build succeeded
snowpatch_ozlabs/checkpatch success total: 0 errors, 0 warnings, 0 checks, 43 lines checked
snowpatch_ozlabs/apply_patch success Successfully applied on branch next (e610a466d16a086e321f0bd421e2fc75cff28605)
snowpatch_ozlabs/build-ppc64le fail build failed!
snowpatch_ozlabs/build-ppc64be fail build failed!
snowpatch_ozlabs/build-ppc64e warning Build succeeded but added 303 new sparse warnings
snowpatch_ozlabs/build-pmac32 warning Build succeeded but added 153 new sparse warnings
snowpatch_ozlabs/checkpatch success total: 0 errors, 0 warnings, 0 checks, 43 lines checked
snowpatch_ozlabs/apply_patch success Successfully applied on branch next (c1774fe4ca71f894bbf1ef92ad928d72775c7b29)
snowpatch_ozlabs/build-ppc64le fail build failed!
snowpatch_ozlabs/build-ppc64be fail build failed!
snowpatch_ozlabs/build-ppc64e warning Build succeeded but added 304 new sparse warnings
snowpatch_ozlabs/build-pmac32 warning Build succeeded but added 153 new sparse warnings
snowpatch_ozlabs/checkpatch success total: 0 errors, 0 warnings, 0 checks, 43 lines checked
snowpatch_ozlabs/apply_patch success Successfully applied on branch next (c1774fe4ca71f894bbf1ef92ad928d72775c7b29)
snowpatch_ozlabs/build-ppc64le fail build failed!
snowpatch_ozlabs/build-ppc64be fail build failed!
snowpatch_ozlabs/build-ppc64e warning Build succeeded but added 304 new sparse warnings
snowpatch_ozlabs/build-pmac32 warning Build succeeded but added 153 new sparse warnings
snowpatch_ozlabs/checkpatch success total: 0 errors, 0 warnings, 0 checks, 43 lines checked
snowpatch_ozlabs/apply_patch success Successfully applied on branch next (c1774fe4ca71f894bbf1ef92ad928d72775c7b29)
snowpatch_ozlabs/build-ppc64le fail build failed!
snowpatch_ozlabs/build-ppc64be fail build failed!
snowpatch_ozlabs/build-ppc64e warning Build succeeded but added 304 new sparse warnings
snowpatch_ozlabs/build-pmac32 warning Build succeeded but added 153 new sparse warnings
snowpatch_ozlabs/checkpatch success Test checkpatch on branch next
snowpatch_ozlabs/apply_patch success Successfully applied on branch next (5df1cfa433945bbe10ea04e8d2733f8e736e1183)
snowpatch_ozlabs/build-ppc64le fail build failed!
snowpatch_ozlabs/build-ppc64be fail build failed!
snowpatch_ozlabs/build-ppc64e warning Build succeeded but added 132 new sparse warnings
snowpatch_ozlabs/build-pmac32 success Build succeeded
snowpatch_ozlabs/checkpatch success total: 0 errors, 0 warnings, 0 checks, 43 lines checked
snowpatch_ozlabs/apply_patch success Successfully applied on branch next (5df1cfa433945bbe10ea04e8d2733f8e736e1183)
snowpatch_ozlabs/build-ppc64le fail build failed!
snowpatch_ozlabs/build-ppc64be fail build failed!
snowpatch_ozlabs/build-ppc64e success Build succeeded
snowpatch_ozlabs/build-pmac32 success Build succeeded
snowpatch_ozlabs/checkpatch success total: 0 errors, 0 warnings, 0 checks, 43 lines checked
snowpatch_ozlabs/apply_patch success Successfully applied on branch next (a2b6f26c264e510f1d76ce347e34a21fbda9d8b2)
snowpatch_ozlabs/build-ppc64le success Build succeeded
snowpatch_ozlabs/build-ppc64be success Build succeeded
snowpatch_ozlabs/build-ppc64e success Build succeeded
snowpatch_ozlabs/build-pmac32 success Build succeeded
snowpatch_ozlabs/checkpatch success total: 0 errors, 0 warnings, 0 checks, 43 lines checked
snowpatch_ozlabs/apply_patch success Successfully applied on branch next (a2b6f26c264e510f1d76ce347e34a21fbda9d8b2)
snowpatch_ozlabs/build-ppc64le success Build succeeded
snowpatch_ozlabs/build-ppc64be success Build succeeded
snowpatch_ozlabs/build-ppc64e success Build succeeded
snowpatch_ozlabs/build-pmac32 success Build succeeded
snowpatch_ozlabs/checkpatch success total: 0 errors, 0 warnings, 0 checks, 43 lines checked

Commit Message

Christopher M. Riedl May 24, 2019, 2:46 a.m. UTC
Add support for disabling the kernel implemented spectre v2 mitigation
(count cache flush on context switch) via the nospectre_v2 and
mitigations=off cmdline options.

Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Christopher M. Riedl <cmr@informatik.wtf>
Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com>
---
v4->v5:
	Fix checkpatch complaint
 arch/powerpc/kernel/security.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

Comments

Andrew Donnellan June 5, 2019, 7:42 a.m. UTC | #1
On 24/5/19 12:46 pm, Christopher M. Riedl wrote:
> Add support for disabling the kernel implemented spectre v2 mitigation
> (count cache flush on context switch) via the nospectre_v2 and
> mitigations=off cmdline options.
> 
> Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
> Signed-off-by: Christopher M. Riedl <cmr@informatik.wtf>
> Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com>

snowpatch is whinging about this breaking the build for some reason... 
https://patchwork.ozlabs.org/patch/1104583/


> ---
> v4->v5:
> 	Fix checkpatch complaint
>   arch/powerpc/kernel/security.c | 19 ++++++++++++++++---
>   1 file changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/security.c b/arch/powerpc/kernel/security.c
> index e1c9cf079503..7cfcb294b11c 100644
> --- a/arch/powerpc/kernel/security.c
> +++ b/arch/powerpc/kernel/security.c
> @@ -28,7 +28,7 @@ static enum count_cache_flush_type count_cache_flush_type = COUNT_CACHE_FLUSH_NO
>   bool barrier_nospec_enabled;
>   static bool no_nospec;
>   static bool btb_flush_enabled;
> -#ifdef CONFIG_PPC_FSL_BOOK3E
> +#if defined(CONFIG_PPC_FSL_BOOK3E) || defined(CONFIG_PPC_BOOK3S_64)
>   static bool no_spectrev2;
>   #endif
>   
> @@ -114,7 +114,7 @@ static __init int security_feature_debugfs_init(void)
>   device_initcall(security_feature_debugfs_init);
>   #endif /* CONFIG_DEBUG_FS */
>   
> -#ifdef CONFIG_PPC_FSL_BOOK3E
> +#if defined(CONFIG_PPC_FSL_BOOK3E) || defined(CONFIG_PPC_BOOK3S_64)
>   static int __init handle_nospectre_v2(char *p)
>   {
>   	no_spectrev2 = true;
> @@ -122,6 +122,9 @@ static int __init handle_nospectre_v2(char *p)
>   	return 0;
>   }
>   early_param("nospectre_v2", handle_nospectre_v2);
> +#endif /* CONFIG_PPC_FSL_BOOK3E || CONFIG_PPC_BOOK3S_64 */
> +
> +#ifdef CONFIG_PPC_FSL_BOOK3E
>   void setup_spectre_v2(void)
>   {
>   	if (no_spectrev2 || cpu_mitigations_off())
> @@ -399,7 +402,17 @@ static void toggle_count_cache_flush(bool enable)
>   
>   void setup_count_cache_flush(void)
>   {
> -	toggle_count_cache_flush(true);
> +	bool enable = true;
> +
> +	if (no_spectrev2 || cpu_mitigations_off()) {
> +		if (security_ftr_enabled(SEC_FTR_BCCTRL_SERIALISED) ||
> +		    security_ftr_enabled(SEC_FTR_COUNT_CACHE_DISABLED))
> +			pr_warn("Spectre v2 mitigations not under software control, can't disable\n");
> +
> +		enable = false;
> +	}
> +
> +	toggle_count_cache_flush(enable);
>   }
>   
>   #ifdef CONFIG_DEBUG_FS
>
Andrew Donnellan July 9, 2019, 8:08 a.m. UTC | #2
On 5/6/19 5:42 pm, Andrew Donnellan wrote:
> On 24/5/19 12:46 pm, Christopher M. Riedl wrote:
>> Add support for disabling the kernel implemented spectre v2 mitigation
>> (count cache flush on context switch) via the nospectre_v2 and
>> mitigations=off cmdline options.
>>
>> Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
>> Signed-off-by: Christopher M. Riedl <cmr@informatik.wtf>
>> Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com>
> 
> snowpatch is whinging about this breaking the build for some reason... 
> https://patchwork.ozlabs.org/patch/1104583/

Upon further inspection, it appears this was bogus, and now snowpatch is 
passing it happily.
Michael Ellerman Aug. 28, 2019, 4:24 a.m. UTC | #3
On Fri, 2019-05-24 at 02:46:48 UTC, "Christopher M. Riedl" wrote:
> Add support for disabling the kernel implemented spectre v2 mitigation
> (count cache flush on context switch) via the nospectre_v2 and
> mitigations=off cmdline options.
> 
> Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
> Signed-off-by: Christopher M. Riedl <cmr@informatik.wtf>
> Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/d8f0e0b073e1ec52a05f0c2a56318b47387d2f10

cheers
diff mbox series

Patch

diff --git a/arch/powerpc/kernel/security.c b/arch/powerpc/kernel/security.c
index e1c9cf079503..7cfcb294b11c 100644
--- a/arch/powerpc/kernel/security.c
+++ b/arch/powerpc/kernel/security.c
@@ -28,7 +28,7 @@  static enum count_cache_flush_type count_cache_flush_type = COUNT_CACHE_FLUSH_NO
 bool barrier_nospec_enabled;
 static bool no_nospec;
 static bool btb_flush_enabled;
-#ifdef CONFIG_PPC_FSL_BOOK3E
+#if defined(CONFIG_PPC_FSL_BOOK3E) || defined(CONFIG_PPC_BOOK3S_64)
 static bool no_spectrev2;
 #endif
 
@@ -114,7 +114,7 @@  static __init int security_feature_debugfs_init(void)
 device_initcall(security_feature_debugfs_init);
 #endif /* CONFIG_DEBUG_FS */
 
-#ifdef CONFIG_PPC_FSL_BOOK3E
+#if defined(CONFIG_PPC_FSL_BOOK3E) || defined(CONFIG_PPC_BOOK3S_64)
 static int __init handle_nospectre_v2(char *p)
 {
 	no_spectrev2 = true;
@@ -122,6 +122,9 @@  static int __init handle_nospectre_v2(char *p)
 	return 0;
 }
 early_param("nospectre_v2", handle_nospectre_v2);
+#endif /* CONFIG_PPC_FSL_BOOK3E || CONFIG_PPC_BOOK3S_64 */
+
+#ifdef CONFIG_PPC_FSL_BOOK3E
 void setup_spectre_v2(void)
 {
 	if (no_spectrev2 || cpu_mitigations_off())
@@ -399,7 +402,17 @@  static void toggle_count_cache_flush(bool enable)
 
 void setup_count_cache_flush(void)
 {
-	toggle_count_cache_flush(true);
+	bool enable = true;
+
+	if (no_spectrev2 || cpu_mitigations_off()) {
+		if (security_ftr_enabled(SEC_FTR_BCCTRL_SERIALISED) ||
+		    security_ftr_enabled(SEC_FTR_COUNT_CACHE_DISABLED))
+			pr_warn("Spectre v2 mitigations not under software control, can't disable\n");
+
+		enable = false;
+	}
+
+	toggle_count_cache_flush(enable);
 }
 
 #ifdef CONFIG_DEBUG_FS