Skip to content

Commit bd42b2c

Browse files
committed
Merge tag 'v4.9.81' into linux-4.9-at91
This is the 4.9.81 stable release
2 parents e2e01ba + 7f3bd8d commit bd42b2c

93 files changed

Lines changed: 2026 additions & 789 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Documentation/kernel-parameters.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2805,8 +2805,6 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
28052805
norandmaps Don't use address space randomization. Equivalent to
28062806
echo 0 > /proc/sys/kernel/randomize_va_space
28072807

2808-
noreplace-paravirt [X86,IA-64,PV_OPS] Don't patch paravirt_ops
2809-
28102808
noreplace-smp [X86-32,SMP] Don't replace SMP instructions
28112809
with UP alternatives
28122810

Documentation/speculation.txt

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
This document explains potential effects of speculation, and how undesirable
2+
effects can be mitigated portably using common APIs.
3+
4+
===========
5+
Speculation
6+
===========
7+
8+
To improve performance and minimize average latencies, many contemporary CPUs
9+
employ speculative execution techniques such as branch prediction, performing
10+
work which may be discarded at a later stage.
11+
12+
Typically speculative execution cannot be observed from architectural state,
13+
such as the contents of registers. However, in some cases it is possible to
14+
observe its impact on microarchitectural state, such as the presence or
15+
absence of data in caches. Such state may form side-channels which can be
16+
observed to extract secret information.
17+
18+
For example, in the presence of branch prediction, it is possible for bounds
19+
checks to be ignored by code which is speculatively executed. Consider the
20+
following code:
21+
22+
int load_array(int *array, unsigned int index)
23+
{
24+
if (index >= MAX_ARRAY_ELEMS)
25+
return 0;
26+
else
27+
return array[index];
28+
}
29+
30+
Which, on arm64, may be compiled to an assembly sequence such as:
31+
32+
CMP <index>, #MAX_ARRAY_ELEMS
33+
B.LT less
34+
MOV <returnval>, #0
35+
RET
36+
less:
37+
LDR <returnval>, [<array>, <index>]
38+
RET
39+
40+
It is possible that a CPU mis-predicts the conditional branch, and
41+
speculatively loads array[index], even if index >= MAX_ARRAY_ELEMS. This
42+
value will subsequently be discarded, but the speculated load may affect
43+
microarchitectural state which can be subsequently measured.
44+
45+
More complex sequences involving multiple dependent memory accesses may
46+
result in sensitive information being leaked. Consider the following
47+
code, building on the prior example:
48+
49+
int load_dependent_arrays(int *arr1, int *arr2, int index)
50+
{
51+
int val1, val2,
52+
53+
val1 = load_array(arr1, index);
54+
val2 = load_array(arr2, val1);
55+
56+
return val2;
57+
}
58+
59+
Under speculation, the first call to load_array() may return the value
60+
of an out-of-bounds address, while the second call will influence
61+
microarchitectural state dependent on this value. This may provide an
62+
arbitrary read primitive.
63+
64+
====================================
65+
Mitigating speculation side-channels
66+
====================================
67+
68+
The kernel provides a generic API to ensure that bounds checks are
69+
respected even under speculation. Architectures which are affected by
70+
speculation-based side-channels are expected to implement these
71+
primitives.
72+
73+
The array_index_nospec() helper in <linux/nospec.h> can be used to
74+
prevent information from being leaked via side-channels.
75+
76+
A call to array_index_nospec(index, size) returns a sanitized index
77+
value that is bounded to [0, size) even under cpu speculation
78+
conditions.
79+
80+
This can be used to protect the earlier load_array() example:
81+
82+
int load_array(int *array, unsigned int index)
83+
{
84+
if (index >= MAX_ARRAY_ELEMS)
85+
return 0;
86+
else {
87+
index = array_index_nospec(index, MAX_ARRAY_ELEMS);
88+
return array[index];
89+
}
90+
}

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
VERSION = 4
22
PATCHLEVEL = 9
3-
SUBLEVEL = 80
3+
SUBLEVEL = 81
44
EXTRAVERSION =
55
NAME = Roaring Lionus
66

