Patch "cpu/SMT: Make SMT control more robust against enumeration failures" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    cpu/SMT: Make SMT control more robust against enumeration failures

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     cpu-smt-make-smt-control-more-robust-against-enumera.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 8d793e42de9821755192236eee336a83a5a48a20
Author: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Date:   Mon Aug 14 10:18:27 2023 +0200

    cpu/SMT: Make SMT control more robust against enumeration failures
    
    [ Upstream commit d91bdd96b55cc3ce98d883a60f133713821b80a6 ]
    
    The SMT control mechanism got added as speculation attack vector
    mitigation. The implemented logic relies on the primary thread mask to
    be set up properly.
    
    This turns out to be an issue with XEN/PV guests because their CPU hotplug
    mechanics do not enumerate APICs and therefore the mask is never correctly
    populated.
    
    This went unnoticed so far because by chance XEN/PV ends up with
    smp_num_siblings == 2. So smt_hotplug_control stays at its default value
    CPU_SMT_ENABLED and the primary thread mask is never evaluated in the
    context of CPU hotplug.
    
    This stopped "working" with the upcoming overhaul of the topology
    evaluation which legitimately provides a fake topology for XEN/PV. That
    sets smp_num_siblings to 1, which causes the core CPU hot-plug core to
    refuse to bring up the APs.
    
    This happens because smt_hotplug_control is set to CPU_SMT_NOT_SUPPORTED
    which causes cpu_smt_allowed() to evaluate the unpopulated primary thread
    mask with the conclusion that all non-boot CPUs are not valid to be
    plugged.
    
    Make cpu_smt_allowed() more robust and take CPU_SMT_NOT_SUPPORTED and
    CPU_SMT_NOT_IMPLEMENTED into account. Rename it to cpu_bootable() while at
    it as that makes it more clear what the function is about.
    
    The primary mask issue on x86 XEN/PV needs to be addressed separately as
    there are users outside of the CPU hotplug code too.
    
    Fixes: 05736e4ac13c ("cpu/hotplug: Provide knobs to control SMT")
    Reported-by: Juergen Gross <jgross@xxxxxxxx>
    Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
    Tested-by: Juergen Gross <jgross@xxxxxxxx>
    Tested-by: Sohil Mehta <sohil.mehta@xxxxxxxxx>
    Tested-by: Michael Kelley <mikelley@xxxxxxxxxxxxx>
    Tested-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
    Tested-by: Zhang Rui <rui.zhang@xxxxxxxxx>
    Acked-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230814085112.149440843@xxxxxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/cpu.c b/kernel/cpu.c
index 6de7c6bb74eee..1a189da3bdac5 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -659,11 +659,19 @@ static inline bool cpu_smt_thread_allowed(unsigned int cpu)
 #endif
 }
 
-static inline bool cpu_smt_allowed(unsigned int cpu)
+static inline bool cpu_bootable(unsigned int cpu)
 {
 	if (cpu_smt_control == CPU_SMT_ENABLED && cpu_smt_thread_allowed(cpu))
 		return true;
 
+	/* All CPUs are bootable if controls are not configured */
+	if (cpu_smt_control == CPU_SMT_NOT_IMPLEMENTED)
+		return true;
+
+	/* All CPUs are bootable if CPU is not SMT capable */
+	if (cpu_smt_control == CPU_SMT_NOT_SUPPORTED)
+		return true;
+
 	if (topology_is_primary_thread(cpu))
 		return true;
 
@@ -685,7 +693,7 @@ bool cpu_smt_possible(void)
 EXPORT_SYMBOL_GPL(cpu_smt_possible);
 
 #else
-static inline bool cpu_smt_allowed(unsigned int cpu) { return true; }
+static inline bool cpu_bootable(unsigned int cpu) { return true; }
 #endif
 
 static inline enum cpuhp_state
@@ -788,10 +796,10 @@ static int bringup_wait_for_ap_online(unsigned int cpu)
 	 * SMT soft disabling on X86 requires to bring the CPU out of the
 	 * BIOS 'wait for SIPI' state in order to set the CR4.MCE bit.  The
 	 * CPU marked itself as booted_once in notify_cpu_starting() so the
-	 * cpu_smt_allowed() check will now return false if this is not the
+	 * cpu_bootable() check will now return false if this is not the
 	 * primary sibling.
 	 */
-	if (!cpu_smt_allowed(cpu))
+	if (!cpu_bootable(cpu))
 		return -ECANCELED;
 	return 0;
 }
@@ -1741,7 +1749,7 @@ static int cpu_up(unsigned int cpu, enum cpuhp_state target)
 		err = -EBUSY;
 		goto out;
 	}
-	if (!cpu_smt_allowed(cpu)) {
+	if (!cpu_bootable(cpu)) {
 		err = -EPERM;
 		goto out;
 	}



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux