From nobody Thu Sep 11 12:46:50 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63A8FC04FDF for ; Mon, 14 Aug 2023 08:55:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234922AbjHNIyv (ORCPT ); Mon, 14 Aug 2023 04:54:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234931AbjHNIx6 (ORCPT ); Mon, 14 Aug 2023 04:53:58 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDC6D10B for ; Mon, 14 Aug 2023 01:53:57 -0700 (PDT) Message-ID: <20230814085112.862835121@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1692003236; 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=bd7aVAkdU8hKlGLozvpCQgzrwCUOG24alOTKZ7VboAQ=; b=uEjAJG0NkROXgPFtaoyDvfr/S9b5Zl0n217RTuiqSmVgO/EMg3diLngXj0b8P8fRG4MGsm iXJrSutNAbJHpsIwbyjpCNHTWzho1hAn0G9bqKzZF9JJq/eICymxN1OELDw2e4qJ+ZfT6w mAfj9ceY0OQW5sNhnTRDBQcLiJZE4YQr5nvXD52XlSoPamZByc0S52DiEh4NnK+hbrvWik 5/YAGptvLvqMwuv9sQwOl7LyYTL35xhea/GT0dCXF/1VIICpjVGaQFZV0vipJEyWZpoaL9 c2fYuxvpT0rQibKioUDNo8nLOhpzoXiBZorBPUrsPsP/xrIk3HKyhVkDWIy5cw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1692003236; 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=bd7aVAkdU8hKlGLozvpCQgzrwCUOG24alOTKZ7VboAQ=; b=udlUfvpc16LJ43bOLabICosbCFJfGjee0veDKBfD7yFKRAHsf9X2p4evlVVGXQeXo50TND txOELKFFDQIobCDw== 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 , Pu Wen , Qiuxu Zhuo , Sohil Mehta Subject: [patch V4 14/41] x86/apic: Use BAD_APICID consistently References: <20230814085006.593997112@linutronix.de> MIME-Version: 1.0 Date: Mon, 14 Aug 2023 10:53:56 +0200 (CEST) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" APIC ID checks compare with BAD_APICID all over the place, but some initializers and some code which fiddles with global data structure use -1[U] instead. That simply cannot work at all. Fix it up and use BAD_APICID consistently all over the place. Signed-off-by: Thomas Gleixner Tested-by: Juergen Gross Tested-by: Sohil Mehta Tested-by: Michael Kelley --- V3: Fixed changelog typos - Sohil --- arch/x86/kernel/acpi/boot.c | 2 +- arch/x86/kernel/apic/apic.c | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c @@ -852,7 +852,7 @@ int acpi_unmap_cpu(int cpu) set_apicid_to_node(per_cpu(x86_cpu_to_apicid, cpu), NUMA_NO_NODE); #endif =20 - per_cpu(x86_cpu_to_apicid, cpu) =3D -1; + per_cpu(x86_cpu_to_apicid, cpu) =3D BAD_APICID; set_cpu_present(cpu, false); num_processors--; =20 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -72,7 +72,7 @@ unsigned int num_processors; unsigned disabled_cpus; =20 /* Processor that is doing the boot up */ -unsigned int boot_cpu_physical_apicid __ro_after_init =3D -1U; +unsigned int boot_cpu_physical_apicid __ro_after_init =3D BAD_APICID; EXPORT_SYMBOL_GPL(boot_cpu_physical_apicid); =20 u8 boot_cpu_apic_version __ro_after_init; @@ -2318,9 +2318,7 @@ static int nr_logical_cpuids =3D 1; /* * Used to store mapping between logical CPU IDs and APIC IDs. */ -int cpuid_to_apicid[] =3D { - [0 ... NR_CPUS - 1] =3D -1, -}; +int cpuid_to_apicid[] =3D { [0 ... NR_CPUS - 1] =3D BAD_APICID, }; =20 bool arch_match_cpu_phys_id(int cpu, u64 phys_id) {