powerpc/64s: Fix compiler store ordering to SLB shadow area
authorNicholas Piggin <npiggin@gmail.com>
Wed, 30 May 2018 10:31:22 +0000 (20:31 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 3 Aug 2018 05:50:25 +0000 (07:50 +0200)
commita23e1da9773bcf90b0caac3c3a7fc06fea351181
tree1ded9fb40013c0cce9d7c755948fd7c1b46ca1a3
parent0aceed2d7ec10eae4bab4912cbae11e47c8ceaec
powerpc/64s: Fix compiler store ordering to SLB shadow area

[ Upstream commit 926bc2f100c24d4842b3064b5af44ae964c1d81c ]

The stores to update the SLB shadow area must be made as they appear
in the C code, so that the hypervisor does not see an entry with
mismatched vsid and esid. Use WRITE_ONCE for this.

GCC has been observed to elide the first store to esid in the update,
which means that if the hypervisor interrupts the guest after storing
to vsid, it could see an entry with old esid and new vsid, which may
possibly result in memory corruption.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/powerpc/mm/slb.c