]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.60/powerpc-64s-fix-compiler-store-ordering-to-slb-shadow-area.patch
Fixes for 5.10
[thirdparty/kernel/stable-queue.git] / releases / 4.14.60 / powerpc-64s-fix-compiler-store-ordering-to-slb-shadow-area.patch
1 From foo@baz Sat Jul 28 10:25:26 CEST 2018
2 From: Nicholas Piggin <npiggin@gmail.com>
3 Date: Wed, 30 May 2018 20:31:22 +1000
4 Subject: powerpc/64s: Fix compiler store ordering to SLB shadow area
5
6 From: Nicholas Piggin <npiggin@gmail.com>
7
8 [ Upstream commit 926bc2f100c24d4842b3064b5af44ae964c1d81c ]
9
10 The stores to update the SLB shadow area must be made as they appear
11 in the C code, so that the hypervisor does not see an entry with
12 mismatched vsid and esid. Use WRITE_ONCE for this.
13
14 GCC has been observed to elide the first store to esid in the update,
15 which means that if the hypervisor interrupts the guest after storing
16 to vsid, it could see an entry with old esid and new vsid, which may
17 possibly result in memory corruption.
18
19 Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
20 Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
21 Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
22 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23 ---
24 arch/powerpc/mm/slb.c | 8 ++++----
25 1 file changed, 4 insertions(+), 4 deletions(-)
26
27 --- a/arch/powerpc/mm/slb.c
28 +++ b/arch/powerpc/mm/slb.c
29 @@ -62,14 +62,14 @@ static inline void slb_shadow_update(uns
30 * updating it. No write barriers are needed here, provided
31 * we only update the current CPU's SLB shadow buffer.
32 */
33 - p->save_area[index].esid = 0;
34 - p->save_area[index].vsid = cpu_to_be64(mk_vsid_data(ea, ssize, flags));
35 - p->save_area[index].esid = cpu_to_be64(mk_esid_data(ea, ssize, index));
36 + WRITE_ONCE(p->save_area[index].esid, 0);
37 + WRITE_ONCE(p->save_area[index].vsid, cpu_to_be64(mk_vsid_data(ea, ssize, flags)));
38 + WRITE_ONCE(p->save_area[index].esid, cpu_to_be64(mk_esid_data(ea, ssize, index)));
39 }
40
41 static inline void slb_shadow_clear(enum slb_index index)
42 {
43 - get_slb_shadow()->save_area[index].esid = 0;
44 + WRITE_ONCE(get_slb_shadow()->save_area[index].esid, 0);
45 }
46
47 static inline void create_shadowed_slbe(unsigned long ea, int ssize,