]> www.infradead.org Git - users/jedix/linux-maple.git/commit
x86/speculation: Add sysfs entry to enable/disable retpoline
authorAlexandre Chartre <alexandre.chartre@oracle.com>
Tue, 4 Sep 2018 12:51:23 +0000 (14:51 +0200)
committerBrian Maly <brian.maly@oracle.com>
Mon, 22 Oct 2018 17:21:18 +0000 (13:21 -0400)
commit11ecaece218962b57966c3997860e8bf92f4efea
tree41854f0fb433f7931560f20ed739184e85fc4361
parent8cab1ba2992da9e86197822fd68c7dccd58f664a
x86/speculation: Add sysfs entry to enable/disable retpoline

Add /sys/kernel/debug/x86/retpoline_enabled to enable/disable retpoline.
Enabling retpoline will also enable IBRS for the firmware.

Note that IBRS and retpoline can't be enabled together. Enabling retpoline
while IBRS is already enabled will automatically disable IBRS. Similarly,
enabling IBRS while retpoline is already enabled will automatically disable
retpoline.

On Skylake, retpoline is not provided and can't be enabled unless the system
has been explicitly booted with retpoline (using spectre_v2=retpoline or
spectre_v2_heuristics=skylake=off).

Also fix the behavior when retpoline is not available (!CONFIG_RETPOLINE):
now we will try using IBRS (if it is available) instead of not using any
mitigation.

Signed-off-by: Alexandre Chartre <alexandre.chartre@oracle.com>
Reviewed-by: Mihai Carabas <mihai.carabas@oracle.com>
(cherry picked from UEK5 commit d75554157882d9b4df91f0b2bbc4907e2731781e)

[Backport: a large part of d75554157882d9b4df91f0b2bbc4907e2731781e
 was already ported in previous commit ("x86/speculation: switch to IBRS
 when loading a non-retpoline module"). This ports the remaining part
 which effectively adds the retpoline_enabled sysfs entry.

 Also we issue a warning when enabling retpoline and a non-retpoline
 module is loaded.]

Orabug: 28607548

Signed-off-by: Alexandre Chartre <alexandre.chartre@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Mihai Carabas <mihai.carabas@oracle.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Brian Maly <brian.maly@oracle.com>
arch/x86/kernel/cpu/spec_ctrl.c