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>
31 static enum branch_cache_flush_type count_cache_flush_type = BRANCH_CACHE_FLUSH_NONE;
32 static enum branch_cache_flush_type link_stack_flush_type = BRANCH_CACHE_FLUSH_NONE;
35 static bool no_nospec;
36 static bool btb_flush_enabled;
38 static bool no_spectrev2;
41 static void enable_barrier_nospec(bool enable) in enable_barrier_nospec() argument
43 barrier_nospec_enabled = enable; in enable_barrier_nospec()
44 do_barrier_nospec_fixups(enable); in enable_barrier_nospec()
49 bool enable; in setup_barrier_nospec() local
58 * not been updated, we would like to enable the barrier. Dropping the in setup_barrier_nospec()
60 * we potentially enable the barrier on systems where the host firmware in setup_barrier_nospec()
61 * is not updated, but that's harmless as it's a no-op. in setup_barrier_nospec()
63 enable = security_ftr_enabled(SEC_FTR_FAVOUR_SECURITY) && in setup_barrier_nospec()
67 enable_barrier_nospec(enable); in setup_barrier_nospec()
70 static int __init handle_nospectre_v1(char *p) in handle_nospectre_v1()
79 static int barrier_nospec_set(void *data, u64 val) in barrier_nospec_set()
86 return -EINVAL; in barrier_nospec_set()
97 static int barrier_nospec_get(void *data, u64 *val) in barrier_nospec_get()
106 static __init int barrier_nospec_debugfs_init(void) in barrier_nospec_debugfs_init()
115 static __init int security_feature_debugfs_init(void) in security_feature_debugfs_init()
125 static int __init handle_nospectre_v2(char *p) in handle_nospectre_v2()
153 seq_buf_init(&s, buf, PAGE_SIZE - 1); in cpu_show_meltdown()
184 seq_buf_init(&s, buf, PAGE_SIZE - 1); in cpu_show_spectre_v1()
207 seq_buf_init(&s, buf, PAGE_SIZE - 1); in cpu_show_spectre_v2()
250 * Store-forwarding barrier support.
253 static enum stf_barrier_type stf_enabled_flush_types;
254 static bool no_stf_barrier;
255 static bool stf_barrier;
257 static int __init handle_no_stf_barrier(char *p) in handle_no_stf_barrier()
259 pr_info("stf-barrier: disabled on command line."); in handle_no_stf_barrier()
272 static int __init handle_ssbd(char *p) in handle_ssbd()
288 static int __init handle_no_ssbd(char *p) in handle_no_ssbd()
295 static void stf_barrier_enable(bool enable) in stf_barrier_enable() argument
297 if (enable) in stf_barrier_enable()
302 stf_barrier = enable; in stf_barrier_enable()
308 bool enable; in setup_stf_barrier() local
310 /* Default to fallback in case fw-features are not available */ in setup_stf_barrier()
320 enable = security_ftr_enabled(SEC_FTR_FAVOUR_SECURITY) && in setup_stf_barrier()
324 pr_info("stf-barrier: fallback barrier available\n"); in setup_stf_barrier()
326 pr_info("stf-barrier: hwsync barrier available\n"); in setup_stf_barrier()
328 pr_info("stf-barrier: eieio barrier available\n"); in setup_stf_barrier()
334 stf_barrier_enable(enable); in setup_stf_barrier()
364 static int ssb_prctl_get(struct task_struct *task) in ssb_prctl_get()
379 * barrier is not a global or per-process mitigation, so the in ssb_prctl_get()
385 return -EINVAL; in ssb_prctl_get()
394 return -ENODEV; in arch_prctl_spec_ctrl_get()
399 static int stf_barrier_set(void *data, u64 val) in stf_barrier_set()
401 bool enable; in stf_barrier_set() local
404 enable = true; in stf_barrier_set()
406 enable = false; in stf_barrier_set()
408 return -EINVAL; in stf_barrier_set()
411 if (enable != stf_barrier) in stf_barrier_set()
412 stf_barrier_enable(enable); in stf_barrier_set()
417 static int stf_barrier_get(void *data, u64 *val) in stf_barrier_get()
426 static __init int stf_barrier_debugfs_init(void) in stf_barrier_debugfs_init()
435 static void update_branch_cache_flush(void) in update_branch_cache_flush()
492 static void toggle_branch_cache_flush(bool enable) in toggle_branch_cache_flush() argument
494 if (!enable || !security_ftr_enabled(SEC_FTR_FLUSH_COUNT_CACHE)) { in toggle_branch_cache_flush()
498 pr_info("count-cache-flush: flush disabled.\n"); in toggle_branch_cache_flush()
502 pr_info("count-cache-flush: hardware flush enabled.\n"); in toggle_branch_cache_flush()
505 pr_info("count-cache-flush: software flush enabled.\n"); in toggle_branch_cache_flush()
509 if (!enable || !security_ftr_enabled(SEC_FTR_FLUSH_LINK_STACK)) { in toggle_branch_cache_flush()
513 pr_info("link-stack-flush: flush disabled.\n"); in toggle_branch_cache_flush()
517 pr_info("link-stack-flush: hardware flush enabled.\n"); in toggle_branch_cache_flush()
520 pr_info("link-stack-flush: software flush enabled.\n"); in toggle_branch_cache_flush()
529 bool enable = true; in setup_count_cache_flush() local
536 enable = false; in setup_count_cache_flush()
548 toggle_branch_cache_flush(enable); in setup_count_cache_flush()
551 static enum l1d_flush_type enabled_flush_types;
552 static void *l1d_flush_fallback_area;
553 static bool no_rfi_flush;
554 static bool no_entry_flush;
555 static bool no_uaccess_flush;
557 static bool entry_flush;
558 static bool uaccess_flush;
562 static int __init handle_no_rfi_flush(char *p) in handle_no_rfi_flush()
564 pr_info("rfi-flush: disabled on command line."); in handle_no_rfi_flush()
570 static int __init handle_no_entry_flush(char *p) in handle_no_entry_flush()
572 pr_info("entry-flush: disabled on command line."); in handle_no_entry_flush()
578 static int __init handle_no_uaccess_flush(char *p) in handle_no_uaccess_flush()
580 pr_info("uaccess-flush: disabled on command line."); in handle_no_uaccess_flush()
590 static int __init handle_no_pti(char *p) in handle_no_pti()
592 pr_info("rfi-flush: disabling due to 'nopti' on command line.\n"); in handle_no_pti()
598 static void do_nothing(void *unused) in do_nothing()
606 void rfi_flush_enable(bool enable) in rfi_flush_enable() argument
608 if (enable) { in rfi_flush_enable()
614 rfi_flush = enable; in rfi_flush_enable()
617 static void entry_flush_enable(bool enable) in entry_flush_enable() argument
619 if (enable) { in entry_flush_enable()
626 entry_flush = enable; in entry_flush_enable()
629 static void uaccess_flush_enable(bool enable) in uaccess_flush_enable() argument
631 if (enable) { in uaccess_flush_enable()
640 uaccess_flush = enable; in uaccess_flush_enable()
643 static void __ref init_fallback_flush(void) in init_fallback_flush()
655 * If there is no d-cache-size property in the device tree, l1d_size in init_fallback_flush()
657 * 2^64-1, and then walking off the end of the fallback area and in init_fallback_flush()
681 paca->rfi_flush_fallback_area = l1d_flush_fallback_area; in init_fallback_flush()
682 paca->l1d_flush_size = l1d_size; in init_fallback_flush()
686 void setup_rfi_flush(enum l1d_flush_type types, bool enable) in setup_rfi_flush() argument
689 pr_info("rfi-flush: fallback displacement flush available\n"); in setup_rfi_flush()
694 pr_info("rfi-flush: ori type flush available\n"); in setup_rfi_flush()
697 pr_info("rfi-flush: mttrig type flush available\n"); in setup_rfi_flush()
702 rfi_flush_enable(enable); in setup_rfi_flush()
705 void setup_entry_flush(bool enable) in setup_entry_flush() argument
711 entry_flush_enable(enable); in setup_entry_flush()
714 void setup_uaccess_flush(bool enable) in setup_uaccess_flush() argument
720 uaccess_flush_enable(enable); in setup_uaccess_flush()
724 static int count_cache_flush_set(void *data, u64 val) in count_cache_flush_set()
726 bool enable; in count_cache_flush_set() local
729 enable = true; in count_cache_flush_set()
731 enable = false; in count_cache_flush_set()
733 return -EINVAL; in count_cache_flush_set()
735 toggle_branch_cache_flush(enable); in count_cache_flush_set()
740 static int count_cache_flush_get(void *data, u64 *val) in count_cache_flush_get()
753 static __init int count_cache_flush_debugfs_init(void) in count_cache_flush_debugfs_init()
762 static int rfi_flush_set(void *data, u64 val) in rfi_flush_set()
764 bool enable; in rfi_flush_set() local
767 enable = true; in rfi_flush_set()
769 enable = false; in rfi_flush_set()
771 return -EINVAL; in rfi_flush_set()
774 if (enable != rfi_flush) in rfi_flush_set()
775 rfi_flush_enable(enable); in rfi_flush_set()
780 static int rfi_flush_get(void *data, u64 *val) in rfi_flush_get()
788 static int entry_flush_set(void *data, u64 val) in entry_flush_set()
790 bool enable; in entry_flush_set() local
793 enable = true; in entry_flush_set()
795 enable = false; in entry_flush_set()
797 return -EINVAL; in entry_flush_set()
800 if (enable != entry_flush) in entry_flush_set()
801 entry_flush_enable(enable); in entry_flush_set()
806 static int entry_flush_get(void *data, u64 *val) in entry_flush_get()
814 static int uaccess_flush_set(void *data, u64 val) in uaccess_flush_set()
816 bool enable; in uaccess_flush_set() local
819 enable = true; in uaccess_flush_set()
821 enable = false; in uaccess_flush_set()
823 return -EINVAL; in uaccess_flush_set()
826 if (enable != uaccess_flush) in uaccess_flush_set()
827 uaccess_flush_enable(enable); in uaccess_flush_set()
832 static int uaccess_flush_get(void *data, u64 *val) in uaccess_flush_get()
840 static __init int rfi_flush_debugfs_init(void) in rfi_flush_debugfs_init()