powerpc/64s: Support disabling RFI flush with no_rfi_flush and nopti

Because there may be some performance overhead of the RFI flush, add
kernel command line options to disable it.

We add a sensibly named 'no_rfi_flush' option, but we also hijack the
x86 option 'nopti'. The RFI flush is not the same as KPTI, but if we
see 'nopti' we can guess that the user is trying to avoid any overhead
of Meltdown mitigations, and it means we don't have to educate every
one about a different command line option.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

+23 -1
+23 -1
arch/powerpc/kernel/setup_64.c
··· 805 #ifdef CONFIG_PPC_BOOK3S_64 806 static enum l1d_flush_type enabled_flush_types; 807 static void *l1d_flush_fallback_area; 808 bool rfi_flush; 809 810 static void do_nothing(void *unused) 811 { ··· 898 899 enabled_flush_types = types; 900 901 - rfi_flush_enable(enable); 902 } 903 #endif /* CONFIG_PPC_BOOK3S_64 */
··· 805 #ifdef CONFIG_PPC_BOOK3S_64 806 static enum l1d_flush_type enabled_flush_types; 807 static void *l1d_flush_fallback_area; 808 + static bool no_rfi_flush; 809 bool rfi_flush; 810 + 811 + static int __init handle_no_rfi_flush(char *p) 812 + { 813 + pr_info("rfi-flush: disabled on command line."); 814 + no_rfi_flush = true; 815 + return 0; 816 + } 817 + early_param("no_rfi_flush", handle_no_rfi_flush); 818 + 819 + /* 820 + * The RFI flush is not KPTI, but because users will see doco that says to use 821 + * nopti we hijack that option here to also disable the RFI flush. 822 + */ 823 + static int __init handle_no_pti(char *p) 824 + { 825 + pr_info("rfi-flush: disabling due to 'nopti' on command line.\n"); 826 + handle_no_rfi_flush(NULL); 827 + return 0; 828 + } 829 + early_param("nopti", handle_no_pti); 830 831 static void do_nothing(void *unused) 832 { ··· 877 878 enabled_flush_types = types; 879 880 + if (!no_rfi_flush) 881 + rfi_flush_enable(enable); 882 } 883 #endif /* CONFIG_PPC_BOOK3S_64 */