Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp143489lqt; Mon, 18 Mar 2024 04:15:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU6J0fq9+3kUUp2JDhvLN4qA7LBSEVksZ12iI05yJDsu7hQ6UDrOgAm8SzqVYiZX5QTNoCRyP5YBJMzWmP9/7OdSm6RxPzk3oQxeBi+Pg== X-Google-Smtp-Source: AGHT+IGaX27UIREo4Fsccx4ernEVR9FNg3YUsr5FZj9xSBTBalAL56s9VV1zEd3od7SwUHZZYk4+ X-Received: by 2002:a17:90b:b06:b0:29b:f909:94b4 with SMTP id bf6-20020a17090b0b0600b0029bf90994b4mr9460093pjb.21.1710760542584; Mon, 18 Mar 2024 04:15:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710760542; cv=pass; d=google.com; s=arc-20160816; b=BjrRRZbYcAYBv174I/O+e+RGi38bXAvvqdRO0ncsFN1vVFKiq21VwuD0vMk14ij0lg 2WIdS6rd2acw0i9ZCb7gyc4WqrkFqVUWgO3uSkpqJ53lIhStpucNX+HYc100iGx5AQYM unNpf2qvqEuieaflX0HgWK0BXzSoGhs38dYvpYtDmNiDsCcBXPwW1ils+BzmsAHwi4bf fr7GtrH9wr3ZTg9gVeu5Q8rDrwsMs0zszm+BJ0T0bPtsRJj1pTTzRJiXi0IJruv+Yv5O FOEtexBb3Xr1DrndAjBEEJdJg4b+YV/MOPxaUK4zXQN7avuMZ+5W/dPXPp3KAerkWtIS Pmmw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=Kz9iUiUQcoOz3awzuNQ4c0iM+L+HbF9KJgq1+b8ISwY=; fh=wLT3i9aLFgT24qpGqJM1q9+8FDdRtAJ6/Vg3HWT5PRA=; b=uohtCCy9QckbxZjMlrejzwY6n8te5x1U0T8R91gn5XN1PqSuaxyhN/3Uw+QXp30h9W iLo6ml5cUKvXbeg1kayw9Gl93qlRzxtMzb1Gpgsg+8hNUYBYFUc0vyY0S1TkT+Zu7Lvd P0Doe6gJy2fVIyIzv8Uz8XT4HNia+qgc37Df2JIBNja9TuJPFkTgCSUVN53FDR7CzD0I PEiKUapL0MJ3pVl4VU7OjUZxOXNmMVZoVqdvfkGEfaCf1fTCtWVmNaPkPq8WbtbC7jhd FDGjv8Xm6K+v188V9yHqgtvW0ZT8yBP0yZLwD7dpQLwiE7OSBSDIduwq5zezt85oU9v+ l8AA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=DsRh2wPZ; 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-106044-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106044-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id k6-20020a17090a9d8600b0029c14d14301si8004218pjp.115.2024.03.18.04.15.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 04:15:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106044-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=DsRh2wPZ; 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-106044-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106044-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id E1E43B21C06 for ; Mon, 18 Mar 2024 11:12:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 81602364A5; Mon, 18 Mar 2024 11:11:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="DsRh2wPZ"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="2rXzzq0j" 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 3746F3717F; Mon, 18 Mar 2024 11:11:43 +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=1710760305; cv=none; b=HzKgJbV3uK6dd2YGKJUx94kP2Jm+vmMHKQiW3WrZ1oSm5URIwE+0/INCFiBtaKwkRcn6z6pQf/s/YFFtTwBfuIOcD95y0YvUkKi191zUEcVJK/M94TKKoI3WnqtYmDuBRou726JK9vyfKjTHTFpk5XvbpQfz+RyIeg7O6T13vKI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710760305; c=relaxed/simple; bh=z5VR/SCFO4fju311eNKwJ63qRf/aHwz2D5n4iQqSiBc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=qpGvhHVBc1qATxPX4whZPGF8T7jP57IHJvIkPBH3rHNdckL7n6efKWDpdWa7oz9f5mbcWOcKWF+Xa0/oxvmR721uTMM4imEM95XJnVH2KgNNojeno7dfRkAooOjD6LzBDKEQ5z+jRCj+BmsGn4J8RAoXwvoiQfeazuUmkGDEkqs= 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=DsRh2wPZ; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=2rXzzq0j; 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 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1710760300; 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: in-reply-to:in-reply-to:references:references; bh=Kz9iUiUQcoOz3awzuNQ4c0iM+L+HbF9KJgq1+b8ISwY=; b=DsRh2wPZKF+ZU54Ol3+3tkG/vZylyJKaZweh1MbTMk/lURjsHdIIxR9igCB9VHwjgkxD8a gQYsU5LPNq2+1Al2TIP9sSnKu2NbYbkdsewheKEY/AnZUJmCVi3AKiUn6h+IhdxT/snRIb ej5HcPt2e8UzOp7tPCSdLosji5ZhlQP8dyxLwV3TlUerZc6wKsq4dkfHuXMwWq7Iyep5js /YgKUt/0Lnm9kv/9dw9hRxSzq9sMEw7b38IAz5P7sfwz+gNxeuFeVrbAEUueNJ97JkK3v3 iScWXdApPrwJwhOZlgmxSmolkbFc2qbTJK1oMkT2xsaPjSPLM9tk0m2FMRoa+Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1710760300; 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: in-reply-to:in-reply-to:references:references; bh=Kz9iUiUQcoOz3awzuNQ4c0iM+L+HbF9KJgq1+b8ISwY=; b=2rXzzq0jJ81Gok9ryRYJKmRQDOliceDGov4GITW3TRUy+rv/y+7Ff0yLJIQxjp1Rt4Gemp yIEWeVdtMHkqiWCQ== To: Linus Torvalds Cc: Guenter Roeck , LKML , x86@kernel.org, Uros Bizjak , linux-sparse@vger.kernel.org, lkp@intel.com, oe-kbuild-all@lists.linux.dev, Arnd Bergmann Subject: Re: [patch 5/9] x86: Cure per CPU madness on UP In-Reply-To: <877ci3j80k.ffs@tglx> References: <20240303235029.555787150@linutronix.de> <20240304005104.622511517@linutronix.de> <87y1ajjsv9.ffs@tglx> <87o7bfjeae.ffs@tglx> <877ci3j80k.ffs@tglx> Date: Mon, 18 Mar 2024 12:11:39 +0100 Message-ID: <87zfuviyl0.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Sat, Mar 16 2024 at 02:11, Thomas Gleixner wrote: > On Fri, Mar 15 2024 at 16:23, Linus Torvalds wrote: >> Either we should just make all machines look like they have the proper >> local apic mappings, or we shouldn't look at any local apic rules AT >> ALL. > > Sure. I can simply check if there was an APIC registered instead. Like the below. I'm not entirely sure though whether the sanity checks should return an error code, which is what caused the crash Guenter observed, but I couldn't come up with something sensible either. Returning 0 might keep the machine alive, but does it make sense? Thanks, tglx --- arch/x86/kernel/cpu/topology.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) --- a/arch/x86/kernel/cpu/topology.c +++ b/arch/x86/kernel/cpu/topology.c @@ -277,10 +277,21 @@ int topology_get_logical_id(u32 apicid, /* Remove the bits below @at_level to get the proper level ID of @apicid */ unsigned int lvlid = topo_apicid(apicid, at_level); - if (lvlid >= MAX_LOCAL_APIC) + if (WARN_ON_ONCE(lvlid >= MAX_LOCAL_APIC)) return -ERANGE; - if (!test_bit(lvlid, apic_maps[at_level].map)) + + /* + * If there was no APIC registered, then the map check below would + * fail. With no APIC this is guaranteed to be an UP system and + * therefore all topology levels have only one entry and their + * logical ID is obviously 0. + */ + if (topo_info.boot_cpu_apic_id == BAD_APICID) + return 0; + + if (WARN_ON_ONCE(!test_bit(lvlid, apic_maps[at_level].map))) return -ENODEV; + /* Get the number of set bits before @lvlid. */ return bitmap_weight(apic_maps[at_level].map, lvlid); }