Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1724290lqp; Sat, 23 Mar 2024 06:25:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVl6513bSly2yrbIzkIQdONwTKJ25qeSkcxSFFBZ+HhS/alqt1pc4S2x+bSyKlXGflQQL+RqAaCxvyoEYE2FGGnxqsreh1AzVeBN57tsQ== X-Google-Smtp-Source: AGHT+IHUkmHyB9FpdxF7eN9TActTG8I4tZmztriWRnWwqrVgAlwTgz0wkJlB/B9mcmQd9ykG8L8E X-Received: by 2002:a81:85c3:0:b0:608:b193:5a3e with SMTP id v186-20020a8185c3000000b00608b1935a3emr2210090ywf.32.1711200311946; Sat, 23 Mar 2024 06:25:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711200311; cv=pass; d=google.com; s=arc-20160816; b=MIV9+7ZT0o8RC0afFAz2XzGE9vJeApwgNltSQItirAMI8hPHSFaL//bw2DN8AtB1f8 9MeFGmO09DihnaWU+GQP0VvF7k+jptOtKTPgowGBhMgnk+TbCUSIJwUenhVXHbGVS09f 4qzaN1X9jtVrzQCZSCKa81J2kFRs1nY7skS6cokRbegTXqWr6PfpbJ3EH35cJlDa5uJ8 i8X2C4D7TrX29PIer0VvK8AtvWhZneud9nzdXN4R75JAsFHsjWkZDtmbEuILzY7VxchF 1DRplqIT0x9zXU5eeCSP5sJI05gX6w103+CN5EZLJX8toQfxAohL950DLfeyoRHBMdcr lGKg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=5M+UNP+f4UxcFh19ikQH+EYN59LPvEb9QbsNWbZnWmc=; fh=jgn8otUhMvtcWA37EIZx6+X3BMNH5HkvHoONMpBLnDs=; b=f8rlmMHgxcANx4/6PUpflLIBoVhEnj08eCXb/vPmguu61pHcMYv1T5LknoNlqN9V2w d8IhuCURn3Xt6fxrkrfpMiloLMreHf4BP0NNCHHgpPDv6Sf7Bg9LIXFg2CP+ISqTADOr BE29lpB6GyDah5A9HL4qdde0sRk0pgtWpy4nNHFCBZaQYQGnzL6n3426E1WFBJBdZRyX WORNH2ux8lqMYYW3LR1N9SaC1iUpBzedIzdd30hgtHbmhGfSQxa123XPVRNMD+RlnlA6 cSSP1NNKo3W09D+lbaY3Z2nictrZb7ai8/qD2rUZDTfWRshIjW+LOKET3tK8l1ZOhtUb frOw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="SIJc9mK/"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-112352-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112352-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id jq6-20020ad45fc6000000b006966d32c9d3si3020421qvb.506.2024.03.23.06.25.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Mar 2024 06:25:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112352-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="SIJc9mK/"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-112352-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112352-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id AB5DB1C219B0 for ; Sat, 23 Mar 2024 13:25:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CE44E3DBBA; Sat, 23 Mar 2024 13:25:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="SIJc9mK/"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="uFgIIrji" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6EE4E282FB; Sat, 23 Mar 2024 13:24:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711200300; cv=none; b=fAD8lRVZ+uIVxtYS8qWzgzG9boMRpof8pZmUoJt8dTj3k89RIEKoJtmTnAjWzlfw8mogthDKn3v9kLBtmg4CjtGTeyA8gdnd7QzXIav9HMO41ivXAH8WRLuouldkjizSYvnDF3RjCmNYcV4ERL+1ragTefO2Gjpu2UG7WEutWzY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711200300; c=relaxed/simple; bh=3+GVOAJtNE1iLOBBfL37PqCMAJwKNS2ockd4OEBRwco=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=RBpKkLNx+pw+2uDHrfHhnNUVILd+u8gxTqyu+TZ3fGvJgGEUMGz+4dxv0Oc2zyEvmFmCd8P/xdrZPxpWhYOip2iPHQa9CW5aj4V3AwM+3x+uZo4JeVnTWIcYR/0g+NHfe9NQOo1uc/dR7CUiIc1LbYQaY/RtvyfzwQE2196oYfM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=SIJc9mK/; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=uFgIIrji; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Sat, 23 Mar 2024 13:24:49 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1711200290; 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=5M+UNP+f4UxcFh19ikQH+EYN59LPvEb9QbsNWbZnWmc=; b=SIJc9mK/EK7fUZQsHGZvsO3xIy4EnFKRGeEqNn8Yxk/wsP++EkGmh+iCSuZGF5OTZsneUH 3/3UFQh4rtiHFQ1NlmumRGZGASzxuXUS+m7XAz/cMRSVkOgmygBlCbTyD1QDTMe1zVHbng zThVAlfCrLBYepkRLHYEgj0jCeMsOuoDb25DkPsqD0rHQROlaotWMFYRlJuOXXVvivuy/P 5QKWak5xyVSHjJHfuNI1xOzw7WIBb31bvY88YYA95rvKGUXRaHyrI5/bGG+oTEQf6g6B9w HZHjmLWDKglQnT9HAMYO90bY/PT7/unXatV6hEGu8cRlZdU+WkVVsK+SdSv5AQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1711200290; 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=5M+UNP+f4UxcFh19ikQH+EYN59LPvEb9QbsNWbZnWmc=; b=uFgIIrji09me/f2+l3v8Uu8coqPZhH5U0QErsvfoSN1FM/1MxXvTX8z9tEKCS1RbbYURwH RCoZKDpLRfwRUNCQ== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/topology: Handle the !APIC case gracefully Cc: Guenter Roeck , Linus Torvalds , Thomas Gleixner , "Borislav Petkov (AMD)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240322185305.242709302@linutronix.de> References: <20240322185305.242709302@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <171120028937.10875.10862174051522129373.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the x86/urgent branch of tip: Commit-ID: 5e25eb25dae9fa0700bbe42aff0e2f105fcd096a Gitweb: https://git.kernel.org/tip/5e25eb25dae9fa0700bbe42aff0e2f105fcd096a Author: Thomas Gleixner AuthorDate: Fri, 22 Mar 2024 19:56:38 +01:00 Committer: Borislav Petkov (AMD) CommitterDate: Sat, 23 Mar 2024 12:35:56 +01:00 x86/topology: Handle the !APIC case gracefully If there is no local APIC enumerated and registered then the topology bitmaps are empty. Therefore, topology_init_possible_cpus() will die with a division by zero exception. Prevent this by registering a fake APIC id to populate the topology bitmap. This also allows to use all topology query interfaces unconditionally. It does not affect the actual APIC code because either the local APIC address was not registered or no local APIC could be detected. Fixes: f1f758a80516 ("x86/topology: Add a mechanism to track topology via APIC IDs") Reported-by: Guenter Roeck Reported-by: Linus Torvalds Signed-off-by: Thomas Gleixner Signed-off-by: Borislav Petkov (AMD) Tested-by: Guenter Roeck Link: https://lore.kernel.org/r/20240322185305.242709302@linutronix.de --- arch/x86/kernel/cpu/topology.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/x86/kernel/cpu/topology.c b/arch/x86/kernel/cpu/topology.c index 3259b1d..aaca8d2 100644 --- a/arch/x86/kernel/cpu/topology.c +++ b/arch/x86/kernel/cpu/topology.c @@ -415,6 +415,17 @@ void __init topology_init_possible_cpus(void) unsigned int total = assigned + disabled; u32 apicid, firstid; + /* + * If there was no APIC registered, then fake one so that the + * topology bitmap is populated. That ensures that the code below + * is valid and the various query interfaces can be used + * unconditionally. This does not affect the actual APIC code in + * any way because either the local APIC address has not been + * registered or the local APIC was disabled on the command line. + */ + if (topo_info.boot_cpu_apic_id == BAD_APICID) + topology_register_boot_apic(0); + if (!restrict_to_up()) { if (WARN_ON_ONCE(assigned > nr_cpu_ids)) { disabled += assigned - nr_cpu_ids;