1 // SPDX-License-Identifier: GPL-2.0+
3 // Security related flags and so on.
5 // Copyright 2018, Michael Ellerman, IBM Corporation.
8 #include <linux/kernel.h>
9 #include <linux/device.h>
10 #include <linux/memblock.h>
11 #include <linux/nospec.h>
12 #include <linux/prctl.h>
13 #include <linux/seq_buf.h>
14 #include <linux/debugfs.h>
16 #include <asm/asm-prototypes.h>
17 #include <asm/text-patching.h>
18 #include <asm/security_features.h>
19 #include <asm/sections.h>
20 #include <asm/setup.h>
25 u64 powerpc_security_features __read_mostly
= SEC_FTR_DEFAULT
;
27 enum branch_cache_flush_type
{
28 BRANCH_CACHE_FLUSH_NONE
= 0x1,
29 BRANCH_CACHE_FLUSH_SW
= 0x2,
30 BRANCH_CACHE_FLUSH_HW
= 0x4,
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
;
35 bool barrier_nospec_enabled
;
36 static bool no_nospec
;
37 static bool btb_flush_enabled
;
38 #if defined(CONFIG_PPC_E500) || defined(CONFIG_PPC_BOOK3S_64)
39 static bool no_spectrev2
;
42 static void enable_barrier_nospec(bool enable
)
44 barrier_nospec_enabled
= enable
;
45 do_barrier_nospec_fixups(enable
);
48 void __init
setup_barrier_nospec(void)
53 * It would make sense to check SEC_FTR_SPEC_BAR_ORI31 below as well.
54 * But there's a good reason not to. The two flags we check below are
55 * both are enabled by default in the kernel, so if the hcall is not
56 * functional they will be enabled.
57 * On a system where the host firmware has been updated (so the ori
58 * functions as a barrier), but on which the hypervisor (KVM/Qemu) has
59 * not been updated, we would like to enable the barrier. Dropping the
60 * check for SEC_FTR_SPEC_BAR_ORI31 achieves that. The only downside is
61 * we potentially enable the barrier on systems where the host firmware
62 * is not updated, but that's harmless as it's a no-op.
64 enable
= security_ftr_enabled(SEC_FTR_FAVOUR_SECURITY
) &&
65 security_ftr_enabled(SEC_FTR_BNDS_CHK_SPEC_BAR
);
67 if (!no_nospec
&& !cpu_mitigations_off())
68 enable_barrier_nospec(enable
);
71 static int __init
handle_nospectre_v1(char *p
)
77 early_param("nospectre_v1", handle_nospectre_v1
);
79 #ifdef CONFIG_DEBUG_FS
80 static int barrier_nospec_set(void *data
, u64 val
)
90 if (!!val
== !!barrier_nospec_enabled
)
93 enable_barrier_nospec(!!val
);
98 static int barrier_nospec_get(void *data
, u64
*val
)
100 *val
= barrier_nospec_enabled
? 1 : 0;
104 DEFINE_DEBUGFS_ATTRIBUTE(fops_barrier_nospec
, barrier_nospec_get
,
105 barrier_nospec_set
, "%llu\n");
107 static __init
int barrier_nospec_debugfs_init(void)
109 debugfs_create_file_unsafe("barrier_nospec", 0600,
110 arch_debugfs_dir
, NULL
,
111 &fops_barrier_nospec
);
114 device_initcall(barrier_nospec_debugfs_init
);
116 static __init
int security_feature_debugfs_init(void)
118 debugfs_create_x64("security_features", 0400, arch_debugfs_dir
,
119 &powerpc_security_features
);
122 device_initcall(security_feature_debugfs_init
);
123 #endif /* CONFIG_DEBUG_FS */
125 #if defined(CONFIG_PPC_E500) || defined(CONFIG_PPC_BOOK3S_64)
126 static int __init
handle_nospectre_v2(char *p
)
132 early_param("nospectre_v2", handle_nospectre_v2
);
133 #endif /* CONFIG_PPC_E500 || CONFIG_PPC_BOOK3S_64 */
135 #ifdef CONFIG_PPC_E500
136 void __init
setup_spectre_v2(void)
138 if (no_spectrev2
|| cpu_mitigations_off())
139 do_btb_flush_fixups();
141 btb_flush_enabled
= true;
143 #endif /* CONFIG_PPC_E500 */
145 #ifdef CONFIG_PPC_BOOK3S_64
146 ssize_t
cpu_show_meltdown(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
150 thread_priv
= security_ftr_enabled(SEC_FTR_L1D_THREAD_PRIV
);
154 seq_buf_init(&s
, buf
, PAGE_SIZE
- 1);
156 seq_buf_printf(&s
, "Mitigation: RFI Flush");
158 seq_buf_printf(&s
, ", L1D private per thread");
160 seq_buf_printf(&s
, "\n");
166 return sprintf(buf
, "Vulnerable: L1D private per thread\n");
168 if (!security_ftr_enabled(SEC_FTR_L1D_FLUSH_HV
) &&
169 !security_ftr_enabled(SEC_FTR_L1D_FLUSH_PR
))
170 return sprintf(buf
, "Not affected\n");
172 return sprintf(buf
, "Vulnerable\n");
175 ssize_t
cpu_show_l1tf(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
177 return cpu_show_meltdown(dev
, attr
, buf
);
181 ssize_t
cpu_show_spectre_v1(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
185 seq_buf_init(&s
, buf
, PAGE_SIZE
- 1);
187 if (security_ftr_enabled(SEC_FTR_BNDS_CHK_SPEC_BAR
)) {
188 if (barrier_nospec_enabled
)
189 seq_buf_printf(&s
, "Mitigation: __user pointer sanitization");
191 seq_buf_printf(&s
, "Vulnerable");
193 if (security_ftr_enabled(SEC_FTR_SPEC_BAR_ORI31
))
194 seq_buf_printf(&s
, ", ori31 speculation barrier enabled");
196 seq_buf_printf(&s
, "\n");
198 seq_buf_printf(&s
, "Not affected\n");
203 ssize_t
cpu_show_spectre_v2(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
208 seq_buf_init(&s
, buf
, PAGE_SIZE
- 1);
210 bcs
= security_ftr_enabled(SEC_FTR_BCCTRL_SERIALISED
);
211 ccd
= security_ftr_enabled(SEC_FTR_COUNT_CACHE_DISABLED
);
214 seq_buf_printf(&s
, "Mitigation: ");
217 seq_buf_printf(&s
, "Indirect branch serialisation (kernel only)");
220 seq_buf_printf(&s
, ", ");
223 seq_buf_printf(&s
, "Indirect branch cache disabled");
225 } else if (count_cache_flush_type
!= BRANCH_CACHE_FLUSH_NONE
) {
226 seq_buf_printf(&s
, "Mitigation: Software count cache flush");
228 if (count_cache_flush_type
== BRANCH_CACHE_FLUSH_HW
)
229 seq_buf_printf(&s
, " (hardware accelerated)");
231 } else if (btb_flush_enabled
) {
232 seq_buf_printf(&s
, "Mitigation: Branch predictor state flush");
234 seq_buf_printf(&s
, "Vulnerable");
237 if (bcs
|| ccd
|| count_cache_flush_type
!= BRANCH_CACHE_FLUSH_NONE
) {
238 if (link_stack_flush_type
!= BRANCH_CACHE_FLUSH_NONE
)
239 seq_buf_printf(&s
, ", Software link stack flush");
240 if (link_stack_flush_type
== BRANCH_CACHE_FLUSH_HW
)
241 seq_buf_printf(&s
, " (hardware accelerated)");
244 seq_buf_printf(&s
, "\n");
249 #ifdef CONFIG_PPC_BOOK3S_64
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
)
260 pr_info("stf-barrier: disabled on command line.");
261 no_stf_barrier
= true;
265 early_param("no_stf_barrier", handle_no_stf_barrier
);
267 enum stf_barrier_type
stf_barrier_type_get(void)
269 return stf_enabled_flush_types
;
272 /* This is the generic flag used by other architectures */
273 static int __init
handle_ssbd(char *p
)
275 if (!p
|| strncmp(p
, "auto", 5) == 0 || strncmp(p
, "on", 2) == 0 ) {
276 /* Until firmware tells us, we have the barrier with auto */
278 } else if (strncmp(p
, "off", 3) == 0) {
279 handle_no_stf_barrier(NULL
);
286 early_param("spec_store_bypass_disable", handle_ssbd
);
288 /* This is the generic flag used by other architectures */
289 static int __init
handle_no_ssbd(char *p
)
291 handle_no_stf_barrier(NULL
);
294 early_param("nospec_store_bypass_disable", handle_no_ssbd
);
296 static void stf_barrier_enable(bool enable
)
299 do_stf_barrier_fixups(stf_enabled_flush_types
);
301 do_stf_barrier_fixups(STF_BARRIER_NONE
);
303 stf_barrier
= enable
;
306 void setup_stf_barrier(void)
308 enum stf_barrier_type type
;
311 /* Default to fallback in case fw-features are not available */
312 if (cpu_has_feature(CPU_FTR_ARCH_300
))
313 type
= STF_BARRIER_EIEIO
;
314 else if (cpu_has_feature(CPU_FTR_ARCH_207S
))
315 type
= STF_BARRIER_SYNC_ORI
;
316 else if (cpu_has_feature(CPU_FTR_ARCH_206
))
317 type
= STF_BARRIER_FALLBACK
;
319 type
= STF_BARRIER_NONE
;
321 enable
= security_ftr_enabled(SEC_FTR_FAVOUR_SECURITY
) &&
322 security_ftr_enabled(SEC_FTR_STF_BARRIER
);
324 if (type
== STF_BARRIER_FALLBACK
) {
325 pr_info("stf-barrier: fallback barrier available\n");
326 } else if (type
== STF_BARRIER_SYNC_ORI
) {
327 pr_info("stf-barrier: hwsync barrier available\n");
328 } else if (type
== STF_BARRIER_EIEIO
) {
329 pr_info("stf-barrier: eieio barrier available\n");
332 stf_enabled_flush_types
= type
;
334 if (!no_stf_barrier
&& !cpu_mitigations_off())
335 stf_barrier_enable(enable
);
338 ssize_t
cpu_show_spec_store_bypass(struct device
*dev
, struct device_attribute
*attr
, char *buf
)
340 if (stf_barrier
&& stf_enabled_flush_types
!= STF_BARRIER_NONE
) {
342 switch (stf_enabled_flush_types
) {
343 case STF_BARRIER_EIEIO
:
346 case STF_BARRIER_SYNC_ORI
:
349 case STF_BARRIER_FALLBACK
:
355 return sprintf(buf
, "Mitigation: Kernel entry/exit barrier (%s)\n", type
);
358 if (!security_ftr_enabled(SEC_FTR_L1D_FLUSH_HV
) &&
359 !security_ftr_enabled(SEC_FTR_L1D_FLUSH_PR
))
360 return sprintf(buf
, "Not affected\n");
362 return sprintf(buf
, "Vulnerable\n");
365 static int ssb_prctl_get(struct task_struct
*task
)
368 * The STF_BARRIER feature is on by default, so if it's off that means
369 * firmware has explicitly said the CPU is not vulnerable via either
370 * the hypercall or device tree.
372 if (!security_ftr_enabled(SEC_FTR_STF_BARRIER
))
373 return PR_SPEC_NOT_AFFECTED
;
376 * If the system's CPU has no known barrier (see setup_stf_barrier())
377 * then assume that the CPU is not vulnerable.
379 if (stf_enabled_flush_types
== STF_BARRIER_NONE
)
380 return PR_SPEC_NOT_AFFECTED
;
383 * Otherwise the CPU is vulnerable. The barrier is not a global or
384 * per-process mitigation, so the only value that can be reported here
385 * is PR_SPEC_ENABLE, which appears as "vulnerable" in /proc.
387 return PR_SPEC_ENABLE
;
390 int arch_prctl_spec_ctrl_get(struct task_struct
*task
, unsigned long which
)
393 case PR_SPEC_STORE_BYPASS
:
394 return ssb_prctl_get(task
);
400 #ifdef CONFIG_DEBUG_FS
401 static int stf_barrier_set(void *data
, u64 val
)
412 /* Only do anything if we're changing state */
413 if (enable
!= stf_barrier
)
414 stf_barrier_enable(enable
);
419 static int stf_barrier_get(void *data
, u64
*val
)
421 *val
= stf_barrier
? 1 : 0;
425 DEFINE_DEBUGFS_ATTRIBUTE(fops_stf_barrier
, stf_barrier_get
, stf_barrier_set
,
428 static __init
int stf_barrier_debugfs_init(void)
430 debugfs_create_file_unsafe("stf_barrier", 0600, arch_debugfs_dir
,
431 NULL
, &fops_stf_barrier
);
434 device_initcall(stf_barrier_debugfs_init
);
435 #endif /* CONFIG_DEBUG_FS */
437 static void update_branch_cache_flush(void)
439 u32
*site
, __maybe_unused
*site2
;
441 #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
442 site
= &patch__call_kvm_flush_link_stack
;
443 site2
= &patch__call_kvm_flush_link_stack_p9
;
444 // This controls the branch from guest_exit_cont to kvm_flush_link_stack
445 if (link_stack_flush_type
== BRANCH_CACHE_FLUSH_NONE
) {
446 patch_instruction_site(site
, ppc_inst(PPC_RAW_NOP()));
447 patch_instruction_site(site2
, ppc_inst(PPC_RAW_NOP()));
449 // Could use HW flush, but that could also flush count cache
450 patch_branch_site(site
, (u64
)&kvm_flush_link_stack
, BRANCH_SET_LINK
);
451 patch_branch_site(site2
, (u64
)&kvm_flush_link_stack
, BRANCH_SET_LINK
);
455 // Patch out the bcctr first, then nop the rest
456 site
= &patch__call_flush_branch_caches3
;
457 patch_instruction_site(site
, ppc_inst(PPC_RAW_NOP()));
458 site
= &patch__call_flush_branch_caches2
;
459 patch_instruction_site(site
, ppc_inst(PPC_RAW_NOP()));
460 site
= &patch__call_flush_branch_caches1
;
461 patch_instruction_site(site
, ppc_inst(PPC_RAW_NOP()));
463 // This controls the branch from _switch to flush_branch_caches
464 if (count_cache_flush_type
== BRANCH_CACHE_FLUSH_NONE
&&
465 link_stack_flush_type
== BRANCH_CACHE_FLUSH_NONE
) {
466 // Nothing to be done
468 } else if (count_cache_flush_type
== BRANCH_CACHE_FLUSH_HW
&&
469 link_stack_flush_type
== BRANCH_CACHE_FLUSH_HW
) {
470 // Patch in the bcctr last
471 site
= &patch__call_flush_branch_caches1
;
472 patch_instruction_site(site
, ppc_inst(0x39207fff)); // li r9,0x7fff
473 site
= &patch__call_flush_branch_caches2
;
474 patch_instruction_site(site
, ppc_inst(0x7d2903a6)); // mtctr r9
475 site
= &patch__call_flush_branch_caches3
;
476 patch_instruction_site(site
, ppc_inst(PPC_INST_BCCTR_FLUSH
));
479 patch_branch_site(site
, (u64
)&flush_branch_caches
, BRANCH_SET_LINK
);
481 // If we just need to flush the link stack, early return
482 if (count_cache_flush_type
== BRANCH_CACHE_FLUSH_NONE
) {
483 patch_instruction_site(&patch__flush_link_stack_return
,
484 ppc_inst(PPC_RAW_BLR()));
486 // If we have flush instruction, early return
487 } else if (count_cache_flush_type
== BRANCH_CACHE_FLUSH_HW
) {
488 patch_instruction_site(&patch__flush_count_cache_return
,
489 ppc_inst(PPC_RAW_BLR()));
494 static void toggle_branch_cache_flush(bool enable
)
496 if (!enable
|| !security_ftr_enabled(SEC_FTR_FLUSH_COUNT_CACHE
)) {
497 if (count_cache_flush_type
!= BRANCH_CACHE_FLUSH_NONE
)
498 count_cache_flush_type
= BRANCH_CACHE_FLUSH_NONE
;
500 pr_info("count-cache-flush: flush disabled.\n");
502 if (security_ftr_enabled(SEC_FTR_BCCTR_FLUSH_ASSIST
)) {
503 count_cache_flush_type
= BRANCH_CACHE_FLUSH_HW
;
504 pr_info("count-cache-flush: hardware flush enabled.\n");
506 count_cache_flush_type
= BRANCH_CACHE_FLUSH_SW
;
507 pr_info("count-cache-flush: software flush enabled.\n");
511 if (!enable
|| !security_ftr_enabled(SEC_FTR_FLUSH_LINK_STACK
)) {
512 if (link_stack_flush_type
!= BRANCH_CACHE_FLUSH_NONE
)
513 link_stack_flush_type
= BRANCH_CACHE_FLUSH_NONE
;
515 pr_info("link-stack-flush: flush disabled.\n");
517 if (security_ftr_enabled(SEC_FTR_BCCTR_LINK_FLUSH_ASSIST
)) {
518 link_stack_flush_type
= BRANCH_CACHE_FLUSH_HW
;
519 pr_info("link-stack-flush: hardware flush enabled.\n");
521 link_stack_flush_type
= BRANCH_CACHE_FLUSH_SW
;
522 pr_info("link-stack-flush: software flush enabled.\n");
526 update_branch_cache_flush();
529 void setup_count_cache_flush(void)
533 if (no_spectrev2
|| cpu_mitigations_off()) {
534 if (security_ftr_enabled(SEC_FTR_BCCTRL_SERIALISED
) ||
535 security_ftr_enabled(SEC_FTR_COUNT_CACHE_DISABLED
))
536 pr_warn("Spectre v2 mitigations not fully under software control, can't disable\n");
542 * There's no firmware feature flag/hypervisor bit to tell us we need to
543 * flush the link stack on context switch. So we set it here if we see
544 * either of the Spectre v2 mitigations that aim to protect userspace.
546 if (security_ftr_enabled(SEC_FTR_COUNT_CACHE_DISABLED
) ||
547 security_ftr_enabled(SEC_FTR_FLUSH_COUNT_CACHE
))
548 security_ftr_set(SEC_FTR_FLUSH_LINK_STACK
);
550 toggle_branch_cache_flush(enable
);
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
;
561 DEFINE_STATIC_KEY_FALSE(uaccess_flush_key
);
562 EXPORT_SYMBOL(uaccess_flush_key
);
564 static int __init
handle_no_rfi_flush(char *p
)
566 pr_info("rfi-flush: disabled on command line.");
570 early_param("no_rfi_flush", handle_no_rfi_flush
);
572 static int __init
handle_no_entry_flush(char *p
)
574 pr_info("entry-flush: disabled on command line.");
575 no_entry_flush
= true;
578 early_param("no_entry_flush", handle_no_entry_flush
);
580 static int __init
handle_no_uaccess_flush(char *p
)
582 pr_info("uaccess-flush: disabled on command line.");
583 no_uaccess_flush
= true;
586 early_param("no_uaccess_flush", handle_no_uaccess_flush
);
589 * The RFI flush is not KPTI, but because users will see doco that says to use
590 * nopti we hijack that option here to also disable the RFI flush.
592 static int __init
handle_no_pti(char *p
)
594 pr_info("rfi-flush: disabling due to 'nopti' on command line.\n");
595 handle_no_rfi_flush(NULL
);
598 early_param("nopti", handle_no_pti
);
600 static void do_nothing(void *unused
)
603 * We don't need to do the flush explicitly, just enter+exit kernel is
604 * sufficient, the RFI exit handlers will do the right thing.
608 void rfi_flush_enable(bool enable
)
611 do_rfi_flush_fixups(enabled_flush_types
);
612 on_each_cpu(do_nothing
, NULL
, 1);
614 do_rfi_flush_fixups(L1D_FLUSH_NONE
);
619 static void entry_flush_enable(bool enable
)
622 do_entry_flush_fixups(enabled_flush_types
);
623 on_each_cpu(do_nothing
, NULL
, 1);
625 do_entry_flush_fixups(L1D_FLUSH_NONE
);
628 entry_flush
= enable
;
631 static void uaccess_flush_enable(bool enable
)
634 do_uaccess_flush_fixups(enabled_flush_types
);
635 static_branch_enable(&uaccess_flush_key
);
636 on_each_cpu(do_nothing
, NULL
, 1);
638 static_branch_disable(&uaccess_flush_key
);
639 do_uaccess_flush_fixups(L1D_FLUSH_NONE
);
642 uaccess_flush
= enable
;
645 static void __ref
init_fallback_flush(void)
650 /* Only allocate the fallback flush area once (at boot time). */
651 if (l1d_flush_fallback_area
)
654 l1d_size
= ppc64_caches
.l1d
.size
;
657 * If there is no d-cache-size property in the device tree, l1d_size
658 * could be zero. That leads to the loop in the asm wrapping around to
659 * 2^64-1, and then walking off the end of the fallback area and
660 * eventually causing a page fault which is fatal. Just default to
661 * something vaguely sane.
664 l1d_size
= (64 * 1024);
666 limit
= min(ppc64_bolted_size(), ppc64_rma_size
);
669 * Align to L1d size, and size it at 2x L1d size, to catch possible
670 * hardware prefetch runoff. We don't have a recipe for load patterns to
671 * reliably avoid the prefetcher.
673 l1d_flush_fallback_area
= memblock_alloc_try_nid(l1d_size
* 2,
674 l1d_size
, MEMBLOCK_LOW_LIMIT
,
675 limit
, NUMA_NO_NODE
);
676 if (!l1d_flush_fallback_area
)
677 panic("%s: Failed to allocate %llu bytes align=0x%llx max_addr=%pa\n",
678 __func__
, l1d_size
* 2, l1d_size
, &limit
);
681 for_each_possible_cpu(cpu
) {
682 struct paca_struct
*paca
= paca_ptrs
[cpu
];
683 paca
->rfi_flush_fallback_area
= l1d_flush_fallback_area
;
684 paca
->l1d_flush_size
= l1d_size
;
688 void setup_rfi_flush(enum l1d_flush_type types
, bool enable
)
690 if (types
& L1D_FLUSH_FALLBACK
) {
691 pr_info("rfi-flush: fallback displacement flush available\n");
692 init_fallback_flush();
695 if (types
& L1D_FLUSH_ORI
)
696 pr_info("rfi-flush: ori type flush available\n");
698 if (types
& L1D_FLUSH_MTTRIG
)
699 pr_info("rfi-flush: mttrig type flush available\n");
701 enabled_flush_types
= types
;
703 if (!cpu_mitigations_off() && !no_rfi_flush
)
704 rfi_flush_enable(enable
);
707 void setup_entry_flush(bool enable
)
709 if (cpu_mitigations_off())
713 entry_flush_enable(enable
);
716 void setup_uaccess_flush(bool enable
)
718 if (cpu_mitigations_off())
721 if (!no_uaccess_flush
)
722 uaccess_flush_enable(enable
);
725 #ifdef CONFIG_DEBUG_FS
726 static int count_cache_flush_set(void *data
, u64 val
)
737 toggle_branch_cache_flush(enable
);
742 static int count_cache_flush_get(void *data
, u64
*val
)
744 if (count_cache_flush_type
== BRANCH_CACHE_FLUSH_NONE
)
752 static int link_stack_flush_get(void *data
, u64
*val
)
754 if (link_stack_flush_type
== BRANCH_CACHE_FLUSH_NONE
)
762 DEFINE_DEBUGFS_ATTRIBUTE(fops_count_cache_flush
, count_cache_flush_get
,
763 count_cache_flush_set
, "%llu\n");
764 DEFINE_DEBUGFS_ATTRIBUTE(fops_link_stack_flush
, link_stack_flush_get
,
765 count_cache_flush_set
, "%llu\n");
767 static __init
int count_cache_flush_debugfs_init(void)
769 debugfs_create_file_unsafe("count_cache_flush", 0600,
770 arch_debugfs_dir
, NULL
,
771 &fops_count_cache_flush
);
772 debugfs_create_file_unsafe("link_stack_flush", 0600,
773 arch_debugfs_dir
, NULL
,
774 &fops_link_stack_flush
);
777 device_initcall(count_cache_flush_debugfs_init
);
779 static int rfi_flush_set(void *data
, u64 val
)
790 /* Only do anything if we're changing state */
791 if (enable
!= rfi_flush
)
792 rfi_flush_enable(enable
);
797 static int rfi_flush_get(void *data
, u64
*val
)
799 *val
= rfi_flush
? 1 : 0;
803 DEFINE_SIMPLE_ATTRIBUTE(fops_rfi_flush
, rfi_flush_get
, rfi_flush_set
, "%llu\n");
805 static int entry_flush_set(void *data
, u64 val
)
816 /* Only do anything if we're changing state */
817 if (enable
!= entry_flush
)
818 entry_flush_enable(enable
);
823 static int entry_flush_get(void *data
, u64
*val
)
825 *val
= entry_flush
? 1 : 0;
829 DEFINE_SIMPLE_ATTRIBUTE(fops_entry_flush
, entry_flush_get
, entry_flush_set
, "%llu\n");
831 static int uaccess_flush_set(void *data
, u64 val
)
842 /* Only do anything if we're changing state */
843 if (enable
!= uaccess_flush
)
844 uaccess_flush_enable(enable
);
849 static int uaccess_flush_get(void *data
, u64
*val
)
851 *val
= uaccess_flush
? 1 : 0;
855 DEFINE_SIMPLE_ATTRIBUTE(fops_uaccess_flush
, uaccess_flush_get
, uaccess_flush_set
, "%llu\n");
857 static __init
int rfi_flush_debugfs_init(void)
859 debugfs_create_file("rfi_flush", 0600, arch_debugfs_dir
, NULL
, &fops_rfi_flush
);
860 debugfs_create_file("entry_flush", 0600, arch_debugfs_dir
, NULL
, &fops_entry_flush
);
861 debugfs_create_file("uaccess_flush", 0600, arch_debugfs_dir
, NULL
, &fops_uaccess_flush
);
864 device_initcall(rfi_flush_debugfs_init
);
865 #endif /* CONFIG_DEBUG_FS */
866 #endif /* CONFIG_PPC_BOOK3S_64 */