提交 19d98b4d 编写于 作者: C Christopher M. Riedl 提交者: Greg Kroah-Hartman

powerpc/64s: support nospectre_v2 cmdline option

commit d8f0e0b073e1ec52a05f0c2a56318b47387d2f10 upstream.

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: NMichael Ellerman <mpe@ellerman.id.au>
Signed-off-by: NChristopher M. Riedl <cmr@informatik.wtf>
Reviewed-by: NAndrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20190524024647.381-1-cmr@informatik.wtfSigned-off-by: NDaniel Axtens <dja@axtens.net>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 b7e2a040
...@@ -28,7 +28,7 @@ static enum count_cache_flush_type count_cache_flush_type = COUNT_CACHE_FLUSH_NO ...@@ -28,7 +28,7 @@ static enum count_cache_flush_type count_cache_flush_type = COUNT_CACHE_FLUSH_NO
bool barrier_nospec_enabled; bool barrier_nospec_enabled;
static bool no_nospec; static bool no_nospec;
static bool btb_flush_enabled; 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; static bool no_spectrev2;
#endif #endif
...@@ -106,7 +106,7 @@ static __init int barrier_nospec_debugfs_init(void) ...@@ -106,7 +106,7 @@ static __init int barrier_nospec_debugfs_init(void)
device_initcall(barrier_nospec_debugfs_init); device_initcall(barrier_nospec_debugfs_init);
#endif /* CONFIG_DEBUG_FS */ #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) static int __init handle_nospectre_v2(char *p)
{ {
no_spectrev2 = true; no_spectrev2 = true;
...@@ -114,6 +114,9 @@ static int __init handle_nospectre_v2(char *p) ...@@ -114,6 +114,9 @@ static int __init handle_nospectre_v2(char *p)
return 0; return 0;
} }
early_param("nospectre_v2", handle_nospectre_v2); 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) void setup_spectre_v2(void)
{ {
if (no_spectrev2 || cpu_mitigations_off()) if (no_spectrev2 || cpu_mitigations_off())
...@@ -391,7 +394,17 @@ static void toggle_count_cache_flush(bool enable) ...@@ -391,7 +394,17 @@ static void toggle_count_cache_flush(bool enable)
void setup_count_cache_flush(void) 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 #ifdef CONFIG_DEBUG_FS
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册