powerpc/64s: Add support for software count cache flush
authorMichael Ellerman <mpe@ellerman.id.au>
Thu, 11 Apr 2019 11:46:15 +0000 (21:46 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Apr 2019 06:36:42 +0000 (08:36 +0200)
commit98f6dedbcb1fe30ee9e7eeafd220269ae75b8afd
tree19327fd4cb2448d2dbc6fb28d41d4b9b1db47625
parent2f4fed0185515cc6da36ac718969fa12537a6868
powerpc/64s: Add support for software count cache flush

commit ee13cb249fabdff8b90aaff61add347749280087 upstream.

Some CPU revisions support a mode where the count cache needs to be
flushed by software on context switch. Additionally some revisions may
have a hardware accelerated flush, in which case the software flush
sequence can be shortened.

If we detect the appropriate flag from firmware we patch a branch
into _switch() which takes us to a count cache flush sequence.

That sequence in turn may be patched to return early if we detect that
the CPU supports accelerating the flush sequence in hardware.

Add debugfs support for reporting the state of the flush, as well as
runtime disabling it.

And modify the spectre_v2 sysfs file to report the state of the
software flush.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/powerpc/include/asm/asm-prototypes.h
arch/powerpc/include/asm/security_features.h
arch/powerpc/kernel/entry_64.S
arch/powerpc/kernel/security.c