Skip to content

Commit 5a6d4b7

Browse files
authored
Merge pull request #178 from zandrey/5.4.x+fslc
Update 5.4.x+fslc to v5.4.79
2 parents c50d1fa + 5a7f422 commit 5a6d4b7

File tree

30 files changed

+856
-172
lines changed

30 files changed

+856
-172
lines changed

Documentation/admin-guide/kernel-parameters.txt

+7
Original file line numberDiff line numberDiff line change
@@ -2667,6 +2667,8 @@
26672667
mds=off [X86]
26682668
tsx_async_abort=off [X86]
26692669
kvm.nx_huge_pages=off [X86]
2670+
no_entry_flush [PPC]
2671+
no_uaccess_flush [PPC]
26702672

26712673
Exceptions:
26722674
This does not have any effect on
@@ -2989,6 +2991,8 @@
29892991

29902992
noefi Disable EFI runtime services support.
29912993

2994+
no_entry_flush [PPC] Don't flush the L1-D cache when entering the kernel.
2995+
29922996
noexec [IA-64]
29932997

29942998
noexec [X86]
@@ -3038,6 +3042,9 @@
30383042
nospec_store_bypass_disable
30393043
[HW] Disable all mitigations for the Speculative Store Bypass vulnerability
30403044

3045+
no_uaccess_flush
3046+
[PPC] Don't flush the L1-D cache after accessing user data.
3047+
30413048
noxsave [BUGS=X86] Disables x86 extended register state save
30423049
and restore using xsave. The kernel will fallback to
30433050
enabling legacy floating-point and sse state.

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22
VERSION = 5
33
PATCHLEVEL = 4
4-
SUBLEVEL = 78
4+
SUBLEVEL = 79
55
EXTRAVERSION =
66
NAME = Kleptomaniac Octopus
77

arch/mips/pci/pci-xtalk-bridge.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ static int bridge_set_affinity(struct irq_data *d, const struct cpumask *mask,
284284
ret = irq_chip_set_affinity_parent(d, mask, force);
285285
if (ret >= 0) {
286286
cpu = cpumask_first_and(mask, cpu_online_mask);
287-
data->nnasid = COMPACT_TO_NASID_NODEID(cpu_to_node(cpu));
287+
data->nasid = COMPACT_TO_NASID_NODEID(cpu_to_node(cpu));
288288
bridge_write(data->bc, b_int_addr[pin].addr,
289289
(((data->bc->intr_addr >> 30) & 0x30000) |
290290
bit | (data->nasid << 8)));

arch/powerpc/include/asm/book3s/64/kup-radix.h

+18-11
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@
1111

1212
#ifdef __ASSEMBLY__
1313

14-
.macro kuap_restore_amr gpr
1514
#ifdef CONFIG_PPC_KUAP
15+
.macro kuap_restore_amr gpr
1616
BEGIN_MMU_FTR_SECTION_NESTED(67)
1717
ld \gpr, STACK_REGS_KUAP(r1)
1818
mtspr SPRN_AMR, \gpr
1919
END_MMU_FTR_SECTION_NESTED_IFSET(MMU_FTR_RADIX_KUAP, 67)
20-
#endif
2120
.endm
2221

2322
.macro kuap_check_amr gpr1, gpr2
@@ -31,6 +30,7 @@
3130
END_MMU_FTR_SECTION_NESTED_IFSET(MMU_FTR_RADIX_KUAP, 67)
3231
#endif
3332
.endm
33+
#endif
3434

3535
.macro kuap_save_amr_and_lock gpr1, gpr2, use_cr, msr_pr_cr
3636
#ifdef CONFIG_PPC_KUAP
@@ -54,6 +54,8 @@
5454

5555
#else /* !__ASSEMBLY__ */
5656

57+
DECLARE_STATIC_KEY_FALSE(uaccess_flush_key);
58+
5759
#ifdef CONFIG_PPC_KUAP
5860

5961
#include <asm/reg.h>
@@ -77,6 +79,18 @@ static inline void set_kuap(unsigned long value)
7779
isync();
7880
}
7981

82+
static inline bool
83+
bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write)
84+
{
85+
return WARN(mmu_has_feature(MMU_FTR_RADIX_KUAP) &&
86+
(regs->kuap & (is_write ? AMR_KUAP_BLOCK_WRITE : AMR_KUAP_BLOCK_READ)),
87+
"Bug: %s fault blocked by AMR!", is_write ? "Write" : "Read");
88+
}
89+
#else /* CONFIG_PPC_KUAP */
90+
static inline void kuap_restore_amr(struct pt_regs *regs, unsigned long amr) { }
91+
static inline void set_kuap(unsigned long value) { }
92+
#endif /* !CONFIG_PPC_KUAP */
93+
8094
static __always_inline void allow_user_access(void __user *to, const void __user *from,
8195
unsigned long size, unsigned long dir)
8296
{
@@ -94,17 +108,10 @@ static inline void prevent_user_access(void __user *to, const void __user *from,
94108
unsigned long size, unsigned long dir)
95109
{
96110
set_kuap(AMR_KUAP_BLOCKED);
111+
if (static_branch_unlikely(&uaccess_flush_key))
112+
do_uaccess_flush();
97113
}
98114

99-
static inline bool
100-
bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write)
101-
{
102-
return WARN(mmu_has_feature(MMU_FTR_RADIX_KUAP) &&
103-
(regs->kuap & (is_write ? AMR_KUAP_BLOCK_WRITE : AMR_KUAP_BLOCK_READ)),
104-
"Bug: %s fault blocked by AMR!", is_write ? "Write" : "Read");
105-
}
106-
#endif /* CONFIG_PPC_KUAP */
107-
108115
#endif /* __ASSEMBLY__ */
109116

