* [PATCH v2] powerpc/64s: support nospectre_v2 cmdline option
@ 2019-05-07 2:43 Christopher M. Riedl
2019-05-07 5:10 ` Andrew Donnellan
2019-05-07 9:54 ` Michael Ellerman
0 siblings, 2 replies; 4+ messages in thread
From: Christopher M. Riedl @ 2019-05-07 2:43 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Christopher M. Riedl, ajd
Add support for disabling the kernel implemented spectre v2 mitigation
(count cache flush on context switch) via the nospectre_v2 cmdline
option.
Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Christopher M. Riedl <cmr@informatik.wtf>
---
v1->v2:
add call to toggle_count_cache_flush(false)
arch/powerpc/kernel/security.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kernel/security.c b/arch/powerpc/kernel/security.c
index b33bafb8fcea..d775da9b9227 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
@@ -106,7 +106,7 @@ static __init int barrier_nospec_debugfs_init(void)
device_initcall(barrier_nospec_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;
@@ -114,6 +114,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)
@@ -391,6 +394,15 @@ static void toggle_count_cache_flush(bool enable)
void setup_count_cache_flush(void)
{
+ if (no_spectrev2) {
+ 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");
+
+ toggle_count_cache_flush(false);
+ return;
+ }
+
toggle_count_cache_flush(true);
}
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] powerpc/64s: support nospectre_v2 cmdline option
2019-05-07 2:43 [PATCH v2] powerpc/64s: support nospectre_v2 cmdline option Christopher M. Riedl
@ 2019-05-07 5:10 ` Andrew Donnellan
2019-05-07 9:54 ` Michael Ellerman
1 sibling, 0 replies; 4+ messages in thread
From: Andrew Donnellan @ 2019-05-07 5:10 UTC (permalink / raw)
To: Christopher M. Riedl, linuxppc-dev
On 7/5/19 12:43 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 cmdline
> option.
>
> 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>
> ---
> v1->v2:
> add call to toggle_count_cache_flush(false)
>
> arch/powerpc/kernel/security.c | 16 ++++++++++++++--
> 1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/kernel/security.c b/arch/powerpc/kernel/security.c
> index b33bafb8fcea..d775da9b9227 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
>
> @@ -106,7 +106,7 @@ static __init int barrier_nospec_debugfs_init(void)
> device_initcall(barrier_nospec_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;
> @@ -114,6 +114,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)
> @@ -391,6 +394,15 @@ static void toggle_count_cache_flush(bool enable)
>
> void setup_count_cache_flush(void)
> {
> + if (no_spectrev2) {
> + 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");
> +
> + toggle_count_cache_flush(false);
> + return;
> + }
> +
> toggle_count_cache_flush(true);
> }
>
>
--
Andrew Donnellan OzLabs, ADL Canberra
ajd@linux.ibm.com IBM Australia Limited
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] powerpc/64s: support nospectre_v2 cmdline option
2019-05-07 2:43 [PATCH v2] powerpc/64s: support nospectre_v2 cmdline option Christopher M. Riedl
2019-05-07 5:10 ` Andrew Donnellan
@ 2019-05-07 9:54 ` Michael Ellerman
2019-05-07 11:54 ` Christopher M Riedl
1 sibling, 1 reply; 4+ messages in thread
From: Michael Ellerman @ 2019-05-07 9:54 UTC (permalink / raw)
To: Christopher M. Riedl, linuxppc-dev; +Cc: Christopher M. Riedl, ajd
"Christopher M. Riedl" <cmr@informatik.wtf> writes:
> diff --git a/arch/powerpc/kernel/security.c b/arch/powerpc/kernel/security.c
> index b33bafb8fcea..d775da9b9227 100644
> --- a/arch/powerpc/kernel/security.c
> +++ b/arch/powerpc/kernel/security.c
> @@ -391,6 +394,15 @@ static void toggle_count_cache_flush(bool enable)
>
> void setup_count_cache_flush(void)
> {
> + if (no_spectrev2) {
> + 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");
> +
> + toggle_count_cache_flush(false);
> + return;
> + }
> +
> toggle_count_cache_flush(true);
> }
I'm nit-picking, but would it be better as:
void setup_count_cache_flush(void)
{
bool enable = true;
if (no_spectrev2) {
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);
}
???
cheers
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] powerpc/64s: support nospectre_v2 cmdline option
2019-05-07 9:54 ` Michael Ellerman
@ 2019-05-07 11:54 ` Christopher M Riedl
0 siblings, 0 replies; 4+ messages in thread
From: Christopher M Riedl @ 2019-05-07 11:54 UTC (permalink / raw)
To: Michael Ellerman, linuxppc-dev; +Cc: ajd
> On May 7, 2019 at 5:54 AM Michael Ellerman <mpe@ellerman.id.au> wrote:
>
>
> "Christopher M. Riedl" <cmr@informatik.wtf> writes:
> > diff --git a/arch/powerpc/kernel/security.c b/arch/powerpc/kernel/security.c
> > index b33bafb8fcea..d775da9b9227 100644
> > --- a/arch/powerpc/kernel/security.c
> > +++ b/arch/powerpc/kernel/security.c
> > @@ -391,6 +394,15 @@ static void toggle_count_cache_flush(bool enable)
> >
> > void setup_count_cache_flush(void)
> > {
> > + if (no_spectrev2) {
> > + 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");
> > +
> > + toggle_count_cache_flush(false);
> > + return;
> > + }
> > +
> > toggle_count_cache_flush(true);
> > }
>
> I'm nit-picking, but would it be better as:
>
Agreed, v3 is on the way :)
>
> void setup_count_cache_flush(void)
> {
> bool enable = true;
>
> if (no_spectrev2) {
> 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);
> }
>
> ???
>
> cheers
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-05-07 11:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-07 2:43 [PATCH v2] powerpc/64s: support nospectre_v2 cmdline option Christopher M. Riedl
2019-05-07 5:10 ` Andrew Donnellan
2019-05-07 9:54 ` Michael Ellerman
2019-05-07 11:54 ` Christopher M Riedl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).