linux/arch
Anand K Mistry 45df7b02a0 x86/speculation: Allow IBPB to be conditionally enabled on CPUs with always-on STIBP
commit 1978b3a53a upstream.

On AMD CPUs which have the feature X86_FEATURE_AMD_STIBP_ALWAYS_ON,
STIBP is set to on and

  spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED

At the same time, IBPB can be set to conditional.

However, this leads to the case where it's impossible to turn on IBPB
for a process because in the PR_SPEC_DISABLE case in ib_prctl_set() the

  spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED

condition leads to a return before the task flag is set. Similarly,
ib_prctl_get() will return PR_SPEC_DISABLE even though IBPB is set to
conditional.

More generally, the following cases are possible:

1. STIBP = conditional && IBPB = on for spectre_v2_user=seccomp,ibpb
2. STIBP = on && IBPB = conditional for AMD CPUs with
   X86_FEATURE_AMD_STIBP_ALWAYS_ON

The first case functions correctly today, but only because
spectre_v2_user_ibpb isn't updated to reflect the IBPB mode.

At a high level, this change does one thing. If either STIBP or IBPB
is set to conditional, allow the prctl to change the task flag.
Also, reflect that capability when querying the state. This isn't
perfect since it doesn't take into account if only STIBP or IBPB is
unconditionally on. But it allows the conditional feature to work as
expected, without affecting the unconditional one.

 [ bp: Massage commit message and comment; space out statements for
   better readability. ]

Fixes: 21998a3515 ("x86/speculation: Avoid force-disabling IBPB based on STIBP and enhanced IBRS.")
Signed-off-by: Anand K Mistry <amistry@google.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
Link: https://lkml.kernel.org/r/20201105163246.v2.1.Ifd7243cd3e2c2206a893ad0a5b9a4f19549e22c6@changeid
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-11-18 19:18:52 +01:00
..
alpha alpha: fix annotation of io{read,write}{16,32}be() 2020-08-26 10:31:02 +02:00
arc Revert "ARC: entry: fix potential EFA clobber when TIF_SYSCALL_TRACE" 2020-11-10 12:36:01 +01:00
arm ARM: 9019/1: kprobes: Avoid fortify_panic() when copying optprobe template 2020-11-18 19:18:46 +01:00
arm64 crypto: arm64/aes-modes - get rid of literal load of addend vector 2020-11-18 19:18:44 +01:00
c6x
h8300 h8300: use cc-cross-prefix instead of hardcoding h8300-unknown-linux- 2019-04-05 22:32:55 +02:00
hexagon hexagon: define ioremap_uc 2020-05-10 10:30:11 +02:00
ia64 ia64: fix build error with !COREDUMP 2020-11-05 11:08:52 +01:00
m68k m68k: q40: Fix info-leak in rtc_ioctl 2020-10-01 13:14:24 +02:00
microblaze microblaze: Prevent the overflow of the start 2020-02-24 08:34:53 +01:00
mips MIPS: Add the missing 'CPU_1074K' into __get_cpu_type() 2020-10-01 13:14:53 +02:00
nds32 nds32: Fix the items of hwcap_str ordering issue. 2019-12-13 08:51:35 +01:00
nios2 nios2: ksyms: Add missing symbol exports 2020-01-27 14:50:30 +01:00
openrisc openrisc: Fix cache API compile issue when not inlining 2020-09-23 12:10:58 +02:00
parisc parisc: Implement __smp_store_release and __smp_load_acquire barriers 2020-08-19 08:15:07 +02:00
powerpc powerpc: Fix undetected data corruption with P9N DD2.1 VSX CI load emulation 2020-11-05 11:08:51 +01:00
riscv riscv: Define AT_VECTOR_SIZE_ARCH for ARCH_DLINFO 2020-11-05 11:08:41 +01:00
s390 s390/smp: move rcu_cpu_starting() earlier 2020-11-18 19:18:45 +01:00
sh sh: landisk: Add missing initialization of sh_io_port_base 2020-08-21 11:05:39 +02:00
sparc sparc64: remove mm_cpumask clearing to fix kthread_use_mm race 2020-11-05 11:08:38 +01:00
um um: change sigio_spinlock to a mutex 2020-11-05 11:08:39 +01:00
unicore32
x86 x86/speculation: Allow IBPB to be conditionally enabled on CPUs with always-on STIBP 2020-11-18 19:18:52 +01:00
xtensa xtensa: fix xtensa_pmu_setup prototype 2020-08-21 11:05:31 +02:00
.gitignore
Kconfig mm: fix exec activate_mm vs TLB shootdown and lazy tlb switching race 2020-11-05 11:08:38 +01:00