arch/powerpc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ config PPC
128128
select ARCH_HAS_GCOV_PROFILE_ALL
129129
select GENERIC_SMP_IDLE_THREAD
130130
select GENERIC_CMOS_UPDATE
131+
select GENERIC_CPU_VULNERABILITIES if PPC_BOOK3S_64
131132
select GENERIC_TIME_VSYSCALL_OLD
132133
select GENERIC_CLOCKEVENTS
133134
select GENERIC_CLOCKEVENTS_BROADCAST if SMP

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,5 +209,11 @@ exc_##label##_book3e:
209209
ori r3,r3,vector_offset@l; \
210210
mtspr SPRN_IVOR##vector_number,r3;
211211

212+
#define RFI_TO_KERNEL \
213+
rfi
214+
215+
#define RFI_TO_USER \
216+
rfi
217+
212218
#endif /* _ASM_POWERPC_EXCEPTION_64E_H */
213219

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

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,59 @@
5151
#define EX_PPR 88 /* SMT thread status register (priority) */
5252
#define EX_CTR 96
5353

54+
/*
55+
* Macros for annotating the expected destination of (h)rfid
56+
*
57+
* The nop instructions allow us to insert one or more instructions to flush the
58+
* L1-D cache when returning to userspace or a guest.
59+
*/
60+
#define RFI_FLUSH_SLOT \
61+
RFI_FLUSH_FIXUP_SECTION; \
62+
nop; \
63+
nop; \
64+
nop
65+
66+
#define RFI_TO_KERNEL \
67+
rfid
68+
69+
#define RFI_TO_USER \
70+
RFI_FLUSH_SLOT; \
71+
rfid; \
72+
b rfi_flush_fallback
73+
74+
#define RFI_TO_USER_OR_KERNEL \
75+
RFI_FLUSH_SLOT; \
76+
rfid; \
77+
b rfi_flush_fallback
78+
79+
#define RFI_TO_GUEST \
80+
RFI_FLUSH_SLOT; \
81+
rfid; \
82+
b rfi_flush_fallback
83+
84+
#define HRFI_TO_KERNEL \
85+
hrfid
86+
87+
#define HRFI_TO_USER \
88+
RFI_FLUSH_SLOT; \
89+
hrfid; \
90+
b hrfi_flush_fallback
91+
92+
#define HRFI_TO_USER_OR_KERNEL \
93+
RFI_FLUSH_SLOT; \
94+
hrfid; \
95+
b hrfi_flush_fallback
96+
97+
#define HRFI_TO_GUEST \
98+
RFI_FLUSH_SLOT; \
99+
hrfid; \
100+
b hrfi_flush_fallback
101+
102+
#define HRFI_TO_UNKNOWN \
103+
RFI_FLUSH_SLOT; \
104+
hrfid; \
105+
b hrfi_flush_fallback
106+
54107
#ifdef CONFIG_RELOCATABLE
55108
#define __EXCEPTION_RELON_PROLOG_PSERIES_1(label, h) \
56109
mfspr r11,SPRN_##h##SRR0; /* save SRR0 */ \

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,19 @@ void apply_feature_fixups(void);
189189
void setup_feature_keys(void);
190190
#endif
191191

192+
#define RFI_FLUSH_FIXUP_SECTION \
193+
951: \
194+
.pushsection __rfi_flush_fixup,"a"; \
195+
.align 2; \
196+
952: \
197+
FTR_ENTRY_OFFSET 951b-952b; \
198+
.popsection;
199+
200+
201+
#ifndef __ASSEMBLY__
202+
203+
extern long __start___rfi_flush_fixup, __stop___rfi_flush_fixup;
204+
205+
#endif
206+
192207
#endif /* __ASM_POWERPC_FEATURE_FIXUPS_H */

