x86/idle: Clear SPEC_CTRL while idle
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 3 Nov 2017 16:43:02 +0000 (16:43 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 26 Jan 2018 14:10:21 +0000 (14:10 +0000)
commit4c7e478d597b0346eef3a256cfd6794ac778b608
treeb4f983b6b01b2d9c3268ed38f2272685f5ef699a
parent67c6838ddacfa646f9d1ae802bd0f16a935665b8
x86/idle: Clear SPEC_CTRL while idle

On contemporary hardware, setting IBRS/STIBP has a performance impact on
adjacent hyperthreads.  It is therefore recommended to clear the setting
before becoming idle, to avoid an idle core preventing adjacent userspace
execution from running at full performance.

Care must be taken to ensure there are no ret or indirect branch instructions
between spec_ctrl_{enter,exit}_idle() invocations, which are forced always
inline.  Care must also be taken to avoid using spec_ctrl_enter_idle() between
flushing caches and becoming idle, in cases where that matters.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/acpi/cpu_idle.c
xen/arch/x86/cpu/mwait-idle.c
xen/arch/x86/domain.c
xen/include/asm-x86/spec_ctrl.h