x86/speculation: Clarify Spectre-v2 mitigation when STIBP/IBPB features are unsupported
Subsystems (3)
RFC PATCH 1/1 x86/speculation: Clarify Spectre-v2 mitigation when STIBP/IBPB features are unsupported
When STIBP/IBPB features are not supported (no microcode update, AWS/Azure/... instances deliberately hiding SPEC_CTRL for performance reasons,...) /sys/devices/system/cpu/vulnerabilities/spectre_v2 looks like
Mitigation: Full generic retpoline, STIBP: disabled, RSB filling
and this looks imperfect. In particular, STIBP is 'disabled' and 'IBPB' is not mentioned while both features are just not supported. Also, for STIBP the 'disabled' state (SPECTRE_V2_USER_NONE) can represent both the absence of hardware support and deliberate user's choice (spectre_v2_user=off)
Make the following adjustments:
- Output 'unsupported' for both STIBP/IBPB when there's no support in hardware.
- Output 'unneeded' for STIBP when SMT is disabled/missing (and this switch_to_cond_stibp is off).
RFC. Some tools out there may be looking at this information so by changing the output we're breaking them. Also, it may make sense to separate kernel and userspace protections and switch to something like
Mitigation: Kernel: Full generic retpoline, RSB filling; Userspace:
Vulnerable
for the above mentioned case.
--- Documentation/admin-guide/hw-vuln/spectre.rst | 3 +++ arch/x86/kernel/cpu/bugs.c | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-)
Documentation/admin-guide/hw-vuln/spectre.rst +3 -0
@@ -385,6 +385,7 @@ The possible values in this file are: an x86 only feature. For more details see below. =================== ======================================================== + 'IBPB: unsupported' IBPB is not supported by hardware 'IBPB: disabled' IBPB unused 'IBPB: always-on' Use IBPB on all tasks 'IBPB: conditional' Use IBPB on SECCOMP or indirect branch restricted tasks
@@ -396,6 +397,8 @@ The possible values in this file are: only feature. For more details see below. ==================== ======================================================== + 'STIBP: unsupported' STIBP is not supported by hardware + 'STIBP: unneeded' STIBP is not needed because SMT is disabled 'STIBP: disabled' STIBP unused 'STIBP: forced' Use STIBP on all tasks 'STIBP: conditional' Use STIBP on SECCOMP or indirect branch restricted tasks
arch/x86/kernel/cpu/bugs.c +7 -2
@@ -1496,7 +1496,10 @@ static char *stibp_state(void)switch (spectre_v2_user) {case SPECTRE_V2_USER_NONE : -return ", STIBP: disabled" ; +if (boot_cpu_has (X86_FEATURE_STIBP )) +return ", STIBP: disabled" ; +else +return ", STIBP: unsupported" ;case SPECTRE_V2_USER_STRICT :return ", STIBP: forced" ;case SPECTRE_V2_USER_STRICT_PREFERRED :
@@ -1505,6 +1508,8 @@ static char *stibp_state(void)case SPECTRE_V2_USER_SECCOMP :if (static_key_enabled (&switch_to_cond_stibp))return ", STIBP: conditional" ; +else +return ", STIBP: unneeded" ; }return "" ; }
@@ -1518,7 +1523,7 @@ static char *ibpb_state(void)return ", IBPB: conditional" ;return ", IBPB: disabled" ; } -return "" ; +return ", IBPB: unsupported" ; } static ssize_t cpu_show_common(struct device *dev, struct device_attribute *attr,
Signature · 1 line
2.24.1
Borislav Petkov
maintainerQuoted 25 lines · Vitaly Kuznetsov
When STIBP/IBPB features are not supported (no microcode update, AWS/Azure/... instances deliberately hiding
SPEC_CTRLfor performance reasons,...)/sys/devices/system/cpu/vulnerabilities/spectre_v2looks likeMitigation: Full generic retpoline, STIBP: disabled, RSB filling
and this looks imperfect. In particular, STIBP is 'disabled' and 'IBPB' is not mentioned while both features are just not supported. Also, for STIBP the 'disabled' state (
SPECTRE_V2_USER_NONE) can represent both the absence of hardware support and deliberate user's choice (spectre_v2_user=off)Make the following adjustments:
- Output 'unsupported' for both STIBP/IBPB when there's no support in hardware.
- Output 'unneeded' for STIBP when SMT is disabled/missing (and thisswitch_to_cond_stibpis off).RFC. Some tools out there may be looking at this information so by changing the output we're breaking them. Also, it may make sense to separate kernel and userspace protections and switch to something like
Mitigation: Kernel: Full generic retpoline, RSB filling; Userspace:
Vulnerable
Quoted 7 lines
for the above mentioned case.
Signed-off-by Vitaly Kuznetsov <[email protected]>--- Documentation/admin-guide/hw-vuln/spectre.rst | 3 +++ arch/x86/kernel/cpu/bugs.c | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-)
There's another attempt to fix similar aspects of this whole deal going on ATM:
https://lkml.kernel.org/r/[email protected]
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteQuoted 34 lines · Borislav Petkov
Quoted 25 lines · Vitaly Kuznetsov
When STIBP/IBPB features are not supported (no microcode update, AWS/Azure/... instances deliberately hiding
SPEC_CTRLfor performance reasons,...)/sys/devices/system/cpu/vulnerabilities/spectre_v2looks likeMitigation: Full generic retpoline, STIBP: disabled, RSB filling
and this looks imperfect. In particular, STIBP is 'disabled' and 'IBPB' is not mentioned while both features are just not supported. Also, for STIBP the 'disabled' state (
SPECTRE_V2_USER_NONE) can represent both the absence of hardware support and deliberate user's choice (spectre_v2_user=off)Make the following adjustments:
- Output 'unsupported' for both STIBP/IBPB when there's no support in hardware.
- Output 'unneeded' for STIBP when SMT is disabled/missing (and thisswitch_to_cond_stibpis off).RFC. Some tools out there may be looking at this information so by changing the output we're breaking them. Also, it may make sense to separate kernel and userspace protections and switch to something like
Mitigation: Kernel: Full generic retpoline, RSB filling; Userspace:
VulnerableQuoted 7 lines
for the above mentioned case.
Signed-off-by Vitaly Kuznetsov <[email protected]>--- Documentation/admin-guide/hw-vuln/spectre.rst | 3 +++ arch/x86/kernel/cpu/bugs.c | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-)
Quoted 4 lines
There's another attempt to fix similar aspects of this whole deal going on ATM:
Missed that, thanks! (Cc: Anthony)
This patch seem to address my STIBP: disabled/unsupported concern but not 'unneeded'. And not IBPB.
Signature · 1 line
Vitaly
Quoted 12 lines · Vitaly Kuznetsov
When STIBP/IBPB features are not supported (no microcode update, AWS/Azure/... instances deliberately hiding
SPEC_CTRLfor performance reasons,...)/sys/devices/system/cpu/vulnerabilities/spectre_v2looks likeMitigation: Full generic retpoline, STIBP: disabled, RSB filling
and this looks imperfect. In particular, STIBP is 'disabled' and 'IBPB' is not mentioned while both features are just not supported. Also, for STIBP the 'disabled' state (
SPECTRE_V2_USER_NONE) can represent both the absence of hardware support and deliberate user's choice (spectre_v2_user=off)
Quoted 5 lines
Make the following adjustments:
- Output 'unsupported' for both STIBP/IBPB when there's no support in hardware.
- Output 'unneeded' for STIBP when SMT is disabled/missing (and thisswitch_to_cond_stibpis off).
I support outputting "unsupported" when the microcode doesn't support it. However, I am not sure if "unneeded" is really necessary or not. STIBP is not needed when SMT is disabled or when Enhanced IBRS is available and used. Your patch handles the first case, but not the second. I think it may be easier to just leave it out in case it is not needed.
Cheers,
Longman
Quoted 19 lines · Waiman Long
Quoted 12 lines · Vitaly Kuznetsov
When STIBP/IBPB features are not supported (no microcode update, AWS/Azure/... instances deliberately hiding
SPEC_CTRLfor performance reasons,...)/sys/devices/system/cpu/vulnerabilities/spectre_v2looks likeMitigation: Full generic retpoline, STIBP: disabled, RSB filling
and this looks imperfect. In particular, STIBP is 'disabled' and 'IBPB' is not mentioned while both features are just not supported. Also, for STIBP the 'disabled' state (
SPECTRE_V2_USER_NONE) can represent both the absence of hardware support and deliberate user's choice (spectre_v2_user=off)Quoted 5 lines
Make the following adjustments:
- Output 'unsupported' for both STIBP/IBPB when there's no support in hardware.
- Output 'unneeded' for STIBP when SMT is disabled/missing (and thisswitch_to_cond_stibpis off).
Quoted 6 lines
I support outputting "unsupported" when the microcode doesn't support it. However, I am not sure if "unneeded" is really necessary or not. STIBP is not needed when SMT is disabled or when Enhanced IBRS is available and used. Your patch handles the first case, but not the second. I think it may be easier to just leave it out in case it is not needed.
Makes sense. Or, alternatively, we can output 'unneeded' in both cases to make things explicit and to distinguish it from the current state of IBPB where missing means 'unsupported by hardware'.
Signature · 1 line
Vitaly