security.c (eb316ae798b36b280ef9e6a79d3aa34d146aa0e4) security.c (3e7318584dfec11992f3ac45658c4bc1210b3778)
1// SPDX-License-Identifier: GPL-2.0+
2//
3// Security related flags and so on.
4//
5// Copyright 2018, Michael Ellerman, IBM Corporation.
6
7#include <linux/cpu.h>
8#include <linux/kernel.h>

--- 21 unchanged lines hidden (view full) ---

30 BRANCH_CACHE_FLUSH_HW = 0x4,
31};
32static enum branch_cache_flush_type count_cache_flush_type = BRANCH_CACHE_FLUSH_NONE;
33static enum branch_cache_flush_type link_stack_flush_type = BRANCH_CACHE_FLUSH_NONE;
34
35bool barrier_nospec_enabled;
36static bool no_nospec;
37static bool btb_flush_enabled;
1// SPDX-License-Identifier: GPL-2.0+
2//
3// Security related flags and so on.
4//
5// Copyright 2018, Michael Ellerman, IBM Corporation.
6
7#include <linux/cpu.h>
8#include <linux/kernel.h>

--- 21 unchanged lines hidden (view full) ---

30 BRANCH_CACHE_FLUSH_HW = 0x4,
31};
32static enum branch_cache_flush_type count_cache_flush_type = BRANCH_CACHE_FLUSH_NONE;
33static enum branch_cache_flush_type link_stack_flush_type = BRANCH_CACHE_FLUSH_NONE;
34
35bool barrier_nospec_enabled;
36static bool no_nospec;
37static bool btb_flush_enabled;
38#if defined(CONFIG_PPC_FSL_BOOK3E) || defined(CONFIG_PPC_BOOK3S_64)
38#if defined(CONFIG_PPC_E500) || defined(CONFIG_PPC_BOOK3S_64)
39static bool no_spectrev2;
40#endif
41
42static void enable_barrier_nospec(bool enable)
43{
44 barrier_nospec_enabled = enable;
45 do_barrier_nospec_fixups(enable);
46}

--- 70 unchanged lines hidden (view full) ---

117{
118 debugfs_create_x64("security_features", 0400, arch_debugfs_dir,
119 &powerpc_security_features);
120 return 0;
121}
122device_initcall(security_feature_debugfs_init);
123#endif /* CONFIG_DEBUG_FS */
124
39static bool no_spectrev2;
40#endif
41
42static void enable_barrier_nospec(bool enable)
43{
44 barrier_nospec_enabled = enable;
45 do_barrier_nospec_fixups(enable);
46}

--- 70 unchanged lines hidden (view full) ---

117{
118 debugfs_create_x64("security_features", 0400, arch_debugfs_dir,
119 &powerpc_security_features);
120 return 0;
121}
122device_initcall(security_feature_debugfs_init);
123#endif /* CONFIG_DEBUG_FS */
124
125#if defined(CONFIG_PPC_FSL_BOOK3E) || defined(CONFIG_PPC_BOOK3S_64)
125#if defined(CONFIG_PPC_E500) || defined(CONFIG_PPC_BOOK3S_64)
126static int __init handle_nospectre_v2(char *p)
127{
128 no_spectrev2 = true;
129
130 return 0;
131}
132early_param("nospectre_v2", handle_nospectre_v2);
126static int __init handle_nospectre_v2(char *p)
127{
128 no_spectrev2 = true;
129
130 return 0;
131}
132early_param("nospectre_v2", handle_nospectre_v2);
133#endif /* CONFIG_PPC_FSL_BOOK3E || CONFIG_PPC_BOOK3S_64 */
133#endif /* CONFIG_PPC_E500 || CONFIG_PPC_BOOK3S_64 */
134
134
135#ifdef CONFIG_PPC_FSL_BOOK3E
135#ifdef CONFIG_PPC_E500
136void __init setup_spectre_v2(void)
137{
138 if (no_spectrev2 || cpu_mitigations_off())
139 do_btb_flush_fixups();
140 else
141 btb_flush_enabled = true;
142}
136void __init setup_spectre_v2(void)
137{
138 if (no_spectrev2 || cpu_mitigations_off())
139 do_btb_flush_fixups();
140 else
141 btb_flush_enabled = true;
142}
143#endif /* CONFIG_PPC_FSL_BOOK3E */
143#endif /* CONFIG_PPC_E500 */
144
145#ifdef CONFIG_PPC_BOOK3S_64
146ssize_t cpu_show_meltdown(struct device *dev, struct device_attribute *attr, char *buf)
147{
148 bool thread_priv;
149
150 thread_priv = security_ftr_enabled(SEC_FTR_L1D_THREAD_PRIV);
151

--- 714 unchanged lines hidden ---
144
145#ifdef CONFIG_PPC_BOOK3S_64
146ssize_t cpu_show_meltdown(struct device *dev, struct device_attribute *attr, char *buf)
147{
148 bool thread_priv;
149
150 thread_priv = security_ftr_enabled(SEC_FTR_L1D_THREAD_PRIV);
151

--- 714 unchanged lines hidden ---