lkml.org 
[lkml]   [2019]   [Nov]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.3 93/95] powerpc/64s: support nospectre_v2 cmdline option
    Date
    From: "Christopher M. Riedl" <cmr@informatik.wtf>

    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: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Christopher M. Riedl <cmr@informatik.wtf>
    Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20190524024647.381-1-cmr@informatik.wtf
    Signed-off-by: Daniel Axtens <dja@axtens.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    arch/powerpc/kernel/security.c | 19 ++++++++++++++++---
    1 file changed, 16 insertions(+), 3 deletions(-)

    --- a/arch/powerpc/kernel/security.c
    +++ b/arch/powerpc/kernel/security.c
    @@ -28,7 +28,7 @@ static enum count_cache_flush_type count
    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_debug
    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(ch
    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(boo

    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

    \
     
     \ /
      Last update: 2019-11-27 22:18    [W:5.090 / U:0.272 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site