Message ID | 169718989311.3135.5099682715244955511.tip-bot2@tip-bot2 |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1768761vqb; Fri, 13 Oct 2023 02:39:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEO5De4/3eWiRWyEMvsxMDnbehF87fEx7MZV5zcV+TlBqUDlWtdmMU3VETc2DZcx4hC3Ohf X-Received: by 2002:a05:6a20:8f01:b0:15a:2c0b:6c81 with SMTP id b1-20020a056a208f0100b0015a2c0b6c81mr30997321pzk.3.1697189956606; Fri, 13 Oct 2023 02:39:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697189956; cv=none; d=google.com; s=arc-20160816; b=tSBRhaysPC9ydKiycMpxYO0trR7Thuji4Ezrvcqm3xE6EtSTPuqLpOduyRx3oYU1Lv 5ynQlI6BgcsaC5zqU7Bk/sgp5NDsGfyRnqCkbeX7osfJCaitUXGwSAFALfilXdsyTTa7 0Y9278mWT+v1PHeCbSRxgvbPXY4Nqs64TKDYkXBQ/IieFQL/BoNX8f1n9h5XD/fbUaFd Tip5X4+eyKBFpifzKBw4pL4c7R+Upv6BnuEXbNNWDw81YTwz+53mn/bCYtlIL1Q7jQ2i 94wmRuNC3XVvihTaWb8NuWpO9ZrstKgcp6IUQrBdBgJD4sU/W1DCTBxdDa90ouvE5VSi 8vnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=rCTCPgo8jeqYDUyGPCO49XEL+tzO99RT05N9qxWKWRc=; fh=jyUaMcKccPBGiHulsFQCVYJjDZYW9PU3yBzpCo/OBHs=; b=c35e3x7dRv1V9WWQNswFdBrP63rKYCbgYdKJfZYwRDDs/FyNg1El8yohPNycGs1pVj vc2PzvJx0vILBqHiaYPwng5ECgaverXZ/lDWgZ4rbCXllx32oSPh432iDmVHCJAEgg60 AwmdsjJmagEtHrXFeXAzHfLZCJrfJ/coQyECMJVTEO5tywCGfLGTMxjV8tIxxfXCcsJ/ x0iLGwdT6VK3Ew77cQ0rMJH6/rXLsyR1oacfkeYaPvzawe4Z40n5Jn/5jAZRs7W4IDBE Ise1lrdPzLQJeaRuL28xFY+jetj0pptH1Khxr5jiItmys72UqrLfdjjvb5tBl4yjxGGa 5cUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=mm5BdMEV; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=DvcCmy6X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id x2-20020a170902ea8200b001c73f364120si271740plb.407.2023.10.13.02.39.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 02:39:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=mm5BdMEV; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=DvcCmy6X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id E6E1582F7FB1; Fri, 13 Oct 2023 02:39:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231357AbjJMJjK (ORCPT <rfc822;rua109.linux@gmail.com> + 19 others); Fri, 13 Oct 2023 05:39:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231284AbjJMJiR (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 13 Oct 2023 05:38:17 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5985EBE; Fri, 13 Oct 2023 02:38:15 -0700 (PDT) Date: Fri, 13 Oct 2023 09:38:13 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1697189893; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rCTCPgo8jeqYDUyGPCO49XEL+tzO99RT05N9qxWKWRc=; b=mm5BdMEVZPLvrOLrHF03QnQw5cfeUH3j/SaZoXapSbD4RDOOarP3e7DxQakQMpKzllDbw2 Y1BRiOkPiiRqpmwr3OAmns2GEwg7dsGzdNuDgnNX3FxB7zRV22948SbPG0Pli/5dFdGigV hKrNoQwX/J6Nf7f3/qgLwCCisG9RS6oRYGng6/Vh7ezfgIJz3khBPoosEclrPcJ1E1wSC0 uey8bGa4oCOpfAy3pMFkzWkdxWszb9qzozpKWRE5vrwRxhk5iDNNJxs3kfZg47F6T5bDHn Dcq+XmAvO4ebYJbeI5+b0bWvPUnOFA/J/WgTlNmkUyQgWV/ws81JdCGsb9HL7A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1697189893; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rCTCPgo8jeqYDUyGPCO49XEL+tzO99RT05N9qxWKWRc=; b=DvcCmy6XUtOkXfbQxEn+2tr3mWOOVAf6mBm3vFU2LUg0vNGSxIVAIi5nH14Hyy3dMSEZF3 xlYIScSP+qSbZsBw== From: "tip-bot2 for Thomas Gleixner" <tip-bot2@linutronix.de> Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/core] x86/apic: Fake primary thread mask for XEN/PV Cc: Juergen Gross <jgross@suse.com>, Thomas Gleixner <tglx@linutronix.de>, Sohil Mehta <sohil.mehta@intel.com>, Michael Kelley <mikelley@microsoft.com>, "Peter Zijlstra (Intel)" <peterz@infradead.org>, Zhang Rui <rui.zhang@intel.com>, x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230814085112.210011520@linutronix.de> References: <20230814085112.210011520@linutronix.de> MIME-Version: 1.0 Message-ID: <169718989311.3135.5099682715244955511.tip-bot2@tip-bot2> Robot-ID: <tip-bot2@linutronix.de> Robot-Unsubscribe: Contact <mailto:tglx@linutronix.de> to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 13 Oct 2023 02:39:16 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774200928393752650 X-GMAIL-MSGID: 1779632655745684481 |
Series |
[tip:,x86/core] x86/apic: Fake primary thread mask for XEN/PV
|
|
Commit Message
tip-bot2 for Thomas Gleixner
Oct. 13, 2023, 9:38 a.m. UTC
The following commit has been merged into the x86/core branch of tip: Commit-ID: 965e05ff8af98c44f9937366715c512000373164 Gitweb: https://git.kernel.org/tip/965e05ff8af98c44f9937366715c512000373164 Author: Thomas Gleixner <tglx@linutronix.de> AuthorDate: Mon, 14 Aug 2023 10:18:28 +02:00 Committer: Thomas Gleixner <tglx@linutronix.de> CommitterDate: Tue, 10 Oct 2023 14:38:17 +02:00 x86/apic: Fake primary thread mask for XEN/PV 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 cpu_smt_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 cpu_smt_control is set to CPU_SMT_NOT_SUPPORTED which causes cpu_bootable() to evaluate the unpopulated primary thread mask with the conclusion that all non-boot CPUs are not valid to be plugged. The core code has already been made more robust against this kind of fail, but the primary thread mask really wants to be populated to avoid other issues all over the place. Just fake the mask by pretending that all XEN/PV vCPUs are primary threads, which is consistent because all of XEN/PVs topology is fake or non-existent. Fixes: 6a4d2657e048 ("x86/smp: Provide topology_is_primary_thread()") Fixes: f54d4434c281 ("x86/apic: Provide cpu_primary_thread mask") Reported-by: Juergen Gross <jgross@suse.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Juergen Gross <jgross@suse.com> Tested-by: Sohil Mehta <sohil.mehta@intel.com> Tested-by: Michael Kelley <mikelley@microsoft.com> Tested-by: Peter Zijlstra (Intel) <peterz@infradead.org> Tested-by: Zhang Rui <rui.zhang@intel.com> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/20230814085112.210011520@linutronix.de --- arch/x86/kernel/apic/apic.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index 760adac..3cdf484 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -36,6 +36,8 @@ #include <linux/smp.h> #include <linux/mm.h> +#include <xen/xen.h> + #include <asm/trace/irq_vectors.h> #include <asm/irq_remapping.h> #include <asm/pc-conf-reg.h> @@ -2344,6 +2346,15 @@ static int __init smp_init_primary_thread_mask(void) { unsigned int cpu; + /* + * XEN/PV provides either none or useless topology information. + * Pretend that all vCPUs are primary threads. + */ + if (xen_pv_domain()) { + cpumask_copy(&__cpu_primary_thread_mask, cpu_possible_mask); + return 0; + } + for (cpu = 0; cpu < nr_logical_cpuids; cpu++) cpu_mark_primary_thread(cpu, cpuid_to_apicid[cpu]); return 0;