110117
#endif /* _ASM_POWERPC_BOOK3S_64_KUP_RADIX_H */

arch/powerpc/include/asm/exception-64s.h

+11-1
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,18 @@
6161
nop; \
6262
nop
6363

64+
#define ENTRY_FLUSH_SLOT \
65+
ENTRY_FLUSH_FIXUP_SECTION; \
66+
nop; \
67+
nop; \
68+
nop;
69+
6470
/*
6571
* r10 must be free to use, r13 must be paca
6672
*/
6773
#define INTERRUPT_TO_KERNEL \
68-
STF_ENTRY_BARRIER_SLOT
74+
STF_ENTRY_BARRIER_SLOT; \
75+
ENTRY_FLUSH_SLOT
6976

7077
/*
7178
* Macros for annotating the expected destination of (h)rfid
@@ -127,6 +134,9 @@
127134
hrfid; \
128135
b hrfi_flush_fallback
129136

137+
#else /* __ASSEMBLY__ */
138+
/* Prototype for function defined in exceptions-64s.S */
139+
void do_uaccess_flush(void);
130140
#endif /* __ASSEMBLY__ */
131141

132142
#endif /* _ASM_POWERPC_EXCEPTION_H */

arch/powerpc/include/asm/feature-fixups.h

+19
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,22 @@ label##3: \
205205
FTR_ENTRY_OFFSET 955b-956b; \
206206
.popsection;
207207

208+
#define UACCESS_FLUSH_FIXUP_SECTION \
209+
959: \
210+
.pushsection __uaccess_flush_fixup,"a"; \
211+
.align 2; \
212+
960: \
213+
FTR_ENTRY_OFFSET 959b-960b; \
214+
.popsection;
215+
216+
#define ENTRY_FLUSH_FIXUP_SECTION \
217+
957: \
218+
.pushsection __entry_flush_fixup,"a"; \
219+
.align 2; \
220+
958: \
221+
FTR_ENTRY_OFFSET 957b-958b; \
222+
.popsection;
223+
208224
#define RFI_FLUSH_FIXUP_SECTION \
209225
951: \
210226
.pushsection __rfi_flush_fixup,"a"; \
@@ -237,8 +253,11 @@ label##3: \
237253
#include <linux/types.h>
238254

239255
extern long stf_barrier_fallback;
256+
extern long entry_flush_fallback;
240257
extern long __start___stf_entry_barrier_fixup, __stop___stf_entry_barrier_fixup;
241258
extern long __start___stf_exit_barrier_fixup, __stop___stf_exit_barrier_fixup;
259+
extern long __start___uaccess_flush_fixup, __stop___uaccess_flush_fixup;
260+
extern long __start___entry_flush_fixup, __stop___entry_flush_fixup;
242261
extern long __start___rfi_flush_fixup, __stop___rfi_flush_fixup;
243262
extern long __start___barrier_nospec_fixup, __stop___barrier_nospec_fixup;
244263
extern long __start__btb_flush_fixup, __stop__btb_flush_fixup;

