Lines Matching +full:static +full:- +full:enable
1 // SPDX-License-Identifier: GPL-2.0+
16 #include <asm/asm-prototypes.h>
17 #include <asm/code-patching.h>
32 static enum branch_cache_flush_type count_cache_flush_type = BRANCH_CACHE_FLUSH_NONE;
33 static enum branch_cache_flush_type link_stack_flush_type = BRANCH_CACHE_FLUSH_NONE;
36 static bool no_nospec;
37 static bool btb_flush_enabled;
39 static bool no_spectrev2;
42 static void enable_barrier_nospec(bool enable) in enable_barrier_nospec() argument
44 barrier_nospec_enabled = enable; in enable_barrier_nospec()
45 do_barrier_nospec_fixups(enable); in enable_barrier_nospec()
50 bool enable; in setup_barrier_nospec() local
59 * not been updated, we would like to enable the barrier. Dropping the in setup_barrier_nospec()
61 * we potentially enable the barrier on systems where the host firmware in setup_barrier_nospec()
62 * is not updated, but that's harmless as it's a no-op. in setup_barrier_nospec()
64 enable = security_ftr_enabled(SEC_FTR_FAVOUR_SECURITY) && in setup_barrier_nospec()
68 enable_barrier_nospec(enable); in setup_barrier_nospec()
71 static int __init handle_nospectre_v1(char *p) in handle_nospectre_v1()
80 static int barrier_nospec_set(void *data, u64 val) in barrier_nospec_set()
87 return -EINVAL; in barrier_nospec_set()
98 static int barrier_nospec_get(void *data, u64 *val) in barrier_nospec_get()
107 static __init int barrier_nospec_debugfs_init(void) in barrier_nospec_debugfs_init()
116 static __init int security_feature_debugfs_init(void) in security_feature_debugfs_init()
126 static int __init handle_nospectre_v2(char *p) in handle_nospectre_v2()
154 seq_buf_init(&s, buf, PAGE_SIZE - 1); in cpu_show_meltdown()
185 seq_buf_init(&s, buf, PAGE_SIZE - 1); in cpu_show_spectre_v1()
208 seq_buf_init(&s, buf, PAGE_SIZE - 1); in cpu_show_spectre_v2()
251 * Store-forwarding barrier support.
254 static enum stf_barrier_type stf_enabled_flush_types;
255 static bool no_stf_barrier;
256 static bool stf_barrier;
258 static int __init handle_no_stf_barrier(char *p) in handle_no_stf_barrier()
260 pr_info("stf-barrier: disabled on command line."); in handle_no_stf_barrier()
273 static int __init handle_ssbd(char *p) in handle_ssbd()
289 static int __init handle_no_ssbd(char *p) in handle_no_ssbd()
296 static void stf_barrier_enable(bool enable) in stf_barrier_enable() argument
298 if (enable) in stf_barrier_enable()
303 stf_barrier = enable; in stf_barrier_enable()
309 bool enable; in setup_stf_barrier() local
311 /* Default to fallback in case fw-features are not available */ in setup_stf_barrier()
321 enable = security_ftr_enabled(SEC_FTR_FAVOUR_SECURITY) && in setup_stf_barrier()
325 pr_info("stf-barrier: fallback barrier available\n"); in setup_stf_barrier()
327 pr_info("stf-barrier: hwsync barrier available\n"); in setup_stf_barrier()
329 pr_info("stf-barrier: eieio barrier available\n"); in setup_stf_barrier()
335 stf_barrier_enable(enable); in setup_stf_barrier()
365 static int ssb_prctl_get(struct task_struct *task) in ssb_prctl_get()
384 * per-process mitigation, so the only value that can be reported here in ssb_prctl_get()
396 return -ENODEV; in arch_prctl_spec_ctrl_get()
401 static int stf_barrier_set(void *data, u64 val) in stf_barrier_set()
403 bool enable; in stf_barrier_set() local
406 enable = true; in stf_barrier_set()
408 enable = false; in stf_barrier_set()
410 return -EINVAL; in stf_barrier_set()
413 if (enable != stf_barrier) in stf_barrier_set()
414 stf_barrier_enable(enable); in stf_barrier_set()
419 static int stf_barrier_get(void *data, u64 *val) in stf_barrier_get()
428 static __init int stf_barrier_debugfs_init(void) in stf_barrier_debugfs_init()
437 static void update_branch_cache_flush(void) in update_branch_cache_flush()
494 static void toggle_branch_cache_flush(bool enable) in toggle_branch_cache_flush() argument
496 if (!enable || !security_ftr_enabled(SEC_FTR_FLUSH_COUNT_CACHE)) { in toggle_branch_cache_flush()
500 pr_info("count-cache-flush: flush disabled.\n"); in toggle_branch_cache_flush()
504 pr_info("count-cache-flush: hardware flush enabled.\n"); in toggle_branch_cache_flush()
507 pr_info("count-cache-flush: software flush enabled.\n"); in toggle_branch_cache_flush()
511 if (!enable || !security_ftr_enabled(SEC_FTR_FLUSH_LINK_STACK)) { in toggle_branch_cache_flush()
515 pr_info("link-stack-flush: flush disabled.\n"); in toggle_branch_cache_flush()
519 pr_info("link-stack-flush: hardware flush enabled.\n"); in toggle_branch_cache_flush()
522 pr_info("link-stack-flush: software flush enabled.\n"); in toggle_branch_cache_flush()
531 bool enable = true; in setup_count_cache_flush() local
538 enable = false; in setup_count_cache_flush()
550 toggle_branch_cache_flush(enable); in setup_count_cache_flush()
553 static enum l1d_flush_type enabled_flush_types;
554 static void *l1d_flush_fallback_area;
555 static bool no_rfi_flush;
556 static bool no_entry_flush;
557 static bool no_uaccess_flush;
559 static bool entry_flush;
560 static bool uaccess_flush;
564 static int __init handle_no_rfi_flush(char *p) in handle_no_rfi_flush()
566 pr_info("rfi-flush: disabled on command line."); in handle_no_rfi_flush()
572 static int __init handle_no_entry_flush(char *p) in handle_no_entry_flush()
574 pr_info("entry-flush: disabled on command line."); in handle_no_entry_flush()
580 static int __init handle_no_uaccess_flush(char *p) in handle_no_uaccess_flush()
582 pr_info("uaccess-flush: disabled on command line."); in handle_no_uaccess_flush()
592 static int __init handle_no_pti(char *p) in handle_no_pti()
594 pr_info("rfi-flush: disabling due to 'nopti' on command line.\n"); in handle_no_pti()
600 static void do_nothing(void *unused) in do_nothing()
608 void rfi_flush_enable(bool enable) in rfi_flush_enable() argument
610 if (enable) { in rfi_flush_enable()
616 rfi_flush = enable; in rfi_flush_enable()
619 static void entry_flush_enable(bool enable) in entry_flush_enable() argument
621 if (enable) { in entry_flush_enable()
628 entry_flush = enable; in entry_flush_enable()
631 static void uaccess_flush_enable(bool enable) in uaccess_flush_enable() argument
633 if (enable) { in uaccess_flush_enable()
642 uaccess_flush = enable; in uaccess_flush_enable()
645 static void __ref init_fallback_flush(void) in init_fallback_flush()
657 * If there is no d-cache-size property in the device tree, l1d_size in init_fallback_flush()
659 * 2^64-1, and then walking off the end of the fallback area and in init_fallback_flush()
683 paca->rfi_flush_fallback_area = l1d_flush_fallback_area; in init_fallback_flush()
684 paca->l1d_flush_size = l1d_size; in init_fallback_flush()
688 void setup_rfi_flush(enum l1d_flush_type types, bool enable) in setup_rfi_flush() argument
691 pr_info("rfi-flush: fallback displacement flush available\n"); in setup_rfi_flush()
696 pr_info("rfi-flush: ori type flush available\n"); in setup_rfi_flush()
699 pr_info("rfi-flush: mttrig type flush available\n"); in setup_rfi_flush()
704 rfi_flush_enable(enable); in setup_rfi_flush()
707 void setup_entry_flush(bool enable) in setup_entry_flush() argument
713 entry_flush_enable(enable); in setup_entry_flush()
716 void setup_uaccess_flush(bool enable) in setup_uaccess_flush() argument
722 uaccess_flush_enable(enable); in setup_uaccess_flush()
726 static int count_cache_flush_set(void *data, u64 val) in count_cache_flush_set()
728 bool enable; in count_cache_flush_set() local
731 enable = true; in count_cache_flush_set()
733 enable = false; in count_cache_flush_set()
735 return -EINVAL; in count_cache_flush_set()
737 toggle_branch_cache_flush(enable); in count_cache_flush_set()
742 static int count_cache_flush_get(void *data, u64 *val) in count_cache_flush_get()
752 static int link_stack_flush_get(void *data, u64 *val) in link_stack_flush_get()
767 static __init int count_cache_flush_debugfs_init(void) in count_cache_flush_debugfs_init()
779 static int rfi_flush_set(void *data, u64 val) in rfi_flush_set()
781 bool enable; in rfi_flush_set() local
784 enable = true; in rfi_flush_set()
786 enable = false; in rfi_flush_set()
788 return -EINVAL; in rfi_flush_set()
791 if (enable != rfi_flush) in rfi_flush_set()
792 rfi_flush_enable(enable); in rfi_flush_set()
797 static int rfi_flush_get(void *data, u64 *val) in rfi_flush_get()
805 static int entry_flush_set(void *data, u64 val) in entry_flush_set()
807 bool enable; in entry_flush_set() local
810 enable = true; in entry_flush_set()
812 enable = false; in entry_flush_set()
814 return -EINVAL; in entry_flush_set()
817 if (enable != entry_flush) in entry_flush_set()
818 entry_flush_enable(enable); in entry_flush_set()
823 static int entry_flush_get(void *data, u64 *val) in entry_flush_get()
831 static int uaccess_flush_set(void *data, u64 val) in uaccess_flush_set()
833 bool enable; in uaccess_flush_set() local
836 enable = true; in uaccess_flush_set()
838 enable = false; in uaccess_flush_set()
840 return -EINVAL; in uaccess_flush_set()
843 if (enable != uaccess_flush) in uaccess_flush_set()
844 uaccess_flush_enable(enable); in uaccess_flush_set()
849 static int uaccess_flush_get(void *data, u64 *val) in uaccess_flush_get()
857 static __init int rfi_flush_debugfs_init(void) in rfi_flush_debugfs_init()