x86/speculation: Fix incorrect MDS/TAA mitigation status
Subsystems (2)
PATCH 1/1 x86/speculation: Fix incorrect MDS/TAA mitigation status
For MDS vulnerable processors with TSX support, enabling either MDS or TAA mitigations will enable the use of VERW to flush internal processor buffers at the right code path. IOW, they are either both mitigated or both not mitigated. However, if the command line options are inconsistent, the vulnerabilites sysfs files may not report the mitigation status correctly.
For example, with only the "mds=off" option:
vulnerabilities/mds:Vulnerable; SMT vulnerable vulnerabilities/tsx_async_abort:Mitigation: Clear CPU buffers; SMT vulnerable
The mds vulnerabilities file has wrong status in this case.
Change taa_select_mitigation() to sync up the two mitigation status and have them turned off if both "mds=off" and "tsx_async_abort=off" are present.
--- arch/x86/kernel/cpu/bugs.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/bugs.c +15 -2
@@ -304,8 +304,12 @@ static void __init taa_select_mitigation(void)return ; } -/* TAA mitigation is turned off on the cmdline (tsx_async_abort=off) */ -if (taa_mitigation ==TAA_MITIGATION_OFF ) +/* +* TAA mitigation via VERW is turned off if both +* tsx_async_abort=off and mds=off are specified. +*/ +if (taa_mitigation ==TAA_MITIGATION_OFF && + mds_mitigation ==MDS_MITIGATION_OFF ) goto out;if (boot_cpu_has (X86_FEATURE_MD_CLEAR ))
@@ -339,6 +343,15 @@ static void __init taa_select_mitigation(void)if (taa_nosmt ||cpu_mitigations_auto_nosmt ())cpu_smt_disable (false); +/* +* Update MDS mitigation, if necessary, as the mds_user_clear is +* now enabled for TAA mitigation. +*/ +if (mds_mitigation ==MDS_MITIGATION_OFF && +boot_cpu_has_bug (X86_BUG_MDS )) { + mds_mitigation =MDS_MITIGATION_FULL ; +mds_select_mitigation (); + } out:pr_info ("%s\n" , taa_strings[taa_mitigation]); }
Signature · 1 line
2.18.1
Borislav Petkov
maintainerQuoted 28 lines · Waiman Long
For MDS vulnerable processors with TSX support, enabling either MDS or TAA mitigations will enable the use of VERW to flush internal processor buffers at the right code path. IOW, they are either both mitigated or both not mitigated. However, if the command line options are inconsistent, the vulnerabilites sysfs files may not report the mitigation status correctly.
For example, with only the "mds=off" option:
vulnerabilities/mds:Vulnerable; SMT vulnerable vulnerabilities/tsx_async_abort:Mitigation: Clear CPU buffers; SMT vulnerable
The mds vulnerabilities file has wrong status in this case.
Change
taa_select_mitigation()to sync up the two mitigation status and have them turned off if both "mds=off" and "tsx_async_abort=off" are present.Signed-off-by Waiman Long <[email protected]>--- arch/x86/kernel/cpu/bugs.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)arch/x86/kernel/cpu/bugs.c +0
-0
arch/x86/kernel/cpu/bugs.c static void __init taa_select_mitigation(void) · line 310
Quoted 9 lines
arch/x86/kernel/cpu/bugs.c +4
-2@@ -304,8 +304,12 @@ static void __init taa_select_mitigation(void)return ; } -/* TAA mitigation is turned off on the cmdline (tsx_async_abort=off) */ -if (taa_mitigation ==TAA_MITIGATION_OFF ) +/* +* TAA mitigation via VERW is turned off if both +* tsx_async_abort=off and mds=off are specified. +*/
So this changes the dependency of switches so if anything, it should be properly documented first in all three:
Documentation/admin-guide/hw-vuln/tsx_async_abort.rst Documentation/x86/tsx_async_abort.rst Documentation/admin-guide/kernel-parameters.txt
However, before we do that, we need to agree on functionality:
Will the mitigations be disabled only with *both* =off supplied on the command line or should the mitigations be disabled when *any* of the two =off is supplied?
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteQuoted 41 lines · Borislav Petkov
Quoted 28 lines · Waiman Long
For MDS vulnerable processors with TSX support, enabling either MDS or TAA mitigations will enable the use of VERW to flush internal processor buffers at the right code path. IOW, they are either both mitigated or both not mitigated. However, if the command line options are inconsistent, the vulnerabilites sysfs files may not report the mitigation status correctly.
For example, with only the "mds=off" option:
vulnerabilities/mds:Vulnerable; SMT vulnerable vulnerabilities/tsx_async_abort:Mitigation: Clear CPU buffers; SMT vulnerable
The mds vulnerabilities file has wrong status in this case.
Change
taa_select_mitigation()to sync up the two mitigation status and have them turned off if both "mds=off" and "tsx_async_abort=off" are present.Signed-off-by Waiman Long <[email protected]>--- arch/x86/kernel/cpu/bugs.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)arch/x86/kernel/cpu/bugs.c +0
-0arch/x86/kernel/cpu/bugs.c static void __init taa_select_mitigation(void) · line 310
Quoted 9 lines
arch/x86/kernel/cpu/bugs.c +4
-2@@ -304,8 +304,12 @@ static void __init taa_select_mitigation(void)return ; } -/* TAA mitigation is turned off on the cmdline (tsx_async_abort=off) */ -if (taa_mitigation ==TAA_MITIGATION_OFF ) +/* +* TAA mitigation via VERW is turned off if both +* tsx_async_abort=off and mds=off are specified. +*/ So this changes the dependency of switches so if anything, it should be properly documented first in all three:
Quoted 5 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rstDocumentation/x86/tsx_async_abort.rstDocumentation/admin-guide/kernel-parameters.txtHowever, before we do that, we need to agree on functionality:
I agree that the documentation needs to be updated. I am going to do that once we have a consensus of what is the right thing to do.
Quoted 3 lines
Will the mitigations be disabled only with *both* =off supplied on the command line or should the mitigations be disabled when *any* of the two =off is supplied?
The mitigation is disabled only with BOTH =off supplied or "mitigations=off". This is the current behavior. This patch is just to make sure that vulnerabilities files reflect the actual behavior. Of course, we can change it to disable mitigation with either =off if this is what the consensus turn out to be.
Cheers,
Longman
Quoted 21 lines · Waiman Long
Quoted 9 lines · Borislav Petkov
arch/x86/kernel/cpu/bugs.c static void __init taa_select_mitigation(void) · line 310
Quoted 6 lines
arch/x86/kernel/cpu/bugs.c +4
-2-/* TAA mitigation is turned off on the cmdline (tsx_async_abort=off) */ -if (taa_mitigation ==TAA_MITIGATION_OFF ) +/* +* TAA mitigation via VERW is turned off if both +* tsx_async_abort=off and mds=off are specified. +*/ So this changes the dependency of switches so if anything, it should be properly documented first in all three:
Quoted 5 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rstDocumentation/x86/tsx_async_abort.rstDocumentation/admin-guide/kernel-parameters.txtHowever, before we do that, we need to agree on functionality:
I agree that the documentation needs to be updated. I am going to do that once we have a consensus of what is the right thing to do.
Quoted 3 lines
Will the mitigations be disabled only with *both* =off supplied on the command line or should the mitigations be disabled when *any* of the two =off is supplied?
Quoted 5 lines
The mitigation is disabled only with BOTH =off supplied or "mitigations=off". This is the current behavior. This patch is just to make sure that vulnerabilities files reflect the actual behavior. Of course, we can change it to disable mitigation with either =off if this is what the consensus turn out to be.
I think the current behaviour is correct. It's just a coincidence that both issues happen to use the same mitigation technology in the exactly same places. So if you leave one on then the other gets mitigated as a side effect and the sysfs file should reflect that.
Thanks,
tglx
Quoted 26 lines · Thomas Gleixner
Quoted 17 lines · Waiman Long
Quoted 9 lines · Borislav Petkov
arch/x86/kernel/cpu/bugs.c static void __init taa_select_mitigation(void) · line 310
Quoted 6 lines
arch/x86/kernel/cpu/bugs.c +4
-2-/* TAA mitigation is turned off on the cmdline (tsx_async_abort=off) */ -if (taa_mitigation ==TAA_MITIGATION_OFF ) +/* +* TAA mitigation via VERW is turned off if both +* tsx_async_abort=off and mds=off are specified. +*/ So this changes the dependency of switches so if anything, it should be properly documented first in all three:
Quoted 5 lines
Documentation/admin-guide/hw-vuln/tsx_async_abort.rstDocumentation/x86/tsx_async_abort.rstDocumentation/admin-guide/kernel-parameters.txtHowever, before we do that, we need to agree on functionality:
I agree that the documentation needs to be updated. I am going to do that once we have a consensus of what is the right thing to do.
Quoted 8 lines
Quoted 3 lines
Will the mitigations be disabled only with *both* =off supplied on the command line or should the mitigations be disabled when *any* of the two =off is supplied?
The mitigation is disabled only with BOTH =off supplied or "mitigations=off". This is the current behavior. This patch is just to make sure that vulnerabilities files reflect the actual behavior. Of course, we can change it to disable mitigation with either =off if this is what the consensus turn out to be.
Quoted 9 lines
I think the current behaviour is correct. It's just a coincidence that both issues happen to use the same mitigation technology in the exactly same places. So if you leave one on then the other gets mitigated as a side effect and the sysfs file should reflect that.
Thanks,
tglx
Good to hear that. I will send a v2 patch with document update.
Cheers,
Longman
Pawan Gupta
reviewerQuoted 44 lines · Waiman Long
For MDS vulnerable processors with TSX support, enabling either MDS or TAA mitigations will enable the use of VERW to flush internal processor buffers at the right code path. IOW, they are either both mitigated or both not mitigated. However, if the command line options are inconsistent, the vulnerabilites sysfs files may not report the mitigation status correctly.
For example, with only the "mds=off" option:
vulnerabilities/mds:Vulnerable; SMT vulnerable vulnerabilities/tsx_async_abort:Mitigation: Clear CPU buffers; SMT vulnerable
The mds vulnerabilities file has wrong status in this case.
Change
taa_select_mitigation()to sync up the two mitigation status and have them turned off if both "mds=off" and "tsx_async_abort=off" are present.Signed-off-by Waiman Long <[email protected]>--- arch/x86/kernel/cpu/bugs.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)arch/x86/kernel/cpu/bugs.c +6
-2@@ -304,8 +304,12 @@ static void __init taa_select_mitigation(void)return ; } -/* TAA mitigation is turned off on the cmdline (tsx_async_abort=off) */ -if (taa_mitigation ==TAA_MITIGATION_OFF ) +/* +* TAA mitigation via VERW is turned off if both +* tsx_async_abort=off and mds=off are specified. +*/ +if (taa_mitigation ==TAA_MITIGATION_OFF && + mds_mitigation ==MDS_MITIGATION_OFF ) goto out;if (boot_cpu_has (X86_FEATURE_MD_CLEAR ))@@ -339,6 +343,15 @@ static void __init taa_select_mitigation(void)if (taa_nosmt ||cpu_mitigations_auto_nosmt ())
arch/x86/kernel/cpu/bugs.c static void __init taa_select_mitigation(void) · line 353
Quoted 10 lines
arch/x86/kernel/cpu/bugs.c +8
-0cpu_smt_disable (false); +/* +* Update MDS mitigation, if necessary, as the mds_user_clear is +* now enabled for TAA mitigation. +*/ +if (mds_mitigation ==MDS_MITIGATION_OFF && +boot_cpu_has_bug (X86_BUG_MDS )) { + mds_mitigation =MDS_MITIGATION_FULL ; +mds_select_mitigation ();
This will cause a confusing print in dmesg from previous and this call to mds_select_mitigation().
"MDS: Vulnerable"
"MDS: Mitigation: Clear CPU buffers"
Maybe delay MDS mitigation print till TAA is evaluated.
Thanks,
Pawan
Quoted 59 lines · Pawan Gupta
Quoted 44 lines · Waiman Long
For MDS vulnerable processors with TSX support, enabling either MDS or TAA mitigations will enable the use of VERW to flush internal processor buffers at the right code path. IOW, they are either both mitigated or both not mitigated. However, if the command line options are inconsistent, the vulnerabilites sysfs files may not report the mitigation status correctly.
For example, with only the "mds=off" option:
vulnerabilities/mds:Vulnerable; SMT vulnerable vulnerabilities/tsx_async_abort:Mitigation: Clear CPU buffers; SMT vulnerable
The mds vulnerabilities file has wrong status in this case.
Change
taa_select_mitigation()to sync up the two mitigation status and have them turned off if both "mds=off" and "tsx_async_abort=off" are present.Signed-off-by Waiman Long <[email protected]>--- arch/x86/kernel/cpu/bugs.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)arch/x86/kernel/cpu/bugs.c +6
-2@@ -304,8 +304,12 @@ static void __init taa_select_mitigation(void)return ; } -/* TAA mitigation is turned off on the cmdline (tsx_async_abort=off) */ -if (taa_mitigation ==TAA_MITIGATION_OFF ) +/* +* TAA mitigation via VERW is turned off if both +* tsx_async_abort=off and mds=off are specified. +*/ +if (taa_mitigation ==TAA_MITIGATION_OFF && + mds_mitigation ==MDS_MITIGATION_OFF ) goto out;if (boot_cpu_has (X86_FEATURE_MD_CLEAR ))@@ -339,6 +343,15 @@ static void __init taa_select_mitigation(void)if (taa_nosmt ||cpu_mitigations_auto_nosmt ())arch/x86/kernel/cpu/bugs.c static void __init taa_select_mitigation(void) · line 353
Quoted 10 lines
arch/x86/kernel/cpu/bugs.c +8
-0cpu_smt_disable (false); +/* +* Update MDS mitigation, if necessary, as the mds_user_clear is +* now enabled for TAA mitigation. +*/ +if (mds_mitigation ==MDS_MITIGATION_OFF && +boot_cpu_has_bug (X86_BUG_MDS )) { + mds_mitigation =MDS_MITIGATION_FULL ; +mds_select_mitigation ();This will cause a confusing print in dmesg from previous and this call to
mds_select_mitigation().
Quoted 4 lines
"MDS: Vulnerable"
"MDS: Mitigation: Clear CPU buffers"Maybe delay MDS mitigation print till TAA is evaluated.
Since they're so intertwined it might make sense to just combine the two mitigations into a single function.
Signature · 1 line
Josh
Quoted 59 lines · Josh Poimboeuf
Quoted 58 lines · Pawan Gupta
Quoted 44 lines · Waiman Long
For MDS vulnerable processors with TSX support, enabling either MDS or TAA mitigations will enable the use of VERW to flush internal processor buffers at the right code path. IOW, they are either both mitigated or both not mitigated. However, if the command line options are inconsistent, the vulnerabilites sysfs files may not report the mitigation status correctly.
For example, with only the "mds=off" option:
vulnerabilities/mds:Vulnerable; SMT vulnerable vulnerabilities/tsx_async_abort:Mitigation: Clear CPU buffers; SMT vulnerable
The mds vulnerabilities file has wrong status in this case.
Change
taa_select_mitigation()to sync up the two mitigation status and have them turned off if both "mds=off" and "tsx_async_abort=off" are present.Signed-off-by Waiman Long <[email protected]>--- arch/x86/kernel/cpu/bugs.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)arch/x86/kernel/cpu/bugs.c +6
-2@@ -304,8 +304,12 @@ static void __init taa_select_mitigation(void)return ; } -/* TAA mitigation is turned off on the cmdline (tsx_async_abort=off) */ -if (taa_mitigation ==TAA_MITIGATION_OFF ) +/* +* TAA mitigation via VERW is turned off if both +* tsx_async_abort=off and mds=off are specified. +*/ +if (taa_mitigation ==TAA_MITIGATION_OFF && + mds_mitigation ==MDS_MITIGATION_OFF ) goto out;if (boot_cpu_has (X86_FEATURE_MD_CLEAR ))@@ -339,6 +343,15 @@ static void __init taa_select_mitigation(void)if (taa_nosmt ||cpu_mitigations_auto_nosmt ())arch/x86/kernel/cpu/bugs.c static void __init taa_select_mitigation(void) · line 353
Quoted 10 lines
arch/x86/kernel/cpu/bugs.c +8
-0cpu_smt_disable (false); +/* +* Update MDS mitigation, if necessary, as the mds_user_clear is +* now enabled for TAA mitigation. +*/ +if (mds_mitigation ==MDS_MITIGATION_OFF && +boot_cpu_has_bug (X86_BUG_MDS )) { + mds_mitigation =MDS_MITIGATION_FULL ; +mds_select_mitigation ();This will cause a confusing print in dmesg from previous and this call to
mds_select_mitigation().
Quoted 7 lines
Quoted 4 lines
"MDS: Vulnerable"
"MDS: Mitigation: Clear CPU buffers"Maybe delay MDS mitigation print till TAA is evaluated.
Since they're so intertwined it might make sense to just combine the two mitigations into a single function.
They are intertwined mainly for non-MDS_NO processors with TSX. The mds_select_mitigation() function is pretty simple. Merging the two together will make the MDS part harder to read. Also the pr_fmt() macro has to be different for MDS and TAA.
Cheers,
Longman
Quoted 58 lines · Pawan Gupta
Quoted 44 lines · Waiman Long
For MDS vulnerable processors with TSX support, enabling either MDS or TAA mitigations will enable the use of VERW to flush internal processor buffers at the right code path. IOW, they are either both mitigated or both not mitigated. However, if the command line options are inconsistent, the vulnerabilites sysfs files may not report the mitigation status correctly.
For example, with only the "mds=off" option:
vulnerabilities/mds:Vulnerable; SMT vulnerable vulnerabilities/tsx_async_abort:Mitigation: Clear CPU buffers; SMT vulnerable
The mds vulnerabilities file has wrong status in this case.
Change
taa_select_mitigation()to sync up the two mitigation status and have them turned off if both "mds=off" and "tsx_async_abort=off" are present.Signed-off-by Waiman Long <[email protected]>--- arch/x86/kernel/cpu/bugs.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)arch/x86/kernel/cpu/bugs.c +6
-2@@ -304,8 +304,12 @@ static void __init taa_select_mitigation(void)return ; } -/* TAA mitigation is turned off on the cmdline (tsx_async_abort=off) */ -if (taa_mitigation ==TAA_MITIGATION_OFF ) +/* +* TAA mitigation via VERW is turned off if both +* tsx_async_abort=off and mds=off are specified. +*/ +if (taa_mitigation ==TAA_MITIGATION_OFF && + mds_mitigation ==MDS_MITIGATION_OFF ) goto out;if (boot_cpu_has (X86_FEATURE_MD_CLEAR ))@@ -339,6 +343,15 @@ static void __init taa_select_mitigation(void)if (taa_nosmt ||cpu_mitigations_auto_nosmt ())arch/x86/kernel/cpu/bugs.c static void __init taa_select_mitigation(void) · line 353
Quoted 10 lines
arch/x86/kernel/cpu/bugs.c +8
-0cpu_smt_disable (false); +/* +* Update MDS mitigation, if necessary, as the mds_user_clear is +* now enabled for TAA mitigation. +*/ +if (mds_mitigation ==MDS_MITIGATION_OFF && +boot_cpu_has_bug (X86_BUG_MDS )) { + mds_mitigation =MDS_MITIGATION_FULL ; +mds_select_mitigation ();This will cause a confusing print in dmesg from previous and this call to
mds_select_mitigation().
Quoted 2 lines
"MDS: Vulnerable"
"MDS: Mitigation: Clear CPU buffers"
Yes, that is the side effect of this patch. It is the last message that is relevant. We saw this kind of messages all the time with early loading of microcode. A message showing a hardware vulnerability as vulnerable and then another message showing it as mitigated after the loading of microcode.
Quoted 2 lines
Maybe delay MDS mitigation print till TAA is evaluated.
I will see what can be done about that. However, this is not a critical issue and I may not change it if there is no easy solution.
Cheers,
Longman
Borislav Petkov
maintainerQuoted 4 lines · Waiman Long
Quoted 1 line
Maybe delay MDS mitigation print till TAA is evaluated.
I will see what can be done about that. However, this is not a critical issue and I may not change it if there is no easy solution.
Swapping the two mitigation selection calls in check_bugs() might work...
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteQuoted 6 lines · Borislav Petkov
Quoted 3 lines · Waiman Long
Quoted 1 line
Maybe delay MDS mitigation print till TAA is evaluated.
I will see what can be done about that. However, this is not a critical issue and I may not change it if there is no easy solution.
Swapping the two mitigation selection calls in
check_bugs()might work...
Not really. If taa_select_mitigation() goes first and with "tsx_async_abort=off" only, the mds file is correct, but the taa file will be wrong.
Cheers,
Longman
Quoted 2 lines · Waiman Long
Quoted 1 line · Pawan Gupta
On Wed, Nov 13, 2019 at 02:33:50PM -0500, Waiman Long wrote:
Folks, please trim your replies ....
Quoted 20 lines
Quoted 11 lines
arch/x86/kernel/cpu/bugs.c static void __init taa_select_mitigation(void) · line 353
Quoted 8 lines
arch/x86/kernel/cpu/bugs.c +8
-0+/* +* Update MDS mitigation, if necessary, as the mds_user_clear is +* now enabled for TAA mitigation. +*/ +if (mds_mitigation ==MDS_MITIGATION_OFF && +boot_cpu_has_bug (X86_BUG_MDS )) { + mds_mitigation =MDS_MITIGATION_FULL ; +mds_select_mitigation ();This will cause a confusing print in dmesg from previous and this call to
mds_select_mitigation().Quoted 2 lines
"MDS: Vulnerable"
"MDS: Mitigation: Clear CPU buffers"Yes, that is the side effect of this patch. It is the last message that is relevant. We saw this kind of messages all the time with early loading of microcode. A message showing a hardware vulnerability as vulnerable and then another message showing it as mitigated after the loading of microcode.
Quoted 1 line
Quoted 4 lines
Quoted 1 line
Maybe delay MDS mitigation print till TAA is evaluated.
I will see what can be done about that. However, this is not a critical issue and I may not change it if there is no easy solution.
Right. There is nothing wrong with these two messages coming after each other. They are both correct and due to the ordering they also make sense.
Quoted 2 lines
Quoted 2 lines
"MDS: Vulnerable"
"MDS: Mitigation: Clear CPU buffers"
CPU is vulnerable and then the next printk tells that mitigation is in effect. So really nothing to worry about.
The important part is that the ordering of these messages is correct which is the case and that the sysfs file corresponds with the last printk.
We really have more urgent problems than bikeshed painting these printks.
Thanks,
tglx