arch/powerpc/include/asm/kup.h

+22-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#define KUAP_WRITE 2
77
#define KUAP_READ_WRITE (KUAP_READ | KUAP_WRITE)
88

9-
#ifdef CONFIG_PPC64
9+
#ifdef CONFIG_PPC_BOOK3S_64
1010
#include <asm/book3s/64/kup-radix.h>
1111
#endif
1212
#ifdef CONFIG_PPC_8xx
@@ -24,9 +24,15 @@
2424
.macro kuap_restore sp, current, gpr1, gpr2, gpr3
2525
.endm
2626

27+
.macro kuap_restore_amr gpr
28+
.endm
29+
2730
.macro kuap_check current, gpr
2831
.endm
2932

33+
.macro kuap_check_amr gpr1, gpr2
34+
.endm
35+
3036
#endif
3137

3238
#else /* !__ASSEMBLY__ */
@@ -45,15 +51,26 @@ static inline void setup_kuep(bool disabled) { }
4551
void setup_kuap(bool disabled);
4652
#else
4753
static inline void setup_kuap(bool disabled) { }
48-
static inline void allow_user_access(void __user *to, const void __user *from,
49-
unsigned long size, unsigned long dir) { }
50-
static inline void prevent_user_access(void __user *to, const void __user *from,
51-
unsigned long size, unsigned long dir) { }
54+
5255
static inline bool
5356
bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write)
5457
{
5558
return false;
5659
}
60+
61+
static inline void kuap_check_amr(void) { }
62+
63+
/*
64+
* book3s/64/kup-radix.h defines these functions for the !KUAP case to flush
65+
* the L1D cache after user accesses. Only include the empty stubs for other
66+
* platforms.
67+
*/
68+
#ifndef CONFIG_PPC_BOOK3S_64
69+
static inline void allow_user_access(void __user *to, const void __user *from,
70+
unsigned long size, unsigned long dir) { }
71+
static inline void prevent_user_access(void __user *to, const void __user *from,
72+
unsigned long size, unsigned long dir) { }
73+
#endif /* CONFIG_PPC_BOOK3S_64 */
5774
#endif /* CONFIG_PPC_KUAP */
5875

5976
static inline void allow_read_from_user(const void __user *from, unsigned long size)

arch/powerpc/include/asm/security_features.h

+7
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,19 @@ static inline bool security_ftr_enabled(u64 feature)
8484
// Software required to flush link stack on context switch
8585
#define SEC_FTR_FLUSH_LINK_STACK 0x0000000000001000ull
8686

87+
// The L1-D cache should be flushed when entering the kernel
88+
#define SEC_FTR_L1D_FLUSH_ENTRY 0x0000000000004000ull
89+
90+
// The L1-D cache should be flushed after user accesses from the kernel
91+
#define SEC_FTR_L1D_FLUSH_UACCESS 0x0000000000008000ull
8792

8893
// Features enabled by default
8994
#define SEC_FTR_DEFAULT \
9095
(SEC_FTR_L1D_FLUSH_HV | \
9196
SEC_FTR_L1D_FLUSH_PR | \
9297
SEC_FTR_BNDS_CHK_SPEC_BAR | \
98+
SEC_FTR_L1D_FLUSH_ENTRY | \
99+
SEC_FTR_L1D_FLUSH_UACCESS | \
93100
SEC_FTR_FAVOUR_SECURITY)
94101

95102
#endif /* _ASM_POWERPC_SECURITY_FEATURES_H */

arch/powerpc/include/asm/setup.h

+4
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,16 @@ enum l1d_flush_type {
5252
};
5353

5454
void setup_rfi_flush(enum l1d_flush_type, bool enable);
55+
void setup_entry_flush(bool enable);
56+
void setup_uaccess_flush(bool enable);
5557
void do_rfi_flush_fixups(enum l1d_flush_type types);
5658
#ifdef CONFIG_PPC_BARRIER_NOSPEC
5759
void setup_barrier_nospec(void);
5860
#else
5961
static inline void setup_barrier_nospec(void) { };
6062
#endif
63+
void do_uaccess_flush_fixups(enum l1d_flush_type types);
64+
void do_entry_flush_fixups(enum l1d_flush_type types);
6165
void do_barrier_nospec_fixups(bool enable);
6266
extern bool barrier_nospec_enabled;
6367

0 commit comments

Comments
 (0)