Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp915763rwo; Wed, 2 Aug 2023 06:14:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlGLYjCGK/GxLuuyge/lHi/5A9vu2/A4datiXTPdS4fkuaQKshxrDihxZAg2/eXsO+IWQrBX X-Received: by 2002:a05:6e02:d0f:b0:345:c8ce:ff49 with SMTP id g15-20020a056e020d0f00b00345c8ceff49mr13151012ilj.11.1690982082752; Wed, 02 Aug 2023 06:14:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690982082; cv=none; d=google.com; s=arc-20160816; b=tUaadFt9leVa25BSrauEACdjgefDJpRILKaw6w8NUCQNl9TZVI3a2FjZoBOy5LT4Qg k5WLQOcysmL0xdJCusJ5nyIxX78aK4NaU1xyzBY3LZ8Dq4d/Imyi6hm+DxLiWuyLroB7 oRzlOKQLOvm33JOEaIJXE4goHFDRCu4QeNcnVOn9M6ZzNFFi59XxSR87DQSJrkPMEpaW ZCRE2FIwdcKPKHC0/hvoHp820OvTaloh1/2fQT/hIfGpGRMOH6iznoSHsg8JKzWfdr7C L6oY26bB2mirSBndSe7ElsQWyLQN4hPPL+dNC3TAFiFdvsyhdaB0uH5KfULUWsTT55Wh npEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=ifKZU+jjVp506gXqEzVY99mBfb+xgbx4G16QrL/5KJI=; fh=O9JPtEgoXN20WvvffwC9vht4C9mlV4cjm0SKbEbqoG0=; b=P6Ow9XPeMiMMbsIut7+qdTNiOdbrVaxSTKwrbEVpbP/wCFFdp+OBNIEJ/Uo/Zb16FZ aTsBdRf5mHJtrbRl3AE7uLp62zmHfDl7g2Rj2n5ot8xEdL/rMKK2W0l60Yq7FPsRorGa FcdG+Kj9EJm5btsiE532T0sPzMXxYQpzoRwItcHv0yqBUpoRFQQo8ob9t5RLC55AdCUc M4z6O3bwahyGdTd57nkPN7f4jK7pevmbONQi5qvTbkzQo12/6vfwYubTb9+zNz+F8Ohq yJ4ryQdwMFYNenO7ZGpwNLcr8Dv9NxlpDnSCHvWeorsovwyoaSlBTQewDPxtHjgkAn24 RkjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Bgi3c5jI; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=SbMoLthr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h185-20020a6383c2000000b0055ba8970e7asi10480798pge.616.2023.08.02.06.14.29; Wed, 02 Aug 2023 06:14:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Bgi3c5jI; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=SbMoLthr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233187AbjHBKVL (ORCPT + 99 others); Wed, 2 Aug 2023 06:21:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230456AbjHBKVC (ORCPT ); Wed, 2 Aug 2023 06:21:02 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70F5E213D for ; Wed, 2 Aug 2023 03:21:01 -0700 (PDT) Message-ID: <20230802101932.758513086@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1690971660; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=ifKZU+jjVp506gXqEzVY99mBfb+xgbx4G16QrL/5KJI=; b=Bgi3c5jIXWreNy1JQ1MW9oDkILk7cgZUTKPxAO8T5MMvnv1n/GW3zEjKiDefWH5acpRFJ7 VrXd5+F/maZKCZcWS9+bjE/LZIrlfkO4cVVrURoQpB+h7ofDPfGhCgpA9TpINiLIFzYfll /Qiho4obvDD73/Bu05lzc7Cw/mkNuwwK7+2b8KD97pZ3Fc70chGo/WXvDjvS0ZEtxNO5Tq VCV4xhMUWq9qhAGAjXch0YicemdBAI9QRTfJX8eHkZh6no/IRsIanCUpIvLMEM+zPNkeTk KLDSJbeGvWYnPkeSIGAwkr5WpY8MaZT5Pa69RV19/RrGQOWAS6KYdrUvaOYcIg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1690971660; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=ifKZU+jjVp506gXqEzVY99mBfb+xgbx4G16QrL/5KJI=; b=SbMoLthrNU8kvnS9+wB47EzWogOFxHaYI+rsI/o92tIgkiI6+VdfYFcC/i7ukbdnahT2go Yky/aTE8jn1fIyCw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Tom Lendacky , Andrew Cooper , Arjan van de Ven , Huang Rui , Juergen Gross , Dimitri Sivanich , Michael Kelley , Wei Liu Subject: [patch V3 01/40] cpu/SMT: Make SMT control more robust against enumeration failures References: <20230802101635.459108805@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Wed, 2 Aug 2023 12:20:59 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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 Signed-off-by: Thomas Gleixner --- kernel/cpu.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -630,6 +630,12 @@ static inline bool cpu_smt_allowed(unsig if (cpu_smt_control == CPU_SMT_ENABLED) return true; + if (cpu_smt_control == CPU_SMT_NOT_SUPPORTED) + return true; + + if (cpu_smt_control == CPU_SMT_NOT_IMPLEMENTED) + return true; + if (topology_is_primary_thread(cpu)) return true;