Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 84ed26f

Browse files
npigginmpe
authored andcommitted
powerpc/security: Add a security feature for STF barrier
Rather than tying this mitigation to RFI L1D flush requirement, add a new bit for it. Signed-off-by: Nicholas Piggin <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 65c7d07 commit 84ed26f

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

arch/powerpc/include/asm/security_features.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,17 @@ static inline bool security_ftr_enabled(u64 feature)
9292
// The L1-D cache should be flushed after user accesses from the kernel
9393
#define SEC_FTR_L1D_FLUSH_UACCESS 0x0000000000008000ull
9494

95+
// The STF flush should be executed on privilege state switch
96+
#define SEC_FTR_STF_BARRIER 0x0000000000010000ull
97+
9598
// Features enabled by default
9699
#define SEC_FTR_DEFAULT \
97100
(SEC_FTR_L1D_FLUSH_HV | \
98101
SEC_FTR_L1D_FLUSH_PR | \
99102
SEC_FTR_BNDS_CHK_SPEC_BAR | \
100103
SEC_FTR_L1D_FLUSH_ENTRY | \
101104
SEC_FTR_L1D_FLUSH_UACCESS | \
105+
SEC_FTR_STF_BARRIER | \
102106
SEC_FTR_FAVOUR_SECURITY)
103107

104108
#endif /* _ASM_POWERPC_SECURITY_FEATURES_H */

arch/powerpc/kernel/security.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,7 @@ static void stf_barrier_enable(bool enable)
300300
void setup_stf_barrier(void)
301301
{
302302
enum stf_barrier_type type;
303-
bool enable, hv;
304-
305-
hv = cpu_has_feature(CPU_FTR_HVMODE);
303+
bool enable;
306304

307305
/* Default to fallback in case fw-features are not available */
308306
if (cpu_has_feature(CPU_FTR_ARCH_300))
@@ -315,8 +313,7 @@ void setup_stf_barrier(void)
315313
type = STF_BARRIER_NONE;
316314

317315
enable = security_ftr_enabled(SEC_FTR_FAVOUR_SECURITY) &&
318-
(security_ftr_enabled(SEC_FTR_L1D_FLUSH_PR) ||
319-
(security_ftr_enabled(SEC_FTR_L1D_FLUSH_HV) && hv));
316+
security_ftr_enabled(SEC_FTR_STF_BARRIER);
320317

321318
if (type == STF_BARRIER_FALLBACK) {
322319
pr_info("stf-barrier: fallback barrier available\n");

0 commit comments

Comments
 (0)