arch/powerpc/include/asm/hvcall.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@
240240
#define H_GET_HCA_INFO 0x1B8
241241
#define H_GET_PERF_COUNT 0x1BC
242242
#define H_MANAGE_TRACE 0x1C0
243+
#define H_GET_CPU_CHARACTERISTICS 0x1C8
243244
#define H_FREE_LOGICAL_LAN_BUFFER 0x1D4
244245
#define H_QUERY_INT_STATE 0x1E4
245246
#define H_POLL_PENDING 0x1D8
@@ -306,6 +307,17 @@
306307
#define H_SET_MODE_RESOURCE_ADDR_TRANS_MODE 3
307308
#define H_SET_MODE_RESOURCE_LE 4
308309

310+
/* H_GET_CPU_CHARACTERISTICS return values */
311+
#define H_CPU_CHAR_SPEC_BAR_ORI31 (1ull << 63) // IBM bit 0
312+
#define H_CPU_CHAR_BCCTRL_SERIALISED (1ull << 62) // IBM bit 1
313+
#define H_CPU_CHAR_L1D_FLUSH_ORI30 (1ull << 61) // IBM bit 2
314+
#define H_CPU_CHAR_L1D_FLUSH_TRIG2 (1ull << 60) // IBM bit 3
315+
#define H_CPU_CHAR_L1D_THREAD_PRIV (1ull << 59) // IBM bit 4
316+
317+
#define H_CPU_BEHAV_FAVOUR_SECURITY (1ull << 63) // IBM bit 0
318+
#define H_CPU_BEHAV_L1D_FLUSH_PR (1ull << 62) // IBM bit 1
319+
#define H_CPU_BEHAV_BNDS_CHK_SPEC_BAR (1ull << 61) // IBM bit 2
320+
309321
#ifndef __ASSEMBLY__
310322

311323
/**
@@ -433,6 +445,11 @@ static inline unsigned long cmo_get_page_size(void)
433445
}
434446
#endif /* CONFIG_PPC_PSERIES */
435447

448+
struct h_cpu_char_result {
449+
u64 character;
450+
u64 behaviour;
451+
};
452+
436453
#endif /* __ASSEMBLY__ */
437454
#endif /* __KERNEL__ */
438455
#endif /* _ASM_POWERPC_HVCALL_H */

arch/powerpc/include/asm/paca.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,16 @@ struct paca_struct {
205205
struct sibling_subcore_state *sibling_subcore_state;
206206
#endif
207207
#endif
208+
#ifdef CONFIG_PPC_BOOK3S_64
209+
/*
210+
* rfi fallback flush must be in its own cacheline to prevent
211+
* other paca data leaking into the L1d
212+
*/
213+
u64 exrfi[13] __aligned(0x80);
214+
void *rfi_flush_fallback_area;
215+
u64 l1d_flush_congruence;
216+
u64 l1d_flush_sets;
217+
#endif
208218
};
209219

210220
#ifdef CONFIG_PPC_BOOK3S

arch/powerpc/include/asm/plpar_wrappers.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,4 +340,18 @@ static inline long plapr_set_watchpoint0(unsigned long dawr0, unsigned long dawr
340340
return plpar_set_mode(0, H_SET_MODE_RESOURCE_SET_DAWR, dawr0, dawrx0);
341341
}
342342

343+
static inline long plpar_get_cpu_characteristics(struct h_cpu_char_result *p)
344+
{
345+
unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
346+
long rc;
347+
348+
rc = plpar_hcall(H_GET_CPU_CHARACTERISTICS, retbuf);
349+
if (rc == H_SUCCESS) {
350+
p->character = retbuf[0];
351+
p->behaviour = retbuf[1];
352+
}
353+
354+
return rc;
355+
}
356+
343357
#endif /* _ASM_POWERPC_PLPAR_WRAPPERS_H */

0 commit comments

Comments
 (0)