KVM: PPC: Book3S HV: Flush link stack on guest exit to host kernel
authorMichael Ellerman <mpe@ellerman.id.au>
Wed, 13 Nov 2019 10:05:44 +0000 (21:05 +1100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 1 Dec 2019 08:17:46 +0000 (09:17 +0100)
commit345712c95eec44bf414782b33e6d5a550fe62b3b
treee819d589792a20cded8d8228237c965f4ed255d5
parent0a60d4bddc0ba6a7e06d10efa59f7861837860b0
KVM: PPC: Book3S HV: Flush link stack on guest exit to host kernel

commit af2e8c68b9c5403f77096969c516f742f5bb29e0 upstream.

On some systems that are vulnerable to Spectre v2, it is up to
software to flush the link stack (return address stack), in order to
protect against Spectre-RSB.

When exiting from a guest we do some house keeping and then
potentially exit to C code which is several stack frames deep in the
host kernel. We will then execute a series of returns without
preceeding calls, opening up the possiblity that the guest could have
poisoned the link stack, and direct speculative execution of the host
to a gadget of some sort.

To prevent this we add a flush of the link stack on exit from a guest.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
[dja: straightforward backport to v4.19]
Signed-off-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/powerpc/include/asm/asm-prototypes.h
arch/powerpc/kernel/security.c
arch/powerpc/kvm/book3s_hv_rmhandlers.S