[PATCH][v2] x86/bugs: Fix GDS mitigation select for non-ARCH_CAP_GDS_CTRL CPUs

lirongqing posted 1 patch 1 month, 2 weeks ago
arch/x86/kernel/cpu/bugs.c | 1 -
1 file changed, 1 deletion(-)
[PATCH][v2] x86/bugs: Fix GDS mitigation select for non-ARCH_CAP_GDS_CTRL CPUs
Posted by lirongqing 1 month, 2 weeks ago
From: Li RongQing <lirongqing@baidu.com>

The current GDS mitigation logic incorrectly returns early when
ARCH_CAP_GDS_CTRL is not present, which leads to two problems:

1. CPUs without ARCH_CAP_GDS_CTRL support are incorrectly marked with
   GDS_MITIGATION_OFF when they should be marked as
   GDS_MITIGATION_UCODE_NEEDED.

2. The mitigation state checks and locking verification that follow are
   skipped, which means:
   - fail to detect if the mitigation was locked
   - miss the warning when trying to disable a locked mitigation

Remove the early return to ensure proper mitigation state handling. This
allows:
- Proper mitigation classification for non-ARCH_CAP_GDS_CTRL CPUs
- Complete mitigation state verification

The change fixes the following runtime issues observed:

[    2.809147] unchecked MSR access error: WRMSR to 0x123 (tried to write 0x0000000000000010) at rIP: 0xffffffffb34527b8 (update_gds_msr+0x38/0xe0)
[    2.809147] Call Trace:
[    2.809147]  <TASK>
[    2.809147]  identify_secondary_cpu+0x72/0x90
[    2.809147]  start_secondary+0x7a/0x140
[    2.809147]  common_startup_64+0x13e/0x141
[    2.809147]  </TASK>
[    2.809147] ------------[ cut here ]------------
[    2.809147] WARNING: CPU: 1 PID: 0 at arch/x86/kernel/cpu/bugs.c:1053 update_gds_msr+0x9b/0xe0

Fixes: 8c7261abcb7ad ("x86/bugs: Add attack vector controls for GDS")
Suggested-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
 arch/x86/kernel/cpu/bugs.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index b74bf93..9e0b9bf 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1071,7 +1071,6 @@ static void __init gds_select_mitigation(void)
 			gds_mitigation = GDS_MITIGATION_FULL;
 		else {
 			gds_mitigation = GDS_MITIGATION_OFF;
-			return;
 		}
 	}
 
-- 
2.9.4
Re: [PATCH][v2] x86/bugs: Fix GDS mitigation select for non-ARCH_CAP_GDS_CTRL CPUs
Posted by Pawan Gupta 1 month, 2 weeks ago
On Sat, Aug 16, 2025 at 08:19:05AM +0800, lirongqing wrote:
> From: Li RongQing <lirongqing@baidu.com>
> 
> The current GDS mitigation logic incorrectly returns early when
> ARCH_CAP_GDS_CTRL is not present, which leads to two problems:

... not present? or the attack vector mitigation is turned off?

> 1. CPUs without ARCH_CAP_GDS_CTRL support are incorrectly marked with
>    GDS_MITIGATION_OFF when they should be marked as
>    GDS_MITIGATION_UCODE_NEEDED.
> 
> 2. The mitigation state checks and locking verification that follow are
>    skipped, which means:
>    - fail to detect if the mitigation was locked
>    - miss the warning when trying to disable a locked mitigation
> 
> Remove the early return to ensure proper mitigation state handling. This
> allows:
> - Proper mitigation classification for non-ARCH_CAP_GDS_CTRL CPUs
> - Complete mitigation state verification
> 
> The change fixes the following runtime issues observed:
> 
> [    2.809147] unchecked MSR access error: WRMSR to 0x123 (tried to write 0x0000000000000010) at rIP: 0xffffffffb34527b8 (update_gds_msr+0x38/0xe0)
> [    2.809147] Call Trace:
> [    2.809147]  <TASK>
> [    2.809147]  identify_secondary_cpu+0x72/0x90
> [    2.809147]  start_secondary+0x7a/0x140
> [    2.809147]  common_startup_64+0x13e/0x141
> [    2.809147]  </TASK>
> [    2.809147] ------------[ cut here ]------------
> [    2.809147] WARNING: CPU: 1 PID: 0 at arch/x86/kernel/cpu/bugs.c:1053 update_gds_msr+0x9b/0xe0
> 
> Fixes: 8c7261abcb7ad ("x86/bugs: Add attack vector controls for GDS")
> Suggested-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
> Signed-off-by: Li RongQing <lirongqing@baidu.com>

Reviewed-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
RE: [????] Re: [PATCH][v2] x86/bugs: Fix GDS mitigation select for non-ARCH_CAP_GDS_CTRL CPUs
Posted by Li,Rongqing 1 month, 2 weeks ago

> -----Original Message-----
> From: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
> Sent: 2025年8月19日 1:33
> To: Li,Rongqing <lirongqing@baidu.com>
> Cc: tglx@linutronix.de; bp@alien8.de; peterz@infradead.org;
> jpoimboe@kernel.org; mingo@redhat.com; dave.hansen@linux.intel.com;
> x86@kernel.org; hpa@zytor.com; david.kaplan@amd.com;
> linux-kernel@vger.kernel.org
> Subject: [????] Re: [PATCH][v2] x86/bugs: Fix GDS mitigation select for
> non-ARCH_CAP_GDS_CTRL CPUs
> 
> On Sat, Aug 16, 2025 at 08:19:05AM +0800, lirongqing wrote:
> > From: Li RongQing <lirongqing@baidu.com>
> >
> > The current GDS mitigation logic incorrectly returns early when
> > ARCH_CAP_GDS_CTRL is not present, which leads to two problems:
> 
> ... not present? or the attack vector mitigation is turned off?


Should be "When the attack vector mitigation is turned off"

I will send v3, thanks

-Li

> 
> > 1. CPUs without ARCH_CAP_GDS_CTRL support are incorrectly marked with
> >    GDS_MITIGATION_OFF when they should be marked as
> >    GDS_MITIGATION_UCODE_NEEDED.
> >
> > 2. The mitigation state checks and locking verification that follow are
> >    skipped, which means:
> >    - fail to detect if the mitigation was locked
> >    - miss the warning when trying to disable a locked mitigation
> >
> > Remove the early return to ensure proper mitigation state handling.
> > This
> > allows:
> > - Proper mitigation classification for non-ARCH_CAP_GDS_CTRL CPUs
> > - Complete mitigation state verification
> >
> > The change fixes the following runtime issues observed:
> >
> > [    2.809147] unchecked MSR access error: WRMSR to 0x123 (tried to
> write 0x0000000000000010) at rIP: 0xffffffffb34527b8
> (update_gds_msr+0x38/0xe0)
> > [    2.809147] Call Trace:
> > [    2.809147]  <TASK>
> > [    2.809147]  identify_secondary_cpu+0x72/0x90
> > [    2.809147]  start_secondary+0x7a/0x140
> > [    2.809147]  common_startup_64+0x13e/0x141
> > [    2.809147]  </TASK>
> > [    2.809147] ------------[ cut here ]------------
> > [    2.809147] WARNING: CPU: 1 PID: 0 at
> arch/x86/kernel/cpu/bugs.c:1053 update_gds_msr+0x9b/0xe0
> >
> > Fixes: 8c7261abcb7ad ("x86/bugs: Add attack vector controls for GDS")
> > Suggested-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
> > Signed-off-by: Li RongQing <lirongqing@baidu.com>
> 
> Reviewed-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>