Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp175075rdh; Tue, 13 Feb 2024 13:09:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX6JN0hWzRFG7u3gOPM6Q3lya2L7yahGvpTviubMXKnJSZ1xFG8KHLqgukmzrmufhec/A7EZ+arOWZf4YlCaBI/r9bqwYI397ObvENAmg== X-Google-Smtp-Source: AGHT+IGQ2WOQ5bNkwMaAKVqjB4E24CjY5sW0HuGelM1G5wZLZZVG/L22+ncXqdM5dPNP/E5f3irn X-Received: by 2002:a17:906:5a96:b0:a3c:8bed:86d5 with SMTP id l22-20020a1709065a9600b00a3c8bed86d5mr350186ejq.12.1707858549296; Tue, 13 Feb 2024 13:09:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707858549; cv=pass; d=google.com; s=arc-20160816; b=HwWlxK1tz1ehRYao800baYUZQUbc6t3TvyoxvUlXx9Fz4wyk1dqAJSW5Xvh+zjKSIY OJaA0JIYmECm4JvT6QQV6qbTEBLPVvbL7qXCV1oChGrWYbeEqGGnd71O4/1Ms2Uj34qt H02gG7DPp6J21AbSS5dc/CqyyYMVN5A7ovbSkH/+G9RoGgCU8lv4DjOF/ZGpBIU604eE tezEVCHhEenteivUF4lPYFGEfPEo8h+ub5bEpMmeadVofQzytYSxg3cJQg4ddr/nqWae JAzbzh/FzJmKBxpLoXO9F3kOF0LRHybhzYewPmcBXaBLfW9LAUSJajRbicuYR21x2p+T tkoQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=date:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:subject:cc:to:from:dkim-signature :dkim-signature:message-id; bh=p1hwX9LEu/e1+Ot1b5cejKkCoScMTR5JGuQ827RCDFo=; fh=qsBtJoatoJ4Uut/UdVCvxEn2aXnVfEOfJd9MNNs1mZ4=; b=Z6IbK7inEY1Vrg99yL444M3IjA8XvrHts0uyY13Mcg7FnW+gS38Q+Bt8QFFxFjMkBg A0F6JHCCYdUf3MgZb3CwJea5UbCRXhT4FaV4zNkVckiHcN5hOyn7Cr4sD+vosBg/53te D43xjekr42gjC5wDzb2IS8Y0Ji8gG6nqp3CjbkcIA/J4rxH/lWe9+v6Wnibj5LYbliCX ke4+Kk1kGRJfKWMmgdobVyh26GKQLRmtH1aqHBrkJDD/En7qWq0wQZrph41jy7BZuGqD MtQt+y7oN0kyWu865wnWD5Ft2Nm+lSwgdgyPTQxXxoVbD7vDl/QTnOy2d/ie3+bwrE/Y /Ujg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0XAlcCZy; 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-64261-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64261-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de X-Forwarded-Encrypted: i=2; AJvYcCVAfQ1tKqvLOTDRUMVshkL3quQwgLk8cVydHMlDpiHgrjINvWPeUdQ+oNzfYeWqJCWPXrHL3iYzyC5U8nN2G+uHglQnjfyCd6mWd1k5fA== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id q21-20020a170906361500b00a3cfd0c91bcsi1035962ejb.33.2024.02.13.13.09.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 13:09:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64261-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0XAlcCZy; 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-64261-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64261-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0E3471F28373 for ; Tue, 13 Feb 2024 21:09:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 75BA362163; Tue, 13 Feb 2024 21:04:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="0XAlcCZy"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="f0vq0FNi" 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 0B27461687 for ; Tue, 13 Feb 2024 21:04:54 +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=1707858295; cv=none; b=hmlnYYvUV2ovh6cAI8Z7zNTfwNvYR8kYpFKAQTSCU0Lb2gwjFX4tuPMb9z0DLRBlhxI1u9/fJ2D64UecprID4wubBCYS3QwFaJn7amiYzhGCjua+BlXClW9MX//ncmg2LYn2yaxrJJ9MSY2HKYJG7PGiqYRW3xngSbrAeL2+qFk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707858295; c=relaxed/simple; bh=3awkOOoO8G9BJISNINVkNbJtDYkDqRW7NjVuJ0C6ZNA=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=bXrnzjwE1DuUjFerQeyCz9YT0+D+uhtItKNBnaLY40AHgHU0nmBtCxWqqvdwb7sbCz5dSKFDrHHj0DKH5xhBdKctivMERiGZ7SqrT6oshjQymm2YTghW9iY3VPfMRKvxg8WA/B2nCiK9dA7YfUHy6CCoVDovUPgOEomQr8+AtyM= 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=0XAlcCZy; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=f0vq0FNi; 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 Message-ID: <20240212154638.867699078@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1707858292; 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=p1hwX9LEu/e1+Ot1b5cejKkCoScMTR5JGuQ827RCDFo=; b=0XAlcCZyuOa8v7jWBN/5z2layZSVZc6d0B5W9uHypJJNA+T38IBMxO+qHuIsNcSuEHtG1p 1wj0dHk8lFwt1XyjMGLbuUVWb9ik2wafUp0DQuOnJdUO80Do5S5bEPmpn3382OtwNQ0CB/ XOKfHdeMXgZ2gOJzPdtwoMUAj13qcTOTzrFSt4aVr7mrw10wY07ExpowNPJ/UKozOFfokk yhHDtegU5KGixeY0A5L3hAa3MtpY4k4URgWqbEk34cKsuWSZsJIQYo/vIhwnUA68y9Erzf Lhuogx/yp78O/8HZq+pbjTn5BvAa10AtxRulOvExN6tsNU+GLKacw7qDagvnfA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1707858292; 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=p1hwX9LEu/e1+Ot1b5cejKkCoScMTR5JGuQ827RCDFo=; b=f0vq0FNiLDIk6lHL1E56iHaU8Pzkz7cd0ngfJjidXgooWtThEbtG7rjKaLo3XpENkyEdoH coiugVsjEmBAEwCg== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Tom Lendacky , Andrew Cooper , Arjan van de Ven , Huang Rui , Juergen Gross , Dimitri Sivanich , Sohil Mehta , K Prateek Nayak , Kan Liang , Zhang Rui , "Paul E. McKenney" , Feng Tang , Andy Shevchenko , Michael Kelley , "Peter Zijlstra (Intel)" , Andy Shevchenko , Wei Liu Subject: [patch V3 01/22] x86/cpu/topology: Make the APIC mismatch warnings complete References: <20240212154529.402604963@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Tue, 13 Feb 2024 22:04:52 +0100 (CET) From: Thomas Gleixner Detect all possible combinations of mismatch right in the CPUID evaluation code. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 5 ++--- arch/x86/kernel/cpu/common.c | 15 ++------------- arch/x86/kernel/cpu/topology_common.c | 12 ++++++++++++ 3 files changed, 16 insertions(+), 16 deletions(-) --- --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -46,16 +46,15 @@ extern void x86_32_probe_apic(void); static inline void x86_32_probe_apic(void) { } #endif -#ifdef CONFIG_X86_LOCAL_APIC +extern u32 cpuid_to_apicid[]; +#ifdef CONFIG_X86_LOCAL_APIC extern int apic_verbosity; extern int local_apic_timer_c2_ok; extern bool apic_is_disabled; extern unsigned int lapic_timer_period; -extern u32 cpuid_to_apicid[]; - extern enum apic_intr_mode_id apic_intr_mode; enum apic_intr_mode_id { APIC_PIC, --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1716,22 +1716,11 @@ static void generic_identify(struct cpui #endif } -/* - * Validate that ACPI/mptables have the same information about the - * effective APIC id and update the package map. - */ -static void validate_apic_and_package_id(struct cpuinfo_x86 *c) +static void update_package_map(struct cpuinfo_x86 *c) { #ifdef CONFIG_SMP unsigned int cpu = smp_processor_id(); - u32 apicid; - apicid = apic->cpu_present_to_apicid(cpu); - - if (apicid != c->topo.apicid) { - pr_err(FW_BUG "CPU%u: APIC id mismatch. Firmware: %x APIC: %x\n", - cpu, apicid, c->topo.initial_apicid); - } BUG_ON(topology_update_package_map(c->topo.pkg_id, cpu)); BUG_ON(topology_update_die_map(c->topo.die_id, cpu)); #else @@ -1923,7 +1912,7 @@ void identify_secondary_cpu(struct cpuin #ifdef CONFIG_X86_32 enable_sep_cpu(); #endif - validate_apic_and_package_id(c); + update_package_map(c); x86_spec_ctrl_setup_ap(); update_srbds_msr(); if (boot_cpu_has_bug(X86_BUG_GDS)) --- a/arch/x86/kernel/cpu/topology_common.c +++ b/arch/x86/kernel/cpu/topology_common.c @@ -177,6 +177,18 @@ void cpu_parse_topology(struct cpuinfo_x parse_topology(&tscan, false); + if (IS_ENABLED(CONFIG_X86_LOCAL_APIC)) { + if (c->topo.initial_apicid != c->topo.apicid) { + pr_err(FW_BUG "CPU%4u: APIC ID mismatch. CPUID: 0x%04x APIC: 0x%04x\n", + cpu, c->topo.initial_apicid, c->topo.apicid); + } + + if (c->topo.apicid != cpuid_to_apicid[cpu]) { + pr_err(FW_BUG "CPU%4u: APIC ID mismatch. Firmware: 0x%04x APIC: 0x%04x\n", + cpu, cpuid_to_apicid[cpu], c->topo.apicid); + } + } + for (dom = TOPO_SMT_DOMAIN; dom < TOPO_MAX_DOMAIN; dom++) { if (tscan.dom_shifts[dom] == x86_topo_system.dom_shifts[dom]) continue;